@terra.gl/core 0.0.1-alpha.16 → 0.0.1-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +72 -5
- package/dist/index.js +6457 -5886
- package/dist/index.umd.cjs +61 -27
- package/package.json +1 -5
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(ee,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],m):(ee=typeof globalThis<"u"?globalThis:ee||self,m(ee["terra-gl"]={},ee.THREE))})(this,function(ee,m){"use strict";var
|
|
1
|
+
(function(ee,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],m):(ee=typeof globalThis<"u"?globalThis:ee||self,m(ee["terra-gl"]={},ee.THREE))})(this,function(ee,m){"use strict";var kb=Object.defineProperty;var Ob=(ee,m,ci)=>m in ee?kb(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:ci}):ee[m]=ci;var T=(ee,m,ci)=>Ob(ee,typeof m!="symbol"?m+"":m,ci);function ci(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const rt=ci(m),Dh="0.0.1-alpha.18",Zs={name:"Criska"};var Vi=function(){var a=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(p){p.preventDefault(),n(++a%t.children.length)},!1);function e(p){return t.appendChild(p.dom),p}function n(p){for(var f=0;f<t.children.length;f++)t.children[f].style.display=f===p?"block":"none";a=p}var i=(performance||Date).now(),s=i,l=0,u=e(new Vi.Panel("FPS","#0ff","#002")),c=e(new Vi.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=e(new Vi.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:e,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){l++;var p=(performance||Date).now();if(c.update(p-i,200),p>=s+1e3&&(u.update(l*1e3/(p-s),100),s=p,l=0,d)){var f=performance.memory;d.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){i=this.end()},domElement:t,setMode:n}};Vi.Panel=function(a,t,e){var n=1/0,i=0,s=Math.round,l=s(window.devicePixelRatio||1),u=80*l,c=48*l,d=3*l,p=2*l,f=3*l,y=15*l,v=74*l,x=30*l,S=document.createElement("canvas");S.width=u,S.height=c,S.style.cssText="width:80px;height:48px";var _=S.getContext("2d");return _.font="bold "+9*l+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=e,_.fillRect(0,0,u,c),_.fillStyle=t,_.fillText(a,d,p),_.fillRect(f,y,v,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f,y,v,x),{dom:S,update:function(Z,M){n=Math.min(n,Z),i=Math.max(i,Z),_.fillStyle=e,_.globalAlpha=1,_.fillRect(0,0,u,y),_.fillStyle=t,_.fillText(s(Z)+" "+a+" ("+s(n)+"-"+s(i)+")",d,p),_.drawImage(S,f+l,y,v-l,x,f,y,v-l,x),_.fillRect(f+v-l,y,l,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f+v-l,y,l,s((1-Z/M)*x))}}};const gr=parseInt(m.REVISION.replace(/\D+/g,"")),Gs=gr>=125?"uv1":"uv2";function za(a,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let e=a.getIndex();if(e===null){const l=[],u=a.getAttribute("position");if(u!==void 0){for(let c=0;c<u.count;c++)l.push(c);a.setIndex(l),e=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}const n=e.count-2,i=[];if(e)if(t===m.TriangleFanDrawMode)for(let l=1;l<=n;l++)i.push(e.getX(0)),i.push(e.getX(l)),i.push(e.getX(l+1));else for(let l=0;l<n;l++)l%2===0?(i.push(e.getX(l)),i.push(e.getX(l+1)),i.push(e.getX(l+2))):(i.push(e.getX(l+2)),i.push(e.getX(l+1)),i.push(e.getX(l)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=a.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),a}var Zt=Uint8Array,_n=Uint16Array,Ws=Uint32Array,Da=new Zt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ka=new Zt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Oa=function(a,t){for(var e=new _n(31),n=0;n<31;++n)e[n]=t+=1<<a[n-1];for(var i=new Ws(e[30]),n=1;n<30;++n)for(var s=e[n];s<e[n+1];++s)i[s]=s-e[n]<<5|n;return[e,i]},Ra=Oa(Da,2),Ka=Ra[0],Oh=Ra[1];Ka[28]=258,Oh[258]=28;for(var Rh=Oa(ka,0),Kh=Rh[0],Ps=new _n(32768),Ie=0;Ie<32768;++Ie){var Mn=(Ie&43690)>>>1|(Ie&21845)<<1;Mn=(Mn&52428)>>>2|(Mn&13107)<<2,Mn=(Mn&61680)>>>4|(Mn&3855)<<4,Ps[Ie]=((Mn&65280)>>>8|(Mn&255)<<8)>>>1}for(var Ai=function(a,t,e){for(var n=a.length,i=0,s=new _n(t);i<n;++i)++s[a[i]-1];var l=new _n(t);for(i=0;i<t;++i)l[i]=l[i-1]+s[i-1]<<1;var u;if(e){u=new _n(1<<t);var c=15-t;for(i=0;i<n;++i)if(a[i])for(var d=i<<4|a[i],p=t-a[i],f=l[a[i]-1]++<<p,y=f|(1<<p)-1;f<=y;++f)u[Ps[f]>>>c]=d}else for(u=new _n(n),i=0;i<n;++i)a[i]&&(u[i]=Ps[l[a[i]-1]++]>>>15-a[i]);return u},Fi=new Zt(288),Ie=0;Ie<144;++Ie)Fi[Ie]=8;for(var Ie=144;Ie<256;++Ie)Fi[Ie]=9;for(var Ie=256;Ie<280;++Ie)Fi[Ie]=7;for(var Ie=280;Ie<288;++Ie)Fi[Ie]=8;for(var Ya=new Zt(32),Ie=0;Ie<32;++Ie)Ya[Ie]=5;var Yh=Ai(Fi,9,1),Uh=Ai(Ya,5,1),Is=function(a){for(var t=a[0],e=1;e<a.length;++e)a[e]>t&&(t=a[e]);return t},Rt=function(a,t,e){var n=t/8|0;return(a[n]|a[n+1]<<8)>>(t&7)&e},Cs=function(a,t){var e=t/8|0;return(a[e]|a[e+1]<<8|a[e+2]<<16)>>(t&7)},Bh=function(a){return(a/8|0)+(a&7&&1)},Nh=function(a,t,e){(e==null||e>a.length)&&(e=a.length);var n=new(a instanceof _n?_n:a instanceof Ws?Ws:Zt)(e-t);return n.set(a.subarray(t,e)),n},jh=function(a,t,e){var n=a.length;if(!n||e&&!e.l&&n<5)return t||new Zt(0);var i=!t||e,s=!e||e.i;e||(e={}),t||(t=new Zt(n*3));var l=function(je){var Je=t.length;if(je>Je){var Qe=new Zt(Math.max(Je*2,je));Qe.set(t),t=Qe}},u=e.f||0,c=e.p||0,d=e.b||0,p=e.l,f=e.d,y=e.m,v=e.n,x=n*8;do{if(!p){e.f=u=Rt(a,c,1);var S=Rt(a,c+1,3);if(c+=3,S)if(S==1)p=Yh,f=Uh,y=9,v=5;else if(S==2){var G=Rt(a,c,31)+257,A=Rt(a,c+10,15)+4,R=G+Rt(a,c+5,31)+1;c+=14;for(var D=new Zt(R),k=new Zt(19),C=0;C<A;++C)k[kh[C]]=Rt(a,c+C*3,7);c+=A*3;for(var K=Is(k),I=(1<<K)-1,z=Ai(k,K,1),C=0;C<R;){var N=z[Rt(a,c,I)];c+=N&15;var _=N>>>4;if(_<16)D[C++]=_;else{var H=0,j=0;for(_==16?(j=3+Rt(a,c,3),c+=2,H=D[C-1]):_==17?(j=3+Rt(a,c,7),c+=3):_==18&&(j=11+Rt(a,c,127),c+=7);j--;)D[C++]=H}}var q=D.subarray(0,G),J=D.subarray(G);y=Is(q),v=Is(J),p=Ai(q,y,1),f=Ai(J,v,1)}else throw"invalid block type";else{var _=Bh(c)+4,Z=a[_-4]|a[_-3]<<8,M=_+Z;if(M>n){if(s)throw"unexpected EOF";break}i&&l(d+Z),t.set(a.subarray(_,M),d),e.b=d+=Z,e.p=c=M*8;continue}if(c>x){if(s)throw"unexpected EOF";break}}i&&l(d+131072);for(var oe=(1<<y)-1,re=(1<<v)-1,te=c;;te=c){var H=p[Cs(a,c)&oe],me=H>>>4;if(c+=H&15,c>x){if(s)throw"unexpected EOF";break}if(!H)throw"invalid length/literal";if(me<256)t[d++]=me;else if(me==256){te=c,p=null;break}else{var be=me-254;if(me>264){var C=me-257,he=Da[C];be=Rt(a,c,(1<<he)-1)+Ka[C],c+=he}var ve=f[Cs(a,c)&re],ze=ve>>>4;if(!ve)throw"invalid distance";c+=ve&15;var J=Kh[ze];if(ze>3){var he=ka[ze];J+=Cs(a,c)&(1<<he)-1,c+=he}if(c>x){if(s)throw"unexpected EOF";break}i&&l(d+131072);for(var Ye=d+be;d<Ye;d+=4)t[d]=t[d-J],t[d+1]=t[d+1-J],t[d+2]=t[d+2-J],t[d+3]=t[d+3-J];d=Ye}}e.l=p,e.p=te,e.b=d,p&&(u=1,e.m=y,e.d=f,e.n=v)}while(!u);return d==t.length?t:Nh(t,0,d)},Jh=new Zt(0),Qh=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Hh(a,t){return jh((Qh(a),a.subarray(2,-4)),t)}var Eh=typeof TextDecoder<"u"&&new TextDecoder,qh=0;try{Eh.decode(Jh,{stream:!0}),qh=1}catch{}class $h extends m.Mesh{constructor(t,e={}){super(t),this.isWater=!0;const n=this,i=e.textureWidth!==void 0?e.textureWidth:512,s=e.textureHeight!==void 0?e.textureHeight:512,l=e.clipBias!==void 0?e.clipBias:0,u=e.alpha!==void 0?e.alpha:1,c=e.time!==void 0?e.time:0,d=e.waterNormals!==void 0?e.waterNormals:null,p=e.sunDirection!==void 0?e.sunDirection:new m.Vector3(.70707,.70707,0),f=new m.Color(e.sunColor!==void 0?e.sunColor:16777215),y=new m.Color(e.waterColor!==void 0?e.waterColor:8355711),v=e.eye!==void 0?e.eye:new m.Vector3(0,0,0),x=e.distortionScale!==void 0?e.distortionScale:20,S=e.side!==void 0?e.side:m.FrontSide,_=e.fog!==void 0?e.fog:!1,Z=new m.Plane,M=new m.Vector3,G=new m.Vector3,A=new m.Vector3,R=new m.Matrix4,D=new m.Vector3(0,0,-1),k=new m.Vector4,C=new m.Vector3,K=new m.Vector3,I=new m.Vector4,z=new m.Matrix4,N=new m.PerspectiveCamera,H=new m.WebGLRenderTarget(i,s),j={uniforms:m.UniformsUtils.merge([m.UniformsLib.fog,m.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new m.Matrix4},sunColor:{value:new m.Color(8355711)},sunDirection:{value:new m.Vector3(.70707,.70707,0)},eye:{value:new m.Vector3},waterColor:{value:new m.Color(5592405)}}]),vertexShader:`
|
|
2
2
|
uniform mat4 textureMatrix;
|
|
3
3
|
uniform float time;
|
|
4
4
|
|
|
@@ -92,14 +92,14 @@
|
|
|
92
92
|
gl_FragColor = vec4( outgoingLight, alpha );
|
|
93
93
|
|
|
94
94
|
#include <tonemapping_fragment>
|
|
95
|
-
#include <${
|
|
95
|
+
#include <${gr>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
96
96
|
#include <fog_fragment>
|
|
97
|
-
}`},q=new m.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:m.UniformsUtils.clone(j.uniforms),lights:!0,side:L,fog:_});q.uniforms.mirrorSampler.value=H.texture,q.uniforms.textureMatrix.value=k,q.uniforms.alpha.value=c,q.uniforms.time.value=u,q.uniforms.normalSampler.value=d,q.uniforms.sunColor.value=f,q.uniforms.waterColor.value=y,q.uniforms.sunDirection.value=p,q.uniforms.distortionScale.value=x,q.uniforms.eye.value=v,n.material=q,n.onBeforeRender=function(J,oe,ie){if(G.setFromMatrixPosition(n.matrixWorld),A.setFromMatrixPosition(ie.matrixWorld),K.extractRotation(n.matrixWorld),Z.set(0,0,1),Z.applyMatrix4(K),V.subVectors(G,A),V.dot(Z)>0)return;V.reflect(Z).negate(),V.add(G),K.extractRotation(ie.matrixWorld),D.set(0,0,-1),D.applyMatrix4(K),D.add(A),R.subVectors(G,D),R.reflect(Z).negate(),R.add(G),N.position.copy(V),N.up.set(0,1,0),N.up.applyMatrix4(K),N.up.reflect(Z),N.lookAt(R),N.far=ie.far,N.updateMatrixWorld(),N.projectionMatrix.copy(ie.projectionMatrix),k.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),k.multiply(N.projectionMatrix),k.multiply(N.matrixWorldInverse),S.setFromNormalAndCoplanarPoint(Z,G),S.applyMatrix4(N.matrixWorldInverse),O.set(S.normal.x,S.normal.y,S.normal.z,S.constant);const te=N.projectionMatrix;W.x=(Math.sign(O.x)+te.elements[8])/te.elements[0],W.y=(Math.sign(O.y)+te.elements[9])/te.elements[5],W.z=-1,W.w=(1+te.elements[10])/te.elements[14],O.multiplyScalar(2/O.dot(W)),te.elements[2]=O.x,te.elements[6]=O.y,te.elements[10]=O.z+1-a,te.elements[14]=O.w,v.setFromMatrixPosition(ie.matrixWorld);const me=J.getRenderTarget(),be=J.xr.enabled,he=J.shadowMap.autoUpdate;n.visible=!1,J.xr.enabled=!1,J.shadowMap.autoUpdate=!1,J.setRenderTarget(H),J.state.buffers.depth.setMask(!0),J.autoClear===!1&&J.clear(),J.render(oe,N),n.visible=!0,J.xr.enabled=be,J.shadowMap.autoUpdate=he,J.setRenderTarget(me);const ve=ie.viewport;ve!==void 0&&J.state.viewport(ve)}}}var Qh=Object.defineProperty,Hh=(l,t,e)=>t in l?Qh(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,Eh=(l,t,e)=>(Hh(l,t+"",e),e);class qh{constructor(){Eh(this,"_listeners")}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const r=this._listeners[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,t);t.target=null}}}var $h=Object.defineProperty,ed=(l,t,e)=>t in l?$h(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,se=(l,t,e)=>(ed(l,typeof t!="symbol"?t+"":t,e),e);const pi=new m.Ray,Da=new m.Plane,td=Math.cos(70*(Math.PI/180)),za=(l,t)=>(l%t+t)%t;class nd extends qh{constructor(t,e){super(),se(this,"object"),se(this,"domElement"),se(this,"enabled",!0),se(this,"target",new m.Vector3),se(this,"minDistance",0),se(this,"maxDistance",1/0),se(this,"minZoom",0),se(this,"maxZoom",1/0),se(this,"minPolarAngle",0),se(this,"maxPolarAngle",Math.PI),se(this,"minAzimuthAngle",-1/0),se(this,"maxAzimuthAngle",1/0),se(this,"enableDamping",!1),se(this,"dampingFactor",.05),se(this,"enableZoom",!0),se(this,"zoomSpeed",1),se(this,"enableRotate",!0),se(this,"rotateSpeed",1),se(this,"enablePan",!0),se(this,"panSpeed",1),se(this,"screenSpacePanning",!0),se(this,"keyPanSpeed",7),se(this,"zoomToCursor",!1),se(this,"autoRotate",!1),se(this,"autoRotateSpeed",2),se(this,"reverseOrbit",!1),se(this,"reverseHorizontalOrbit",!1),se(this,"reverseVerticalOrbit",!1),se(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),se(this,"mouseButtons",{LEFT:m.MOUSE.ROTATE,MIDDLE:m.MOUSE.DOLLY,RIGHT:m.MOUSE.PAN}),se(this,"touches",{ONE:m.TOUCH.ROTATE,TWO:m.TOUCH.DOLLY_PAN}),se(this,"target0"),se(this,"position0"),se(this,"zoom0"),se(this,"_domElementKeyEvents",null),se(this,"getPolarAngle"),se(this,"getAzimuthalAngle"),se(this,"setPolarAngle"),se(this,"setAzimuthalAngle"),se(this,"getDistance"),se(this,"getZoomScale"),se(this,"listenToKeyEvents"),se(this,"stopListenToKeyEvents"),se(this,"saveState"),se(this,"reset"),se(this,"update"),se(this,"connect"),se(this,"dispose"),se(this,"dollyIn"),se(this,"dollyOut"),se(this,"getScale"),se(this,"setScale"),this.object=t,this.domElement=e,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=X=>{let E=za(X,2*Math.PI),ue=p.phi;ue<0&&(ue+=2*Math.PI),E<0&&(E+=2*Math.PI);let Se=Math.abs(E-ue);2*Math.PI-Se<Se&&(E<ue?E+=2*Math.PI:ue+=2*Math.PI),f.phi=E-ue,n.update()},this.setAzimuthalAngle=X=>{let E=za(X,2*Math.PI),ue=p.theta;ue<0&&(ue+=2*Math.PI),E<0&&(E+=2*Math.PI);let Se=Math.abs(E-ue);2*Math.PI-Se<Se&&(E<ue?E+=2*Math.PI:ue+=2*Math.PI),f.theta=E-ue,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=X=>{X.addEventListener("keydown",sn),this._domElementKeyEvents=X},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",sn),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),u=c.NONE},this.update=(()=>{const X=new m.Vector3,E=new m.Vector3(0,1,0),ue=new m.Quaternion().setFromUnitVectors(t.up,E),Se=ue.clone().invert(),Re=new m.Vector3,Ct=new m.Quaternion,Bt=2*Math.PI;return function(){const ki=n.object.position;ue.setFromUnitVectors(t.up,E),Se.copy(ue).invert(),X.copy(ki).sub(n.target),X.applyQuaternion(ue),p.setFromVector3(X),n.autoRotate&&u===c.NONE&&j(N()),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let Nt=n.minAzimuthAngle,jt=n.maxAzimuthAngle;isFinite(Nt)&&isFinite(jt)&&(Nt<-Math.PI?Nt+=Bt:Nt>Math.PI&&(Nt-=Bt),jt<-Math.PI?jt+=Bt:jt>Math.PI&&(jt-=Bt),Nt<=jt?p.theta=Math.max(Nt,Math.min(jt,p.theta)):p.theta=p.theta>(Nt+jt)/2?Math.max(Nt,p.theta):Math.min(jt,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(v,n.dampingFactor):n.target.add(v),n.zoomToCursor&&R||n.object.isOrthographicCamera?p.radius=ve(p.radius):p.radius=ve(p.radius*y),X.setFromSpherical(p),X.applyQuaternion(Se),ki.copy(n.target).add(X),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,v.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),v.set(0,0,0));let Cn=!1;if(n.zoomToCursor&&R){let qn=null;if(n.object instanceof m.PerspectiveCamera&&n.object.isPerspectiveCamera){const $n=X.length();qn=ve($n*y);const yr=$n-qn;n.object.position.addScaledVector(O,yr),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const $n=new m.Vector3(V.x,V.y,0);$n.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/y)),n.object.updateProjectionMatrix(),Cn=!0;const yr=new m.Vector3(V.x,V.y,0);yr.unproject(n.object),n.object.position.sub(yr).add($n),n.object.updateMatrixWorld(),qn=X.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;qn!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(qn).add(n.object.position):(pi.origin.copy(n.object.position),pi.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(pi.direction))<td?t.lookAt(n.target):(Da.setFromNormalAndCoplanarPoint(n.object.up,n.target),pi.intersectPlane(Da,n.target))))}else n.object instanceof m.OrthographicCamera&&n.object.isOrthographicCamera&&(Cn=y!==1,Cn&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/y)),n.object.updateProjectionMatrix()));return y=1,R=!1,Cn||Re.distanceToSquared(n.object.position)>d||8*(1-Ct.dot(n.object.quaternion))>d?(n.dispatchEvent(r),Re.copy(n.object.position),Ct.copy(n.object.quaternion),Cn=!1,!0):!1}})(),this.connect=X=>{n.domElement=X,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",mr),n.domElement.addEventListener("pointerdown",Pn),n.domElement.addEventListener("pointercancel",Qn),n.domElement.addEventListener("wheel",Wn)},this.dispose=()=>{var X,E,ue,Se,Re,Ct;n.domElement&&(n.domElement.style.touchAction="auto"),(X=n.domElement)==null||X.removeEventListener("contextmenu",mr),(E=n.domElement)==null||E.removeEventListener("pointerdown",Pn),(ue=n.domElement)==null||ue.removeEventListener("pointercancel",Qn),(Se=n.domElement)==null||Se.removeEventListener("wheel",Wn),(Re=n.domElement)==null||Re.ownerDocument.removeEventListener("pointermove",In),(Ct=n.domElement)==null||Ct.ownerDocument.removeEventListener("pointerup",Qn),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",sn)};const n=this,r={type:"change"},s={type:"start"},a={type:"end"},c={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=c.NONE;const d=1e-6,p=new m.Spherical,f=new m.Spherical;let y=1;const v=new m.Vector3,x=new m.Vector2,L=new m.Vector2,_=new m.Vector2,S=new m.Vector2,Z=new m.Vector2,G=new m.Vector2,A=new m.Vector2,K=new m.Vector2,D=new m.Vector2,O=new m.Vector3,V=new m.Vector2;let R=!1;const W=[],k={};function N(){return 2*Math.PI/60/60*n.autoRotateSpeed}function H(){return Math.pow(.95,n.zoomSpeed)}function j(X){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=X:f.theta-=X}function q(X){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=X:f.phi-=X}const J=(()=>{const X=new m.Vector3;return function(ue,Se){X.setFromMatrixColumn(Se,0),X.multiplyScalar(-ue),v.add(X)}})(),oe=(()=>{const X=new m.Vector3;return function(ue,Se){n.screenSpacePanning===!0?X.setFromMatrixColumn(Se,1):(X.setFromMatrixColumn(Se,0),X.crossVectors(n.object.up,X)),X.multiplyScalar(ue),v.add(X)}})(),ie=(()=>{const X=new m.Vector3;return function(ue,Se){const Re=n.domElement;if(Re&&n.object instanceof m.PerspectiveCamera&&n.object.isPerspectiveCamera){const Ct=n.object.position;X.copy(Ct).sub(n.target);let Bt=X.length();Bt*=Math.tan(n.object.fov/2*Math.PI/180),J(2*ue*Bt/Re.clientHeight,n.object.matrix),oe(2*Se*Bt/Re.clientHeight,n.object.matrix)}else Re&&n.object instanceof m.OrthographicCamera&&n.object.isOrthographicCamera?(J(ue*(n.object.right-n.object.left)/n.object.zoom/Re.clientWidth,n.object.matrix),oe(Se*(n.object.top-n.object.bottom)/n.object.zoom/Re.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function te(X){n.object instanceof m.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof m.OrthographicCamera&&n.object.isOrthographicCamera?y=X:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function me(X){te(y/X)}function be(X){te(y*X)}function he(X){if(!n.zoomToCursor||!n.domElement)return;R=!0;const E=n.domElement.getBoundingClientRect(),ue=X.clientX-E.left,Se=X.clientY-E.top,Re=E.width,Ct=E.height;V.x=ue/Re*2-1,V.y=-(Se/Ct)*2+1,O.set(V.x,V.y,1).unproject(n.object).sub(n.object.position).normalize()}function ve(X){return Math.max(n.minDistance,Math.min(n.maxDistance,X))}function ke(X){x.set(X.clientX,X.clientY)}function Ye(X){he(X),A.set(X.clientX,X.clientY)}function je(X){S.set(X.clientX,X.clientY)}function Je(X){L.set(X.clientX,X.clientY),_.subVectors(L,x).multiplyScalar(n.rotateSpeed);const E=n.domElement;E&&(j(2*Math.PI*_.x/E.clientHeight),q(2*Math.PI*_.y/E.clientHeight)),x.copy(L),n.update()}function Qe(X){K.set(X.clientX,X.clientY),D.subVectors(K,A),D.y>0?me(H()):D.y<0&&be(H()),A.copy(K),n.update()}function ct(X){Z.set(X.clientX,X.clientY),G.subVectors(Z,S).multiplyScalar(n.panSpeed),ie(G.x,G.y),S.copy(Z),n.update()}function pt(X){he(X),X.deltaY<0?be(H()):X.deltaY>0&&me(H()),n.update()}function Ue(X){let E=!1;switch(X.code){case n.keys.UP:ie(0,n.keyPanSpeed),E=!0;break;case n.keys.BOTTOM:ie(0,-n.keyPanSpeed),E=!0;break;case n.keys.LEFT:ie(n.keyPanSpeed,0),E=!0;break;case n.keys.RIGHT:ie(-n.keyPanSpeed,0),E=!0;break}E&&(X.preventDefault(),n.update())}function hn(){if(W.length==1)x.set(W[0].pageX,W[0].pageY);else{const X=.5*(W[0].pageX+W[1].pageX),E=.5*(W[0].pageY+W[1].pageY);x.set(X,E)}}function Gn(){if(W.length==1)S.set(W[0].pageX,W[0].pageY);else{const X=.5*(W[0].pageX+W[1].pageX),E=.5*(W[0].pageY+W[1].pageY);S.set(X,E)}}function Ae(){const X=W[0].pageX-W[1].pageX,E=W[0].pageY-W[1].pageY,ue=Math.sqrt(X*X+E*E);A.set(0,ue)}function Ut(){n.enableZoom&&Ae(),n.enablePan&&Gn()}function It(){n.enableZoom&&Ae(),n.enableRotate&&hn()}function Wt(X){if(W.length==1)L.set(X.pageX,X.pageY);else{const ue=En(X),Se=.5*(X.pageX+ue.x),Re=.5*(X.pageY+ue.y);L.set(Se,Re)}_.subVectors(L,x).multiplyScalar(n.rotateSpeed);const E=n.domElement;E&&(j(2*Math.PI*_.x/E.clientHeight),q(2*Math.PI*_.y/E.clientHeight)),x.copy(L)}function jr(X){if(W.length==1)Z.set(X.pageX,X.pageY);else{const E=En(X),ue=.5*(X.pageX+E.x),Se=.5*(X.pageY+E.y);Z.set(ue,Se)}G.subVectors(Z,S).multiplyScalar(n.panSpeed),ie(G.x,G.y),S.copy(Z)}function Xi(X){const E=En(X),ue=X.pageX-E.x,Se=X.pageY-E.y,Re=Math.sqrt(ue*ue+Se*Se);K.set(0,Re),D.set(0,Math.pow(K.y/A.y,n.zoomSpeed)),me(D.y),A.copy(K)}function Jn(X){n.enableZoom&&Xi(X),n.enablePan&&jr(X)}function xt(X){n.enableZoom&&Xi(X),n.enableRotate&&Wt(X)}function Pn(X){var E,ue;n.enabled!==!1&&(W.length===0&&((E=n.domElement)==null||E.ownerDocument.addEventListener("pointermove",In),(ue=n.domElement)==null||ue.ownerDocument.addEventListener("pointerup",Qn)),Hr(X),X.pointerType==="touch"?Jr(X):Hn(X))}function In(X){n.enabled!==!1&&(X.pointerType==="touch"?Qr(X):vo(X))}function Qn(X){var E,ue,Se;Er(X),W.length===0&&((E=n.domElement)==null||E.releasePointerCapture(X.pointerId),(ue=n.domElement)==null||ue.ownerDocument.removeEventListener("pointermove",In),(Se=n.domElement)==null||Se.ownerDocument.removeEventListener("pointerup",Qn)),n.dispatchEvent(a),u=c.NONE}function Hn(X){let E;switch(X.button){case 0:E=n.mouseButtons.LEFT;break;case 1:E=n.mouseButtons.MIDDLE;break;case 2:E=n.mouseButtons.RIGHT;break;default:E=-1}switch(E){case m.MOUSE.DOLLY:if(n.enableZoom===!1)return;Ye(X),u=c.DOLLY;break;case m.MOUSE.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(n.enablePan===!1)return;je(X),u=c.PAN}else{if(n.enableRotate===!1)return;ke(X),u=c.ROTATE}break;case m.MOUSE.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(n.enableRotate===!1)return;ke(X),u=c.ROTATE}else{if(n.enablePan===!1)return;je(X),u=c.PAN}break;default:u=c.NONE}u!==c.NONE&&n.dispatchEvent(s)}function vo(X){if(n.enabled!==!1)switch(u){case c.ROTATE:if(n.enableRotate===!1)return;Je(X);break;case c.DOLLY:if(n.enableZoom===!1)return;Qe(X);break;case c.PAN:if(n.enablePan===!1)return;ct(X);break}}function Wn(X){n.enabled===!1||n.enableZoom===!1||u!==c.NONE&&u!==c.ROTATE||(X.preventDefault(),n.dispatchEvent(s),pt(X),n.dispatchEvent(a))}function sn(X){n.enabled===!1||n.enablePan===!1||Ue(X)}function Jr(X){switch(gr(X),W.length){case 1:switch(n.touches.ONE){case m.TOUCH.ROTATE:if(n.enableRotate===!1)return;hn(),u=c.TOUCH_ROTATE;break;case m.TOUCH.PAN:if(n.enablePan===!1)return;Gn(),u=c.TOUCH_PAN;break;default:u=c.NONE}break;case 2:switch(n.touches.TWO){case m.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ut(),u=c.TOUCH_DOLLY_PAN;break;case m.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;It(),u=c.TOUCH_DOLLY_ROTATE;break;default:u=c.NONE}break;default:u=c.NONE}u!==c.NONE&&n.dispatchEvent(s)}function Qr(X){switch(gr(X),u){case c.TOUCH_ROTATE:if(n.enableRotate===!1)return;Wt(X),n.update();break;case c.TOUCH_PAN:if(n.enablePan===!1)return;jr(X),n.update();break;case c.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Jn(X),n.update();break;case c.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;xt(X),n.update();break;default:u=c.NONE}}function mr(X){n.enabled!==!1&&X.preventDefault()}function Hr(X){W.push(X)}function Er(X){delete k[X.pointerId];for(let E=0;E<W.length;E++)if(W[E].pointerId==X.pointerId){W.splice(E,1);return}}function gr(X){let E=k[X.pointerId];E===void 0&&(E=new m.Vector2,k[X.pointerId]=E),E.set(X.pageX,X.pageY)}function En(X){const E=X.pointerId===W[0].pointerId?W[1]:W[0];return k[E.pointerId]}this.dollyIn=(X=H())=>{be(X),n.update()},this.dollyOut=(X=H())=>{me(X),n.update()},this.getScale=()=>y,this.setScale=X=>{te(X),n.update()},this.getZoomScale=()=>H(),e!==void 0&&this.connect(e),this.update()}}class rd extends nd{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons.LEFT=m.MOUSE.PAN,this.mouseButtons.RIGHT=m.MOUSE.ROTATE,this.touches.ONE=m.TOUCH.PAN,this.touches.TWO=m.TOUCH.DOLLY_ROTATE}}function ur(l){if(typeof TextDecoder<"u")return new TextDecoder().decode(l);let t="";for(let e=0,n=l.length;e<n;e++)t+=String.fromCharCode(l[e]);try{return decodeURIComponent(escape(t))}catch{return t}}const Rn="srgb",cn="srgb-linear",Oa=3001,id=3e3;class sd extends m.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new ud(e)}),this.register(function(e){return new hd(e)}),this.register(function(e){return new xd(e)}),this.register(function(e){return new bd(e)}),this.register(function(e){return new _d(e)}),this.register(function(e){return new fd(e)}),this.register(function(e){return new pd(e)}),this.register(function(e){return new md(e)}),this.register(function(e){return new gd(e)}),this.register(function(e){return new cd(e)}),this.register(function(e){return new yd(e)}),this.register(function(e){return new dd(e)}),this.register(function(e){return new wd(e)}),this.register(function(e){return new vd(e)}),this.register(function(e){return new ad(e)}),this.register(function(e){return new Md(e)}),this.register(function(e){return new Ld(e)})}load(t,e,n,r){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const d=m.LoaderUtils.extractUrlBase(t);a=m.LoaderUtils.resolveURL(d,this.path)}else a=m.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const c=function(d){r?r(d):console.error(d),s.manager.itemError(t),s.manager.itemEnd(t)},u=new m.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(t,function(d){try{s.parse(d,a,function(p){e(p),s.manager.itemEnd(t)},c)}catch(p){c(p)}},n,c)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,r){let s;const a={},c={};if(typeof t=="string")s=JSON.parse(t);else if(t instanceof ArrayBuffer)if(ur(new Uint8Array(t.slice(0,4)))===Ka){try{a[we.KHR_BINARY_GLTF]=new Sd(t)}catch(p){r&&r(p);return}s=JSON.parse(a[we.KHR_BINARY_GLTF].content)}else s=JSON.parse(ur(new Uint8Array(t)));else s=t;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new Dd(s,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const p=this.pluginCallbacks[d](u);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[p.name]=p,a[p.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const p=s.extensionsUsed[d],f=s.extensionsRequired||[];switch(p){case we.KHR_MATERIALS_UNLIT:a[p]=new ld;break;case we.KHR_DRACO_MESH_COMPRESSION:a[p]=new Zd(s,this.dracoLoader);break;case we.KHR_TEXTURE_TRANSFORM:a[p]=new Td;break;case we.KHR_MESH_QUANTIZATION:a[p]=new Gd;break;default:f.indexOf(p)>=0&&c[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}u.setExtensions(a),u.setPlugins(c),u.parse(n,r)}parseAsync(t,e){const n=this;return new Promise(function(r,s){n.parse(t,e,r,s)})}}function od(){let l={};return{get:function(t){return l[t]},add:function(t,e){l[t]=e},remove:function(t){delete l[t]},removeAll:function(){l={}}}}const we={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ad{constructor(t){this.parser=t,this.name=we.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,r=e.length;n<r;n++){const s=e[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let r=e.cache.get(n);if(r)return r;const s=e.json,u=((s.extensions&&s.extensions[this.name]||{}).lights||[])[t];let d;const p=new m.Color(16777215);u.color!==void 0&&p.setRGB(u.color[0],u.color[1],u.color[2],cn);const f=u.range!==void 0?u.range:0;switch(u.type){case"directional":d=new m.DirectionalLight(p),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new m.PointLight(p),d.distance=f;break;case"spot":d=new m.SpotLight(p),d.distance=f,u.spot=u.spot||{},u.spot.innerConeAngle=u.spot.innerConeAngle!==void 0?u.spot.innerConeAngle:0,u.spot.outerConeAngle=u.spot.outerConeAngle!==void 0?u.spot.outerConeAngle:Math.PI/4,d.angle=u.spot.outerConeAngle,d.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return d.position.set(0,0,0),d.decay=2,un(d,u),u.intensity!==void 0&&(d.intensity=u.intensity),d.name=e.createUniqueName(u.name||"light_"+t),r=Promise.resolve(d),e.cache.add(n,r),r}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,s=n.json.nodes[t],c=(s.extensions&&s.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(u){return n._getNodeRef(e.cache,c,u)})}}class ld{constructor(){this.name=we.KHR_MATERIALS_UNLIT}getMaterialType(){return m.MeshBasicMaterial}extendParams(t,e,n){const r=[];t.color=new m.Color(1,1,1),t.opacity=1;const s=e.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;t.color.setRGB(a[0],a[1],a[2],cn),t.opacity=a[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(t,"map",s.baseColorTexture,Rn))}return Promise.all(r)}}class cd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const r=this.parser.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(e.emissiveIntensity=s),Promise.resolve()}}class ud{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];if(a.clearcoatFactor!==void 0&&(e.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&s.push(n.assignTexture(e,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(e,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(e,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const c=a.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new m.Vector2(c,c)}return Promise.all(s)}}class hd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_DISPERSION}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name];return e.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class dd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];return a.iridescenceFactor!==void 0&&(e.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&s.push(n.assignTexture(e,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(e.iridescenceIOR=a.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(e,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(s)}}class fd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_SHEEN}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[];e.sheenColor=new m.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const a=r.extensions[this.name];if(a.sheenColorFactor!==void 0){const c=a.sheenColorFactor;e.sheenColor.setRGB(c[0],c[1],c[2],cn)}return a.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&s.push(n.assignTexture(e,"sheenColorMap",a.sheenColorTexture,Rn)),a.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(e,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(s)}}class pd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];return a.transmissionFactor!==void 0&&(e.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&s.push(n.assignTexture(e,"transmissionMap",a.transmissionTexture)),Promise.all(s)}}class md{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_VOLUME}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];e.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&s.push(n.assignTexture(e,"thicknessMap",a.thicknessTexture)),e.attenuationDistance=a.attenuationDistance||1/0;const c=a.attenuationColor||[1,1,1];return e.attenuationColor=new m.Color().setRGB(c[0],c[1],c[2],cn),Promise.all(s)}}class gd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_IOR}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const r=this.parser.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name];return e.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class yd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_SPECULAR}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];e.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&s.push(n.assignTexture(e,"specularIntensityMap",a.specularTexture));const c=a.specularColorFactor||[1,1,1];return e.specularColor=new m.Color().setRGB(c[0],c[1],c[2],cn),a.specularColorTexture!==void 0&&s.push(n.assignTexture(e,"specularColorMap",a.specularColorTexture,Rn)),Promise.all(s)}}class vd{constructor(t){this.parser=t,this.name=we.EXT_MATERIALS_BUMP}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];return e.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&s.push(n.assignTexture(e,"bumpMap",a.bumpTexture)),Promise.all(s)}}class wd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,r=n.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],a=r.extensions[this.name];return a.anisotropyStrength!==void 0&&(e.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(e.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&s.push(n.assignTexture(e,"anisotropyMap",a.anisotropyTexture)),Promise.all(s)}}class xd{constructor(t){this.parser=t,this.name=we.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,r=n.textures[t];if(!r.extensions||!r.extensions[this.name])return null;const s=r.extensions[this.name],a=e.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,s.source,a)}}class bd{constructor(t){this.parser=t,this.name=we.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,s=r.textures[t];if(!s.extensions||!s.extensions[e])return null;const a=s.extensions[e],c=r.images[a.source];let u=n.textureLoader;if(c.uri){const d=n.options.manager.getHandler(c.uri);d!==null&&(u=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(t,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class _d{constructor(t){this.parser=t,this.name=we.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,r=n.json,s=r.textures[t];if(!s.extensions||!s.extensions[e])return null;const a=s.extensions[e],c=r.images[a.source];let u=n.textureLoader;if(c.uri){const d=n.options.manager.getHandler(c.uri);d!==null&&(u=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(t,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Md{constructor(t){this.name=we.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(c){const u=r.byteOffset||0,d=r.byteLength||0,p=r.count,f=r.byteStride,y=new Uint8Array(c,u,d);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(p,f,y,r.mode,r.filter).then(function(v){return v.buffer}):a.ready.then(function(){const v=new ArrayBuffer(p*f);return a.decodeGltfBuffer(new Uint8Array(v),p,f,y,r.mode,r.filter),v})})}else return null}}class Ld{constructor(t){this.name=we.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=e.meshes[n.mesh];for(const d of r.primitives)if(d.mode!==Gt.TRIANGLES&&d.mode!==Gt.TRIANGLE_STRIP&&d.mode!==Gt.TRIANGLE_FAN&&d.mode!==void 0)return null;const a=n.extensions[this.name].attributes,c=[],u={};for(const d in a)c.push(this.parser.getDependency("accessor",a[d]).then(p=>(u[d]=p,u[d])));return c.length<1?null:(c.push(this.parser.createNodeMesh(t)),Promise.all(c).then(d=>{const p=d.pop(),f=p.isGroup?p.children:[p],y=d[0].count,v=[];for(const x of f){const L=new m.Matrix4,_=new m.Vector3,S=new m.Quaternion,Z=new m.Vector3(1,1,1),G=new m.InstancedMesh(x.geometry,x.material,y);for(let A=0;A<y;A++)u.TRANSLATION&&_.fromBufferAttribute(u.TRANSLATION,A),u.ROTATION&&S.fromBufferAttribute(u.ROTATION,A),u.SCALE&&Z.fromBufferAttribute(u.SCALE,A),G.setMatrixAt(A,L.compose(_,S,Z));for(const A in u)if(A==="_COLOR_0"){const K=u[A];G.instanceColor=new m.InstancedBufferAttribute(K.array,K.itemSize,K.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&x.geometry.setAttribute(A,u[A]);m.Object3D.prototype.copy.call(G,x),this.parser.assignFinalMaterial(G),v.push(G)}return p.isGroup?(p.clear(),p.add(...v),p):v[0]}))}}const Ka="glTF",Fr=12,Ra={JSON:1313821514,BIN:5130562};class Sd{constructor(t){this.name=we.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,Fr);if(this.header={magic:ur(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Ka)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Fr,r=new DataView(t,Fr);let s=0;for(;s<n;){const a=r.getUint32(s,!0);s+=4;const c=r.getUint32(s,!0);if(s+=4,c===Ra.JSON){const u=new Uint8Array(t,Fr+s,a);this.content=ur(u)}else if(c===Ra.BIN){const u=Fr+s;this.body=t.slice(u,u+a)}s+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Zd{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=we.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,r=this.dracoLoader,s=t.extensions[this.name].bufferView,a=t.extensions[this.name].attributes,c={},u={},d={};for(const p in a){const f=Vs[p]||p.toLowerCase();c[f]=a[p]}for(const p in t.attributes){const f=Vs[p]||p.toLowerCase();if(a[p]!==void 0){const y=n.accessors[t.attributes[p]],v=hr[y.componentType];d[f]=v.name,u[f]=y.normalized===!0}}return e.getDependency("bufferView",s).then(function(p){return new Promise(function(f,y){r.decodeDracoFile(p,function(v){for(const x in v.attributes){const L=v.attributes[x],_=u[x];_!==void 0&&(L.normalized=_)}f(v)},c,d,cn,y)})})}}class Td{constructor(){this.name=we.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Gd{constructor(){this.name=we.KHR_MESH_QUANTIZATION}}class Ya extends m.Interpolant{constructor(t,e,n,r){super(t,e,n,r)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r*3+r;for(let a=0;a!==r;a++)e[a]=n[s+a];return e}interpolate_(t,e,n,r){const s=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=c*2,d=c*3,p=r-e,f=(n-e)/p,y=f*f,v=y*f,x=t*d,L=x-d,_=-2*v+3*y,S=v-y,Z=1-_,G=S-y+f;for(let A=0;A!==c;A++){const K=a[L+A+c],D=a[L+A+u]*p,O=a[x+A+c],V=a[x+A]*p;s[A]=Z*K+G*D+_*O+S*V}return s}}const Pd=new m.Quaternion;class Id extends Ya{interpolate_(t,e,n,r){const s=super.interpolate_(t,e,n,r);return Pd.fromArray(s).normalize().toArray(s),s}}const Gt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},hr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ua={9728:m.NearestFilter,9729:m.LinearFilter,9984:m.NearestMipmapNearestFilter,9985:m.LinearMipmapNearestFilter,9986:m.NearestMipmapLinearFilter,9987:m.LinearMipmapLinearFilter},Ba={33071:m.ClampToEdgeWrapping,33648:m.MirroredRepeatWrapping,10497:m.RepeatWrapping},Cs={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vs={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...fi>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Mn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Wd={CUBICSPLINE:void 0,LINEAR:m.InterpolateLinear,STEP:m.InterpolateDiscrete},As={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Cd(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new m.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m.FrontSide})),l.DefaultMaterial}function Yn(l,t,e){for(const n in e.extensions)l[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function un(l,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(l.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Vd(l,t,e){let n=!1,r=!1,s=!1;for(let d=0,p=t.length;d<p;d++){const f=t[d];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(r=!0),f.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(l);const a=[],c=[],u=[];for(let d=0,p=t.length;d<p;d++){const f=t[d];if(n){const y=f.POSITION!==void 0?e.getDependency("accessor",f.POSITION):l.attributes.position;a.push(y)}if(r){const y=f.NORMAL!==void 0?e.getDependency("accessor",f.NORMAL):l.attributes.normal;c.push(y)}if(s){const y=f.COLOR_0!==void 0?e.getDependency("accessor",f.COLOR_0):l.attributes.color;u.push(y)}}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(u)]).then(function(d){const p=d[0],f=d[1],y=d[2];return n&&(l.morphAttributes.position=p),r&&(l.morphAttributes.normal=f),s&&(l.morphAttributes.color=y),l.morphTargetsRelative=!0,l})}function Ad(l,t){if(l.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)l.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(l.morphTargetInfluences.length===e.length){l.morphTargetDictionary={};for(let n=0,r=e.length;n<r;n++)l.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Fd(l){let t;const e=l.extensions&&l.extensions[we.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+Fs(e.attributes):t=l.indices+":"+Fs(l.attributes)+":"+l.mode,l.targets!==void 0)for(let n=0,r=l.targets.length;n<r;n++)t+=":"+Fs(l.targets[n]);return t}function Fs(l){let t="";const e=Object.keys(l).sort();for(let n=0,r=e.length;n<r;n++)t+=e[n]+":"+l[e[n]]+";";return t}function Xs(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Xd(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const kd=new m.Matrix4;class Dd{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new od,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,s=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||r&&s<98?this.textureLoader=new m.TextureLoader(this.options.manager):this.textureLoader=new m.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new m.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const c={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:n,userData:{}};return Yn(s,c,r),un(c,r),Promise.all(n._invokeAll(function(u){return u.afterRoot&&u.afterRoot(c)})).then(function(){for(const u of c.scenes)u.updateMatrixWorld();t(c)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=e.length;r<s;r++){const a=e[r].joints;for(let c=0,u=a.length;c<u;c++)t[a[c]].isBone=!0}for(let r=0,s=t.length;r<s;r++){const a=t[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const r=n.clone(),s=(a,c)=>{const u=this.associations.get(a);u!=null&&this.associations.set(c,u);for(const[d,p]of a.children.entries())s(p,c.children[d])};return s(n,r),r.name+="_instance_"+t.uses[e]++,r}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const r=t(e[n]);if(r)return r}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let r=0;r<e.length;r++){const s=t(e[r]);s&&n.push(s)}return n}getDependency(t,e){const n=t+":"+e;let r=this.cache.get(n);if(!r){switch(t){case"scene":r=this.loadScene(e);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(e)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(e)});break;case"accessor":r=this.loadAccessor(e);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(e)});break;case"buffer":r=this.loadBuffer(e);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(e)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(e)});break;case"skin":r=this.loadSkin(e);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(e)});break;case"camera":r=this.loadCamera(e);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(t,e)}),!r)throw new Error("Unknown type: "+t);break}this.cache.add(n,r)}return r}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,r=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(r.map(function(s,a){return n.getDependency(t,a)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[we.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(s,a){n.load(m.LoaderUtils.resolveURL(e.uri,r.path),s,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){const r=e.byteLength||0,s=e.byteOffset||0;return n.slice(s,s+r)})}loadAccessor(t){const e=this,n=this.json,r=this.json.accessors[t];if(r.bufferView===void 0&&r.sparse===void 0){const a=Cs[r.type],c=hr[r.componentType],u=r.normalized===!0,d=new c(r.count*a);return Promise.resolve(new m.BufferAttribute(d,a,u))}const s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(a){const c=a[0],u=Cs[r.type],d=hr[r.componentType],p=d.BYTES_PER_ELEMENT,f=p*u,y=r.byteOffset||0,v=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,x=r.normalized===!0;let L,_;if(v&&v!==f){const S=Math.floor(y/v),Z="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+S+":"+r.count;let G=e.cache.get(Z);G||(L=new d(c,S*v,r.count*v/p),G=new m.InterleavedBuffer(L,v/p),e.cache.add(Z,G)),_=new m.InterleavedBufferAttribute(G,u,y%v/p,x)}else c===null?L=new d(r.count*u):L=new d(c,y,r.count*u),_=new m.BufferAttribute(L,u,x);if(r.sparse!==void 0){const S=Cs.SCALAR,Z=hr[r.sparse.indices.componentType],G=r.sparse.indices.byteOffset||0,A=r.sparse.values.byteOffset||0,K=new Z(a[1],G,r.sparse.count*S),D=new d(a[2],A,r.sparse.count*u);c!==null&&(_=new m.BufferAttribute(_.array.slice(),_.itemSize,_.normalized));for(let O=0,V=K.length;O<V;O++){const R=K[O];if(_.setX(R,D[O*u]),u>=2&&_.setY(R,D[O*u+1]),u>=3&&_.setZ(R,D[O*u+2]),u>=4&&_.setW(R,D[O*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(t){const e=this.json,n=this.options,s=e.textures[t].source,a=e.images[s];let c=this.textureLoader;if(a.uri){const u=n.manager.getHandler(a.uri);u!==null&&(c=u)}return this.loadTextureImage(t,s,c)}loadTextureImage(t,e,n){const r=this,s=this.json,a=s.textures[t],c=s.images[e],u=(c.uri||c.bufferView)+":"+a.sampler;if(this.textureCache[u])return this.textureCache[u];const d=this.loadImageSource(e,n).then(function(p){p.flipY=!1,p.name=a.name||c.name||"",p.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(p.name=c.uri);const y=(s.samplers||{})[a.sampler]||{};return p.magFilter=Ua[y.magFilter]||m.LinearFilter,p.minFilter=Ua[y.minFilter]||m.LinearMipmapLinearFilter,p.wrapS=Ba[y.wrapS]||m.RepeatWrapping,p.wrapT=Ba[y.wrapT]||m.RepeatWrapping,r.associations.set(p,{textures:t}),p}).catch(function(){return null});return this.textureCache[u]=d,d}loadImageSource(t,e){const n=this,r=this.json,s=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(f=>f.clone());const a=r.images[t],c=self.URL||self.webkitURL;let u=a.uri||"",d=!1;if(a.bufferView!==void 0)u=n.getDependency("bufferView",a.bufferView).then(function(f){d=!0;const y=new Blob([f],{type:a.mimeType});return u=c.createObjectURL(y),u});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const p=Promise.resolve(u).then(function(f){return new Promise(function(y,v){let x=y;e.isImageBitmapLoader===!0&&(x=function(L){const _=new m.Texture(L);_.needsUpdate=!0,y(_)}),e.load(m.LoaderUtils.resolveURL(f,s.path),x,void 0,v)})}).then(function(f){return d===!0&&c.revokeObjectURL(u),un(f,a),f.userData.mimeType=a.mimeType||Xd(a.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",u),f});return this.sourceCache[t]=p,p}assignTexture(t,e,n,r){const s=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),s.extensions[we.KHR_TEXTURE_TRANSFORM]){const c=n.extensions!==void 0?n.extensions[we.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const u=s.associations.get(a);a=s.extensions[we.KHR_TEXTURE_TRANSFORM].extendTexture(a,c),s.associations.set(a,u)}}return r!==void 0&&(typeof r=="number"&&(r=r===Oa?Rn:cn),"colorSpace"in a?a.colorSpace=r:a.encoding=r===Rn?Oa:id),t[e]=a,a})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const r=e.attributes.tangent===void 0,s=e.attributes.color!==void 0,a=e.attributes.normal===void 0;if(t.isPoints){const c="PointsMaterial:"+n.uuid;let u=this.cache.get(c);u||(u=new m.PointsMaterial,m.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.sizeAttenuation=!1,this.cache.add(c,u)),n=u}else if(t.isLine){const c="LineBasicMaterial:"+n.uuid;let u=this.cache.get(c);u||(u=new m.LineBasicMaterial,m.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(c,u)),n=u}if(r||s||a){let c="ClonedMaterial:"+n.uuid+":";r&&(c+="derivative-tangents:"),s&&(c+="vertex-colors:"),a&&(c+="flat-shading:");let u=this.cache.get(c);u||(u=n.clone(),s&&(u.vertexColors=!0),a&&(u.flatShading=!0),r&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(c,u),this.associations.set(u,this.associations.get(n))),n=u}t.material=n}getMaterialType(){return m.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,r=this.extensions,s=n.materials[t];let a;const c={},u=s.extensions||{},d=[];if(u[we.KHR_MATERIALS_UNLIT]){const f=r[we.KHR_MATERIALS_UNLIT];a=f.getMaterialType(),d.push(f.extendParams(c,s,e))}else{const f=s.pbrMetallicRoughness||{};if(c.color=new m.Color(1,1,1),c.opacity=1,Array.isArray(f.baseColorFactor)){const y=f.baseColorFactor;c.color.setRGB(y[0],y[1],y[2],cn),c.opacity=y[3]}f.baseColorTexture!==void 0&&d.push(e.assignTexture(c,"map",f.baseColorTexture,Rn)),c.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,c.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(d.push(e.assignTexture(c,"metalnessMap",f.metallicRoughnessTexture)),d.push(e.assignTexture(c,"roughnessMap",f.metallicRoughnessTexture))),a=this._invokeOne(function(y){return y.getMaterialType&&y.getMaterialType(t)}),d.push(Promise.all(this._invokeAll(function(y){return y.extendMaterialParams&&y.extendMaterialParams(t,c)})))}s.doubleSided===!0&&(c.side=m.DoubleSide);const p=s.alphaMode||As.OPAQUE;if(p===As.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,p===As.MASK&&(c.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==m.MeshBasicMaterial&&(d.push(e.assignTexture(c,"normalMap",s.normalTexture)),c.normalScale=new m.Vector2(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;c.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&a!==m.MeshBasicMaterial&&(d.push(e.assignTexture(c,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==m.MeshBasicMaterial){const f=s.emissiveFactor;c.emissive=new m.Color().setRGB(f[0],f[1],f[2],cn)}return s.emissiveTexture!==void 0&&a!==m.MeshBasicMaterial&&d.push(e.assignTexture(c,"emissiveMap",s.emissiveTexture,Rn)),Promise.all(d).then(function(){const f=new a(c);return s.name&&(f.name=s.name),un(f,s),e.associations.set(f,{materials:t}),s.extensions&&Yn(r,f,s),f})}createUniqueName(t){const e=m.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,r=this.primitiveCache;function s(c){return n[we.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,e).then(function(u){return Na(u,c,e)})}const a=[];for(let c=0,u=t.length;c<u;c++){const d=t[c],p=Fd(d),f=r[p];if(f)a.push(f.promise);else{let y;d.extensions&&d.extensions[we.KHR_DRACO_MESH_COMPRESSION]?y=s(d):y=Na(new m.BufferGeometry,d,e),r[p]={primitive:d,promise:y},a.push(y)}}return Promise.all(a)}loadMesh(t){const e=this,n=this.json,r=this.extensions,s=n.meshes[t],a=s.primitives,c=[];for(let u=0,d=a.length;u<d;u++){const p=a[u].material===void 0?Cd(this.cache):this.getDependency("material",a[u].material);c.push(p)}return c.push(e.loadGeometries(a)),Promise.all(c).then(function(u){const d=u.slice(0,u.length-1),p=u[u.length-1],f=[];for(let v=0,x=p.length;v<x;v++){const L=p[v],_=a[v];let S;const Z=d[v];if(_.mode===Gt.TRIANGLES||_.mode===Gt.TRIANGLE_STRIP||_.mode===Gt.TRIANGLE_FAN||_.mode===void 0)S=s.isSkinnedMesh===!0?new m.SkinnedMesh(L,Z):new m.Mesh(L,Z),S.isSkinnedMesh===!0&&S.normalizeSkinWeights(),_.mode===Gt.TRIANGLE_STRIP?S.geometry=Wa(S.geometry,m.TriangleStripDrawMode):_.mode===Gt.TRIANGLE_FAN&&(S.geometry=Wa(S.geometry,m.TriangleFanDrawMode));else if(_.mode===Gt.LINES)S=new m.LineSegments(L,Z);else if(_.mode===Gt.LINE_STRIP)S=new m.Line(L,Z);else if(_.mode===Gt.LINE_LOOP)S=new m.LineLoop(L,Z);else if(_.mode===Gt.POINTS)S=new m.Points(L,Z);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(S.geometry.morphAttributes).length>0&&Ad(S,s),S.name=e.createUniqueName(s.name||"mesh_"+t),un(S,s),_.extensions&&Yn(r,S,_),e.assignFinalMaterial(S),f.push(S)}for(let v=0,x=f.length;v<x;v++)e.associations.set(f[v],{meshes:t,primitives:v});if(f.length===1)return s.extensions&&Yn(r,f[0],s),f[0];const y=new m.Group;s.extensions&&Yn(r,y,s),e.associations.set(y,{meshes:t});for(let v=0,x=f.length;v<x;v++)y.add(f[v]);return y})}loadCamera(t){let e;const n=this.json.cameras[t],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new m.PerspectiveCamera(m.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(e=new m.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),un(e,n),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],n=[];for(let r=0,s=e.joints.length;r<s;r++)n.push(this._loadNodeShallow(e.joints[r]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const s=r.pop(),a=r,c=[],u=[];for(let d=0,p=a.length;d<p;d++){const f=a[d];if(f){c.push(f);const y=new m.Matrix4;s!==null&&y.fromArray(s.array,d*16),u.push(y)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[d])}return new m.Skeleton(c,u)})}loadAnimation(t){const e=this.json,n=this,r=e.animations[t],s=r.name?r.name:"animation_"+t,a=[],c=[],u=[],d=[],p=[];for(let f=0,y=r.channels.length;f<y;f++){const v=r.channels[f],x=r.samplers[v.sampler],L=v.target,_=L.node,S=r.parameters!==void 0?r.parameters[x.input]:x.input,Z=r.parameters!==void 0?r.parameters[x.output]:x.output;L.node!==void 0&&(a.push(this.getDependency("node",_)),c.push(this.getDependency("accessor",S)),u.push(this.getDependency("accessor",Z)),d.push(x),p.push(L))}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(u),Promise.all(d),Promise.all(p)]).then(function(f){const y=f[0],v=f[1],x=f[2],L=f[3],_=f[4],S=[];for(let Z=0,G=y.length;Z<G;Z++){const A=y[Z],K=v[Z],D=x[Z],O=L[Z],V=_[Z];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const R=n._createAnimationTracks(A,K,D,O,V);if(R)for(let W=0;W<R.length;W++)S.push(R[W])}return new m.AnimationClip(s,void 0,S)})}createNodeMesh(t){const e=this.json,n=this,r=e.nodes[t];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(s){const a=n._getNodeRef(n.meshCache,r.mesh,s);return r.weights!==void 0&&a.traverse(function(c){if(c.isMesh)for(let u=0,d=r.weights.length;u<d;u++)c.morphTargetInfluences[u]=r.weights[u]}),a})}loadNode(t){const e=this.json,n=this,r=e.nodes[t],s=n._loadNodeShallow(t),a=[],c=r.children||[];for(let d=0,p=c.length;d<p;d++)a.push(n.getDependency("node",c[d]));const u=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(a),u]).then(function(d){const p=d[0],f=d[1],y=d[2];y!==null&&p.traverse(function(v){v.isSkinnedMesh&&v.bind(y,kd)});for(let v=0,x=f.length;v<x;v++)p.add(f[v]);return p})}_loadNodeShallow(t){const e=this.json,n=this.extensions,r=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const s=e.nodes[t],a=s.name?r.createUniqueName(s.name):"",c=[],u=r._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(t)});return u&&c.push(u),s.camera!==void 0&&c.push(r.getDependency("camera",s.camera).then(function(d){return r._getNodeRef(r.cameraCache,s.camera,d)})),r._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(t)}).forEach(function(d){c.push(d)}),this.nodeCache[t]=Promise.all(c).then(function(d){let p;if(s.isBone===!0?p=new m.Bone:d.length>1?p=new m.Group:d.length===1?p=d[0]:p=new m.Object3D,p!==d[0])for(let f=0,y=d.length;f<y;f++)p.add(d[f]);if(s.name&&(p.userData.name=s.name,p.name=a),un(p,s),s.extensions&&Yn(n,p,s),s.matrix!==void 0){const f=new m.Matrix4;f.fromArray(s.matrix),p.applyMatrix4(f)}else s.translation!==void 0&&p.position.fromArray(s.translation),s.rotation!==void 0&&p.quaternion.fromArray(s.rotation),s.scale!==void 0&&p.scale.fromArray(s.scale);return r.associations.has(p)||r.associations.set(p,{}),r.associations.get(p).nodes=t,p}),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],r=this,s=new m.Group;n.name&&(s.name=r.createUniqueName(n.name)),un(s,n),n.extensions&&Yn(e,s,n);const a=n.nodes||[],c=[];for(let u=0,d=a.length;u<d;u++)c.push(r.getDependency("node",a[u]));return Promise.all(c).then(function(u){for(let p=0,f=u.length;p<f;p++)s.add(u[p]);const d=p=>{const f=new Map;for(const[y,v]of r.associations)(y instanceof m.Material||y instanceof m.Texture)&&f.set(y,v);return p.traverse(y=>{const v=r.associations.get(y);v!=null&&f.set(y,v)}),f};return r.associations=d(s),s})}_createAnimationTracks(t,e,n,r,s){const a=[],c=t.name?t.name:t.uuid,u=[];Mn[s.path]===Mn.weights?t.traverse(function(y){y.morphTargetInfluences&&u.push(y.name?y.name:y.uuid)}):u.push(c);let d;switch(Mn[s.path]){case Mn.weights:d=m.NumberKeyframeTrack;break;case Mn.rotation:d=m.QuaternionKeyframeTrack;break;case Mn.position:case Mn.scale:d=m.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:d=m.NumberKeyframeTrack;break;case 2:case 3:default:d=m.VectorKeyframeTrack;break}break}const p=r.interpolation!==void 0?Wd[r.interpolation]:m.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let y=0,v=u.length;y<v;y++){const x=new d(u[y]+"."+Mn[s.path],e.array,f,p);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),a.push(x)}return a}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const n=Xs(e.constructor),r=new Float32Array(e.length);for(let s=0,a=e.length;s<a;s++)r[s]=e[s]*n;e=r}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){const r=this instanceof m.QuaternionKeyframeTrack?Id:Ya;return new r(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function zd(l,t,e){const n=t.attributes,r=new m.Box3;if(n.POSITION!==void 0){const c=e.json.accessors[n.POSITION],u=c.min,d=c.max;if(u!==void 0&&d!==void 0){if(r.set(new m.Vector3(u[0],u[1],u[2]),new m.Vector3(d[0],d[1],d[2])),c.normalized){const p=Xs(hr[c.componentType]);r.min.multiplyScalar(p),r.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=t.targets;if(s!==void 0){const c=new m.Vector3,u=new m.Vector3;for(let d=0,p=s.length;d<p;d++){const f=s[d];if(f.POSITION!==void 0){const y=e.json.accessors[f.POSITION],v=y.min,x=y.max;if(v!==void 0&&x!==void 0){if(u.setX(Math.max(Math.abs(v[0]),Math.abs(x[0]))),u.setY(Math.max(Math.abs(v[1]),Math.abs(x[1]))),u.setZ(Math.max(Math.abs(v[2]),Math.abs(x[2]))),y.normalized){const L=Xs(hr[y.componentType]);u.multiplyScalar(L)}c.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(c)}l.boundingBox=r;const a=new m.Sphere;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,l.boundingSphere=a}function Na(l,t,e){const n=t.attributes,r=[];function s(a,c){return e.getDependency("accessor",a).then(function(u){l.setAttribute(c,u)})}for(const a in n){const c=Vs[a]||a.toLowerCase();c in l.attributes||r.push(s(n[a],c))}if(t.indices!==void 0&&!l.index){const a=e.getDependency("accessor",t.indices).then(function(c){l.setIndex(c)});r.push(a)}return un(l,t),zd(l,t,e),Promise.all(r).then(function(){return t.targets!==void 0?Vd(l,t.targets,e):l})}function ja(l,t,e){const n=e.length-l-1;if(t>=e[n])return n-1;if(t<=e[l])return l;let r=l,s=n,a=Math.floor((r+s)/2);for(;t<e[a]||t>=e[a+1];)t<e[a]?s=a:r=a,a=Math.floor((r+s)/2);return a}function Od(l,t,e,n){const r=[],s=[],a=[];r[0]=1;for(let c=1;c<=e;++c){s[c]=t-n[l+1-c],a[c]=n[l+c]-t;let u=0;for(let d=0;d<c;++d){const p=a[d+1],f=s[c-d],y=r[d]/(p+f);r[d]=u+p*y,u=f*y}r[c]=u}return r}function Kd(l,t,e,n){const r=ja(l,n,t),s=Od(r,n,l,t),a=new m.Vector4(0,0,0,0);for(let c=0;c<=l;++c){const u=e[r-l+c],d=s[c],p=u.w*d;a.x+=u.x*p,a.y+=u.y*p,a.z+=u.z*p,a.w+=u.w*d}return a}function Rd(l,t,e,n,r){const s=[];for(let f=0;f<=e;++f)s[f]=0;const a=[];for(let f=0;f<=n;++f)a[f]=s.slice(0);const c=[];for(let f=0;f<=e;++f)c[f]=s.slice(0);c[0][0]=1;const u=s.slice(0),d=s.slice(0);for(let f=1;f<=e;++f){u[f]=t-r[l+1-f],d[f]=r[l+f]-t;let y=0;for(let v=0;v<f;++v){const x=d[v+1],L=u[f-v];c[f][v]=x+L;const _=c[v][f-1]/c[f][v];c[v][f]=y+x*_,y=L*_}c[f][f]=y}for(let f=0;f<=e;++f)a[0][f]=c[f][e];for(let f=0;f<=e;++f){let y=0,v=1;const x=[];for(let L=0;L<=e;++L)x[L]=s.slice(0);x[0][0]=1;for(let L=1;L<=n;++L){let _=0;const S=f-L,Z=e-L;f>=L&&(x[v][0]=x[y][0]/c[Z+1][S],_=x[v][0]*c[S][Z]);const G=S>=-1?1:-S,A=f-1<=Z?L-1:e-f;for(let D=G;D<=A;++D)x[v][D]=(x[y][D]-x[y][D-1])/c[Z+1][S+D],_+=x[v][D]*c[S+D][Z];f<=Z&&(x[v][L]=-x[y][L-1]/c[Z+1][f],_+=x[v][L]*c[f][Z]),a[L][f]=_;const K=y;y=v,v=K}}let p=e;for(let f=1;f<=n;++f){for(let y=0;y<=e;++y)a[f][y]*=p;p*=e-f}return a}function Yd(l,t,e,n,r){const s=r<l?r:l,a=[],c=ja(l,n,t),u=Rd(c,n,l,s,t),d=[];for(let p=0;p<e.length;++p){const f=e[p].clone(),y=f.w;f.x*=y,f.y*=y,f.z*=y,d[p]=f}for(let p=0;p<=s;++p){const f=d[c-l].clone().multiplyScalar(u[p][0]);for(let y=1;y<=l;++y)f.add(d[c-l+y].clone().multiplyScalar(u[p][y]));a[p]=f}for(let p=s+1;p<=r+1;++p)a[p]=new m.Vector4(0,0,0);return a}function Ud(l,t){let e=1;for(let r=2;r<=l;++r)e*=r;let n=1;for(let r=2;r<=t;++r)n*=r;for(let r=2;r<=l-t;++r)n*=r;return e/n}function Bd(l){const t=l.length,e=[],n=[];for(let s=0;s<t;++s){const a=l[s];e[s]=new m.Vector3(a.x,a.y,a.z),n[s]=a.w}const r=[];for(let s=0;s<t;++s){const a=e[s].clone();for(let c=1;c<=s;++c)a.sub(r[s-c].clone().multiplyScalar(Ud(s,c)*n[c]));r[s]=a.divideScalar(n[0])}return r}function Nd(l,t,e,n,r){const s=Yd(l,t,e,n,r);return Bd(s)}class Ja extends m.Curve{constructor(t,e,n,r,s){super(),this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=r||0,this.endKnot=s||this.knots.length-1;for(let a=0;a<n.length;++a){const c=n[a];this.controlPoints[a]=new m.Vector4(c.x,c.y,c.z,c.w)}}getPoint(t,e){const n=e||new m.Vector3,r=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Kd(this.degree,this.knots,this.controlPoints,r);return s.w!=1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(t,e){const n=e||new m.Vector3,r=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),s=Nd(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}}let xe,ze,ft;class jd extends m.Loader{constructor(t){super(t)}load(t,e,n,r){const s=this,a=s.path===""?m.LoaderUtils.extractUrlBase(t):s.path,c=new m.FileLoader(this.manager);c.setPath(s.path),c.setResponseType("arraybuffer"),c.setRequestHeader(s.requestHeader),c.setWithCredentials(s.withCredentials),c.load(t,function(u){try{e(s.parse(u,a))}catch(d){r?r(d):console.error(d),s.manager.itemError(t)}},n,r)}parse(t,e){if($d(t))xe=new qd().parse(t);else{const r=el(t);if(!ef(r))throw new Error("THREE.FBXLoader: Unknown format.");if(Ea(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Ea(r));xe=new Ed().parse(r)}const n=new m.TextureLoader(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new Jd(n,this.manager).parse(xe)}}class Jd{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){ze=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),r=this.parseDeformers(),s=new Qd().parse(r);return this.parseScene(r,s,n),ft}parseConnections(){const t=new Map;return"Connections"in xe&&xe.Connections.connections.forEach(function(n){const r=n[0],s=n[1],a=n[2];t.has(r)||t.set(r,{parents:[],children:[]});const c={ID:s,relationship:a};t.get(r).parents.push(c),t.has(s)||t.set(s,{parents:[],children:[]});const u={ID:r,relationship:a};t.get(s).children.push(u)}),t}parseImages(){const t={},e={};if("Video"in xe.Objects){const n=xe.Objects.Video;for(const r in n){const s=n[r],a=parseInt(r);if(t[a]=s.RelativeFilename||s.Filename,"Content"in s){const c=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,u=typeof s.Content=="string"&&s.Content!=="";if(c||u){const d=this.parseImage(n[r]);e[s.RelativeFilename||s.Filename]=d}}}}for(const n in t){const r=t[n];e[r]!==void 0?t[n]=e[r]:t[n]=t[n].split("\\").pop()}return t}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(r){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+r+'" is not supported.');return}if(typeof e=="string")return"data:"+s+";base64,"+e;{const a=new Uint8Array(e);return window.URL.createObjectURL(new Blob([a],{type:s}))}}parseTextures(t){const e=new Map;if("Texture"in xe.Objects){const n=xe.Objects.Texture;for(const r in n){const s=this.parseTexture(n[r],t);e.set(parseInt(r),s)}}return e}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const r=t.WrapModeU,s=t.WrapModeV,a=r!==void 0?r.value:0,c=s!==void 0?s.value:0;if(n.wrapS=a===0?m.RepeatWrapping:m.ClampToEdgeWrapping,n.wrapT=c===0?m.RepeatWrapping:m.ClampToEdgeWrapping,"Scaling"in t){const u=t.Scaling.value;n.repeat.x=u[0],n.repeat.y=u[1]}return n}loadTexture(t,e){let n;const r=this.textureLoader.path,s=ze.get(t.id).children;s!==void 0&&s.length>0&&e[s[0].ID]!==void 0&&(n=e[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let a;const c=t.FileName.slice(-3).toLowerCase();if(c==="tga"){const u=this.manager.getHandler(".tga");u===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),a=new m.Texture):(u.setPath(this.textureLoader.path),a=u.load(n))}else c==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),a=new m.Texture):a=this.textureLoader.load(n);return this.textureLoader.setPath(r),a}parseMaterials(t){const e=new Map;if("Material"in xe.Objects){const n=xe.Objects.Material;for(const r in n){const s=this.parseMaterial(n[r],t);s!==null&&e.set(parseInt(r),s)}}return e}parseMaterial(t,e){const n=t.id,r=t.attrName;let s=t.ShadingModel;if(typeof s=="object"&&(s=s.value),!ze.has(n))return null;const a=this.parseParameters(t,e,n);let c;switch(s.toLowerCase()){case"phong":c=new m.MeshPhongMaterial;break;case"lambert":c=new m.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),c=new m.MeshPhongMaterial;break}return c.setValues(a),c.name=r,c}parseParameters(t,e,n){const r={};t.BumpFactor&&(r.bumpScale=t.BumpFactor.value),t.Diffuse?r.color=new m.Color().fromArray(t.Diffuse.value):t.DiffuseColor&&(t.DiffuseColor.type==="Color"||t.DiffuseColor.type==="ColorRGB")&&(r.color=new m.Color().fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(r.displacementScale=t.DisplacementFactor.value),t.Emissive?r.emissive=new m.Color().fromArray(t.Emissive.value):t.EmissiveColor&&(t.EmissiveColor.type==="Color"||t.EmissiveColor.type==="ColorRGB")&&(r.emissive=new m.Color().fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(r.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(r.opacity=parseFloat(t.Opacity.value)),r.opacity<1&&(r.transparent=!0),t.ReflectionFactor&&(r.reflectivity=t.ReflectionFactor.value),t.Shininess&&(r.shininess=t.Shininess.value),t.Specular?r.specular=new m.Color().fromArray(t.Specular.value):t.SpecularColor&&t.SpecularColor.type==="Color"&&(r.specular=new m.Color().fromArray(t.SpecularColor.value));const s=this;return ze.get(n).children.forEach(function(a){const c=a.relationship;switch(c){case"Bump":r.bumpMap=s.getTexture(e,a.ID);break;case"Maya|TEX_ao_map":r.aoMap=s.getTexture(e,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=s.getTexture(e,a.ID),r.map!==void 0&&("colorSpace"in r.map?r.map.colorSpace="srgb":r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=s.getTexture(e,a.ID);break;case"EmissiveColor":r.emissiveMap=s.getTexture(e,a.ID),r.emissiveMap!==void 0&&("colorSpace"in r.emissiveMap?r.emissiveMap.colorSpace="srgb":r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=s.getTexture(e,a.ID);break;case"ReflectionColor":r.envMap=s.getTexture(e,a.ID),r.envMap!==void 0&&(r.envMap.mapping=m.EquirectangularReflectionMapping,"colorSpace"in r.envMap?r.envMap.colorSpace="srgb":r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=s.getTexture(e,a.ID),r.specularMap!==void 0&&("colorSpace"in r.specularMap?r.specularMap.colorSpace="srgb":r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=s.getTexture(e,a.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",c);break}}),r}getTexture(t,e){return"LayeredTexture"in xe.Objects&&e in xe.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=ze.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in xe.Objects){const n=xe.Objects.Deformer;for(const r in n){const s=n[r],a=ze.get(parseInt(r));if(s.attrType==="Skin"){const c=this.parseSkeleton(a,n);c.ID=r,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),c.geometryID=a.parents[0].ID,t[r]=c}else if(s.attrType==="BlendShape"){const c={id:r};c.rawTargets=this.parseMorphTargets(a,n),c.id=r,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[r]=c}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const n=[];return t.children.forEach(function(r){const s=e[r.ID];if(s.attrType!=="Cluster")return;const a={ID:r.ID,indices:[],weights:[],transformLink:new m.Matrix4().fromArray(s.TransformLink.a)};"Indexes"in s&&(a.indices=s.Indexes.a,a.weights=s.Weights.a),n.push(a)}),{rawBones:n,bones:[]}}parseMorphTargets(t,e){const n=[];for(let r=0;r<t.children.length;r++){const s=t.children[r],a=e[s.ID],c={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!=="BlendShapeChannel")return;c.geoID=ze.get(parseInt(s.ID)).children.filter(function(u){return u.relationship===void 0})[0].ID,n.push(c)}return n}parseScene(t,e,n){ft=new m.Group;const r=this.parseModels(t.skeletons,e,n),s=xe.Objects.Model,a=this;r.forEach(function(u){const d=s[u.ID];a.setLookAtProperties(u,d),ze.get(u.ID).parents.forEach(function(f){const y=r.get(f.ID);y!==void 0&&y.add(u)}),u.parent===null&&ft.add(u)}),this.bindSkeleton(t.skeletons,e,r),this.createAmbientLight(),ft.traverse(function(u){if(u.userData.transformData){u.parent&&(u.userData.transformData.parentMatrix=u.parent.matrix,u.userData.transformData.parentMatrixWorld=u.parent.matrixWorld);const d=qa(u.userData.transformData);u.applyMatrix4(d),u.updateWorldMatrix()}});const c=new Hd().parse();ft.children.length===1&&ft.children[0].isGroup&&(ft.children[0].animations=c,ft=ft.children[0]),ft.animations=c}parseModels(t,e,n){const r=new Map,s=xe.Objects.Model;for(const a in s){const c=parseInt(a),u=s[a],d=ze.get(c);let p=this.buildSkeleton(d,t,c,u.attrName);if(!p){switch(u.attrType){case"Camera":p=this.createCamera(d);break;case"Light":p=this.createLight(d);break;case"Mesh":p=this.createMesh(d,e,n);break;case"NurbsCurve":p=this.createCurve(d,e);break;case"LimbNode":case"Root":p=new m.Bone;break;case"Null":default:p=new m.Group;break}p.name=u.attrName?m.PropertyBinding.sanitizeNodeName(u.attrName):"",p.ID=c}this.getTransformData(p,u),r.set(c,p)}return r}buildSkeleton(t,e,n,r){let s=null;return t.parents.forEach(function(a){for(const c in e){const u=e[c];u.rawBones.forEach(function(d,p){if(d.ID===a.ID){const f=s;s=new m.Bone,s.matrixWorld.copy(d.transformLink),s.name=r?m.PropertyBinding.sanitizeNodeName(r):"",s.ID=n,u.bones[p]=s,f!==null&&s.add(f)}})}}),s}createCamera(t){let e,n;if(t.children.forEach(function(r){const s=xe.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)e=new m.Object3D;else{let r=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(r=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let a=1e3;n.FarPlane!==void 0&&(a=n.FarPlane.value/1e3);let c=window.innerWidth,u=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(c=n.AspectWidth.value,u=n.AspectHeight.value);const d=c/u;let p=45;n.FieldOfView!==void 0&&(p=n.FieldOfView.value);const f=n.FocalLength?n.FocalLength.value:null;switch(r){case 0:e=new m.PerspectiveCamera(p,d,s,a),f!==null&&e.setFocalLength(f);break;case 1:e=new m.OrthographicCamera(-c/2,c/2,u/2,-u/2,s,a);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+r+"."),e=new m.Object3D;break}}return e}createLight(t){let e,n;if(t.children.forEach(function(r){const s=xe.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)e=new m.Object3D;else{let r;n.LightType===void 0?r=0:r=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=new m.Color().fromArray(n.Color.value));let a=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(a=0);let c=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?c=0:c=n.FarAttenuationEnd.value);const u=1;switch(r){case 0:e=new m.PointLight(s,a,c,u);break;case 1:e=new m.DirectionalLight(s,a);break;case 2:let d=Math.PI/3;n.InnerAngle!==void 0&&(d=m.MathUtils.degToRad(n.InnerAngle.value));let p=0;n.OuterAngle!==void 0&&(p=m.MathUtils.degToRad(n.OuterAngle.value),p=Math.max(p,1)),e=new m.SpotLight(s,a,c,d,p,u);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new m.PointLight(s,a);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(e.castShadow=!0)}return e}createMesh(t,e,n){let r,s=null,a=null;const c=[];return t.children.forEach(function(u){e.has(u.ID)&&(s=e.get(u.ID)),n.has(u.ID)&&c.push(n.get(u.ID))}),c.length>1?a=c:c.length>0?a=c[0]:(a=new m.MeshPhongMaterial({color:13421772}),c.push(a)),"color"in s.attributes&&c.forEach(function(u){u.vertexColors=!0}),s.FBX_Deformer?(r=new m.SkinnedMesh(s,a),r.normalizeSkinWeights()):r=new m.Mesh(s,a),r}createCurve(t,e){const n=t.children.reduce(function(s,a){return e.has(a.ID)&&(s=e.get(a.ID)),s},null),r=new m.LineBasicMaterial({color:3342591,linewidth:1});return new m.Line(n,r)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),"RotationOrder"in e?n.eulerOrder=$a(e.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(t,e){"LookAtProperty"in e&&ze.get(t.ID).children.forEach(function(r){if(r.relationship==="LookAtProperty"){const s=xe.Objects.Model[r.ID];if("Lcl_Translation"in s){const a=s.Lcl_Translation.value;t.target!==void 0?(t.target.position.fromArray(a),ft.add(t.target)):t.lookAt(new m.Vector3().fromArray(a))}}})}bindSkeleton(t,e,n){const r=this.parsePoseNodes();for(const s in t){const a=t[s];ze.get(parseInt(a.ID)).parents.forEach(function(u){if(e.has(u.ID)){const d=u.ID;ze.get(d).parents.forEach(function(f){n.has(f.ID)&&n.get(f.ID).bind(new m.Skeleton(a.bones),r[f.ID])})}})}}parsePoseNodes(){const t={};if("Pose"in xe.Objects){const e=xe.Objects.Pose;for(const n in e)if(e[n].attrType==="BindPose"&&e[n].NbPoseNodes>0){const r=e[n].PoseNode;Array.isArray(r)?r.forEach(function(s){t[s.Node]=new m.Matrix4().fromArray(s.Matrix.a)}):t[r.Node]=new m.Matrix4().fromArray(r.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in xe&&"AmbientColor"in xe.GlobalSettings){const t=xe.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],r=t[2];if(e!==0||n!==0||r!==0){const s=new m.Color(e,n,r);ft.add(new m.AmbientLight(s,1))}}}}class Qd{parse(t){const e=new Map;if("Geometry"in xe.Objects){const n=xe.Objects.Geometry;for(const r in n){const s=ze.get(parseInt(r)),a=this.parseGeometry(s,n[r],t);e.set(parseInt(r),a)}}return e}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,n){const r=n.skeletons,s=[],a=t.parents.map(function(f){return xe.Objects.Model[f.ID]});if(a.length===0)return;const c=t.children.reduce(function(f,y){return r[y.ID]!==void 0&&(f=r[y.ID]),f},null);t.children.forEach(function(f){n.morphTargets[f.ID]!==void 0&&s.push(n.morphTargets[f.ID])});const u=a[0],d={};"RotationOrder"in u&&(d.eulerOrder=$a(u.RotationOrder.value)),"InheritType"in u&&(d.inheritType=parseInt(u.InheritType.value)),"GeometricTranslation"in u&&(d.translation=u.GeometricTranslation.value),"GeometricRotation"in u&&(d.rotation=u.GeometricRotation.value),"GeometricScaling"in u&&(d.scale=u.GeometricScaling.value);const p=qa(d);return this.genGeometry(e,c,s,p)}genGeometry(t,e,n,r){const s=new m.BufferGeometry;t.attrName&&(s.name=t.attrName);const a=this.parseGeoNode(t,e),c=this.genBuffers(a),u=new m.Float32BufferAttribute(c.vertex,3);if(u.applyMatrix4(r),s.setAttribute("position",u),c.colors.length>0&&s.setAttribute("color",new m.Float32BufferAttribute(c.colors,3)),e&&(s.setAttribute("skinIndex",new m.Uint16BufferAttribute(c.weightsIndices,4)),s.setAttribute("skinWeight",new m.Float32BufferAttribute(c.vertexWeights,4)),s.FBX_Deformer=e),c.normal.length>0){const d=new m.Matrix3().getNormalMatrix(r),p=new m.Float32BufferAttribute(c.normal,3);p.applyNormalMatrix(d),s.setAttribute("normal",p)}if(c.uvs.forEach(function(d,p){Ts==="uv2"&&p++;const f=p===0?"uv":`uv${p}`;s.setAttribute(f,new m.Float32BufferAttribute(c.uvs[p],2))}),a.material&&a.material.mappingType!=="AllSame"){let d=c.materialIndex[0],p=0;if(c.materialIndex.forEach(function(f,y){f!==d&&(s.addGroup(p,y-p,d),d=f,p=y)}),s.groups.length>0){const f=s.groups[s.groups.length-1],y=f.start+f.count;y!==c.materialIndex.length&&s.addGroup(y,c.materialIndex.length-y,d)}s.groups.length===0&&s.addGroup(0,c.materialIndex.length,c.materialIndex[0])}return this.addMorphTargets(s,t,n,r),s}parseGeoNode(t,e){const n={};if(n.vertexPositions=t.Vertices!==void 0?t.Vertices.a:[],n.vertexIndices=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let r=0;for(;t.LayerElementUV[r];)t.LayerElementUV[r].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[r])),r++}return n.weightTable={},e!==null&&(n.skeleton=e,e.rawBones.forEach(function(r,s){r.indices.forEach(function(a,c){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:s,weight:r.weights[c]})})})),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,s=!1,a=[],c=[],u=[],d=[],p=[],f=[];const y=this;return t.vertexIndices.forEach(function(v,x){let L,_=!1;v<0&&(v=v^-1,_=!0);let S=[],Z=[];if(a.push(v*3,v*3+1,v*3+2),t.color){const G=mi(x,n,v,t.color);u.push(G[0],G[1],G[2])}if(t.skeleton){if(t.weightTable[v]!==void 0&&t.weightTable[v].forEach(function(G){Z.push(G.weight),S.push(G.id)}),Z.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const G=[0,0,0,0],A=[0,0,0,0];Z.forEach(function(K,D){let O=K,V=S[D];A.forEach(function(R,W,k){if(O>R){k[W]=O,O=R;const N=G[W];G[W]=V,V=N}})}),S=G,Z=A}for(;Z.length<4;)Z.push(0),S.push(0);for(let G=0;G<4;++G)p.push(Z[G]),f.push(S[G])}if(t.normal){const G=mi(x,n,v,t.normal);c.push(G[0],G[1],G[2])}t.material&&t.material.mappingType!=="AllSame"&&(L=mi(x,n,v,t.material)[0]),t.uv&&t.uv.forEach(function(G,A){const K=mi(x,n,v,G);d[A]===void 0&&(d[A]=[]),d[A].push(K[0]),d[A].push(K[1])}),r++,_&&(y.genFace(e,t,a,L,c,u,d,p,f,r),n++,r=0,a=[],c=[],u=[],d=[],p=[],f=[])}),e}genFace(t,e,n,r,s,a,c,u,d,p){for(let f=2;f<p;f++)t.vertex.push(e.vertexPositions[n[0]]),t.vertex.push(e.vertexPositions[n[1]]),t.vertex.push(e.vertexPositions[n[2]]),t.vertex.push(e.vertexPositions[n[(f-1)*3]]),t.vertex.push(e.vertexPositions[n[(f-1)*3+1]]),t.vertex.push(e.vertexPositions[n[(f-1)*3+2]]),t.vertex.push(e.vertexPositions[n[f*3]]),t.vertex.push(e.vertexPositions[n[f*3+1]]),t.vertex.push(e.vertexPositions[n[f*3+2]]),e.skeleton&&(t.vertexWeights.push(u[0]),t.vertexWeights.push(u[1]),t.vertexWeights.push(u[2]),t.vertexWeights.push(u[3]),t.vertexWeights.push(u[(f-1)*4]),t.vertexWeights.push(u[(f-1)*4+1]),t.vertexWeights.push(u[(f-1)*4+2]),t.vertexWeights.push(u[(f-1)*4+3]),t.vertexWeights.push(u[f*4]),t.vertexWeights.push(u[f*4+1]),t.vertexWeights.push(u[f*4+2]),t.vertexWeights.push(u[f*4+3]),t.weightsIndices.push(d[0]),t.weightsIndices.push(d[1]),t.weightsIndices.push(d[2]),t.weightsIndices.push(d[3]),t.weightsIndices.push(d[(f-1)*4]),t.weightsIndices.push(d[(f-1)*4+1]),t.weightsIndices.push(d[(f-1)*4+2]),t.weightsIndices.push(d[(f-1)*4+3]),t.weightsIndices.push(d[f*4]),t.weightsIndices.push(d[f*4+1]),t.weightsIndices.push(d[f*4+2]),t.weightsIndices.push(d[f*4+3])),e.color&&(t.colors.push(a[0]),t.colors.push(a[1]),t.colors.push(a[2]),t.colors.push(a[(f-1)*3]),t.colors.push(a[(f-1)*3+1]),t.colors.push(a[(f-1)*3+2]),t.colors.push(a[f*3]),t.colors.push(a[f*3+1]),t.colors.push(a[f*3+2])),e.material&&e.material.mappingType!=="AllSame"&&(t.materialIndex.push(r),t.materialIndex.push(r),t.materialIndex.push(r)),e.normal&&(t.normal.push(s[0]),t.normal.push(s[1]),t.normal.push(s[2]),t.normal.push(s[(f-1)*3]),t.normal.push(s[(f-1)*3+1]),t.normal.push(s[(f-1)*3+2]),t.normal.push(s[f*3]),t.normal.push(s[f*3+1]),t.normal.push(s[f*3+2])),e.uv&&e.uv.forEach(function(y,v){t.uvs[v]===void 0&&(t.uvs[v]=[]),t.uvs[v].push(c[v][0]),t.uvs[v].push(c[v][1]),t.uvs[v].push(c[v][(f-1)*2]),t.uvs[v].push(c[v][(f-1)*2+1]),t.uvs[v].push(c[v][f*2]),t.uvs[v].push(c[v][f*2+1])})}addMorphTargets(t,e,n,r){if(n.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const s=this;n.forEach(function(a){a.rawTargets.forEach(function(c){const u=xe.Objects.Geometry[c.geoID];u!==void 0&&s.genMorphGeometry(t,e,u,r,c.name)})})}genMorphGeometry(t,e,n,r,s){const a=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],c=n.Vertices!==void 0?n.Vertices.a:[],u=n.Indexes!==void 0?n.Indexes.a:[],d=t.attributes.position.count*3,p=new Float32Array(d);for(let x=0;x<u.length;x++){const L=u[x]*3;p[L]=c[x*3],p[L+1]=c[x*3+1],p[L+2]=c[x*3+2]}const f={vertexIndices:a,vertexPositions:p},y=this.genBuffers(f),v=new m.Float32BufferAttribute(y.vertex,3);v.name=s||n.attrName,v.applyMatrix4(r),t.morphAttributes.position.push(v)}parseNormals(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Normals.a;let s=[];return n==="IndexToDirect"&&("NormalIndex"in t?s=t.NormalIndex.a:"NormalsIndex"in t&&(s=t.NormalsIndex.a)),{dataSize:3,buffer:r,indices:s,mappingType:e,referenceType:n}}parseUVs(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.UV.a;let s=[];return n==="IndexToDirect"&&(s=t.UVIndex.a),{dataSize:2,buffer:r,indices:s,mappingType:e,referenceType:n}}parseVertexColors(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,r=t.Colors.a;let s=[];return n==="IndexToDirect"&&(s=t.ColorIndex.a),{dataSize:4,buffer:r,indices:s,mappingType:e,referenceType:n}}parseMaterialIndices(t){const e=t.MappingInformationType,n=t.ReferenceInformationType;if(e==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=t.Materials.a,s=[];for(let a=0;a<r.length;++a)s.push(a);return{dataSize:1,buffer:r,indices:s,mappingType:e,referenceType:n}}parseNurbsGeometry(t){if(Ja===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new m.BufferGeometry;const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new m.BufferGeometry;const n=e-1,r=t.KnotVector.a,s=[],a=t.Points.a;for(let f=0,y=a.length;f<y;f+=4)s.push(new m.Vector4().fromArray(a,f));let c,u;if(t.Form==="Closed")s.push(s[0]);else if(t.Form==="Periodic"){c=n,u=r.length-1-c;for(let f=0;f<n;++f)s.push(s[f])}const p=new Ja(n,r,s,c,u).getPoints(s.length*12);return new m.BufferGeometry().setFromPoints(p)}}class Hd{parse(){const t=[],e=this.parseClips();if(e!==void 0)for(const n in e){const r=e[n],s=this.addClip(r);t.push(s)}return t}parseClips(){if(xe.Objects.AnimationCurve===void 0)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=xe.Objects.AnimationCurveNode,e=new Map;for(const n in t){const r=t[n];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:r.id,attr:r.attrName,curves:{}};e.set(s.id,s)}}return e}parseAnimationCurves(t){const e=xe.Objects.AnimationCurve;for(const n in e){const r={id:e[n].id,times:e[n].KeyTime.a.map(tf),values:e[n].KeyValueFloat.a},s=ze.get(r.id);if(s!==void 0){const a=s.parents[0].ID,c=s.parents[0].relationship;c.match(/X/)?t.get(a).curves.x=r:c.match(/Y/)?t.get(a).curves.y=r:c.match(/Z/)?t.get(a).curves.z=r:c.match(/d|DeformPercent/)&&t.has(a)&&(t.get(a).curves.morph=r)}}}parseAnimationLayers(t){const e=xe.Objects.AnimationLayer,n=new Map;for(const r in e){const s=[],a=ze.get(parseInt(r));a!==void 0&&(a.children.forEach(function(u,d){if(t.has(u.ID)){const p=t.get(u.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(s[d]===void 0){const f=ze.get(u.ID).parents.filter(function(y){return y.relationship!==void 0})[0].ID;if(f!==void 0){const y=xe.Objects.Model[f.toString()];if(y===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",u);return}const v={modelName:y.attrName?m.PropertyBinding.sanitizeNodeName(y.attrName):"",ID:y.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ft.traverse(function(x){x.ID===y.id&&(v.transform=x.matrix,x.userData.transformData&&(v.eulerOrder=x.userData.transformData.eulerOrder))}),v.transform||(v.transform=new m.Matrix4),"PreRotation"in y&&(v.preRotation=y.PreRotation.value),"PostRotation"in y&&(v.postRotation=y.PostRotation.value),s[d]=v}}s[d]&&(s[d][p.attr]=p)}else if(p.curves.morph!==void 0){if(s[d]===void 0){const f=ze.get(u.ID).parents.filter(function(S){return S.relationship!==void 0})[0].ID,y=ze.get(f).parents[0].ID,v=ze.get(y).parents[0].ID,x=ze.get(v).parents[0].ID,L=xe.Objects.Model[x],_={modelName:L.attrName?m.PropertyBinding.sanitizeNodeName(L.attrName):"",morphName:xe.Objects.Deformer[f].attrName};s[d]=_}s[d][p.attr]=p}}}),n.set(parseInt(r),s))}return n}parseAnimStacks(t){const e=xe.Objects.AnimationStack,n={};for(const r in e){const s=ze.get(parseInt(r)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=t.get(s[0].ID);n[r]={name:e[r].attrName,layer:a}}return n}addClip(t){let e=[];const n=this;return t.layer.forEach(function(r){e=e.concat(n.generateTracks(r))}),new m.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new m.Vector3,r=new m.Quaternion,s=new m.Vector3;if(t.transform&&t.transform.decompose(n,r,s),n=n.toArray(),r=new m.Euler().setFromQuaternion(r,t.eulerOrder).toArray(),s=s.toArray(),t.T!==void 0&&Object.keys(t.T.curves).length>0){const a=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");a!==void 0&&e.push(a)}if(t.R!==void 0&&Object.keys(t.R.curves).length>0){const a=this.generateRotationTrack(t.modelName,t.R.curves,r,t.preRotation,t.postRotation,t.eulerOrder);a!==void 0&&e.push(a)}if(t.S!==void 0&&Object.keys(t.S.curves).length>0){const a=this.generateVectorTrack(t.modelName,t.S.curves,s,"scale");a!==void 0&&e.push(a)}if(t.DeformPercent!==void 0){const a=this.generateMorphTrack(t);a!==void 0&&e.push(a)}return e}generateVectorTrack(t,e,n,r){const s=this.getTimesForAllAxes(e),a=this.getKeyframeTrackValues(s,e,n);return new m.VectorKeyframeTrack(t+"."+r,s,a)}generateRotationTrack(t,e,n,r,s,a){e.x!==void 0&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(m.MathUtils.degToRad)),e.y!==void 0&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(m.MathUtils.degToRad)),e.z!==void 0&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(m.MathUtils.degToRad));const c=this.getTimesForAllAxes(e),u=this.getKeyframeTrackValues(c,e,n);r!==void 0&&(r=r.map(m.MathUtils.degToRad),r.push(a),r=new m.Euler().fromArray(r),r=new m.Quaternion().setFromEuler(r)),s!==void 0&&(s=s.map(m.MathUtils.degToRad),s.push(a),s=new m.Euler().fromArray(s),s=new m.Quaternion().setFromEuler(s).invert());const d=new m.Quaternion,p=new m.Euler,f=[];for(let y=0;y<u.length;y+=3)p.set(u[y],u[y+1],u[y+2],a),d.setFromEuler(p),r!==void 0&&d.premultiply(r),s!==void 0&&d.multiply(s),d.toArray(f,y/3*4);return new m.QuaternionKeyframeTrack(t+".quaternion",c,f)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map(function(s){return s/100}),r=ft.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new m.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+r+"]",e.times,n)}getTimesForAllAxes(t){let e=[];if(t.x!==void 0&&(e=e.concat(t.x.times)),t.y!==void 0&&(e=e.concat(t.y.times)),t.z!==void 0&&(e=e.concat(t.z.times)),e=e.sort(function(n,r){return n-r}),e.length>1){let n=1,r=e[0];for(let s=1;s<e.length;s++){const a=e[s];a!==r&&(e[n]=a,r=a,n++)}e=e.slice(0,n)}return e}getKeyframeTrackValues(t,e,n){const r=n,s=[];let a=-1,c=-1,u=-1;return t.forEach(function(d){if(e.x&&(a=e.x.times.indexOf(d)),e.y&&(c=e.y.times.indexOf(d)),e.z&&(u=e.z.times.indexOf(d)),a!==-1){const p=e.x.values[a];s.push(p),r[0]=p}else s.push(r[0]);if(c!==-1){const p=e.y.values[c];s.push(p),r[1]=p}else s.push(r[1]);if(u!==-1){const p=e.z.values[u];s.push(p),r[2]=p}else s.push(r[2])}),s}interpolateRotations(t){for(let e=1;e<t.values.length;e++){const n=t.values[e-1],r=t.values[e]-n,s=Math.abs(r);if(s>=180){const a=s/180,c=r/a;let u=n+c;const d=t.times[e-1],f=(t.times[e]-d)/a;let y=d+f;const v=[],x=[];for(;y<t.times[e];)v.push(y),y+=f,x.push(u),u+=c;t.times=tl(t.times,e,v),t.values=tl(t.values,e,x)}}}}class Ed{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new Ha,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,n=t.split(/[\r\n]+/);return n.forEach(function(r,s){const a=r.match(/^[\s\t]*;/),c=r.match(/^[\s\t]*$/);if(a||c)return;const u=r.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),d=r.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),p=r.match("^\\t{"+(e.currentIndent-1)+"}}");u?e.parseNodeBegin(r,u):d?e.parseNodeProperty(r,d,n[++s]):p?e.popStack():r.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(r)}),this.allNodes}parseNodeBegin(t,e){const n=e[1].trim().replace(/^"/,"").replace(/"$/,""),r=e[2].split(",").map(function(u){return u.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},a=this.parseNodeAttr(r),c=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in c?(n==="PoseNode"?c.PoseNode.push(s):c[n].id!==void 0&&(c[n]={},c[n][c[n].id]=c[n]),a.id!==""&&(c[n][a.id]=s)):typeof a.id=="number"?(c[n]={},c[n][a.id]=s):n!=="Properties70"&&(n==="PoseNode"?c[n]=[s]:c[n]=s),typeof a.id=="number"&&(s.id=a.id),a.name!==""&&(s.attrName=a.name),a.type!==""&&(s.attrType=a.type),this.pushStack(s)}parseNodeAttr(t){let e=t[0];t[0]!==""&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let n="",r="";return t.length>1&&(n=t[1].replace(/^(\w+)::/,""),r=t[2]),{id:e,name:n,type:r}}parseNodeProperty(t,e,n){let r=e[1].replace(/^"/,"").replace(/"$/,"").trim(),s=e[2].replace(/^"/,"").replace(/"$/,"").trim();r==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(t,r,s);return}if(r==="C"){const u=s.split(",").slice(1),d=parseInt(u[0]),p=parseInt(u[1]);let f=s.split(",").slice(3);f=f.map(function(y){return y.trim().replace(/^"/,"")}),r="connections",s=[d,p],rf(s,f),a[r]===void 0&&(a[r]=[])}r==="Node"&&(a.id=s),r in a&&Array.isArray(a[r])?a[r].push(s):r!=="a"?a[r]=s:a.a=s,this.setCurrentProp(a,r),r==="a"&&s.slice(-1)!==","&&(a.a=Ds(s))}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,t.slice(-1)!==","&&(e.a=Ds(e.a))}parseNodeSpecialProperty(t,e,n){const r=n.split('",').map(function(p){return p.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],a=r[1],c=r[2],u=r[3];let d=r[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":d=parseFloat(d);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":d=Ds(d);break}this.getPrevNode()[s]={type:a,type2:c,flag:u,value:d},this.setCurrentProp(this.getPrevNode(),s)}}class qd{parse(t){const e=new Qa(t);e.skip(23);const n=e.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new Ha;for(;!this.endOfContent(e);){const s=this.parseNode(e,n);s!==null&&r.add(s.name,s)}return r}endOfContent(t){return t.size()%16===0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},r=e>=7500?t.getUint64():t.getUint32(),s=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const a=t.getUint8(),c=t.getString(a);if(r===0)return null;const u=[];for(let y=0;y<s;y++)u.push(this.parseProperty(t));const d=u.length>0?u[0]:"",p=u.length>1?u[1]:"",f=u.length>2?u[2]:"";for(n.singleProperty=s===1&&t.getOffset()===r;r>t.getOffset();){const y=this.parseNode(t,e);y!==null&&this.parseSubNode(c,n,y)}return n.propertyList=u,typeof d=="number"&&(n.id=d),p!==""&&(n.attrName=p),f!==""&&(n.attrType=f),c!==""&&(n.name=c),n}parseSubNode(t,e,n){if(n.singleProperty===!0){const r=n.propertyList[0];Array.isArray(r)?(e[n.name]=n,n.a=r):e[n.name]=r}else if(t==="Connections"&&n.name==="C"){const r=[];n.propertyList.forEach(function(s,a){a!==0&&r.push(s)}),e.connections===void 0&&(e.connections=[]),e.connections.push(r)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){e[s]=n[s]});else if(t==="Properties70"&&n.name==="P"){let r=n.propertyList[0],s=n.propertyList[1];const a=n.propertyList[2],c=n.propertyList[3];let u;r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?u=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:u=n.propertyList[4],e[r]={type:s,type2:a,flag:c,value:u}}else e[n.name]===void 0?typeof n.id=="number"?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:n.name==="PoseNode"?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):e[n.name][n.id]===void 0&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),s=t.getUint32(),a=t.getUint32();if(s===0)switch(e){case"b":case"c":return t.getBooleanArray(r);case"d":return t.getFloat64Array(r);case"f":return t.getFloat32Array(r);case"i":return t.getInt32Array(r);case"l":return t.getInt64Array(r)}const c=Bh(new Uint8Array(t.getArrayBuffer(a))),u=new Qa(c.buffer);switch(e){case"b":case"c":return u.getBooleanArray(r);case"d":return u.getFloat64Array(r);case"f":return u.getFloat32Array(r);case"i":return u.getInt32Array(r);case"l":return u.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class Qa{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=e!==void 0?e:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(t){const e=[];for(let n=0;n<t;n++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e&2147483648?(e=~e&4294967295,t=~t&4294967295,t===4294967295&&(e=e+1&4294967295),t=t+1&4294967295,-(e*4294967296+t)):e*4294967296+t}getInt64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e*4294967296+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){let e=[];for(let r=0;r<t;r++)e[r]=this.getUint8();const n=e.indexOf(0);return n>=0&&(e=e.slice(0,n)),ur(new Uint8Array(e))}}class Ha{add(t,e){this[t]=e}}function $d(l){const t="Kaydara FBX Binary \0";return l.byteLength>=t.length&&t===el(l,0,t.length)}function ef(l){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let e=0;function n(r){const s=l[r-1];return l=l.slice(e+r),e++,s}for(let r=0;r<t.length;++r)if(n(1)===t[r])return!1;return!0}function Ea(l){const t=/FBXVersion: (\d+)/,e=l.match(t);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function tf(l){return l/46186158e3}const nf=[];function mi(l,t,e,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=l;break;case"ByPolygon":r=t;break;case"ByVertice":r=e;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(r=n.indices[r]);const s=r*n.dataSize,a=s+n.dataSize;return sf(nf,n.buffer,s,a)}const ks=new m.Euler,dr=new m.Vector3;function qa(l){const t=new m.Matrix4,e=new m.Matrix4,n=new m.Matrix4,r=new m.Matrix4,s=new m.Matrix4,a=new m.Matrix4,c=new m.Matrix4,u=new m.Matrix4,d=new m.Matrix4,p=new m.Matrix4,f=new m.Matrix4,y=new m.Matrix4,v=l.inheritType?l.inheritType:0;if(l.translation&&t.setPosition(dr.fromArray(l.translation)),l.preRotation){const W=l.preRotation.map(m.MathUtils.degToRad);W.push(l.eulerOrder),e.makeRotationFromEuler(ks.fromArray(W))}if(l.rotation){const W=l.rotation.map(m.MathUtils.degToRad);W.push(l.eulerOrder),n.makeRotationFromEuler(ks.fromArray(W))}if(l.postRotation){const W=l.postRotation.map(m.MathUtils.degToRad);W.push(l.eulerOrder),r.makeRotationFromEuler(ks.fromArray(W)),r.invert()}l.scale&&s.scale(dr.fromArray(l.scale)),l.scalingOffset&&c.setPosition(dr.fromArray(l.scalingOffset)),l.scalingPivot&&a.setPosition(dr.fromArray(l.scalingPivot)),l.rotationOffset&&u.setPosition(dr.fromArray(l.rotationOffset)),l.rotationPivot&&d.setPosition(dr.fromArray(l.rotationPivot)),l.parentMatrixWorld&&(f.copy(l.parentMatrix),p.copy(l.parentMatrixWorld));const x=e.clone().multiply(n).multiply(r),L=new m.Matrix4;L.extractRotation(p);const _=new m.Matrix4;_.copyPosition(p);const S=_.clone().invert().multiply(p),Z=L.clone().invert().multiply(S),G=s,A=new m.Matrix4;if(v===0)A.copy(L).multiply(x).multiply(Z).multiply(G);else if(v===1)A.copy(L).multiply(Z).multiply(x).multiply(G);else{const k=new m.Matrix4().scale(new m.Vector3().setFromMatrixScale(f)).clone().invert(),N=Z.clone().multiply(k);A.copy(L).multiply(x).multiply(N).multiply(G)}const K=d.clone().invert(),D=a.clone().invert();let O=t.clone().multiply(u).multiply(d).multiply(e).multiply(n).multiply(r).multiply(K).multiply(c).multiply(a).multiply(s).multiply(D);const V=new m.Matrix4().copyPosition(O),R=p.clone().multiply(V);return y.copyPosition(R),O=y.clone().multiply(A),O.premultiply(p.invert()),O}function $a(l){l=l||0;const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return l===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[l]}function Ds(l){return l.split(",").map(function(e){return parseFloat(e)})}function el(l,t,e){return t===void 0&&(t=0),e===void 0&&(e=l.byteLength),ur(new Uint8Array(l,t,e))}function rf(l,t){for(let e=0,n=l.length,r=t.length;e<r;e++,n++)l[n]=t[e]}function sf(l,t,e,n){for(let r=e,s=0;r<n;r++,s++)l[s]=t[r];return l}function tl(l,t,e){return l.slice(0,t).concat(e).concat(l.slice(t))}class of extends m.DataTextureLoader{constructor(t){super(t),this.type=m.HalfFloatType}parse(t){const a=function(V,R){switch(V){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(R||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(R||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(R||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(R||""))}},p=`
|
|
98
|
-
`,f=function(
|
|
99
|
-
`;q=f(
|
|
97
|
+
}`},q=new m.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:m.UniformsUtils.clone(j.uniforms),lights:!0,side:S,fog:_});q.uniforms.mirrorSampler.value=H.texture,q.uniforms.textureMatrix.value=z,q.uniforms.alpha.value=u,q.uniforms.time.value=c,q.uniforms.normalSampler.value=d,q.uniforms.sunColor.value=f,q.uniforms.waterColor.value=y,q.uniforms.sunDirection.value=p,q.uniforms.distortionScale.value=x,q.uniforms.eye.value=v,n.material=q,n.onBeforeRender=function(J,oe,re){if(G.setFromMatrixPosition(n.matrixWorld),A.setFromMatrixPosition(re.matrixWorld),R.extractRotation(n.matrixWorld),M.set(0,0,1),M.applyMatrix4(R),C.subVectors(G,A),C.dot(M)>0)return;C.reflect(M).negate(),C.add(G),R.extractRotation(re.matrixWorld),D.set(0,0,-1),D.applyMatrix4(R),D.add(A),K.subVectors(G,D),K.reflect(M).negate(),K.add(G),N.position.copy(C),N.up.set(0,1,0),N.up.applyMatrix4(R),N.up.reflect(M),N.lookAt(K),N.far=re.far,N.updateMatrixWorld(),N.projectionMatrix.copy(re.projectionMatrix),z.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),z.multiply(N.projectionMatrix),z.multiply(N.matrixWorldInverse),Z.setFromNormalAndCoplanarPoint(M,G),Z.applyMatrix4(N.matrixWorldInverse),k.set(Z.normal.x,Z.normal.y,Z.normal.z,Z.constant);const te=N.projectionMatrix;I.x=(Math.sign(k.x)+te.elements[8])/te.elements[0],I.y=(Math.sign(k.y)+te.elements[9])/te.elements[5],I.z=-1,I.w=(1+te.elements[10])/te.elements[14],k.multiplyScalar(2/k.dot(I)),te.elements[2]=k.x,te.elements[6]=k.y,te.elements[10]=k.z+1-l,te.elements[14]=k.w,v.setFromMatrixPosition(re.matrixWorld);const me=J.getRenderTarget(),be=J.xr.enabled,he=J.shadowMap.autoUpdate;n.visible=!1,J.xr.enabled=!1,J.shadowMap.autoUpdate=!1,J.setRenderTarget(H),J.state.buffers.depth.setMask(!0),J.autoClear===!1&&J.clear(),J.render(oe,N),n.visible=!0,J.xr.enabled=be,J.shadowMap.autoUpdate=he,J.setRenderTarget(me);const ve=re.viewport;ve!==void 0&&J.state.viewport(ve)}}}var ed=Object.defineProperty,td=(a,t,e)=>t in a?ed(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,nd=(a,t,e)=>(td(a,t+"",e),e);class id{constructor(){nd(this,"_listeners")}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,l=i.length;s<l;s++)i[s].call(this,t);t.target=null}}}var rd=Object.defineProperty,sd=(a,t,e)=>t in a?rd(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,se=(a,t,e)=>(sd(a,typeof t!="symbol"?t+"":t,e),e);const yr=new m.Ray,Ua=new m.Plane,od=Math.cos(70*(Math.PI/180)),Ba=(a,t)=>(a%t+t)%t;class ad extends id{constructor(t,e){super(),se(this,"object"),se(this,"domElement"),se(this,"enabled",!0),se(this,"target",new m.Vector3),se(this,"minDistance",0),se(this,"maxDistance",1/0),se(this,"minZoom",0),se(this,"maxZoom",1/0),se(this,"minPolarAngle",0),se(this,"maxPolarAngle",Math.PI),se(this,"minAzimuthAngle",-1/0),se(this,"maxAzimuthAngle",1/0),se(this,"enableDamping",!1),se(this,"dampingFactor",.05),se(this,"enableZoom",!0),se(this,"zoomSpeed",1),se(this,"enableRotate",!0),se(this,"rotateSpeed",1),se(this,"enablePan",!0),se(this,"panSpeed",1),se(this,"screenSpacePanning",!0),se(this,"keyPanSpeed",7),se(this,"zoomToCursor",!1),se(this,"autoRotate",!1),se(this,"autoRotateSpeed",2),se(this,"reverseOrbit",!1),se(this,"reverseHorizontalOrbit",!1),se(this,"reverseVerticalOrbit",!1),se(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),se(this,"mouseButtons",{LEFT:m.MOUSE.ROTATE,MIDDLE:m.MOUSE.DOLLY,RIGHT:m.MOUSE.PAN}),se(this,"touches",{ONE:m.TOUCH.ROTATE,TWO:m.TOUCH.DOLLY_PAN}),se(this,"target0"),se(this,"position0"),se(this,"zoom0"),se(this,"_domElementKeyEvents",null),se(this,"getPolarAngle"),se(this,"getAzimuthalAngle"),se(this,"setPolarAngle"),se(this,"setAzimuthalAngle"),se(this,"getDistance"),se(this,"getZoomScale"),se(this,"listenToKeyEvents"),se(this,"stopListenToKeyEvents"),se(this,"saveState"),se(this,"reset"),se(this,"update"),se(this,"connect"),se(this,"dispose"),se(this,"dollyIn"),se(this,"dollyOut"),se(this,"getScale"),se(this,"setScale"),this.object=t,this.domElement=e,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=X=>{let E=Ba(X,2*Math.PI),ue=p.phi;ue<0&&(ue+=2*Math.PI),E<0&&(E+=2*Math.PI);let Se=Math.abs(E-ue);2*Math.PI-Se<Se&&(E<ue?E+=2*Math.PI:ue+=2*Math.PI),f.phi=E-ue,n.update()},this.setAzimuthalAngle=X=>{let E=Ba(X,2*Math.PI),ue=p.theta;ue<0&&(ue+=2*Math.PI),E<0&&(E+=2*Math.PI);let Se=Math.abs(E-ue);2*Math.PI-Se<Se&&(E<ue?E+=2*Math.PI:ue+=2*Math.PI),f.theta=E-ue,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=X=>{X.addEventListener("keydown",sn),this._domElementKeyEvents=X},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",sn),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(i),n.update(),c=u.NONE},this.update=(()=>{const X=new m.Vector3,E=new m.Vector3(0,1,0),ue=new m.Quaternion().setFromUnitVectors(t.up,E),Se=ue.clone().invert(),Ke=new m.Vector3,Ct=new m.Quaternion,Bt=2*Math.PI;return function(){const Dr=n.object.position;ue.setFromUnitVectors(t.up,E),Se.copy(ue).invert(),X.copy(Dr).sub(n.target),X.applyQuaternion(ue),p.setFromVector3(X),n.autoRotate&&c===u.NONE&&j(N()),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let Nt=n.minAzimuthAngle,jt=n.maxAzimuthAngle;isFinite(Nt)&&isFinite(jt)&&(Nt<-Math.PI?Nt+=Bt:Nt>Math.PI&&(Nt-=Bt),jt<-Math.PI?jt+=Bt:jt>Math.PI&&(jt-=Bt),Nt<=jt?p.theta=Math.max(Nt,Math.min(jt,p.theta)):p.theta=p.theta>(Nt+jt)/2?Math.max(Nt,p.theta):Math.min(jt,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(v,n.dampingFactor):n.target.add(v),n.zoomToCursor&&K||n.object.isOrthographicCamera?p.radius=ve(p.radius):p.radius=ve(p.radius*y),X.setFromSpherical(p),X.applyQuaternion(Se),Dr.copy(n.target).add(X),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,v.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),v.set(0,0,0));let Cn=!1;if(n.zoomToCursor&&K){let qn=null;if(n.object instanceof m.PerspectiveCamera&&n.object.isPerspectiveCamera){const $n=X.length();qn=ve($n*y);const vi=$n-qn;n.object.position.addScaledVector(k,vi),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const $n=new m.Vector3(C.x,C.y,0);$n.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/y)),n.object.updateProjectionMatrix(),Cn=!0;const vi=new m.Vector3(C.x,C.y,0);vi.unproject(n.object),n.object.position.sub(vi).add($n),n.object.updateMatrixWorld(),qn=X.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;qn!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(qn).add(n.object.position):(yr.origin.copy(n.object.position),yr.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(yr.direction))<od?t.lookAt(n.target):(Ua.setFromNormalAndCoplanarPoint(n.object.up,n.target),yr.intersectPlane(Ua,n.target))))}else n.object instanceof m.OrthographicCamera&&n.object.isOrthographicCamera&&(Cn=y!==1,Cn&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/y)),n.object.updateProjectionMatrix()));return y=1,K=!1,Cn||Ke.distanceToSquared(n.object.position)>d||8*(1-Ct.dot(n.object.quaternion))>d?(n.dispatchEvent(i),Ke.copy(n.object.position),Ct.copy(n.object.quaternion),Cn=!1,!0):!1}})(),this.connect=X=>{n.domElement=X,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",gi),n.domElement.addEventListener("pointerdown",Wn),n.domElement.addEventListener("pointercancel",Qn),n.domElement.addEventListener("wheel",In)},this.dispose=()=>{var X,E,ue,Se,Ke,Ct;n.domElement&&(n.domElement.style.touchAction="auto"),(X=n.domElement)==null||X.removeEventListener("contextmenu",gi),(E=n.domElement)==null||E.removeEventListener("pointerdown",Wn),(ue=n.domElement)==null||ue.removeEventListener("pointercancel",Qn),(Se=n.domElement)==null||Se.removeEventListener("wheel",In),(Ke=n.domElement)==null||Ke.ownerDocument.removeEventListener("pointermove",Pn),(Ct=n.domElement)==null||Ct.ownerDocument.removeEventListener("pointerup",Qn),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",sn)};const n=this,i={type:"change"},s={type:"start"},l={type:"end"},u={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let c=u.NONE;const d=1e-6,p=new m.Spherical,f=new m.Spherical;let y=1;const v=new m.Vector3,x=new m.Vector2,S=new m.Vector2,_=new m.Vector2,Z=new m.Vector2,M=new m.Vector2,G=new m.Vector2,A=new m.Vector2,R=new m.Vector2,D=new m.Vector2,k=new m.Vector3,C=new m.Vector2;let K=!1;const I=[],z={};function N(){return 2*Math.PI/60/60*n.autoRotateSpeed}function H(){return Math.pow(.95,n.zoomSpeed)}function j(X){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=X:f.theta-=X}function q(X){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=X:f.phi-=X}const J=(()=>{const X=new m.Vector3;return function(ue,Se){X.setFromMatrixColumn(Se,0),X.multiplyScalar(-ue),v.add(X)}})(),oe=(()=>{const X=new m.Vector3;return function(ue,Se){n.screenSpacePanning===!0?X.setFromMatrixColumn(Se,1):(X.setFromMatrixColumn(Se,0),X.crossVectors(n.object.up,X)),X.multiplyScalar(ue),v.add(X)}})(),re=(()=>{const X=new m.Vector3;return function(ue,Se){const Ke=n.domElement;if(Ke&&n.object instanceof m.PerspectiveCamera&&n.object.isPerspectiveCamera){const Ct=n.object.position;X.copy(Ct).sub(n.target);let Bt=X.length();Bt*=Math.tan(n.object.fov/2*Math.PI/180),J(2*ue*Bt/Ke.clientHeight,n.object.matrix),oe(2*Se*Bt/Ke.clientHeight,n.object.matrix)}else Ke&&n.object instanceof m.OrthographicCamera&&n.object.isOrthographicCamera?(J(ue*(n.object.right-n.object.left)/n.object.zoom/Ke.clientWidth,n.object.matrix),oe(Se*(n.object.top-n.object.bottom)/n.object.zoom/Ke.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function te(X){n.object instanceof m.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof m.OrthographicCamera&&n.object.isOrthographicCamera?y=X:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function me(X){te(y/X)}function be(X){te(y*X)}function he(X){if(!n.zoomToCursor||!n.domElement)return;K=!0;const E=n.domElement.getBoundingClientRect(),ue=X.clientX-E.left,Se=X.clientY-E.top,Ke=E.width,Ct=E.height;C.x=ue/Ke*2-1,C.y=-(Se/Ct)*2+1,k.set(C.x,C.y,1).unproject(n.object).sub(n.object.position).normalize()}function ve(X){return Math.max(n.minDistance,Math.min(n.maxDistance,X))}function ze(X){x.set(X.clientX,X.clientY)}function Ye(X){he(X),A.set(X.clientX,X.clientY)}function je(X){Z.set(X.clientX,X.clientY)}function Je(X){S.set(X.clientX,X.clientY),_.subVectors(S,x).multiplyScalar(n.rotateSpeed);const E=n.domElement;E&&(j(2*Math.PI*_.x/E.clientHeight),q(2*Math.PI*_.y/E.clientHeight)),x.copy(S),n.update()}function Qe(X){R.set(X.clientX,X.clientY),D.subVectors(R,A),D.y>0?me(H()):D.y<0&&be(H()),A.copy(R),n.update()}function ut(X){M.set(X.clientX,X.clientY),G.subVectors(M,Z).multiplyScalar(n.panSpeed),re(G.x,G.y),Z.copy(M),n.update()}function mt(X){he(X),X.deltaY<0?be(H()):X.deltaY>0&&me(H()),n.update()}function Ue(X){let E=!1;switch(X.code){case n.keys.UP:re(0,n.keyPanSpeed),E=!0;break;case n.keys.BOTTOM:re(0,-n.keyPanSpeed),E=!0;break;case n.keys.LEFT:re(n.keyPanSpeed,0),E=!0;break;case n.keys.RIGHT:re(-n.keyPanSpeed,0),E=!0;break}E&&(X.preventDefault(),n.update())}function dn(){if(I.length==1)x.set(I[0].pageX,I[0].pageY);else{const X=.5*(I[0].pageX+I[1].pageX),E=.5*(I[0].pageY+I[1].pageY);x.set(X,E)}}function Gn(){if(I.length==1)Z.set(I[0].pageX,I[0].pageY);else{const X=.5*(I[0].pageX+I[1].pageX),E=.5*(I[0].pageY+I[1].pageY);Z.set(X,E)}}function Ae(){const X=I[0].pageX-I[1].pageX,E=I[0].pageY-I[1].pageY,ue=Math.sqrt(X*X+E*E);A.set(0,ue)}function Ut(){n.enableZoom&&Ae(),n.enablePan&&Gn()}function Pt(){n.enableZoom&&Ae(),n.enableRotate&&dn()}function It(X){if(I.length==1)S.set(X.pageX,X.pageY);else{const ue=En(X),Se=.5*(X.pageX+ue.x),Ke=.5*(X.pageY+ue.y);S.set(Se,Ke)}_.subVectors(S,x).multiplyScalar(n.rotateSpeed);const E=n.domElement;E&&(j(2*Math.PI*_.x/E.clientHeight),q(2*Math.PI*_.y/E.clientHeight)),x.copy(S)}function Hi(X){if(I.length==1)M.set(X.pageX,X.pageY);else{const E=En(X),ue=.5*(X.pageX+E.x),Se=.5*(X.pageY+E.y);M.set(ue,Se)}G.subVectors(M,Z).multiplyScalar(n.panSpeed),re(G.x,G.y),Z.copy(M)}function zr(X){const E=En(X),ue=X.pageX-E.x,Se=X.pageY-E.y,Ke=Math.sqrt(ue*ue+Se*Se);R.set(0,Ke),D.set(0,Math.pow(R.y/A.y,n.zoomSpeed)),me(D.y),A.copy(R)}function Jn(X){n.enableZoom&&zr(X),n.enablePan&&Hi(X)}function xt(X){n.enableZoom&&zr(X),n.enableRotate&&It(X)}function Wn(X){var E,ue;n.enabled!==!1&&(I.length===0&&((E=n.domElement)==null||E.ownerDocument.addEventListener("pointermove",Pn),(ue=n.domElement)==null||ue.ownerDocument.addEventListener("pointerup",Qn)),$i(X),X.pointerType==="touch"?Ei(X):Hn(X))}function Pn(X){n.enabled!==!1&&(X.pointerType==="touch"?qi(X):Lo(X))}function Qn(X){var E,ue,Se;er(X),I.length===0&&((E=n.domElement)==null||E.releasePointerCapture(X.pointerId),(ue=n.domElement)==null||ue.ownerDocument.removeEventListener("pointermove",Pn),(Se=n.domElement)==null||Se.ownerDocument.removeEventListener("pointerup",Qn)),n.dispatchEvent(l),c=u.NONE}function Hn(X){let E;switch(X.button){case 0:E=n.mouseButtons.LEFT;break;case 1:E=n.mouseButtons.MIDDLE;break;case 2:E=n.mouseButtons.RIGHT;break;default:E=-1}switch(E){case m.MOUSE.DOLLY:if(n.enableZoom===!1)return;Ye(X),c=u.DOLLY;break;case m.MOUSE.ROTATE:if(X.ctrlKey||X.metaKey||X.shiftKey){if(n.enablePan===!1)return;je(X),c=u.PAN}else{if(n.enableRotate===!1)return;ze(X),c=u.ROTATE}break;case m.MOUSE.PAN:if(X.ctrlKey||X.metaKey||X.shiftKey){if(n.enableRotate===!1)return;ze(X),c=u.ROTATE}else{if(n.enablePan===!1)return;je(X),c=u.PAN}break;default:c=u.NONE}c!==u.NONE&&n.dispatchEvent(s)}function Lo(X){if(n.enabled!==!1)switch(c){case u.ROTATE:if(n.enableRotate===!1)return;Je(X);break;case u.DOLLY:if(n.enableZoom===!1)return;Qe(X);break;case u.PAN:if(n.enablePan===!1)return;ut(X);break}}function In(X){n.enabled===!1||n.enableZoom===!1||c!==u.NONE&&c!==u.ROTATE||(X.preventDefault(),n.dispatchEvent(s),mt(X),n.dispatchEvent(l))}function sn(X){n.enabled===!1||n.enablePan===!1||Ue(X)}function Ei(X){switch(yi(X),I.length){case 1:switch(n.touches.ONE){case m.TOUCH.ROTATE:if(n.enableRotate===!1)return;dn(),c=u.TOUCH_ROTATE;break;case m.TOUCH.PAN:if(n.enablePan===!1)return;Gn(),c=u.TOUCH_PAN;break;default:c=u.NONE}break;case 2:switch(n.touches.TWO){case m.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Ut(),c=u.TOUCH_DOLLY_PAN;break;case m.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Pt(),c=u.TOUCH_DOLLY_ROTATE;break;default:c=u.NONE}break;default:c=u.NONE}c!==u.NONE&&n.dispatchEvent(s)}function qi(X){switch(yi(X),c){case u.TOUCH_ROTATE:if(n.enableRotate===!1)return;It(X),n.update();break;case u.TOUCH_PAN:if(n.enablePan===!1)return;Hi(X),n.update();break;case u.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Jn(X),n.update();break;case u.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;xt(X),n.update();break;default:c=u.NONE}}function gi(X){n.enabled!==!1&&X.preventDefault()}function $i(X){I.push(X)}function er(X){delete z[X.pointerId];for(let E=0;E<I.length;E++)if(I[E].pointerId==X.pointerId){I.splice(E,1);return}}function yi(X){let E=z[X.pointerId];E===void 0&&(E=new m.Vector2,z[X.pointerId]=E),E.set(X.pageX,X.pageY)}function En(X){const E=X.pointerId===I[0].pointerId?I[1]:I[0];return z[E.pointerId]}this.dollyIn=(X=H())=>{be(X),n.update()},this.dollyOut=(X=H())=>{me(X),n.update()},this.getScale=()=>y,this.setScale=X=>{te(X),n.update()},this.getZoomScale=()=>H(),e!==void 0&&this.connect(e),this.update()}}class ld extends ad{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons.LEFT=m.MOUSE.PAN,this.mouseButtons.RIGHT=m.MOUSE.ROTATE,this.touches.ONE=m.TOUCH.PAN,this.touches.TWO=m.TOUCH.DOLLY_ROTATE}}function ui(a){if(typeof TextDecoder<"u")return new TextDecoder().decode(a);let t="";for(let e=0,n=a.length;e<n;e++)t+=String.fromCharCode(a[e]);try{return decodeURIComponent(escape(t))}catch{return t}}const Kn="srgb",cn="srgb-linear",Na=3001,cd=3e3;class ud extends m.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new md(e)}),this.register(function(e){return new gd(e)}),this.register(function(e){return new Sd(e)}),this.register(function(e){return new Td(e)}),this.register(function(e){return new Zd(e)}),this.register(function(e){return new vd(e)}),this.register(function(e){return new wd(e)}),this.register(function(e){return new xd(e)}),this.register(function(e){return new bd(e)}),this.register(function(e){return new pd(e)}),this.register(function(e){return new _d(e)}),this.register(function(e){return new yd(e)}),this.register(function(e){return new Ld(e)}),this.register(function(e){return new Md(e)}),this.register(function(e){return new dd(e)}),this.register(function(e){return new Gd(e)}),this.register(function(e){return new Wd(e)})}load(t,e,n,i){const s=this;let l;if(this.resourcePath!=="")l=this.resourcePath;else if(this.path!==""){const d=m.LoaderUtils.extractUrlBase(t);l=m.LoaderUtils.resolveURL(d,this.path)}else l=m.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const u=function(d){i?i(d):console.error(d),s.manager.itemError(t),s.manager.itemEnd(t)},c=new m.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(t,function(d){try{s.parse(d,l,function(p){e(p),s.manager.itemEnd(t)},u)}catch(p){u(p)}},n,u)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let s;const l={},u={};if(typeof t=="string")s=JSON.parse(t);else if(t instanceof ArrayBuffer)if(ui(new Uint8Array(t.slice(0,4)))===ja){try{l[we.KHR_BINARY_GLTF]=new Pd(t)}catch(p){i&&i(p);return}s=JSON.parse(l[we.KHR_BINARY_GLTF].content)}else s=JSON.parse(ui(new Uint8Array(t)));else s=t;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Yd(s,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const p=this.pluginCallbacks[d](c);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[p.name]=p,l[p.name]=!0}if(s.extensionsUsed)for(let d=0;d<s.extensionsUsed.length;++d){const p=s.extensionsUsed[d],f=s.extensionsRequired||[];switch(p){case we.KHR_MATERIALS_UNLIT:l[p]=new fd;break;case we.KHR_DRACO_MESH_COMPRESSION:l[p]=new Id(s,this.dracoLoader);break;case we.KHR_TEXTURE_TRANSFORM:l[p]=new Cd;break;case we.KHR_MESH_QUANTIZATION:l[p]=new Vd;break;default:f.indexOf(p)>=0&&u[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}c.setExtensions(l),c.setPlugins(u),c.parse(n,i)}parseAsync(t,e){const n=this;return new Promise(function(i,s){n.parse(t,e,i,s)})}}function hd(){let a={};return{get:function(t){return a[t]},add:function(t,e){a[t]=e},remove:function(t){delete a[t]},removeAll:function(){a={}}}}const we={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class dd{constructor(t){this.parser=t,this.name=we.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const s=e[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const s=e.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[t];let d;const p=new m.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],cn);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":d=new m.DirectionalLight(p),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new m.PointLight(p),d.distance=f;break;case"spot":d=new m.SpotLight(p),d.distance=f,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,d.angle=c.spot.outerConeAngle,d.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return d.position.set(0,0,0),d.decay=2,un(d,c),c.intensity!==void 0&&(d.intensity=c.intensity),d.name=e.createUniqueName(c.name||"light_"+t),i=Promise.resolve(d),e.cache.add(n,i),i}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,s=n.json.nodes[t],u=(s.extensions&&s.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(c){return n._getNodeRef(e.cache,u,c)})}}class fd{constructor(){this.name=we.KHR_MATERIALS_UNLIT}getMaterialType(){return m.MeshBasicMaterial}extendParams(t,e,n){const i=[];t.color=new m.Color(1,1,1),t.opacity=1;const s=e.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const l=s.baseColorFactor;t.color.setRGB(l[0],l[1],l[2],cn),t.opacity=l[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(t,"map",s.baseColorTexture,Kn))}return Promise.all(i)}}class pd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(e.emissiveIntensity=s),Promise.resolve()}}class md{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];if(l.clearcoatFactor!==void 0&&(e.clearcoat=l.clearcoatFactor),l.clearcoatTexture!==void 0&&s.push(n.assignTexture(e,"clearcoatMap",l.clearcoatTexture)),l.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=l.clearcoatRoughnessFactor),l.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(e,"clearcoatRoughnessMap",l.clearcoatRoughnessTexture)),l.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(e,"clearcoatNormalMap",l.clearcoatNormalTexture)),l.clearcoatNormalTexture.scale!==void 0)){const u=l.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new m.Vector2(u,u)}return Promise.all(s)}}class gd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_DISPERSION}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return e.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class yd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];return l.iridescenceFactor!==void 0&&(e.iridescence=l.iridescenceFactor),l.iridescenceTexture!==void 0&&s.push(n.assignTexture(e,"iridescenceMap",l.iridescenceTexture)),l.iridescenceIor!==void 0&&(e.iridescenceIOR=l.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),l.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=l.iridescenceThicknessMinimum),l.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=l.iridescenceThicknessMaximum),l.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(e,"iridescenceThicknessMap",l.iridescenceThicknessTexture)),Promise.all(s)}}class vd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_SHEEN}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];e.sheenColor=new m.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const l=i.extensions[this.name];if(l.sheenColorFactor!==void 0){const u=l.sheenColorFactor;e.sheenColor.setRGB(u[0],u[1],u[2],cn)}return l.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=l.sheenRoughnessFactor),l.sheenColorTexture!==void 0&&s.push(n.assignTexture(e,"sheenColorMap",l.sheenColorTexture,Kn)),l.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(e,"sheenRoughnessMap",l.sheenRoughnessTexture)),Promise.all(s)}}class wd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];return l.transmissionFactor!==void 0&&(e.transmission=l.transmissionFactor),l.transmissionTexture!==void 0&&s.push(n.assignTexture(e,"transmissionMap",l.transmissionTexture)),Promise.all(s)}}class xd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_VOLUME}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];e.thickness=l.thicknessFactor!==void 0?l.thicknessFactor:0,l.thicknessTexture!==void 0&&s.push(n.assignTexture(e,"thicknessMap",l.thicknessTexture)),e.attenuationDistance=l.attenuationDistance||1/0;const u=l.attenuationColor||[1,1,1];return e.attenuationColor=new m.Color().setRGB(u[0],u[1],u[2],cn),Promise.all(s)}}class bd{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_IOR}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return e.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class _d{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_SPECULAR}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];e.specularIntensity=l.specularFactor!==void 0?l.specularFactor:1,l.specularTexture!==void 0&&s.push(n.assignTexture(e,"specularIntensityMap",l.specularTexture));const u=l.specularColorFactor||[1,1,1];return e.specularColor=new m.Color().setRGB(u[0],u[1],u[2],cn),l.specularColorTexture!==void 0&&s.push(n.assignTexture(e,"specularColorMap",l.specularColorTexture,Kn)),Promise.all(s)}}class Md{constructor(t){this.parser=t,this.name=we.EXT_MATERIALS_BUMP}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];return e.bumpScale=l.bumpFactor!==void 0?l.bumpFactor:1,l.bumpTexture!==void 0&&s.push(n.assignTexture(e,"bumpMap",l.bumpTexture)),Promise.all(s)}}class Ld{constructor(t){this.parser=t,this.name=we.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],l=i.extensions[this.name];return l.anisotropyStrength!==void 0&&(e.anisotropy=l.anisotropyStrength),l.anisotropyRotation!==void 0&&(e.anisotropyRotation=l.anisotropyRotation),l.anisotropyTexture!==void 0&&s.push(n.assignTexture(e,"anisotropyMap",l.anisotropyTexture)),Promise.all(s)}}class Sd{constructor(t){this.parser=t,this.name=we.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],l=e.options.ktx2Loader;if(!l){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,s.source,l)}}class Td{constructor(t){this.parser=t,this.name=we.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,s=i.textures[t];if(!s.extensions||!s.extensions[e])return null;const l=s.extensions[e],u=i.images[l.source];let c=n.textureLoader;if(u.uri){const d=n.options.manager.getHandler(u.uri);d!==null&&(c=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(t,l.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Zd{constructor(t){this.parser=t,this.name=we.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,s=i.textures[t];if(!s.extensions||!s.extensions[e])return null;const l=s.extensions[e],u=i.images[l.source];let c=n.textureLoader;if(u.uri){const d=n.options.manager.getHandler(u.uri);d!==null&&(c=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(t,l.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Gd{constructor(t){this.name=we.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),l=this.parser.options.meshoptDecoder;if(!l||!l.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(u){const c=i.byteOffset||0,d=i.byteLength||0,p=i.count,f=i.byteStride,y=new Uint8Array(u,c,d);return l.decodeGltfBufferAsync?l.decodeGltfBufferAsync(p,f,y,i.mode,i.filter).then(function(v){return v.buffer}):l.ready.then(function(){const v=new ArrayBuffer(p*f);return l.decodeGltfBuffer(new Uint8Array(v),p,f,y,i.mode,i.filter),v})})}else return null}}class Wd{constructor(t){this.name=we.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=e.meshes[n.mesh];for(const d of i.primitives)if(d.mode!==Gt.TRIANGLES&&d.mode!==Gt.TRIANGLE_STRIP&&d.mode!==Gt.TRIANGLE_FAN&&d.mode!==void 0)return null;const l=n.extensions[this.name].attributes,u=[],c={};for(const d in l)u.push(this.parser.getDependency("accessor",l[d]).then(p=>(c[d]=p,c[d])));return u.length<1?null:(u.push(this.parser.createNodeMesh(t)),Promise.all(u).then(d=>{const p=d.pop(),f=p.isGroup?p.children:[p],y=d[0].count,v=[];for(const x of f){const S=new m.Matrix4,_=new m.Vector3,Z=new m.Quaternion,M=new m.Vector3(1,1,1),G=new m.InstancedMesh(x.geometry,x.material,y);for(let A=0;A<y;A++)c.TRANSLATION&&_.fromBufferAttribute(c.TRANSLATION,A),c.ROTATION&&Z.fromBufferAttribute(c.ROTATION,A),c.SCALE&&M.fromBufferAttribute(c.SCALE,A),G.setMatrixAt(A,S.compose(_,Z,M));for(const A in c)if(A==="_COLOR_0"){const R=c[A];G.instanceColor=new m.InstancedBufferAttribute(R.array,R.itemSize,R.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&x.geometry.setAttribute(A,c[A]);m.Object3D.prototype.copy.call(G,x),this.parser.assignFinalMaterial(G),v.push(G)}return p.isGroup?(p.clear(),p.add(...v),p):v[0]}))}}const ja="glTF",Xi=12,Ja={JSON:1313821514,BIN:5130562};class Pd{constructor(t){this.name=we.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,Xi);if(this.header={magic:ui(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==ja)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Xi,i=new DataView(t,Xi);let s=0;for(;s<n;){const l=i.getUint32(s,!0);s+=4;const u=i.getUint32(s,!0);if(s+=4,u===Ja.JSON){const c=new Uint8Array(t,Xi+s,l);this.content=ui(c)}else if(u===Ja.BIN){const c=Xi+s;this.body=t.slice(c,c+l)}s+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Id{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=we.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,s=t.extensions[this.name].bufferView,l=t.extensions[this.name].attributes,u={},c={},d={};for(const p in l){const f=As[p]||p.toLowerCase();u[f]=l[p]}for(const p in t.attributes){const f=As[p]||p.toLowerCase();if(l[p]!==void 0){const y=n.accessors[t.attributes[p]],v=hi[y.componentType];d[f]=v.name,c[f]=y.normalized===!0}}return e.getDependency("bufferView",s).then(function(p){return new Promise(function(f,y){i.decodeDracoFile(p,function(v){for(const x in v.attributes){const S=v.attributes[x],_=c[x];_!==void 0&&(S.normalized=_)}f(v)},u,d,cn,y)})})}}class Cd{constructor(){this.name=we.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Vd{constructor(){this.name=we.KHR_MESH_QUANTIZATION}}class Qa extends m.Interpolant{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i*3+i;for(let l=0;l!==i;l++)e[l]=n[s+l];return e}interpolate_(t,e,n,i){const s=this.resultBuffer,l=this.sampleValues,u=this.valueSize,c=u*2,d=u*3,p=i-e,f=(n-e)/p,y=f*f,v=y*f,x=t*d,S=x-d,_=-2*v+3*y,Z=v-y,M=1-_,G=Z-y+f;for(let A=0;A!==u;A++){const R=l[S+A+u],D=l[S+A+c]*p,k=l[x+A+u],C=l[x+A]*p;s[A]=M*R+G*D+_*k+Z*C}return s}}const Ad=new m.Quaternion;class Fd extends Qa{interpolate_(t,e,n,i){const s=super.interpolate_(t,e,n,i);return Ad.fromArray(s).normalize().toArray(s),s}}const Gt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},hi={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ha={9728:m.NearestFilter,9729:m.LinearFilter,9984:m.NearestMipmapNearestFilter,9985:m.LinearMipmapNearestFilter,9986:m.NearestMipmapLinearFilter,9987:m.LinearMipmapLinearFilter},Ea={33071:m.ClampToEdgeWrapping,33648:m.MirroredRepeatWrapping,10497:m.RepeatWrapping},Vs={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},As={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...gr>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ln={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Xd={CUBICSPLINE:void 0,LINEAR:m.InterpolateLinear,STEP:m.InterpolateDiscrete},Fs={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function zd(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new m.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m.FrontSide})),a.DefaultMaterial}function Yn(a,t,e){for(const n in e.extensions)a[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function un(a,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(a.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Dd(a,t,e){let n=!1,i=!1,s=!1;for(let d=0,p=t.length;d<p;d++){const f=t[d];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(i=!0),f.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(a);const l=[],u=[],c=[];for(let d=0,p=t.length;d<p;d++){const f=t[d];if(n){const y=f.POSITION!==void 0?e.getDependency("accessor",f.POSITION):a.attributes.position;l.push(y)}if(i){const y=f.NORMAL!==void 0?e.getDependency("accessor",f.NORMAL):a.attributes.normal;u.push(y)}if(s){const y=f.COLOR_0!==void 0?e.getDependency("accessor",f.COLOR_0):a.attributes.color;c.push(y)}}return Promise.all([Promise.all(l),Promise.all(u),Promise.all(c)]).then(function(d){const p=d[0],f=d[1],y=d[2];return n&&(a.morphAttributes.position=p),i&&(a.morphAttributes.normal=f),s&&(a.morphAttributes.color=y),a.morphTargetsRelative=!0,a})}function kd(a,t){if(a.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)a.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(a.morphTargetInfluences.length===e.length){a.morphTargetDictionary={};for(let n=0,i=e.length;n<i;n++)a.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Od(a){let t;const e=a.extensions&&a.extensions[we.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+Xs(e.attributes):t=a.indices+":"+Xs(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,i=a.targets.length;n<i;n++)t+=":"+Xs(a.targets[n]);return t}function Xs(a){let t="";const e=Object.keys(a).sort();for(let n=0,i=e.length;n<i;n++)t+=e[n]+":"+a[e[n]]+";";return t}function zs(a){switch(a){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Rd(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Kd=new m.Matrix4;class Yd{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new hd,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,s=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,s=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&s<98?this.textureLoader=new m.TextureLoader(this.options.manager):this.textureLoader=new m.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new m.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(l){return l._markDefs&&l._markDefs()}),Promise.all(this._invokeAll(function(l){return l.beforeRoot&&l.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(l){const u={scene:l[0][i.scene||0],scenes:l[0],animations:l[1],cameras:l[2],asset:i.asset,parser:n,userData:{}};return Yn(s,u,i),un(u,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(u)})).then(function(){for(const c of u.scenes)c.updateMatrixWorld();t(u)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=e.length;i<s;i++){const l=e[i].joints;for(let u=0,c=l.length;u<c;u++)t[l[u]].isBone=!0}for(let i=0,s=t.length;i<s;i++){const l=t[i];l.mesh!==void 0&&(this._addNodeRef(this.meshCache,l.mesh),l.skin!==void 0&&(n[l.mesh].isSkinnedMesh=!0)),l.camera!==void 0&&this._addNodeRef(this.cameraCache,l.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),s=(l,u)=>{const c=this.associations.get(l);c!=null&&this.associations.set(u,c);for(const[d,p]of l.children.entries())s(p,u.children[d])};return s(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const s=t(e[i]);s&&n.push(s)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(e)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(e)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t);break}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(i.map(function(s,l){return n.getDependency(t,l)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[we.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,l){n.load(m.LoaderUtils.resolveURL(e.uri,i.path),s,void 0,function(){l(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){const i=e.byteLength||0,s=e.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(i.bufferView===void 0&&i.sparse===void 0){const l=Vs[i.type],u=hi[i.componentType],c=i.normalized===!0,d=new u(i.count*l);return Promise.resolve(new m.BufferAttribute(d,l,c))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(l){const u=l[0],c=Vs[i.type],d=hi[i.componentType],p=d.BYTES_PER_ELEMENT,f=p*c,y=i.byteOffset||0,v=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,x=i.normalized===!0;let S,_;if(v&&v!==f){const Z=Math.floor(y/v),M="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+Z+":"+i.count;let G=e.cache.get(M);G||(S=new d(u,Z*v,i.count*v/p),G=new m.InterleavedBuffer(S,v/p),e.cache.add(M,G)),_=new m.InterleavedBufferAttribute(G,c,y%v/p,x)}else u===null?S=new d(i.count*c):S=new d(u,y,i.count*c),_=new m.BufferAttribute(S,c,x);if(i.sparse!==void 0){const Z=Vs.SCALAR,M=hi[i.sparse.indices.componentType],G=i.sparse.indices.byteOffset||0,A=i.sparse.values.byteOffset||0,R=new M(l[1],G,i.sparse.count*Z),D=new d(l[2],A,i.sparse.count*c);u!==null&&(_=new m.BufferAttribute(_.array.slice(),_.itemSize,_.normalized));for(let k=0,C=R.length;k<C;k++){const K=R[k];if(_.setX(K,D[k*c]),c>=2&&_.setY(K,D[k*c+1]),c>=3&&_.setZ(K,D[k*c+2]),c>=4&&_.setW(K,D[k*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}loadTexture(t){const e=this.json,n=this.options,s=e.textures[t].source,l=e.images[s];let u=this.textureLoader;if(l.uri){const c=n.manager.getHandler(l.uri);c!==null&&(u=c)}return this.loadTextureImage(t,s,u)}loadTextureImage(t,e,n){const i=this,s=this.json,l=s.textures[t],u=s.images[e],c=(u.uri||u.bufferView)+":"+l.sampler;if(this.textureCache[c])return this.textureCache[c];const d=this.loadImageSource(e,n).then(function(p){p.flipY=!1,p.name=l.name||u.name||"",p.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(p.name=u.uri);const y=(s.samplers||{})[l.sampler]||{};return p.magFilter=Ha[y.magFilter]||m.LinearFilter,p.minFilter=Ha[y.minFilter]||m.LinearMipmapLinearFilter,p.wrapS=Ea[y.wrapS]||m.RepeatWrapping,p.wrapT=Ea[y.wrapT]||m.RepeatWrapping,i.associations.set(p,{textures:t}),p}).catch(function(){return null});return this.textureCache[c]=d,d}loadImageSource(t,e){const n=this,i=this.json,s=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(f=>f.clone());const l=i.images[t],u=self.URL||self.webkitURL;let c=l.uri||"",d=!1;if(l.bufferView!==void 0)c=n.getDependency("bufferView",l.bufferView).then(function(f){d=!0;const y=new Blob([f],{type:l.mimeType});return c=u.createObjectURL(y),c});else if(l.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(f){return new Promise(function(y,v){let x=y;e.isImageBitmapLoader===!0&&(x=function(S){const _=new m.Texture(S);_.needsUpdate=!0,y(_)}),e.load(m.LoaderUtils.resolveURL(f,s.path),x,void 0,v)})}).then(function(f){return d===!0&&u.revokeObjectURL(c),un(f,l),f.userData.mimeType=l.mimeType||Rd(l.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[t]=p,p}assignTexture(t,e,n,i){const s=this;return this.getDependency("texture",n.index).then(function(l){if(!l)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(l=l.clone(),l.channel=n.texCoord),s.extensions[we.KHR_TEXTURE_TRANSFORM]){const u=n.extensions!==void 0?n.extensions[we.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const c=s.associations.get(l);l=s.extensions[we.KHR_TEXTURE_TRANSFORM].extendTexture(l,u),s.associations.set(l,c)}}return i!==void 0&&(typeof i=="number"&&(i=i===Na?Kn:cn),"colorSpace"in l?l.colorSpace=i:l.encoding=i===Kn?Na:cd),t[e]=l,l})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=e.attributes.tangent===void 0,s=e.attributes.color!==void 0,l=e.attributes.normal===void 0;if(t.isPoints){const u="PointsMaterial:"+n.uuid;let c=this.cache.get(u);c||(c=new m.PointsMaterial,m.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(u,c)),n=c}else if(t.isLine){const u="LineBasicMaterial:"+n.uuid;let c=this.cache.get(u);c||(c=new m.LineBasicMaterial,m.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(u,c)),n=c}if(i||s||l){let u="ClonedMaterial:"+n.uuid+":";i&&(u+="derivative-tangents:"),s&&(u+="vertex-colors:"),l&&(u+="flat-shading:");let c=this.cache.get(u);c||(c=n.clone(),s&&(c.vertexColors=!0),l&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(u,c),this.associations.set(c,this.associations.get(n))),n=c}t.material=n}getMaterialType(){return m.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,i=this.extensions,s=n.materials[t];let l;const u={},c=s.extensions||{},d=[];if(c[we.KHR_MATERIALS_UNLIT]){const f=i[we.KHR_MATERIALS_UNLIT];l=f.getMaterialType(),d.push(f.extendParams(u,s,e))}else{const f=s.pbrMetallicRoughness||{};if(u.color=new m.Color(1,1,1),u.opacity=1,Array.isArray(f.baseColorFactor)){const y=f.baseColorFactor;u.color.setRGB(y[0],y[1],y[2],cn),u.opacity=y[3]}f.baseColorTexture!==void 0&&d.push(e.assignTexture(u,"map",f.baseColorTexture,Kn)),u.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,u.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(d.push(e.assignTexture(u,"metalnessMap",f.metallicRoughnessTexture)),d.push(e.assignTexture(u,"roughnessMap",f.metallicRoughnessTexture))),l=this._invokeOne(function(y){return y.getMaterialType&&y.getMaterialType(t)}),d.push(Promise.all(this._invokeAll(function(y){return y.extendMaterialParams&&y.extendMaterialParams(t,u)})))}s.doubleSided===!0&&(u.side=m.DoubleSide);const p=s.alphaMode||Fs.OPAQUE;if(p===Fs.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,p===Fs.MASK&&(u.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&l!==m.MeshBasicMaterial&&(d.push(e.assignTexture(u,"normalMap",s.normalTexture)),u.normalScale=new m.Vector2(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;u.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&l!==m.MeshBasicMaterial&&(d.push(e.assignTexture(u,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&l!==m.MeshBasicMaterial){const f=s.emissiveFactor;u.emissive=new m.Color().setRGB(f[0],f[1],f[2],cn)}return s.emissiveTexture!==void 0&&l!==m.MeshBasicMaterial&&d.push(e.assignTexture(u,"emissiveMap",s.emissiveTexture,Kn)),Promise.all(d).then(function(){const f=new l(u);return s.name&&(f.name=s.name),un(f,s),e.associations.set(f,{materials:t}),s.extensions&&Yn(i,f,s),f})}createUniqueName(t){const e=m.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function s(u){return n[we.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,e).then(function(c){return qa(c,u,e)})}const l=[];for(let u=0,c=t.length;u<c;u++){const d=t[u],p=Od(d),f=i[p];if(f)l.push(f.promise);else{let y;d.extensions&&d.extensions[we.KHR_DRACO_MESH_COMPRESSION]?y=s(d):y=qa(new m.BufferGeometry,d,e),i[p]={primitive:d,promise:y},l.push(y)}}return Promise.all(l)}loadMesh(t){const e=this,n=this.json,i=this.extensions,s=n.meshes[t],l=s.primitives,u=[];for(let c=0,d=l.length;c<d;c++){const p=l[c].material===void 0?zd(this.cache):this.getDependency("material",l[c].material);u.push(p)}return u.push(e.loadGeometries(l)),Promise.all(u).then(function(c){const d=c.slice(0,c.length-1),p=c[c.length-1],f=[];for(let v=0,x=p.length;v<x;v++){const S=p[v],_=l[v];let Z;const M=d[v];if(_.mode===Gt.TRIANGLES||_.mode===Gt.TRIANGLE_STRIP||_.mode===Gt.TRIANGLE_FAN||_.mode===void 0)Z=s.isSkinnedMesh===!0?new m.SkinnedMesh(S,M):new m.Mesh(S,M),Z.isSkinnedMesh===!0&&Z.normalizeSkinWeights(),_.mode===Gt.TRIANGLE_STRIP?Z.geometry=za(Z.geometry,m.TriangleStripDrawMode):_.mode===Gt.TRIANGLE_FAN&&(Z.geometry=za(Z.geometry,m.TriangleFanDrawMode));else if(_.mode===Gt.LINES)Z=new m.LineSegments(S,M);else if(_.mode===Gt.LINE_STRIP)Z=new m.Line(S,M);else if(_.mode===Gt.LINE_LOOP)Z=new m.LineLoop(S,M);else if(_.mode===Gt.POINTS)Z=new m.Points(S,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(Z.geometry.morphAttributes).length>0&&kd(Z,s),Z.name=e.createUniqueName(s.name||"mesh_"+t),un(Z,s),_.extensions&&Yn(i,Z,_),e.assignFinalMaterial(Z),f.push(Z)}for(let v=0,x=f.length;v<x;v++)e.associations.set(f[v],{meshes:t,primitives:v});if(f.length===1)return s.extensions&&Yn(i,f[0],s),f[0];const y=new m.Group;s.extensions&&Yn(i,y,s),e.associations.set(y,{meshes:t});for(let v=0,x=f.length;v<x;v++)y.add(f[v]);return y})}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new m.PerspectiveCamera(m.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(e=new m.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),un(e,n),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],n=[];for(let i=0,s=e.joints.length;i<s;i++)n.push(this._loadNodeShallow(e.joints[i]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),l=i,u=[],c=[];for(let d=0,p=l.length;d<p;d++){const f=l[d];if(f){u.push(f);const y=new m.Matrix4;s!==null&&y.fromArray(s.array,d*16),c.push(y)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[d])}return new m.Skeleton(u,c)})}loadAnimation(t){const e=this.json,n=this,i=e.animations[t],s=i.name?i.name:"animation_"+t,l=[],u=[],c=[],d=[],p=[];for(let f=0,y=i.channels.length;f<y;f++){const v=i.channels[f],x=i.samplers[v.sampler],S=v.target,_=S.node,Z=i.parameters!==void 0?i.parameters[x.input]:x.input,M=i.parameters!==void 0?i.parameters[x.output]:x.output;S.node!==void 0&&(l.push(this.getDependency("node",_)),u.push(this.getDependency("accessor",Z)),c.push(this.getDependency("accessor",M)),d.push(x),p.push(S))}return Promise.all([Promise.all(l),Promise.all(u),Promise.all(c),Promise.all(d),Promise.all(p)]).then(function(f){const y=f[0],v=f[1],x=f[2],S=f[3],_=f[4],Z=[];for(let M=0,G=y.length;M<G;M++){const A=y[M],R=v[M],D=x[M],k=S[M],C=_[M];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const K=n._createAnimationTracks(A,R,D,k,C);if(K)for(let I=0;I<K.length;I++)Z.push(K[I])}return new m.AnimationClip(s,void 0,Z)})}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const l=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&l.traverse(function(u){if(u.isMesh)for(let c=0,d=i.weights.length;c<d;c++)u.morphTargetInfluences[c]=i.weights[c]}),l})}loadNode(t){const e=this.json,n=this,i=e.nodes[t],s=n._loadNodeShallow(t),l=[],u=i.children||[];for(let d=0,p=u.length;d<p;d++)l.push(n.getDependency("node",u[d]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(l),c]).then(function(d){const p=d[0],f=d[1],y=d[2];y!==null&&p.traverse(function(v){v.isSkinnedMesh&&v.bind(y,Kd)});for(let v=0,x=f.length;v<x;v++)p.add(f[v]);return p})}_loadNodeShallow(t){const e=this.json,n=this.extensions,i=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const s=e.nodes[t],l=s.name?i.createUniqueName(s.name):"",u=[],c=i._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(t)});return c&&u.push(c),s.camera!==void 0&&u.push(i.getDependency("camera",s.camera).then(function(d){return i._getNodeRef(i.cameraCache,s.camera,d)})),i._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(t)}).forEach(function(d){u.push(d)}),this.nodeCache[t]=Promise.all(u).then(function(d){let p;if(s.isBone===!0?p=new m.Bone:d.length>1?p=new m.Group:d.length===1?p=d[0]:p=new m.Object3D,p!==d[0])for(let f=0,y=d.length;f<y;f++)p.add(d[f]);if(s.name&&(p.userData.name=s.name,p.name=l),un(p,s),s.extensions&&Yn(n,p,s),s.matrix!==void 0){const f=new m.Matrix4;f.fromArray(s.matrix),p.applyMatrix4(f)}else s.translation!==void 0&&p.position.fromArray(s.translation),s.rotation!==void 0&&p.quaternion.fromArray(s.rotation),s.scale!==void 0&&p.scale.fromArray(s.scale);return i.associations.has(p)||i.associations.set(p,{}),i.associations.get(p).nodes=t,p}),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],i=this,s=new m.Group;n.name&&(s.name=i.createUniqueName(n.name)),un(s,n),n.extensions&&Yn(e,s,n);const l=n.nodes||[],u=[];for(let c=0,d=l.length;c<d;c++)u.push(i.getDependency("node",l[c]));return Promise.all(u).then(function(c){for(let p=0,f=c.length;p<f;p++)s.add(c[p]);const d=p=>{const f=new Map;for(const[y,v]of i.associations)(y instanceof m.Material||y instanceof m.Texture)&&f.set(y,v);return p.traverse(y=>{const v=i.associations.get(y);v!=null&&f.set(y,v)}),f};return i.associations=d(s),s})}_createAnimationTracks(t,e,n,i,s){const l=[],u=t.name?t.name:t.uuid,c=[];Ln[s.path]===Ln.weights?t.traverse(function(y){y.morphTargetInfluences&&c.push(y.name?y.name:y.uuid)}):c.push(u);let d;switch(Ln[s.path]){case Ln.weights:d=m.NumberKeyframeTrack;break;case Ln.rotation:d=m.QuaternionKeyframeTrack;break;case Ln.position:case Ln.scale:d=m.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:d=m.NumberKeyframeTrack;break;case 2:case 3:default:d=m.VectorKeyframeTrack;break}break}const p=i.interpolation!==void 0?Xd[i.interpolation]:m.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let y=0,v=c.length;y<v;y++){const x=new d(c[y]+"."+Ln[s.path],e.array,f,p);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),l.push(x)}return l}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const n=zs(e.constructor),i=new Float32Array(e.length);for(let s=0,l=e.length;s<l;s++)i[s]=e[s]*n;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){const i=this instanceof m.QuaternionKeyframeTrack?Fd:Qa;return new i(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ud(a,t,e){const n=t.attributes,i=new m.Box3;if(n.POSITION!==void 0){const u=e.json.accessors[n.POSITION],c=u.min,d=u.max;if(c!==void 0&&d!==void 0){if(i.set(new m.Vector3(c[0],c[1],c[2]),new m.Vector3(d[0],d[1],d[2])),u.normalized){const p=zs(hi[u.componentType]);i.min.multiplyScalar(p),i.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=t.targets;if(s!==void 0){const u=new m.Vector3,c=new m.Vector3;for(let d=0,p=s.length;d<p;d++){const f=s[d];if(f.POSITION!==void 0){const y=e.json.accessors[f.POSITION],v=y.min,x=y.max;if(v!==void 0&&x!==void 0){if(c.setX(Math.max(Math.abs(v[0]),Math.abs(x[0]))),c.setY(Math.max(Math.abs(v[1]),Math.abs(x[1]))),c.setZ(Math.max(Math.abs(v[2]),Math.abs(x[2]))),y.normalized){const S=zs(hi[y.componentType]);c.multiplyScalar(S)}u.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(u)}a.boundingBox=i;const l=new m.Sphere;i.getCenter(l.center),l.radius=i.min.distanceTo(i.max)/2,a.boundingSphere=l}function qa(a,t,e){const n=t.attributes,i=[];function s(l,u){return e.getDependency("accessor",l).then(function(c){a.setAttribute(u,c)})}for(const l in n){const u=As[l]||l.toLowerCase();u in a.attributes||i.push(s(n[l],u))}if(t.indices!==void 0&&!a.index){const l=e.getDependency("accessor",t.indices).then(function(u){a.setIndex(u)});i.push(l)}return un(a,t),Ud(a,t,e),Promise.all(i).then(function(){return t.targets!==void 0?Dd(a,t.targets,e):a})}function $a(a,t,e){const n=e.length-a-1;if(t>=e[n])return n-1;if(t<=e[a])return a;let i=a,s=n,l=Math.floor((i+s)/2);for(;t<e[l]||t>=e[l+1];)t<e[l]?s=l:i=l,l=Math.floor((i+s)/2);return l}function Bd(a,t,e,n){const i=[],s=[],l=[];i[0]=1;for(let u=1;u<=e;++u){s[u]=t-n[a+1-u],l[u]=n[a+u]-t;let c=0;for(let d=0;d<u;++d){const p=l[d+1],f=s[u-d],y=i[d]/(p+f);i[d]=c+p*y,c=f*y}i[u]=c}return i}function Nd(a,t,e,n){const i=$a(a,n,t),s=Bd(i,n,a,t),l=new m.Vector4(0,0,0,0);for(let u=0;u<=a;++u){const c=e[i-a+u],d=s[u],p=c.w*d;l.x+=c.x*p,l.y+=c.y*p,l.z+=c.z*p,l.w+=c.w*d}return l}function jd(a,t,e,n,i){const s=[];for(let f=0;f<=e;++f)s[f]=0;const l=[];for(let f=0;f<=n;++f)l[f]=s.slice(0);const u=[];for(let f=0;f<=e;++f)u[f]=s.slice(0);u[0][0]=1;const c=s.slice(0),d=s.slice(0);for(let f=1;f<=e;++f){c[f]=t-i[a+1-f],d[f]=i[a+f]-t;let y=0;for(let v=0;v<f;++v){const x=d[v+1],S=c[f-v];u[f][v]=x+S;const _=u[v][f-1]/u[f][v];u[v][f]=y+x*_,y=S*_}u[f][f]=y}for(let f=0;f<=e;++f)l[0][f]=u[f][e];for(let f=0;f<=e;++f){let y=0,v=1;const x=[];for(let S=0;S<=e;++S)x[S]=s.slice(0);x[0][0]=1;for(let S=1;S<=n;++S){let _=0;const Z=f-S,M=e-S;f>=S&&(x[v][0]=x[y][0]/u[M+1][Z],_=x[v][0]*u[Z][M]);const G=Z>=-1?1:-Z,A=f-1<=M?S-1:e-f;for(let D=G;D<=A;++D)x[v][D]=(x[y][D]-x[y][D-1])/u[M+1][Z+D],_+=x[v][D]*u[Z+D][M];f<=M&&(x[v][S]=-x[y][S-1]/u[M+1][f],_+=x[v][S]*u[f][M]),l[S][f]=_;const R=y;y=v,v=R}}let p=e;for(let f=1;f<=n;++f){for(let y=0;y<=e;++y)l[f][y]*=p;p*=e-f}return l}function Jd(a,t,e,n,i){const s=i<a?i:a,l=[],u=$a(a,n,t),c=jd(u,n,a,s,t),d=[];for(let p=0;p<e.length;++p){const f=e[p].clone(),y=f.w;f.x*=y,f.y*=y,f.z*=y,d[p]=f}for(let p=0;p<=s;++p){const f=d[u-a].clone().multiplyScalar(c[p][0]);for(let y=1;y<=a;++y)f.add(d[u-a+y].clone().multiplyScalar(c[p][y]));l[p]=f}for(let p=s+1;p<=i+1;++p)l[p]=new m.Vector4(0,0,0);return l}function Qd(a,t){let e=1;for(let i=2;i<=a;++i)e*=i;let n=1;for(let i=2;i<=t;++i)n*=i;for(let i=2;i<=a-t;++i)n*=i;return e/n}function Hd(a){const t=a.length,e=[],n=[];for(let s=0;s<t;++s){const l=a[s];e[s]=new m.Vector3(l.x,l.y,l.z),n[s]=l.w}const i=[];for(let s=0;s<t;++s){const l=e[s].clone();for(let u=1;u<=s;++u)l.sub(i[s-u].clone().multiplyScalar(Qd(s,u)*n[u]));i[s]=l.divideScalar(n[0])}return i}function Ed(a,t,e,n,i){const s=Jd(a,t,e,n,i);return Hd(s)}class el extends m.Curve{constructor(t,e,n,i,s){super(),this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=i||0,this.endKnot=s||this.knots.length-1;for(let l=0;l<n.length;++l){const u=n[l];this.controlPoints[l]=new m.Vector4(u.x,u.y,u.z,u.w)}}getPoint(t,e){const n=e||new m.Vector3,i=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Nd(this.degree,this.knots,this.controlPoints,i);return s.w!=1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(t,e){const n=e||new m.Vector3,i=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),s=Ed(this.degree,this.knots,this.controlPoints,i,1);return n.copy(s[1]).normalize(),n}}let xe,ke,pt;class qd extends m.Loader{constructor(t){super(t)}load(t,e,n,i){const s=this,l=s.path===""?m.LoaderUtils.extractUrlBase(t):s.path,u=new m.FileLoader(this.manager);u.setPath(s.path),u.setResponseType("arraybuffer"),u.setRequestHeader(s.requestHeader),u.setWithCredentials(s.withCredentials),u.load(t,function(c){try{e(s.parse(c,l))}catch(d){i?i(d):console.error(d),s.manager.itemError(t)}},n,i)}parse(t,e){if(sf(t))xe=new rf().parse(t);else{const i=ol(t);if(!of(i))throw new Error("THREE.FBXLoader: Unknown format.");if(il(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+il(i));xe=new nf().parse(i)}const n=new m.TextureLoader(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new $d(n,this.manager).parse(xe)}}class $d{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){ke=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),i=this.parseDeformers(),s=new ef().parse(i);return this.parseScene(i,s,n),pt}parseConnections(){const t=new Map;return"Connections"in xe&&xe.Connections.connections.forEach(function(n){const i=n[0],s=n[1],l=n[2];t.has(i)||t.set(i,{parents:[],children:[]});const u={ID:s,relationship:l};t.get(i).parents.push(u),t.has(s)||t.set(s,{parents:[],children:[]});const c={ID:i,relationship:l};t.get(s).children.push(c)}),t}parseImages(){const t={},e={};if("Video"in xe.Objects){const n=xe.Objects.Video;for(const i in n){const s=n[i],l=parseInt(i);if(t[l]=s.RelativeFilename||s.Filename,"Content"in s){const u=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,c=typeof s.Content=="string"&&s.Content!=="";if(u||c){const d=this.parseImage(n[i]);e[s.RelativeFilename||s.Filename]=d}}}}for(const n in t){const i=t[n];e[i]!==void 0?t[n]=e[i]:t[n]=t[n].split("\\").pop()}return t}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(i){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof e=="string")return"data:"+s+";base64,"+e;{const l=new Uint8Array(e);return window.URL.createObjectURL(new Blob([l],{type:s}))}}parseTextures(t){const e=new Map;if("Texture"in xe.Objects){const n=xe.Objects.Texture;for(const i in n){const s=this.parseTexture(n[i],t);e.set(parseInt(i),s)}}return e}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const i=t.WrapModeU,s=t.WrapModeV,l=i!==void 0?i.value:0,u=s!==void 0?s.value:0;if(n.wrapS=l===0?m.RepeatWrapping:m.ClampToEdgeWrapping,n.wrapT=u===0?m.RepeatWrapping:m.ClampToEdgeWrapping,"Scaling"in t){const c=t.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}return n}loadTexture(t,e){let n;const i=this.textureLoader.path,s=ke.get(t.id).children;s!==void 0&&s.length>0&&e[s[0].ID]!==void 0&&(n=e[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let l;const u=t.FileName.slice(-3).toLowerCase();if(u==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),l=new m.Texture):(c.setPath(this.textureLoader.path),l=c.load(n))}else u==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),l=new m.Texture):l=this.textureLoader.load(n);return this.textureLoader.setPath(i),l}parseMaterials(t){const e=new Map;if("Material"in xe.Objects){const n=xe.Objects.Material;for(const i in n){const s=this.parseMaterial(n[i],t);s!==null&&e.set(parseInt(i),s)}}return e}parseMaterial(t,e){const n=t.id,i=t.attrName;let s=t.ShadingModel;if(typeof s=="object"&&(s=s.value),!ke.has(n))return null;const l=this.parseParameters(t,e,n);let u;switch(s.toLowerCase()){case"phong":u=new m.MeshPhongMaterial;break;case"lambert":u=new m.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),u=new m.MeshPhongMaterial;break}return u.setValues(l),u.name=i,u}parseParameters(t,e,n){const i={};t.BumpFactor&&(i.bumpScale=t.BumpFactor.value),t.Diffuse?i.color=new m.Color().fromArray(t.Diffuse.value):t.DiffuseColor&&(t.DiffuseColor.type==="Color"||t.DiffuseColor.type==="ColorRGB")&&(i.color=new m.Color().fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(i.displacementScale=t.DisplacementFactor.value),t.Emissive?i.emissive=new m.Color().fromArray(t.Emissive.value):t.EmissiveColor&&(t.EmissiveColor.type==="Color"||t.EmissiveColor.type==="ColorRGB")&&(i.emissive=new m.Color().fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(i.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(i.opacity=parseFloat(t.Opacity.value)),i.opacity<1&&(i.transparent=!0),t.ReflectionFactor&&(i.reflectivity=t.ReflectionFactor.value),t.Shininess&&(i.shininess=t.Shininess.value),t.Specular?i.specular=new m.Color().fromArray(t.Specular.value):t.SpecularColor&&t.SpecularColor.type==="Color"&&(i.specular=new m.Color().fromArray(t.SpecularColor.value));const s=this;return ke.get(n).children.forEach(function(l){const u=l.relationship;switch(u){case"Bump":i.bumpMap=s.getTexture(e,l.ID);break;case"Maya|TEX_ao_map":i.aoMap=s.getTexture(e,l.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=s.getTexture(e,l.ID),i.map!==void 0&&("colorSpace"in i.map?i.map.colorSpace="srgb":i.map.encoding=3001);break;case"DisplacementColor":i.displacementMap=s.getTexture(e,l.ID);break;case"EmissiveColor":i.emissiveMap=s.getTexture(e,l.ID),i.emissiveMap!==void 0&&("colorSpace"in i.emissiveMap?i.emissiveMap.colorSpace="srgb":i.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=s.getTexture(e,l.ID);break;case"ReflectionColor":i.envMap=s.getTexture(e,l.ID),i.envMap!==void 0&&(i.envMap.mapping=m.EquirectangularReflectionMapping,"colorSpace"in i.envMap?i.envMap.colorSpace="srgb":i.envMap.encoding=3001);break;case"SpecularColor":i.specularMap=s.getTexture(e,l.ID),i.specularMap!==void 0&&("colorSpace"in i.specularMap?i.specularMap.colorSpace="srgb":i.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=s.getTexture(e,l.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",u);break}}),i}getTexture(t,e){return"LayeredTexture"in xe.Objects&&e in xe.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=ke.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in xe.Objects){const n=xe.Objects.Deformer;for(const i in n){const s=n[i],l=ke.get(parseInt(i));if(s.attrType==="Skin"){const u=this.parseSkeleton(l,n);u.ID=i,l.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),u.geometryID=l.parents[0].ID,t[i]=u}else if(s.attrType==="BlendShape"){const u={id:i};u.rawTargets=this.parseMorphTargets(l,n),u.id=i,l.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[i]=u}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const n=[];return t.children.forEach(function(i){const s=e[i.ID];if(s.attrType!=="Cluster")return;const l={ID:i.ID,indices:[],weights:[],transformLink:new m.Matrix4().fromArray(s.TransformLink.a)};"Indexes"in s&&(l.indices=s.Indexes.a,l.weights=s.Weights.a),n.push(l)}),{rawBones:n,bones:[]}}parseMorphTargets(t,e){const n=[];for(let i=0;i<t.children.length;i++){const s=t.children[i],l=e[s.ID],u={name:l.attrName,initialWeight:l.DeformPercent,id:l.id,fullWeights:l.FullWeights.a};if(l.attrType!=="BlendShapeChannel")return;u.geoID=ke.get(parseInt(s.ID)).children.filter(function(c){return c.relationship===void 0})[0].ID,n.push(u)}return n}parseScene(t,e,n){pt=new m.Group;const i=this.parseModels(t.skeletons,e,n),s=xe.Objects.Model,l=this;i.forEach(function(c){const d=s[c.ID];l.setLookAtProperties(c,d),ke.get(c.ID).parents.forEach(function(f){const y=i.get(f.ID);y!==void 0&&y.add(c)}),c.parent===null&&pt.add(c)}),this.bindSkeleton(t.skeletons,e,i),this.createAmbientLight(),pt.traverse(function(c){if(c.userData.transformData){c.parent&&(c.userData.transformData.parentMatrix=c.parent.matrix,c.userData.transformData.parentMatrixWorld=c.parent.matrixWorld);const d=rl(c.userData.transformData);c.applyMatrix4(d),c.updateWorldMatrix()}});const u=new tf().parse();pt.children.length===1&&pt.children[0].isGroup&&(pt.children[0].animations=u,pt=pt.children[0]),pt.animations=u}parseModels(t,e,n){const i=new Map,s=xe.Objects.Model;for(const l in s){const u=parseInt(l),c=s[l],d=ke.get(u);let p=this.buildSkeleton(d,t,u,c.attrName);if(!p){switch(c.attrType){case"Camera":p=this.createCamera(d);break;case"Light":p=this.createLight(d);break;case"Mesh":p=this.createMesh(d,e,n);break;case"NurbsCurve":p=this.createCurve(d,e);break;case"LimbNode":case"Root":p=new m.Bone;break;case"Null":default:p=new m.Group;break}p.name=c.attrName?m.PropertyBinding.sanitizeNodeName(c.attrName):"",p.ID=u}this.getTransformData(p,c),i.set(u,p)}return i}buildSkeleton(t,e,n,i){let s=null;return t.parents.forEach(function(l){for(const u in e){const c=e[u];c.rawBones.forEach(function(d,p){if(d.ID===l.ID){const f=s;s=new m.Bone,s.matrixWorld.copy(d.transformLink),s.name=i?m.PropertyBinding.sanitizeNodeName(i):"",s.ID=n,c.bones[p]=s,f!==null&&s.add(f)}})}}),s}createCamera(t){let e,n;if(t.children.forEach(function(i){const s=xe.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)e=new m.Object3D;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let l=1e3;n.FarPlane!==void 0&&(l=n.FarPlane.value/1e3);let u=window.innerWidth,c=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(u=n.AspectWidth.value,c=n.AspectHeight.value);const d=u/c;let p=45;n.FieldOfView!==void 0&&(p=n.FieldOfView.value);const f=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:e=new m.PerspectiveCamera(p,d,s,l),f!==null&&e.setFocalLength(f);break;case 1:e=new m.OrthographicCamera(-u/2,u/2,c/2,-c/2,s,l);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),e=new m.Object3D;break}}return e}createLight(t){let e,n;if(t.children.forEach(function(i){const s=xe.Objects.NodeAttribute[i.ID];s!==void 0&&(n=s)}),n===void 0)e=new m.Object3D;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=new m.Color().fromArray(n.Color.value));let l=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(l=0);let u=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?u=0:u=n.FarAttenuationEnd.value);const c=1;switch(i){case 0:e=new m.PointLight(s,l,u,c);break;case 1:e=new m.DirectionalLight(s,l);break;case 2:let d=Math.PI/3;n.InnerAngle!==void 0&&(d=m.MathUtils.degToRad(n.InnerAngle.value));let p=0;n.OuterAngle!==void 0&&(p=m.MathUtils.degToRad(n.OuterAngle.value),p=Math.max(p,1)),e=new m.SpotLight(s,l,u,d,p,c);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new m.PointLight(s,l);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(e.castShadow=!0)}return e}createMesh(t,e,n){let i,s=null,l=null;const u=[];return t.children.forEach(function(c){e.has(c.ID)&&(s=e.get(c.ID)),n.has(c.ID)&&u.push(n.get(c.ID))}),u.length>1?l=u:u.length>0?l=u[0]:(l=new m.MeshPhongMaterial({color:13421772}),u.push(l)),"color"in s.attributes&&u.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(i=new m.SkinnedMesh(s,l),i.normalizeSkinWeights()):i=new m.Mesh(s,l),i}createCurve(t,e){const n=t.children.reduce(function(s,l){return e.has(l.ID)&&(s=e.get(l.ID)),s},null),i=new m.LineBasicMaterial({color:3342591,linewidth:1});return new m.Line(n,i)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),"RotationOrder"in e?n.eulerOrder=sl(e.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(t,e){"LookAtProperty"in e&&ke.get(t.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const s=xe.Objects.Model[i.ID];if("Lcl_Translation"in s){const l=s.Lcl_Translation.value;t.target!==void 0?(t.target.position.fromArray(l),pt.add(t.target)):t.lookAt(new m.Vector3().fromArray(l))}}})}bindSkeleton(t,e,n){const i=this.parsePoseNodes();for(const s in t){const l=t[s];ke.get(parseInt(l.ID)).parents.forEach(function(c){if(e.has(c.ID)){const d=c.ID;ke.get(d).parents.forEach(function(f){n.has(f.ID)&&n.get(f.ID).bind(new m.Skeleton(l.bones),i[f.ID])})}})}}parsePoseNodes(){const t={};if("Pose"in xe.Objects){const e=xe.Objects.Pose;for(const n in e)if(e[n].attrType==="BindPose"&&e[n].NbPoseNodes>0){const i=e[n].PoseNode;Array.isArray(i)?i.forEach(function(s){t[s.Node]=new m.Matrix4().fromArray(s.Matrix.a)}):t[i.Node]=new m.Matrix4().fromArray(i.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in xe&&"AmbientColor"in xe.GlobalSettings){const t=xe.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],i=t[2];if(e!==0||n!==0||i!==0){const s=new m.Color(e,n,i);pt.add(new m.AmbientLight(s,1))}}}}class ef{parse(t){const e=new Map;if("Geometry"in xe.Objects){const n=xe.Objects.Geometry;for(const i in n){const s=ke.get(parseInt(i)),l=this.parseGeometry(s,n[i],t);e.set(parseInt(i),l)}}return e}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,n){const i=n.skeletons,s=[],l=t.parents.map(function(f){return xe.Objects.Model[f.ID]});if(l.length===0)return;const u=t.children.reduce(function(f,y){return i[y.ID]!==void 0&&(f=i[y.ID]),f},null);t.children.forEach(function(f){n.morphTargets[f.ID]!==void 0&&s.push(n.morphTargets[f.ID])});const c=l[0],d={};"RotationOrder"in c&&(d.eulerOrder=sl(c.RotationOrder.value)),"InheritType"in c&&(d.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(d.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(d.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(d.scale=c.GeometricScaling.value);const p=rl(d);return this.genGeometry(e,u,s,p)}genGeometry(t,e,n,i){const s=new m.BufferGeometry;t.attrName&&(s.name=t.attrName);const l=this.parseGeoNode(t,e),u=this.genBuffers(l),c=new m.Float32BufferAttribute(u.vertex,3);if(c.applyMatrix4(i),s.setAttribute("position",c),u.colors.length>0&&s.setAttribute("color",new m.Float32BufferAttribute(u.colors,3)),e&&(s.setAttribute("skinIndex",new m.Uint16BufferAttribute(u.weightsIndices,4)),s.setAttribute("skinWeight",new m.Float32BufferAttribute(u.vertexWeights,4)),s.FBX_Deformer=e),u.normal.length>0){const d=new m.Matrix3().getNormalMatrix(i),p=new m.Float32BufferAttribute(u.normal,3);p.applyNormalMatrix(d),s.setAttribute("normal",p)}if(u.uvs.forEach(function(d,p){Gs==="uv2"&&p++;const f=p===0?"uv":`uv${p}`;s.setAttribute(f,new m.Float32BufferAttribute(u.uvs[p],2))}),l.material&&l.material.mappingType!=="AllSame"){let d=u.materialIndex[0],p=0;if(u.materialIndex.forEach(function(f,y){f!==d&&(s.addGroup(p,y-p,d),d=f,p=y)}),s.groups.length>0){const f=s.groups[s.groups.length-1],y=f.start+f.count;y!==u.materialIndex.length&&s.addGroup(y,u.materialIndex.length-y,d)}s.groups.length===0&&s.addGroup(0,u.materialIndex.length,u.materialIndex[0])}return this.addMorphTargets(s,t,n,i),s}parseGeoNode(t,e){const n={};if(n.vertexPositions=t.Vertices!==void 0?t.Vertices.a:[],n.vertexIndices=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let i=0;for(;t.LayerElementUV[i];)t.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[i])),i++}return n.weightTable={},e!==null&&(n.skeleton=e,e.rawBones.forEach(function(i,s){i.indices.forEach(function(l,u){n.weightTable[l]===void 0&&(n.weightTable[l]=[]),n.weightTable[l].push({id:s,weight:i.weights[u]})})})),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,s=!1,l=[],u=[],c=[],d=[],p=[],f=[];const y=this;return t.vertexIndices.forEach(function(v,x){let S,_=!1;v<0&&(v=v^-1,_=!0);let Z=[],M=[];if(l.push(v*3,v*3+1,v*3+2),t.color){const G=vr(x,n,v,t.color);c.push(G[0],G[1],G[2])}if(t.skeleton){if(t.weightTable[v]!==void 0&&t.weightTable[v].forEach(function(G){M.push(G.weight),Z.push(G.id)}),M.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const G=[0,0,0,0],A=[0,0,0,0];M.forEach(function(R,D){let k=R,C=Z[D];A.forEach(function(K,I,z){if(k>K){z[I]=k,k=K;const N=G[I];G[I]=C,C=N}})}),Z=G,M=A}for(;M.length<4;)M.push(0),Z.push(0);for(let G=0;G<4;++G)p.push(M[G]),f.push(Z[G])}if(t.normal){const G=vr(x,n,v,t.normal);u.push(G[0],G[1],G[2])}t.material&&t.material.mappingType!=="AllSame"&&(S=vr(x,n,v,t.material)[0]),t.uv&&t.uv.forEach(function(G,A){const R=vr(x,n,v,G);d[A]===void 0&&(d[A]=[]),d[A].push(R[0]),d[A].push(R[1])}),i++,_&&(y.genFace(e,t,l,S,u,c,d,p,f,i),n++,i=0,l=[],u=[],c=[],d=[],p=[],f=[])}),e}genFace(t,e,n,i,s,l,u,c,d,p){for(let f=2;f<p;f++)t.vertex.push(e.vertexPositions[n[0]]),t.vertex.push(e.vertexPositions[n[1]]),t.vertex.push(e.vertexPositions[n[2]]),t.vertex.push(e.vertexPositions[n[(f-1)*3]]),t.vertex.push(e.vertexPositions[n[(f-1)*3+1]]),t.vertex.push(e.vertexPositions[n[(f-1)*3+2]]),t.vertex.push(e.vertexPositions[n[f*3]]),t.vertex.push(e.vertexPositions[n[f*3+1]]),t.vertex.push(e.vertexPositions[n[f*3+2]]),e.skeleton&&(t.vertexWeights.push(c[0]),t.vertexWeights.push(c[1]),t.vertexWeights.push(c[2]),t.vertexWeights.push(c[3]),t.vertexWeights.push(c[(f-1)*4]),t.vertexWeights.push(c[(f-1)*4+1]),t.vertexWeights.push(c[(f-1)*4+2]),t.vertexWeights.push(c[(f-1)*4+3]),t.vertexWeights.push(c[f*4]),t.vertexWeights.push(c[f*4+1]),t.vertexWeights.push(c[f*4+2]),t.vertexWeights.push(c[f*4+3]),t.weightsIndices.push(d[0]),t.weightsIndices.push(d[1]),t.weightsIndices.push(d[2]),t.weightsIndices.push(d[3]),t.weightsIndices.push(d[(f-1)*4]),t.weightsIndices.push(d[(f-1)*4+1]),t.weightsIndices.push(d[(f-1)*4+2]),t.weightsIndices.push(d[(f-1)*4+3]),t.weightsIndices.push(d[f*4]),t.weightsIndices.push(d[f*4+1]),t.weightsIndices.push(d[f*4+2]),t.weightsIndices.push(d[f*4+3])),e.color&&(t.colors.push(l[0]),t.colors.push(l[1]),t.colors.push(l[2]),t.colors.push(l[(f-1)*3]),t.colors.push(l[(f-1)*3+1]),t.colors.push(l[(f-1)*3+2]),t.colors.push(l[f*3]),t.colors.push(l[f*3+1]),t.colors.push(l[f*3+2])),e.material&&e.material.mappingType!=="AllSame"&&(t.materialIndex.push(i),t.materialIndex.push(i),t.materialIndex.push(i)),e.normal&&(t.normal.push(s[0]),t.normal.push(s[1]),t.normal.push(s[2]),t.normal.push(s[(f-1)*3]),t.normal.push(s[(f-1)*3+1]),t.normal.push(s[(f-1)*3+2]),t.normal.push(s[f*3]),t.normal.push(s[f*3+1]),t.normal.push(s[f*3+2])),e.uv&&e.uv.forEach(function(y,v){t.uvs[v]===void 0&&(t.uvs[v]=[]),t.uvs[v].push(u[v][0]),t.uvs[v].push(u[v][1]),t.uvs[v].push(u[v][(f-1)*2]),t.uvs[v].push(u[v][(f-1)*2+1]),t.uvs[v].push(u[v][f*2]),t.uvs[v].push(u[v][f*2+1])})}addMorphTargets(t,e,n,i){if(n.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const s=this;n.forEach(function(l){l.rawTargets.forEach(function(u){const c=xe.Objects.Geometry[u.geoID];c!==void 0&&s.genMorphGeometry(t,e,c,i,u.name)})})}genMorphGeometry(t,e,n,i,s){const l=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],u=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],d=t.attributes.position.count*3,p=new Float32Array(d);for(let x=0;x<c.length;x++){const S=c[x]*3;p[S]=u[x*3],p[S+1]=u[x*3+1],p[S+2]=u[x*3+2]}const f={vertexIndices:l,vertexPositions:p},y=this.genBuffers(f),v=new m.Float32BufferAttribute(y.vertex,3);v.name=s||n.attrName,v.applyMatrix4(i),t.morphAttributes.position.push(v)}parseNormals(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,i=t.Normals.a;let s=[];return n==="IndexToDirect"&&("NormalIndex"in t?s=t.NormalIndex.a:"NormalsIndex"in t&&(s=t.NormalsIndex.a)),{dataSize:3,buffer:i,indices:s,mappingType:e,referenceType:n}}parseUVs(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,i=t.UV.a;let s=[];return n==="IndexToDirect"&&(s=t.UVIndex.a),{dataSize:2,buffer:i,indices:s,mappingType:e,referenceType:n}}parseVertexColors(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,i=t.Colors.a;let s=[];return n==="IndexToDirect"&&(s=t.ColorIndex.a),{dataSize:4,buffer:i,indices:s,mappingType:e,referenceType:n}}parseMaterialIndices(t){const e=t.MappingInformationType,n=t.ReferenceInformationType;if(e==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=t.Materials.a,s=[];for(let l=0;l<i.length;++l)s.push(l);return{dataSize:1,buffer:i,indices:s,mappingType:e,referenceType:n}}parseNurbsGeometry(t){if(el===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new m.BufferGeometry;const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new m.BufferGeometry;const n=e-1,i=t.KnotVector.a,s=[],l=t.Points.a;for(let f=0,y=l.length;f<y;f+=4)s.push(new m.Vector4().fromArray(l,f));let u,c;if(t.Form==="Closed")s.push(s[0]);else if(t.Form==="Periodic"){u=n,c=i.length-1-u;for(let f=0;f<n;++f)s.push(s[f])}const p=new el(n,i,s,u,c).getPoints(s.length*12);return new m.BufferGeometry().setFromPoints(p)}}class tf{parse(){const t=[],e=this.parseClips();if(e!==void 0)for(const n in e){const i=e[n],s=this.addClip(i);t.push(s)}return t}parseClips(){if(xe.Objects.AnimationCurve===void 0)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=xe.Objects.AnimationCurveNode,e=new Map;for(const n in t){const i=t[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:i.id,attr:i.attrName,curves:{}};e.set(s.id,s)}}return e}parseAnimationCurves(t){const e=xe.Objects.AnimationCurve;for(const n in e){const i={id:e[n].id,times:e[n].KeyTime.a.map(af),values:e[n].KeyValueFloat.a},s=ke.get(i.id);if(s!==void 0){const l=s.parents[0].ID,u=s.parents[0].relationship;u.match(/X/)?t.get(l).curves.x=i:u.match(/Y/)?t.get(l).curves.y=i:u.match(/Z/)?t.get(l).curves.z=i:u.match(/d|DeformPercent/)&&t.has(l)&&(t.get(l).curves.morph=i)}}}parseAnimationLayers(t){const e=xe.Objects.AnimationLayer,n=new Map;for(const i in e){const s=[],l=ke.get(parseInt(i));l!==void 0&&(l.children.forEach(function(c,d){if(t.has(c.ID)){const p=t.get(c.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(s[d]===void 0){const f=ke.get(c.ID).parents.filter(function(y){return y.relationship!==void 0})[0].ID;if(f!==void 0){const y=xe.Objects.Model[f.toString()];if(y===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",c);return}const v={modelName:y.attrName?m.PropertyBinding.sanitizeNodeName(y.attrName):"",ID:y.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};pt.traverse(function(x){x.ID===y.id&&(v.transform=x.matrix,x.userData.transformData&&(v.eulerOrder=x.userData.transformData.eulerOrder))}),v.transform||(v.transform=new m.Matrix4),"PreRotation"in y&&(v.preRotation=y.PreRotation.value),"PostRotation"in y&&(v.postRotation=y.PostRotation.value),s[d]=v}}s[d]&&(s[d][p.attr]=p)}else if(p.curves.morph!==void 0){if(s[d]===void 0){const f=ke.get(c.ID).parents.filter(function(Z){return Z.relationship!==void 0})[0].ID,y=ke.get(f).parents[0].ID,v=ke.get(y).parents[0].ID,x=ke.get(v).parents[0].ID,S=xe.Objects.Model[x],_={modelName:S.attrName?m.PropertyBinding.sanitizeNodeName(S.attrName):"",morphName:xe.Objects.Deformer[f].attrName};s[d]=_}s[d][p.attr]=p}}}),n.set(parseInt(i),s))}return n}parseAnimStacks(t){const e=xe.Objects.AnimationStack,n={};for(const i in e){const s=ke.get(parseInt(i)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const l=t.get(s[0].ID);n[i]={name:e[i].attrName,layer:l}}return n}addClip(t){let e=[];const n=this;return t.layer.forEach(function(i){e=e.concat(n.generateTracks(i))}),new m.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new m.Vector3,i=new m.Quaternion,s=new m.Vector3;if(t.transform&&t.transform.decompose(n,i,s),n=n.toArray(),i=new m.Euler().setFromQuaternion(i,t.eulerOrder).toArray(),s=s.toArray(),t.T!==void 0&&Object.keys(t.T.curves).length>0){const l=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");l!==void 0&&e.push(l)}if(t.R!==void 0&&Object.keys(t.R.curves).length>0){const l=this.generateRotationTrack(t.modelName,t.R.curves,i,t.preRotation,t.postRotation,t.eulerOrder);l!==void 0&&e.push(l)}if(t.S!==void 0&&Object.keys(t.S.curves).length>0){const l=this.generateVectorTrack(t.modelName,t.S.curves,s,"scale");l!==void 0&&e.push(l)}if(t.DeformPercent!==void 0){const l=this.generateMorphTrack(t);l!==void 0&&e.push(l)}return e}generateVectorTrack(t,e,n,i){const s=this.getTimesForAllAxes(e),l=this.getKeyframeTrackValues(s,e,n);return new m.VectorKeyframeTrack(t+"."+i,s,l)}generateRotationTrack(t,e,n,i,s,l){e.x!==void 0&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(m.MathUtils.degToRad)),e.y!==void 0&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(m.MathUtils.degToRad)),e.z!==void 0&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(m.MathUtils.degToRad));const u=this.getTimesForAllAxes(e),c=this.getKeyframeTrackValues(u,e,n);i!==void 0&&(i=i.map(m.MathUtils.degToRad),i.push(l),i=new m.Euler().fromArray(i),i=new m.Quaternion().setFromEuler(i)),s!==void 0&&(s=s.map(m.MathUtils.degToRad),s.push(l),s=new m.Euler().fromArray(s),s=new m.Quaternion().setFromEuler(s).invert());const d=new m.Quaternion,p=new m.Euler,f=[];for(let y=0;y<c.length;y+=3)p.set(c[y],c[y+1],c[y+2],l),d.setFromEuler(p),i!==void 0&&d.premultiply(i),s!==void 0&&d.multiply(s),d.toArray(f,y/3*4);return new m.QuaternionKeyframeTrack(t+".quaternion",u,f)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map(function(s){return s/100}),i=pt.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new m.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+i+"]",e.times,n)}getTimesForAllAxes(t){let e=[];if(t.x!==void 0&&(e=e.concat(t.x.times)),t.y!==void 0&&(e=e.concat(t.y.times)),t.z!==void 0&&(e=e.concat(t.z.times)),e=e.sort(function(n,i){return n-i}),e.length>1){let n=1,i=e[0];for(let s=1;s<e.length;s++){const l=e[s];l!==i&&(e[n]=l,i=l,n++)}e=e.slice(0,n)}return e}getKeyframeTrackValues(t,e,n){const i=n,s=[];let l=-1,u=-1,c=-1;return t.forEach(function(d){if(e.x&&(l=e.x.times.indexOf(d)),e.y&&(u=e.y.times.indexOf(d)),e.z&&(c=e.z.times.indexOf(d)),l!==-1){const p=e.x.values[l];s.push(p),i[0]=p}else s.push(i[0]);if(u!==-1){const p=e.y.values[u];s.push(p),i[1]=p}else s.push(i[1]);if(c!==-1){const p=e.z.values[c];s.push(p),i[2]=p}else s.push(i[2])}),s}interpolateRotations(t){for(let e=1;e<t.values.length;e++){const n=t.values[e-1],i=t.values[e]-n,s=Math.abs(i);if(s>=180){const l=s/180,u=i/l;let c=n+u;const d=t.times[e-1],f=(t.times[e]-d)/l;let y=d+f;const v=[],x=[];for(;y<t.times[e];)v.push(y),y+=f,x.push(c),c+=u;t.times=al(t.times,e,v),t.values=al(t.values,e,x)}}}}class nf{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new nl,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,n=t.split(/[\r\n]+/);return n.forEach(function(i,s){const l=i.match(/^[\s\t]*;/),u=i.match(/^[\s\t]*$/);if(l||u)return;const c=i.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),d=i.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),p=i.match("^\\t{"+(e.currentIndent-1)+"}}");c?e.parseNodeBegin(i,c):d?e.parseNodeProperty(i,d,n[++s]):p?e.popStack():i.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(t,e){const n=e[1].trim().replace(/^"/,"").replace(/"$/,""),i=e[2].split(",").map(function(c){return c.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},l=this.parseNodeAttr(i),u=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in u?(n==="PoseNode"?u.PoseNode.push(s):u[n].id!==void 0&&(u[n]={},u[n][u[n].id]=u[n]),l.id!==""&&(u[n][l.id]=s)):typeof l.id=="number"?(u[n]={},u[n][l.id]=s):n!=="Properties70"&&(n==="PoseNode"?u[n]=[s]:u[n]=s),typeof l.id=="number"&&(s.id=l.id),l.name!==""&&(s.attrName=l.name),l.type!==""&&(s.attrType=l.type),this.pushStack(s)}parseNodeAttr(t){let e=t[0];t[0]!==""&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let n="",i="";return t.length>1&&(n=t[1].replace(/^(\w+)::/,""),i=t[2]),{id:e,name:n,type:i}}parseNodeProperty(t,e,n){let i=e[1].replace(/^"/,"").replace(/"$/,"").trim(),s=e[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const l=this.getCurrentNode();if(l.name==="Properties70"){this.parseNodeSpecialProperty(t,i,s);return}if(i==="C"){const c=s.split(",").slice(1),d=parseInt(c[0]),p=parseInt(c[1]);let f=s.split(",").slice(3);f=f.map(function(y){return y.trim().replace(/^"/,"")}),i="connections",s=[d,p],cf(s,f),l[i]===void 0&&(l[i]=[])}i==="Node"&&(l.id=s),i in l&&Array.isArray(l[i])?l[i].push(s):i!=="a"?l[i]=s:l.a=s,this.setCurrentProp(l,i),i==="a"&&s.slice(-1)!==","&&(l.a=ks(s))}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,t.slice(-1)!==","&&(e.a=ks(e.a))}parseNodeSpecialProperty(t,e,n){const i=n.split('",').map(function(p){return p.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=i[0],l=i[1],u=i[2],c=i[3];let d=i[4];switch(l){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":d=parseFloat(d);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":d=ks(d);break}this.getPrevNode()[s]={type:l,type2:u,flag:c,value:d},this.setCurrentProp(this.getPrevNode(),s)}}class rf{parse(t){const e=new tl(t);e.skip(23);const n=e.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new nl;for(;!this.endOfContent(e);){const s=this.parseNode(e,n);s!==null&&i.add(s.name,s)}return i}endOfContent(t){return t.size()%16===0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},i=e>=7500?t.getUint64():t.getUint32(),s=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const l=t.getUint8(),u=t.getString(l);if(i===0)return null;const c=[];for(let y=0;y<s;y++)c.push(this.parseProperty(t));const d=c.length>0?c[0]:"",p=c.length>1?c[1]:"",f=c.length>2?c[2]:"";for(n.singleProperty=s===1&&t.getOffset()===i;i>t.getOffset();){const y=this.parseNode(t,e);y!==null&&this.parseSubNode(u,n,y)}return n.propertyList=c,typeof d=="number"&&(n.id=d),p!==""&&(n.attrName=p),f!==""&&(n.attrType=f),u!==""&&(n.name=u),n}parseSubNode(t,e,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(e[n.name]=n,n.a=i):e[n.name]=i}else if(t==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(s,l){l!==0&&i.push(s)}),e.connections===void 0&&(e.connections=[]),e.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){e[s]=n[s]});else if(t==="Properties70"&&n.name==="P"){let i=n.propertyList[0],s=n.propertyList[1];const l=n.propertyList[2],u=n.propertyList[3];let c;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],e[i]={type:s,type2:l,flag:u,value:c}}else e[n.name]===void 0?typeof n.id=="number"?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:n.name==="PoseNode"?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):e[n.name][n.id]===void 0&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=t.getUint32(),s=t.getUint32(),l=t.getUint32();if(s===0)switch(e){case"b":case"c":return t.getBooleanArray(i);case"d":return t.getFloat64Array(i);case"f":return t.getFloat32Array(i);case"i":return t.getInt32Array(i);case"l":return t.getInt64Array(i)}const u=Hh(new Uint8Array(t.getArrayBuffer(l))),c=new tl(u.buffer);switch(e){case"b":case"c":return c.getBooleanArray(i);case"d":return c.getFloat64Array(i);case"f":return c.getFloat32Array(i);case"i":return c.getInt32Array(i);case"l":return c.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class tl{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=e!==void 0?e:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(t){const e=[];for(let n=0;n<t;n++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e&2147483648?(e=~e&4294967295,t=~t&4294967295,t===4294967295&&(e=e+1&4294967295),t=t+1&4294967295,-(e*4294967296+t)):e*4294967296+t}getInt64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e*4294967296+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){let e=[];for(let i=0;i<t;i++)e[i]=this.getUint8();const n=e.indexOf(0);return n>=0&&(e=e.slice(0,n)),ui(new Uint8Array(e))}}class nl{add(t,e){this[t]=e}}function sf(a){const t="Kaydara FBX Binary \0";return a.byteLength>=t.length&&t===ol(a,0,t.length)}function of(a){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let e=0;function n(i){const s=a[i-1];return a=a.slice(e+i),e++,s}for(let i=0;i<t.length;++i)if(n(1)===t[i])return!1;return!0}function il(a){const t=/FBXVersion: (\d+)/,e=a.match(t);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function af(a){return a/46186158e3}const lf=[];function vr(a,t,e,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=a;break;case"ByPolygon":i=t;break;case"ByVertice":i=e;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);const s=i*n.dataSize,l=s+n.dataSize;return uf(lf,n.buffer,s,l)}const Ds=new m.Euler,di=new m.Vector3;function rl(a){const t=new m.Matrix4,e=new m.Matrix4,n=new m.Matrix4,i=new m.Matrix4,s=new m.Matrix4,l=new m.Matrix4,u=new m.Matrix4,c=new m.Matrix4,d=new m.Matrix4,p=new m.Matrix4,f=new m.Matrix4,y=new m.Matrix4,v=a.inheritType?a.inheritType:0;if(a.translation&&t.setPosition(di.fromArray(a.translation)),a.preRotation){const I=a.preRotation.map(m.MathUtils.degToRad);I.push(a.eulerOrder),e.makeRotationFromEuler(Ds.fromArray(I))}if(a.rotation){const I=a.rotation.map(m.MathUtils.degToRad);I.push(a.eulerOrder),n.makeRotationFromEuler(Ds.fromArray(I))}if(a.postRotation){const I=a.postRotation.map(m.MathUtils.degToRad);I.push(a.eulerOrder),i.makeRotationFromEuler(Ds.fromArray(I)),i.invert()}a.scale&&s.scale(di.fromArray(a.scale)),a.scalingOffset&&u.setPosition(di.fromArray(a.scalingOffset)),a.scalingPivot&&l.setPosition(di.fromArray(a.scalingPivot)),a.rotationOffset&&c.setPosition(di.fromArray(a.rotationOffset)),a.rotationPivot&&d.setPosition(di.fromArray(a.rotationPivot)),a.parentMatrixWorld&&(f.copy(a.parentMatrix),p.copy(a.parentMatrixWorld));const x=e.clone().multiply(n).multiply(i),S=new m.Matrix4;S.extractRotation(p);const _=new m.Matrix4;_.copyPosition(p);const Z=_.clone().invert().multiply(p),M=S.clone().invert().multiply(Z),G=s,A=new m.Matrix4;if(v===0)A.copy(S).multiply(x).multiply(M).multiply(G);else if(v===1)A.copy(S).multiply(M).multiply(x).multiply(G);else{const z=new m.Matrix4().scale(new m.Vector3().setFromMatrixScale(f)).clone().invert(),N=M.clone().multiply(z);A.copy(S).multiply(x).multiply(N).multiply(G)}const R=d.clone().invert(),D=l.clone().invert();let k=t.clone().multiply(c).multiply(d).multiply(e).multiply(n).multiply(i).multiply(R).multiply(u).multiply(l).multiply(s).multiply(D);const C=new m.Matrix4().copyPosition(k),K=p.clone().multiply(C);return y.copyPosition(K),k=y.clone().multiply(A),k.premultiply(p.invert()),k}function sl(a){a=a||0;const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return a===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[a]}function ks(a){return a.split(",").map(function(e){return parseFloat(e)})}function ol(a,t,e){return t===void 0&&(t=0),e===void 0&&(e=a.byteLength),ui(new Uint8Array(a,t,e))}function cf(a,t){for(let e=0,n=a.length,i=t.length;e<i;e++,n++)a[n]=t[e]}function uf(a,t,e,n){for(let i=e,s=0;i<n;i++,s++)a[s]=t[i];return a}function al(a,t,e){return a.slice(0,t).concat(e).concat(a.slice(t))}class hf extends m.DataTextureLoader{constructor(t){super(t),this.type=m.HalfFloatType}parse(t){const l=function(C,K){switch(C){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(K||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(K||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(K||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(K||""))}},p=`
|
|
98
|
+
`,f=function(C,K,I){K=K||1024;let N=C.pos,H=-1,j=0,q="",J=String.fromCharCode.apply(null,new Uint16Array(C.subarray(N,N+128)));for(;0>(H=J.indexOf(p))&&j<K&&N<C.byteLength;)q+=J,j+=J.length,N+=128,J+=String.fromCharCode.apply(null,new Uint16Array(C.subarray(N,N+128)));return-1<H?(C.pos+=j+H+1,q+J.slice(0,H)):!1},y=function(C){const K=/^#\?(\S+)/,I=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,z=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,N=/^\s*FORMAT=(\S+)\s*$/,H=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,j={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let q,J;for((C.pos>=C.byteLength||!(q=f(C)))&&l(1,"no header found"),(J=q.match(K))||l(3,"bad initial token"),j.valid|=1,j.programtype=J[1],j.string+=q+`
|
|
99
|
+
`;q=f(C),q!==!1;){if(j.string+=q+`
|
|
100
100
|
`,q.charAt(0)==="#"){j.comments+=q+`
|
|
101
|
-
`;continue}if((J=q.match(
|
|
102
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([
|
|
101
|
+
`;continue}if((J=q.match(I))&&(j.gamma=parseFloat(J[1])),(J=q.match(z))&&(j.exposure=parseFloat(J[1])),(J=q.match(N))&&(j.valid|=2,j.format=J[1]),(J=q.match(H))&&(j.valid|=4,j.height=parseInt(J[1],10),j.width=parseInt(J[2],10)),j.valid&2&&j.valid&4)break}return j.valid&2||l(3,"missing format specifier"),j.valid&4||l(3,"missing image size specifier"),j},v=function(C,K,I){const z=K;if(z<8||z>32767||C[0]!==2||C[1]!==2||C[2]&128)return new Uint8Array(C);z!==(C[2]<<8|C[3])&&l(3,"wrong scanline width");const N=new Uint8Array(4*K*I);N.length||l(4,"unable to allocate buffer space");let H=0,j=0;const q=4*z,J=new Uint8Array(4),oe=new Uint8Array(q);let re=I;for(;re>0&&j<C.byteLength;){j+4>C.byteLength&&l(1),J[0]=C[j++],J[1]=C[j++],J[2]=C[j++],J[3]=C[j++],(J[0]!=2||J[1]!=2||(J[2]<<8|J[3])!=z)&&l(3,"bad rgbe scanline format");let te=0,me;for(;te<q&&j<C.byteLength;){me=C[j++];const he=me>128;if(he&&(me-=128),(me===0||te+me>q)&&l(3,"bad scanline data"),he){const ve=C[j++];for(let ze=0;ze<me;ze++)oe[te++]=ve}else oe.set(C.subarray(j,j+me),te),te+=me,j+=me}const be=z;for(let he=0;he<be;he++){let ve=0;N[H]=oe[he+ve],ve+=z,N[H+1]=oe[he+ve],ve+=z,N[H+2]=oe[he+ve],ve+=z,N[H+3]=oe[he+ve],H+=4}re--}return N},x=function(C,K,I,z){const N=C[K+3],H=Math.pow(2,N-128)/255;I[z+0]=C[K+0]*H,I[z+1]=C[K+1]*H,I[z+2]=C[K+2]*H,I[z+3]=1},S=function(C,K,I,z){const N=C[K+3],H=Math.pow(2,N-128)/255;I[z+0]=m.DataUtils.toHalfFloat(Math.min(C[K+0]*H,65504)),I[z+1]=m.DataUtils.toHalfFloat(Math.min(C[K+1]*H,65504)),I[z+2]=m.DataUtils.toHalfFloat(Math.min(C[K+2]*H,65504)),I[z+3]=m.DataUtils.toHalfFloat(1)},_=new Uint8Array(t);_.pos=0;const Z=y(_),M=Z.width,G=Z.height,A=v(_.subarray(_.pos),M,G);let R,D,k;switch(this.type){case m.FloatType:k=A.length/4;const C=new Float32Array(k*4);for(let I=0;I<k;I++)x(A,I*4,C,I*4);R=C,D=m.FloatType;break;case m.HalfFloatType:k=A.length/4;const K=new Uint16Array(k*4);for(let I=0;I<k;I++)S(A,I*4,K,I*4);R=K,D=m.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:M,height:G,data:R,header:Z.string,gamma:Z.gamma,exposure:Z.exposure,type:D}}setDataType(t){return this.type=t,this}load(t,e,n,i){function s(l,u){switch(l.type){case m.FloatType:case m.HalfFloatType:"colorSpace"in l?l.colorSpace="srgb-linear":l.encoding=3e3,l.minFilter=m.LinearFilter,l.magFilter=m.LinearFilter,l.generateMipmaps=!1,l.flipY=!0;break}e&&e(l,u)}return super.load(t,s,n,i)}}const Os=new WeakMap;class df extends m.Loader{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,n,i){const s=new m.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,l=>{const u={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(l,u).then(e).catch(i)},n,i)}decodeDracoFile(t,e,n,i){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){for(const c in e.attributeTypes){const d=e.attributeTypes[c];d.BYTES_PER_ELEMENT!==void 0&&(e.attributeTypes[c]=d.name)}const n=JSON.stringify(e);if(Os.has(t)){const c=Os.get(t);if(c.key===n)return c.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,l=t.byteLength,u=this._getWorker(s,l).then(c=>(i=c,new Promise((d,p)=>{i._callbacks[s]={resolve:d,reject:p},i.postMessage({type:"decode",id:s,taskConfig:e,buffer:t},[t])}))).then(c=>this._createGeometry(c.geometry));return u.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Os.set(t,{key:n,promise:u}),u}_createGeometry(t){const e=new m.BufferGeometry;t.index&&e.setIndex(new m.BufferAttribute(t.index.array,1));for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n],s=i.name,l=i.array,u=i.itemSize;e.setAttribute(s,new m.BufferAttribute(l,u))}return e}_loadLibrary(t,e){const n=new m.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(t,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(n=>{const i=n[0];t||(this.decoderConfig.wasmBinary=n[1]);const s=ff.toString(),l=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
102
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([l]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const l=s.data;switch(l.type){case"decode":i._callbacks[l.id].resolve(l);break;case"error":i._callbacks[l.id].reject(l);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+l.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this}}function ff(){let a,t;onmessage=function(l){const u=l.data;switch(u.type){case"init":a=u.decoderConfig,t=new Promise(function(p){a.onModuleLoaded=function(f){p({draco:f})},DracoDecoderModule(a)});break;case"decode":const c=u.buffer,d=u.taskConfig;t.then(p=>{const f=p.draco,y=new f.Decoder,v=new f.DecoderBuffer;v.Init(new Int8Array(c),c.byteLength);try{const x=e(f,y,v,d),S=x.attributes.map(_=>_.array.buffer);x.index&&S.push(x.index.array.buffer),self.postMessage({type:"decode",id:u.id,geometry:x},S)}catch(x){console.error(x),self.postMessage({type:"error",id:u.id,error:x.message})}finally{f.destroy(v),f.destroy(y)}});break}};function e(l,u,c,d){const p=d.attributeIDs,f=d.attributeTypes;let y,v;const x=u.GetEncodedGeometryType(c);if(x===l.TRIANGULAR_MESH)y=new l.Mesh,v=u.DecodeBufferToMesh(c,y);else if(x===l.POINT_CLOUD)y=new l.PointCloud,v=u.DecodeBufferToPointCloud(c,y);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!v.ok()||y.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+v.error_msg());const S={index:null,attributes:[]};for(const _ in p){const Z=self[f[_]];let M,G;if(d.useUniqueIDs)G=p[_],M=u.GetAttributeByUniqueId(y,G);else{if(G=u.GetAttributeId(y,l[p[_]]),G===-1)continue;M=u.GetAttribute(y,G)}S.attributes.push(i(l,u,y,_,Z,M))}return x===l.TRIANGULAR_MESH&&(S.index=n(l,u,y)),l.destroy(y),S}function n(l,u,c){const p=c.num_faces()*3,f=p*4,y=l._malloc(f);u.GetTrianglesUInt32Array(c,f,y);const v=new Uint32Array(l.HEAPF32.buffer,y,p).slice();return l._free(y),{array:v,itemSize:1}}function i(l,u,c,d,p,f){const y=f.num_components(),x=c.num_points()*y,S=x*p.BYTES_PER_ELEMENT,_=s(l,p),Z=l._malloc(S);u.GetAttributeDataArrayForAllPoints(c,f,_,S,Z);const M=new p(l.HEAPF32.buffer,Z,x).slice();return l._free(Z),{name:d,array:M,itemSize:y}}function s(l,u){switch(u){case Float32Array:return l.DT_FLOAT32;case Int8Array:return l.DT_INT8;case Int16Array:return l.DT_INT16;case Int32Array:return l.DT_INT32;case Uint8Array:return l.DT_UINT8;case Uint16Array:return l.DT_UINT16;case Uint32Array:return l.DT_UINT32}}}const ll=new m.Box3,wr=new m.Vector3;class cl extends m.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const t=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],e=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new m.Float32BufferAttribute(t,3)),this.setAttribute("uv",new m.Float32BufferAttribute(e,2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return e!==void 0&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new m.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new m.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new m.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t,e=3){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));const i=new m.InstancedInterleavedBuffer(n,e*2,1);return this.setAttribute("instanceColorStart",new m.InterleavedBufferAttribute(i,e,0)),this.setAttribute("instanceColorEnd",new m.InterleavedBufferAttribute(i,e,e)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new m.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new m.Box3);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;t!==void 0&&e!==void 0&&(this.boundingBox.setFromBufferAttribute(t),ll.setFromBufferAttribute(e),this.boundingBox.union(ll))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new m.Sphere),this.boundingBox===null&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(t!==void 0&&e!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let s=0,l=t.count;s<l;s++)wr.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(wr)),wr.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(wr));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}class xr extends cl{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(t){const e=t.length-3,n=new Float32Array(2*e);for(let i=0;i<e;i+=3)n[2*i]=t[i],n[2*i+1]=t[i+1],n[2*i+2]=t[i+2],n[2*i+3]=t[i+3],n[2*i+4]=t[i+4],n[2*i+5]=t[i+5];return super.setPositions(n),this}setColors(t,e=3){const n=t.length-e,i=new Float32Array(2*n);if(e===3)for(let s=0;s<n;s+=e)i[2*s]=t[s],i[2*s+1]=t[s+1],i[2*s+2]=t[s+2],i[2*s+3]=t[s+3],i[2*s+4]=t[s+4],i[2*s+5]=t[s+5];else for(let s=0;s<n;s+=e)i[2*s]=t[s],i[2*s+1]=t[s+1],i[2*s+2]=t[s+2],i[2*s+3]=t[s+3],i[2*s+4]=t[s+4],i[2*s+5]=t[s+5],i[2*s+6]=t[s+6],i[2*s+7]=t[s+7];return super.setColors(i,e),this}fromLine(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}}class zi extends m.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:m.UniformsUtils.clone(m.UniformsUtils.merge([m.UniformsLib.common,m.UniformsLib.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new m.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
|
|
103
103
|
#include <common>
|
|
104
104
|
#include <fog_pars_vertex>
|
|
105
105
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -502,19 +502,19 @@
|
|
|
502
502
|
gl_FragColor = diffuseColor;
|
|
503
503
|
|
|
504
504
|
#include <tonemapping_fragment>
|
|
505
|
-
#include <${
|
|
505
|
+
#include <${gr>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
506
506
|
#include <fog_fragment>
|
|
507
507
|
#include <premultiplied_alpha_fragment>
|
|
508
508
|
|
|
509
509
|
}
|
|
510
|
-
`,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(e){!!e!="USE_DASH"in this.defines&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(e){!!e!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}const Os=new m.Vector4,il=new m.Vector3,sl=new m.Vector3,Ee=new m.Vector4,qe=new m.Vector4,qt=new m.Vector4,Ks=new m.Vector3,Rs=new m.Matrix4,$e=new m.Line3,ol=new m.Vector3,vi=new m.Box3,wi=new m.Sphere,$t=new m.Vector4;let en,Un;function al(l,t,e){return $t.set(0,0,-t,1).applyMatrix4(l.projectionMatrix),$t.multiplyScalar(1/$t.w),$t.x=Un/e.width,$t.y=Un/e.height,$t.applyMatrix4(l.projectionMatrixInverse),$t.multiplyScalar(1/$t.w),Math.abs(Math.max($t.x,$t.y))}function cf(l,t){const e=l.matrixWorld,n=l.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let c=0,u=a;c<u;c++){$e.start.fromBufferAttribute(r,c),$e.end.fromBufferAttribute(s,c),$e.applyMatrix4(e);const d=new m.Vector3,p=new m.Vector3;en.distanceSqToSegment($e.start,$e.end,p,d),p.distanceTo(d)<Un*.5&&t.push({point:p,pointOnLine:d,distance:en.origin.distanceTo(p),object:l,face:null,faceIndex:c,uv:null,[Ts]:null})}}function uf(l,t,e){const n=t.projectionMatrix,s=l.material.resolution,a=l.matrixWorld,c=l.geometry,u=c.attributes.instanceStart,d=c.attributes.instanceEnd,p=Math.min(c.instanceCount,u.count),f=-t.near;en.at(1,qt),qt.w=1,qt.applyMatrix4(t.matrixWorldInverse),qt.applyMatrix4(n),qt.multiplyScalar(1/qt.w),qt.x*=s.x/2,qt.y*=s.y/2,qt.z=0,Ks.copy(qt),Rs.multiplyMatrices(t.matrixWorldInverse,a);for(let y=0,v=p;y<v;y++){if(Ee.fromBufferAttribute(u,y),qe.fromBufferAttribute(d,y),Ee.w=1,qe.w=1,Ee.applyMatrix4(Rs),qe.applyMatrix4(Rs),Ee.z>f&&qe.z>f)continue;if(Ee.z>f){const G=Ee.z-qe.z,A=(Ee.z-f)/G;Ee.lerp(qe,A)}else if(qe.z>f){const G=qe.z-Ee.z,A=(qe.z-f)/G;qe.lerp(Ee,A)}Ee.applyMatrix4(n),qe.applyMatrix4(n),Ee.multiplyScalar(1/Ee.w),qe.multiplyScalar(1/qe.w),Ee.x*=s.x/2,Ee.y*=s.y/2,qe.x*=s.x/2,qe.y*=s.y/2,$e.start.copy(Ee),$e.start.z=0,$e.end.copy(qe),$e.end.z=0;const L=$e.closestPointToPointParameter(Ks,!0);$e.at(L,ol);const _=m.MathUtils.lerp(Ee.z,qe.z,L),S=_>=-1&&_<=1,Z=Ks.distanceTo(ol)<Un*.5;if(S&&Z){$e.start.fromBufferAttribute(u,y),$e.end.fromBufferAttribute(d,y),$e.start.applyMatrix4(a),$e.end.applyMatrix4(a);const G=new m.Vector3,A=new m.Vector3;en.distanceSqToSegment($e.start,$e.end,A,G),e.push({point:A,pointOnLine:G,distance:en.origin.distanceTo(A),object:l,face:null,faceIndex:y,uv:null,[Ts]:null})}}}class hf extends m.Mesh{constructor(t=new rl,e=new Xr({color:Math.random()*16777215})){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,r=new Float32Array(2*e.count);for(let a=0,c=0,u=e.count;a<u;a++,c+=2)il.fromBufferAttribute(e,a),sl.fromBufferAttribute(n,a),r[c]=c===0?0:r[c-1],r[c+1]=r[c]+il.distanceTo(sl);const s=new m.InstancedInterleavedBuffer(r,2,1);return t.setAttribute("instanceDistanceStart",new m.InterleavedBufferAttribute(s,1,0)),t.setAttribute("instanceDistanceEnd",new m.InterleavedBufferAttribute(s,1,1)),this}raycast(t,e){const n=this.material.worldUnits,r=t.camera;r===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=t.params.Line2!==void 0&&t.params.Line2.threshold||0;en=t.ray;const a=this.matrixWorld,c=this.geometry,u=this.material;Un=u.linewidth+s,c.boundingSphere===null&&c.computeBoundingSphere(),wi.copy(c.boundingSphere).applyMatrix4(a);let d;if(n)d=Un*.5;else{const f=Math.max(r.near,wi.distanceToPoint(en.origin));d=al(r,f,u.resolution)}if(wi.radius+=d,en.intersectsSphere(wi)===!1)return;c.boundingBox===null&&c.computeBoundingBox(),vi.copy(c.boundingBox).applyMatrix4(a);let p;if(n)p=Un*.5;else{const f=Math.max(r.near,vi.distanceToPoint(en.origin));p=al(r,f,u.resolution)}vi.expandByScalar(p),en.intersectsBox(vi)!==!1&&(n?cf(this,e):uf(this,r,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Os),this.material.uniforms.resolution.value.set(Os.z,Os.w))}}class Ys extends hf{constructor(t=new yi,e=new Xr({color:Math.random()*16777215})){super(t,e),this.isLine2=!0,this.type="Line2"}}var Ln=Object.freeze({Linear:Object.freeze({None:function(l){return l},In:function(l){return this.None(l)},Out:function(l){return this.None(l)},InOut:function(l){return this.None(l)}}),Quadratic:Object.freeze({In:function(l){return l*l},Out:function(l){return l*(2-l)},InOut:function(l){return(l*=2)<1?.5*l*l:-.5*(--l*(l-2)-1)}}),Cubic:Object.freeze({In:function(l){return l*l*l},Out:function(l){return--l*l*l+1},InOut:function(l){return(l*=2)<1?.5*l*l*l:.5*((l-=2)*l*l+2)}}),Quartic:Object.freeze({In:function(l){return l*l*l*l},Out:function(l){return 1- --l*l*l*l},InOut:function(l){return(l*=2)<1?.5*l*l*l*l:-.5*((l-=2)*l*l*l-2)}}),Quintic:Object.freeze({In:function(l){return l*l*l*l*l},Out:function(l){return--l*l*l*l*l+1},InOut:function(l){return(l*=2)<1?.5*l*l*l*l*l:.5*((l-=2)*l*l*l*l+2)}}),Sinusoidal:Object.freeze({In:function(l){return 1-Math.sin((1-l)*Math.PI/2)},Out:function(l){return Math.sin(l*Math.PI/2)},InOut:function(l){return .5*(1-Math.sin(Math.PI*(.5-l)))}}),Exponential:Object.freeze({In:function(l){return l===0?0:Math.pow(1024,l-1)},Out:function(l){return l===1?1:1-Math.pow(2,-10*l)},InOut:function(l){return l===0?0:l===1?1:(l*=2)<1?.5*Math.pow(1024,l-1):.5*(-Math.pow(2,-10*(l-1))+2)}}),Circular:Object.freeze({In:function(l){return 1-Math.sqrt(1-l*l)},Out:function(l){return Math.sqrt(1- --l*l)},InOut:function(l){return(l*=2)<1?-.5*(Math.sqrt(1-l*l)-1):.5*(Math.sqrt(1-(l-=2)*l)+1)}}),Elastic:Object.freeze({In:function(l){return l===0?0:l===1?1:-Math.pow(2,10*(l-1))*Math.sin((l-1.1)*5*Math.PI)},Out:function(l){return l===0?0:l===1?1:Math.pow(2,-10*l)*Math.sin((l-.1)*5*Math.PI)+1},InOut:function(l){return l===0?0:l===1?1:(l*=2,l<1?-.5*Math.pow(2,10*(l-1))*Math.sin((l-1.1)*5*Math.PI):.5*Math.pow(2,-10*(l-1))*Math.sin((l-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(l){var t=1.70158;return l===1?1:l*l*((t+1)*l-t)},Out:function(l){var t=1.70158;return l===0?0:--l*l*((t+1)*l+t)+1},InOut:function(l){var t=2.5949095;return(l*=2)<1?.5*(l*l*((t+1)*l-t)):.5*((l-=2)*l*((t+1)*l+t)+2)}}),Bounce:Object.freeze({In:function(l){return 1-Ln.Bounce.Out(1-l)},Out:function(l){return l<1/2.75?7.5625*l*l:l<2/2.75?7.5625*(l-=1.5/2.75)*l+.75:l<2.5/2.75?7.5625*(l-=2.25/2.75)*l+.9375:7.5625*(l-=2.625/2.75)*l+.984375},InOut:function(l){return l<.5?Ln.Bounce.In(l*2)*.5:Ln.Bounce.Out(l*2-1)*.5+.5}}),generatePow:function(l){return l===void 0&&(l=4),l=l<Number.EPSILON?Number.EPSILON:l,l=l>1e4?1e4:l,{In:function(t){return Math.pow(t,l)},Out:function(t){return 1-Math.pow(1-t,l)},InOut:function(t){return t<.5?Math.pow(t*2,l)/2:(1-Math.pow(2-t*2,l))/2+.5}}}}),kr=function(){return performance.now()},df=function(){function l(){this._tweens={},this._tweensAddedDuringUpdate={}}return l.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},l.prototype.removeAll=function(){this._tweens={}},l.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},l.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},l.prototype.update=function(t,e){t===void 0&&(t=kr()),e===void 0&&(e=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var s=this._tweens[n[r]],a=!e;s&&s.update(t,a)===!1&&!e&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},l}(),Us={Linear:function(l,t){var e=l.length-1,n=e*t,r=Math.floor(n),s=Us.Utils.Linear;return t<0?s(l[0],l[1],n):t>1?s(l[e],l[e-1],e-n):s(l[r],l[r+1>e?e:r+1],n-r)},Utils:{Linear:function(l,t,e){return(t-l)*e+l}}},ll=function(){function l(){}return l.nextId=function(){return l._nextId++},l._nextId=0,l}(),Bs=new df,xi=function(){function l(t,e){e===void 0&&(e=Bs),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Ln.Linear.None,this._interpolationFunction=Us.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ll.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return l.prototype.getId=function(){return this._id},l.prototype.isPlaying=function(){return this._isPlaying},l.prototype.isPaused=function(){return this._isPaused},l.prototype.getDuration=function(){return this._duration},l.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},l.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},l.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},l.prototype.start=function(t,e){if(t===void 0&&(t=kr()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var s in this._valuesEnd)r[s]=this._valuesEnd[s];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},l.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},l.prototype._setupProperties=function(t,e,n,r,s){for(var a in n){var c=t[a],u=Array.isArray(c),d=u?"array":typeof c,p=!u&&Array.isArray(n[a]);if(!(d==="undefined"||d==="function")){if(p){var f=n[a];if(f.length===0)continue;for(var y=[c],v=0,x=f.length;v<x;v+=1){var L=this._handleRelativeValue(c,f[v]);if(isNaN(L)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}y.push(L)}p&&(n[a]=y)}if((d==="object"||u)&&c&&!p){e[a]=u?[]:{};var _=c;for(var S in _)e[a][S]=_[S];r[a]=u?[]:{};var f=n[a];if(!this._isDynamic){var Z={};for(var S in f)Z[S]=f[S];n[a]=f=Z}this._setupProperties(_,e[a],f,r[a],s)}else(typeof e[a]>"u"||s)&&(e[a]=c),u||(e[a]*=1),p?r[a]=n[a].slice().reverse():r[a]=e[a]||0}}},l.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},l.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},l.prototype.pause=function(t){return t===void 0&&(t=kr()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},l.prototype.resume=function(t){return t===void 0&&(t=kr()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},l.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},l.prototype.group=function(t){return t===void 0&&(t=Bs),this._group=t,this},l.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},l.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},l.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},l.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},l.prototype.easing=function(t){return t===void 0&&(t=Ln.Linear.None),this._easingFunction=t,this},l.prototype.interpolation=function(t){return t===void 0&&(t=Us.Linear),this._interpolationFunction=t,this},l.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},l.prototype.onStart=function(t){return this._onStartCallback=t,this},l.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},l.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},l.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},l.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},l.prototype.onStop=function(t){return this._onStopCallback=t,this},l.prototype.update=function(t,e){var n=this,r;if(t===void 0&&(t=kr()),e===void 0&&(e=!0),this._isPaused)return!0;var s,a=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>a)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var c=t-this._startTime,u=this._duration+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),d=this._duration+this._repeat*u,p=function(){if(n._duration===0||c>d)return 1;var _=Math.trunc(c/u),S=c-_*u,Z=Math.min(S/n._duration,1);return Z===0&&c===n._duration?1:Z},f=p(),y=this._easingFunction(f);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,y),this._onUpdateCallback&&this._onUpdateCallback(this._object,f),this._duration===0||c>=this._duration)if(this._repeat>0){var v=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=v);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*v,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var x=0,L=this._chainedTweens.length;x<L;x++)this._chainedTweens[x].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},l.prototype._updateProperties=function(t,e,n,r){for(var s in n)if(e[s]!==void 0){var a=e[s]||0,c=n[s],u=Array.isArray(t[s]),d=Array.isArray(c),p=!u&&d;p?t[s]=this._interpolationFunction(c,r):typeof c=="object"&&c?this._updateProperties(t[s],a,c,r):(c=this._handleRelativeValue(a,c),typeof c=="number"&&(t[s]=a+(c-a)*r))}},l.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},l.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];typeof n=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(n):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},l}();ll.nextId;var tn=Bs;tn.getAll.bind(tn),tn.removeAll.bind(tn),tn.add.bind(tn),tn.remove.bind(tn);var ff=tn.update.bind(tn);function Ns(l,t,e){if(l==null||l==="")throw new Error(e||`Parameter "${t}" is required but received: ${l}`);return l}function cl(l,t,e){const n=t.split(".");let r=l;for(const s of n){if(r[s]===void 0||r[s]===null)throw new Error(`Property "${t}" is required but missing at path: "${s}"`);r=r[s]}return r}function pf(l,t,e,n=0,r=1){const s=(l-t)*(r-n)/(e-t)+n,a=Math.min(n,r),c=Math.max(n,r);return s<a?a:s>c?c:s||0}class ul extends m.EventDispatcher{constructor(e,n={}){super();T(this,"scene");T(this,"renderer");T(this,"camera");T(this,"controls");T(this,"ambLight");T(this,"dirLight");T(this,"auxDirLight");T(this,"clouds",null);T(this,"container");T(this,"_clock",new m.Clock);T(this,"stats");T(this,"_animationCallbacks",new Set);T(this,"_fogFactor",1);T(this,"_sceneSize",5e4*2);T(this,"gorund");T(this,"map");T(this,"centerPostion");T(this,"_isInteracting",!1);T(this,"debug",!1);T(this,"flyTween",null);T(this,"calculateCameraPosition",(e,n,r,s)=>{const a=new m.Vector3(0,n*Math.cos(r),n*Math.sin(r));return a.applyAxisAngle(new m.Vector3(0,1,0),s),new m.Vector3(e.x+a.x,e.y+a.y,e.z+a.z)});const{antialias:r=!1,stencil:s=!0,logarithmicDepthBuffer:a=!0,skybox:c,map:u}=n;this.map=u,this.centerPostion=this.map.geo2world(new m.Vector3(this.map.center[0],this.map.center[1],0)),this.renderer=this._createRenderer(r,s,a),this.scene=this._createScene(c),this.camera=this._createCamera(),e&&this.addTo(e),this.controls=this._createControls(),this.ambLight=this._createAmbLight(),this.scene.add(this.ambLight),this.dirLight=this._createDirLight(),this.scene.add(this.dirLight),this.scene.add(this.dirLight.target),this.auxDirLight=this._createAuxDirLight(),this.gorund=this._createGorund(),this.scene.add(this.gorund),this.renderer.setAnimationLoop(this.animate.bind(this)),this.debug=n.debug||!1,this.flyTween=null,this.debug&&(this.stats=new Cr,document.body.appendChild(this.stats.dom))}get fogFactor(){return this._fogFactor}get isInteracting(){return this._isInteracting}set fogFactor(e){this._fogFactor=e,this.controls.dispatchEvent({type:"change",target:this.controls})}get width(){return this.container?.clientWidth||0}get height(){return this.container?.clientHeight||0}addTo(e){const n=typeof e=="string"?document.querySelector(e):e;if(n instanceof HTMLElement)this.container=n,n.appendChild(this.renderer.domElement),new ResizeObserver(this.resize.bind(this)).observe(n);else throw`${e} not found!}`;return this}_createScene(e){const n=new m.Scene,r=e?.defaultColor||"rgb(21,48,94)";if(n.background=new m.Color(r),n.fog=new m.FogExp2(r,2e-4),e?.files){const s=new m.CubeTextureLoader;e.path&&s.setPath(e.path),s.load(e.files,a=>{n.background=a},void 0,a=>{console.error("Error loading skybox:",a),n.background=new m.Color(r)})}else e?.hdr&&this._loadHDRWithPMREM(n,e);return n}async _loadHDRWithPMREM(e,n){try{if(n){const s=await new of().setPath(n.path||"").setDataType(m.FloatType).loadAsync(n.hdr);s.colorSpace=this.renderer.outputColorSpace,s.mapping=303,s.needsUpdate=!0,e.background=s,e.environment=s}}catch(r){console.error("加载HDR失败:",r),e.background=new m.Color(n?.defaultColor||14414079)}}_createRenderer(e,n,r){const s=new m.WebGLRenderer({antialias:e,logarithmicDepthBuffer:r,stencil:n,alpha:!0,precision:"highp",powerPreference:"high-performance",failIfMajorPerformanceCaveat:!0});return s.debug.checkShaderErrors=!0,s.sortObjects=!0,s.setPixelRatio(window.devicePixelRatio),s.domElement.tabIndex=0,s.shadowMap.enabled=!0,s.shadowMap.needsUpdate=!0,s.shadowMap.type=m.PCFSoftShadowMap,s.toneMapping=m.ACESFilmicToneMapping,s.toneMappingExposure=1,s}_createCamera(){return new m.PerspectiveCamera(45,this.getAspect(),.1,this._sceneSize*2)}_createControls(){const e=new rd(this.camera,this.renderer.domElement),n=Math.PI/2.1;return e.screenSpacePanning=!1,e.minDistance=.1,e.maxDistance=3e4*2,e.maxPolarAngle=n,e.enableDamping=!0,e.dampingFactor=.08,e.keyPanSpeed=1,e.listenToKeyEvents(this.renderer.domElement),e.addEventListener("change",()=>{const r=Math.max(e.getPolarAngle(),.1),s=Math.max(e.getDistance(),100);e.zoomSpeed=Math.max(Math.log(s/1e3),1)+3;const a=3e5*2;e.maxDistance>a*.95&&(e.maxDistance=a*.95),this.camera.far=m.MathUtils.clamp(s/r*8,100,a),this.camera.near=m.MathUtils.clamp(this.camera.far/1e3,.001,1),this.camera.updateProjectionMatrix(),this.scene.fog instanceof m.FogExp2&&(this.scene.fog.density=r/(s+5)*this.fogFactor*.1);const u=s>6e4;e.minAzimuthAngle=u?0:-1/0,e.maxAzimuthAngle=u?0:1/0,e.maxPolarAngle=pf(e.getDistance(),0,7e4,n,0),this.map?.trigger("control-change",{type:"control-change",control:e,camera:this.camera,target:this.map})}),e.addEventListener("start",()=>{this._isInteracting=!0,this.map?.trigger("control-start",{type:"control-start",control:e,camera:this.camera,target:this.map})}),e.addEventListener("end",()=>{this._isInteracting=!1,this.map?.trigger("control-end",{type:"control-end",control:e,camera:this.camera,target:this.map})}),e}_createAmbLight(){return new m.AmbientLight(16777215,.1)}_createDirLight(){const y=new m.DirectionalLight("rgb(255, 255, 255)",3);y.position.set(this.centerPostion.x+55e3*1.2,55e3*2,this.centerPostion.z+55e3*1);const v=new m.Object3D;if(v.position.copy(this.centerPostion),this.scene.add(v),y.target=v,y.castShadow=!0,y.shadow.mapSize.width=1024*10,y.shadow.mapSize.height=1024*10,y.shadow.camera.near=1,y.shadow.camera.far=192500,y.shadow.camera.left=-55e3,y.shadow.camera.bottom=-55e3,y.shadow.camera.top=55e3,y.shadow.camera.right=55e3,y.shadow.radius=1,y.shadow.bias=-0,this.debug){const x=new m.CameraHelper(y.shadow.camera);x.name="dirLightCameraHelper",this.scene.add(x)}return y}_createAuxDirLight(){const c=this._createAuxLightInstance(this.centerPostion.x+-66e3,82500,this.centerPostion.z+-55e3,.5);c.name="AuxDirLight_BackFill",this.scene.add(c),this.scene.add(c.target);const f=this._createAuxLightInstance(this.centerPostion.x+55e3*-1,55e3*1.5,this.centerPostion.z+55e3*1.2,.5);f.name="AuxDirLight_LeftRim",this.scene.add(f),this.scene.add(f.target);const L=this._createAuxLightInstance(this.centerPostion.x+55e3*1,55e3*1.5,this.centerPostion.z+55e3*-1.2,.5);return L.name="AuxDirLight_RightRim",this.scene.add(L),this.scene.add(L.target),c}_createAuxLightInstance(e,n,r,s){const a=new m.DirectionalLight(16777215,s);a.position.set(e,n,r);const c=new m.Object3D;return c.position.copy(this.centerPostion),this.scene.add(c),a.target=c,a.castShadow=!1,a}resize(){const e=this.width,n=this.height;return this.renderer.setSize(e,n),this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this}addAnimationCallback(e){return this._animationCallbacks.add(e),()=>this._animationCallbacks.delete(e)}animate(){const e=this._clock.getDelta(),n=this._clock.getElapsedTime();this._animationCallbacks.forEach(r=>r(e,n,this)),this.controls.update(),this.renderer.render(this.scene,this.camera),ff(),this.stats&&this.stats.update(),this.dispatchEvent({type:"update",delta:e})}flyTo(e,n,r=!0,s){if(this.controls.target.copy(e),r){const a=this.camera.position;new xi(a).to({y:2e7,z:0},500).chain(new xi(a).to(n,2e3).easing(Ln.Quintic.Out).onComplete(c=>s&&s(c))).start()}else this.camera.position.copy(n)}flyToAdvanced(e){const n=this.camera,r=this.controls,s=e.center,a=e.cameraCoord,c=e.duration??2e3,u=e.delay??0,d=e.complete,p=!!e.curvePath;if(!s||!a)return;const f=this.map.geo2world(new m.Vector3(s[0],s[1],0)),y=this.map.geo2world(new m.Vector3(a[0],a[1],a[2]));if(!n||!r||!f||!y)return;const v=r.target.clone(),x=n.position.clone(),L=new m.Vector3(f.x,f.y,f.z),_=new m.Vector3(y.x,y.y,y.z);if(this.flyTween&&(this.flyTween.stop(),this.flyTween=null),p){const S=[x,x.clone().lerp(_,.33),x.clone().lerp(_,.67),_],Z=new m.CubicBezierCurve3(...S),G={t:0,x:v.x,y:v.y,z:v.z};this.flyTween=new xi(G).to({t:1,x:L.x,y:L.y,z:L.z},c).easing(Ln.Quadratic.InOut).onUpdate(()=>{const A=Z.getPoint(G.t),K=new m.Vector3(G.x,G.y,G.z);n.position.copy(A),n.lookAt(K),n.updateProjectionMatrix(),r.target.copy(K),r.update()})}else{const S={tx:v.x,ty:v.y,tz:v.z,px:x.x,py:x.y,pz:x.z};this.flyTween=new xi(S).to({tx:L.x,ty:L.y,tz:L.z,px:_.x,py:_.y,pz:_.z},c).easing(Ln.Quadratic.InOut).onUpdate(()=>{const Z=new m.Vector3(S.tx,S.ty,S.tz),G=new m.Vector3(S.px,S.py,S.pz);n.position.copy(G),n.lookAt(Z),r.target.copy(Z),r.update()})}this.flyTween&&(this.flyTween.onComplete(()=>{this.flyTween&&(this.flyTween.stop(),this.flyTween=null),d&&d()}),u>0?setTimeout(()=>{this.flyTween&&this.flyTween.start()},u):this.flyTween.start())}flyToPoint(e){const{controls:n}=this,r=e.center,s=e.duration??2e3,a=typeof e.distance=="number"?e.distance:typeof e.altitude=="number"?e.altitude:n.getDistance(),c=L=>L*Math.PI/180,u=typeof e.polarDeg=="number"?c(e.polarDeg):e.polarAngle||n.getPolarAngle(),d=typeof e.azimuthDeg=="number"?c(e.azimuthDeg):e.azimuthAngle||n.getAzimuthalAngle(),p=e.complete,f=!!e.curvePath,y=this.map.geo2world(new m.Vector3(r[0],r[1],0)),v=this.calculateCameraPosition(y,a,u,d),x=this.map.world2geo(v);this.flyToAdvanced({center:[r[0],r[1],0],cameraCoord:[x.x,x.y,x.z||0],duration:s,complete:p,curvePath:f})}getState(){return{centerPosition:this.controls.target,cameraPosition:this.camera.position}}_bindMap(e){e&&(this.map=e)}getMap(){return this.map?this.map:null}getAspect(){const[e,n]=this.getWidthHeight();return e/n}getWidthHeight(){let e=window.innerWidth,n=window.innerHeight;return[e,n]}_createGorund(){const e=this.centerPostion,n=new m.MeshStandardMaterial({transparent:!1,color:new m.Color("rgb(45,52,60)").multiplyScalar(.7),metalness:.2,roughness:1}),r=new m.PlaneGeometry(this._sceneSize*2,this._sceneSize*2),s=new m.Mesh(r,n);return s.name="地面",s.castShadow=!1,s.receiveShadow=!1,s.position.y=0,s.position.add(e),s.rotateX(-Math.PI/2),s.visible=!1,s}}var Dr=(l=>(l[l.none=0]="none",l[l.create=1]="create",l[l.remove=2]="remove",l))(Dr||{});function mf(l,t){const e=l.position.clone().setZ(l.maxZ).applyMatrix4(l.matrixWorld);return t.distanceTo(e)}function gf(l){const t=l.scale,e=new m.Vector3(-t.x,-t.y,0).applyMatrix4(l.matrixWorld),n=new m.Vector3(t.x,t.y,0).applyMatrix4(l.matrixWorld);return e.sub(n).length()}function yf(l){return l.distToCamera/l.sizeInWorld*.8}function vf(l,t,e,n){const r=yf(l);if(l.isLeaf){if(l.inFrustum&&l.z<e&&(l.z<t||l.showing)&&(l.z<t||r<n))return 1}else if(l.z>=t&&(l.z>e||r>n))return 2;return 0}function wf(l,t,e,n){const r=[],s=n+1,a=t*2,c=0,u=.25;{const d=e*2,p=new m.Vector3(.5,.5,1),f=new nn(a,d,s),y=new nn(a+1,d,s),v=new nn(a,d+1,s),x=new nn(a+1,d+1,s);f.position.set(-u,u,c),f.scale.copy(p),y.position.set(u,u,c),y.scale.copy(p),v.position.set(-u,-u,c),v.scale.copy(p),x.position.set(u,-u,c),x.scale.copy(p),r.push(f,y,v,x)}return r}const xf=10,bf=new m.InstancedBufferGeometry,_f=new m.Vector3,Mf=new m.Matrix4,Lf=new m.Box3(new m.Vector3(-.5,-.5,0),new m.Vector3(.5,.5,1)),hl=new m.Frustum,jn=class jn extends m.Mesh{constructor(e=0,n=0,r=0){super(bf,[]);T(this,"_dataOnlyMode",!1);T(this,"vectorData",null);T(this,"x");T(this,"y");T(this,"z");T(this,"isTile",!0);T(this,"parent",null);T(this,"children",[]);T(this,"_ready",!1);T(this,"_isDummy",!1);T(this,"_showing",!1);T(this,"_maxZ",0);T(this,"distToCamera",0);T(this,"sizeInWorld",0);T(this,"_loaded",!1);T(this,"_inFrustum",!1);this.x=e,this.y=n,this.z=r,this.name=`Tile ${r}-${e}-${n}`,this.up.set(0,0,1),this.matrixAutoUpdate=!1}setDataOnlyMode(e){return this._dataOnlyMode=e,e&&(this.visible=!1),this}isDataOnlyMode(){return this._dataOnlyMode}getVectorData(){return this.vectorData}static get downloadThreads(){return jn._downloadThreads}get isDummy(){return this._isDummy}get showing(){return this._showing}set showing(e){const n=this._showing;this._showing=e,this.material.forEach(r=>r.visible=e),n===!1&&this._showing===!0&&this._loaded&&this.dispatchEvent({type:"tile-shown",tile:this}),n===!0&&this._showing===!1&&this.dispatchEvent({type:"tile-hidden",tile:this})}get maxZ(){return this._maxZ}set maxZ(e){this._maxZ=e}get index(){return this.parent?this.parent.children.indexOf(this):-1}get loaded(){return this._loaded}get inFrustum(){return this._inFrustum}set inFrustum(e){this._inFrustum=e}get isLeaf(){return this.children.filter(e=>e.isTile).length===0}traverse(e){e(this),this.children.forEach(n=>{n.isTile&&n.traverse(e)})}traverseVisible(e){this.visible&&(e(this),this.children.forEach(n=>{n.isTile&&n.traverseVisible(e)}))}raycast(e,n){this.showing&&this.loaded&&this.isTile&&super.raycast(e,n)}LOD(e){if(jn.downloadThreads>xf)return{action:Dr.none};let n=[];const{loader:r,minLevel:s,maxLevel:a,LODThreshold:c}=e,u=vf(this,s,a,c);return u===Dr.create&&(n=wf(r,this.x,this.y,this.z),this.add(...n)),{action:u,newTiles:n}}_checkVisible(){const e=this.parent;if(e&&e.isTile){const n=e.children.filter(s=>s.isTile),r=n.every(s=>s.loaded);e.showing=!r,n.forEach(s=>s.showing=r)}return this}async _load(e){jn._downloadThreads++;const{x:n,y:r,z:s}=this;if(this._dataOnlyMode)try{const a=await e.load({x:n,y:r,z:s,bounds:[-1/0,-1/0,1/0,1/0]});this.vectorData=a.geometry?.userData||{},this._loaded=!0,this.dispatchEvent({type:"vector-data-loaded",data:this.vectorData,tile:this})}catch(a){console.error(`数据模式加载失败 ${s}/${n}/${r}:`,a),this._loaded=!1}else{const a=await e.load({x:n,y:r,z:s,bounds:[-1/0,-1/0,1/0,1/0]});this.material=a.materials,this.geometry=a.geometry,this.maxZ=this.geometry.boundingBox?.max.z||0,this._loaded=!0}return jn._downloadThreads--,this}_init(){this.updateMatrix(),this.updateMatrixWorld(),this.sizeInWorld=gf(this)}update(e){if(console.assert(this.z===0),!this.parent)return this;hl.setFromProjectionMatrix(Mf.multiplyMatrices(e.camera.projectionMatrix,e.camera.matrixWorldInverse));const n=e.camera.getWorldPosition(_f);return this.traverse(r=>{r.receiveShadow=this.receiveShadow,r.castShadow=this.castShadow;const s=Lf.clone().applyMatrix4(r.matrixWorld);s.max.setY(9e3),r.inFrustum=hl.intersectsBox(s),r.distToCamera=mf(r,n);const{action:a,newTiles:c}=r.LOD(e);this._doAction(r,a,c,e)}),this._checkReady(),this}_doAction(e,n,r,s){return n===Dr.create?r?.forEach(a=>{a._init(),a._isDummy=a.z<s.minLevel,this.dispatchEvent({type:"tile-created",tile:a}),a.isDummy||a._load(s.loader).then(()=>{a._checkVisible(),this.dispatchEvent({type:"tile-loaded",tile:a})})}):n===Dr.remove&&(e.showing=!0,e._unLoad(!1,s.loader),this.dispatchEvent({type:"tile-unload",tile:e})),this}reload(e){return this._unLoad(!0,e),this}_checkReady(){return this._ready||(this._ready=!0,this.traverse(e=>{if(e.isLeaf&&e.loaded&&!e.isDummy){this._ready=!1;return}}),this._ready&&this.dispatchEvent({type:"ready"})),this}_unLoad(e,n){return e&&this.isTile&&!this.isDummy&&(this.dispatchEvent({type:"unload"}),n?.unload?.(this)),this.children.forEach(r=>r._unLoad(!0,n)),this.clear(),this}};T(jn,"_downloadThreads",0);let nn=jn;class dl{constructor(t=0){T(this,"_lon0",0);this._lon0=t}get lon0(){return this._lon0}getTileXWithCenterLon(t,e){const n=Math.pow(2,e);let r=t+Math.round(n/360*this._lon0);return r>=n?r-=n:r<0&&(r+=n),r}getTileXYZproj(t,e,n){const r=this.mapWidth,s=this.mapHeight/2,a=t/Math.pow(2,n)*r-r/2,c=s-e/Math.pow(2,n)*s*2;return{x:a,y:c}}getProjBoundsFromLonLat(t){const e=t[0]===-180&&t[2]===180,n=this.project(t[0]+(e?this._lon0:0),t[1]),r=this.project(t[2]+(e?this._lon0:0),t[3]);return[Math.min(n.x,r.x),Math.min(n.y,r.y),Math.max(n.x,r.x),Math.max(n.y,r.y)]}getProjBoundsFromXYZ(t,e,n){const r=this.getTileXYZproj(t,e,n),s=this.getTileXYZproj(t+1,e+1,n);return[Math.min(r.x,s.x),Math.min(r.y,s.y),Math.max(r.x,s.x),Math.max(r.y,s.y)]}getLonLatBoundsFromXYZ(t,e,n){const r=this.getProjBoundsFromXYZ(t,e,n),s=this.unProject(r[0],r[1]),a=this.unProject(r[2],r[3]);return[s.lon,s.lat,a.lon,a.lat]}}const zr=6378e3;class fl extends dl{constructor(){super(...arguments);T(this,"ID","3857");T(this,"mapWidth",2*Math.PI*zr);T(this,"mapHeight",this.mapWidth);T(this,"mapDepth",1)}project(e,n){const r=(e-this.lon0)*(Math.PI/180),s=n*(Math.PI/180),a=zr*r,c=zr*Math.log(Math.tan(Math.PI/4+s/2));return{x:a,y:c}}unProject(e,n){let r=e/zr*(180/Math.PI)+this.lon0;return r>180&&(r-=360),{lat:(2*Math.atan(Math.exp(n/zr))-Math.PI/2)*(180/Math.PI),lon:r}}}class Sf extends dl{constructor(){super(...arguments);T(this,"ID","4326");T(this,"mapWidth",36e3);T(this,"mapHeight",18e3);T(this,"mapDepth",1)}project(e,n){return{x:(e-this.lon0)*100,y:n*100}}unProject(e,n){return{lon:e/100+this.lon0,lat:n/100}}}const Zf={createFromID:(l="3857",t)=>{let e;switch(l){case"3857":e=new fl(t);break;case"4326":e=new Sf(t);break;default:throw new Error(`Projection ID: ${l} is not supported.`)}return e}};function js(l,t){const e=l.getLayers().find(r=>r.isBaseLayer===!0)?._rootTile,n=t.intersectObjects([e]);for(const r of n)if(r.object instanceof nn){const s=l.worldToLocal(r.point.clone()),a=l.map2geo(s);return Object.assign(r,{location:a})}}function Js(l,t){const e=new m.Vector3(0,-1,0),n=new m.Vector3(t.x,10*1e3,t.z),r=new m.Raycaster(n,e);return js(l,r)}function pl(l,t,e){const n=new m.Raycaster;return n.setFromCamera(e,l),js(t,n)}function Tf(l,t=128){const e=document.createElement("canvas"),n=e.getContext("2d");if(!n)throw new Error("Failed to get canvas context");e.width=t,e.height=t;const r=t/2,s=t/2;return n.imageSmoothingEnabled=!1,n.fillStyle="#000022",n.strokeStyle="DarkGoldenrod",n.lineWidth=5,n.moveTo(r,3),n.lineTo(r,t),n.stroke(),n.closePath(),n.lineWidth=2,n.beginPath(),n.roundRect(2,2,t-4,s-8,10),n.closePath(),n.fill(),n.stroke(),n.font="24px Arial",n.fillStyle="Goldenrod",n.strokeStyle="black",n.textAlign="center",n.textBaseline="top",n.strokeText(l,r,20),n.fillText(l,r,20),e}function Gf(l,t=128){const e=new m.CanvasTexture(Tf(l,t)),n=new m.SpriteMaterial({map:e,sizeAttenuation:!1}),r=new m.Sprite(n);return r.visible=!1,r.center.set(.5,.3),r.scale.setScalar(.11),r.renderOrder=999,r}class bi extends m.Mesh{constructor(e){super();T(this,"name","map");T(this,"_clock",new m.Clock);T(this,"isLOD",!0);T(this,"autoUpdate",!0);T(this,"updateInterval",100);T(this,"_minLevel",2);T(this,"_layers",new Map);T(this,"_maxLevel",24);T(this,"_projection",new fl(0));T(this,"_LODThreshold",1);this.up.set(0,0,1);const{minLevel:n=2,maxLevel:r=19}=e;this.minLevel=n,this.maxLevel=r}get minLevel(){return this._minLevel}set minLevel(e){this._minLevel=e}get maxLevel(){return this._maxLevel}set maxLevel(e){this._maxLevel=e}get lon0(){return this.projection.lon0}get projection(){return this._projection}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}static create(e){return new bi(e)}update(e){if(!this.autoUpdate)return;const n=this._clock.getElapsedTime();n>this.updateInterval/1e3&&(this._layers.forEach(r=>{r.enabled&&r.visible&&r.update(e)}),this._clock.start(),this.dispatchEvent({type:"update",delta:n}))}dispose(){this.removeFromParent()}geo2pos(e){return this.geo2map(e)}geo2map(e){const n=this.projection.project(e.x,e.y);return new m.Vector3(n.x,n.y,e.z)}geo2world(e){return this.localToWorld(this.geo2map(e))}pos2geo(e){return this.map2geo(e)}map2geo(e){const n=this.projection.unProject(e.x,e.y);return new m.Vector3(n.lon,n.lat,e.z)}world2geo(e){return this.pos2geo(this.worldToLocal(e.clone()))}getLocalInfoFromGeo(e){const n=this.geo2world(e);return Js(this,n)}getLocalInfoFromWorld(e){return Js(this,e)}getLocalInfoFromScreen(e,n){return pl(e,this,n)}get downloading(){return nn.downloadThreads}addLayer(e){return this._layers.has(e.layerId)&&console.warn(`图层 ${e.layerid} 已存在,将被替换`),this._layers.set(e.layerId,e),this.add(e),this}removeLayer(e){const n=this._layers.get(e);return n?(this._layers.delete(e),this.remove(n),n.dispose(),console.log(`✅ 图层 ${e} 移除成功`),!0):(console.warn(`⚠️ 图层 ${e} 不存在`),!1)}getLayer(e){return this._layers.get(e)}getLayerIds(){return Array.from(this._layers.keys())}clearLayers(){return this._layers.forEach(e=>{this.remove(e),e.dispose()}),this._layers.clear(),console.log("✅ 所有图层已清空"),this}getLayers(){return Array.from(this._layers.values())}getApproxZoomLevel(){let e=this.minLevel;const n=this.getLayers().find(s=>s.isBaseLayer===!0);return!n||!n._rootTile||n._rootTile.traverseVisible(s=>{s.showing&&s.inFrustum&&(e=Math.max(e,s.z))}),e}getDataZoom(){let e=this.minLevel;const n=this.getLayers().find(s=>s.isBaseLayer===!0);return!n||!n._rootTile||n._rootTile.traverseVisible(s=>{s.showing&&s.inFrustum&&(e=Math.max(e,s.z))}),e}}class Qs{constructor(){T(this,"_dispatcher",new m.EventDispatcher);T(this,"_listenerMap",new Map)}on(t,e){const n=r=>e(r.data||r);return this._listenerMap.has(t)||this._listenerMap.set(t,new Map),this._listenerMap.get(t).set(e,n),this._dispatcher.addEventListener(t,n),this}once(t,e){const n=r=>{this.off(t,n),e(r.data||r)};return this.on(t,n)}off(t,e){const n=this._listenerMap.get(t);if(!n)return this;const r=n.get(e);return r&&(this._dispatcher.removeEventListener(t,r),n.delete(e),n.size===0&&this._listenerMap.delete(t)),this}trigger(t,e){const n={type:t,data:e};return this._dispatcher.dispatchEvent(n),this}get threeEventDispatcher(){return this._dispatcher}}function Pf(l,t){return l.replace(/\{(\w+)\}/g,(e,n)=>{if(t.hasOwnProperty(n)){const r=t[n];return r!==void 0?String(r):e}throw new Error(`缺少必要参数: ${n}`)})}function Hs(l,...t){for(let e=0;e<t.length;e++){const n=t[e];for(const r in n)l[r]=n[r]}return l}function _i(l){return l==null}function Or(l){return _i(l)?!1:typeof l=="function"||l.constructor!==null&&l.constructor===Function}function If(l=new Date){const t=l.getFullYear().toString(),e=(l.getMonth()+1).toString().padStart(2,"0"),n=l.getDate().toString().padStart(2,"0"),r=l.getHours().toString().padStart(2,"0"),s=l.getMinutes().toString().padStart(2,"0"),a=l.getSeconds().toString().padStart(2,"0");return`${t}-${e}-${n} ${r}:${s}:${a}`}class Wf{}class ml extends Mi(Li(Wf)){constructor(e){super();T(this,"target");T(this,"dom");T(this,"_enabled",!1);this.target=e}enable(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)}disable(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this}enabled(){return!!this._enabled}remove(){this.disable(),delete this.target,delete this.dom}}const gl=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]"&&!process.versions.electron&&!process.versions.nw&&!process.versions["node-webkit"];let Kr={};function yl(){return window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI}if(!gl){const l=navigator.userAgent.toLowerCase(),t=document.documentElement||{style:{}},e="ActiveXObject"in window,n=l.indexOf("webkit")!==-1,r=l.indexOf("phantom")!==-1,s=l.search("android [23]")!==-1,a=l.indexOf("chrome")!==-1,c=l.indexOf("gecko")!==-1&&!n&&!("opera"in window)&&!e,u=/iphone/i.test(l)&&/micromessenger/i.test(l),d=typeof orientation<"u"||l.indexOf("mobile")!==-1,p=!window.PointerEvent&&"MSPointerEvent"in window,f=window.PointerEvent&&navigator.pointerEnabled||p,y=e&&"transition"in t.style,v="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!s,x="MozPerspective"in t.style,L="OTransition"in t.style,_=(y||v||x)&&!L&&!r,S=typeof window<"u"&&Or(window.createImageBitmap),Z=typeof window<"u"&&Or(window.ResizeObserver),G=typeof window<"u"&&Or(window.btoa),A=typeof window<"u"&&Or(window.Proxy),K=typeof window<"u"&&Or(window.requestIdleCallback);let D=0;if(a){const N=l.match(/chrome\/([\d.]+)/);D=N?N[1]:0}const O=!r&&(f||"ontouchstart"in window||"DocumentTouch"in window&&document instanceof window.DocumentTouch),V=typeof window<"u"&&"WebGLRenderingContext"in window,R=yl();let W=!1;try{new OffscreenCanvas(2,2).getContext("2d"),W=!0}catch{W=!1}let k=!1;try{window.addEventListener("testPassive",()=>{},{get passive(){return k=!0,!0}})}catch{}Kr={IS_NODE:gl,isTest:!1,ie:e,ielt9:e&&!document.addEventListener,edge:"msLaunchUri"in navigator&&!("documentMode"in document),webkit:n,gecko:c,android:l.indexOf("android")!==-1,android23:s,chrome:a,chromeVersion:D,safari:!a&&l.indexOf("safari")!==-1,phantomjs:r,ie3d:y,webkit3d:v,gecko3d:x,opera12:L,any3d:_,iosWeixin:u,mobile:d,mobileWebkit:d&&n,mobileWebkit3d:d&&v,mobileOpera:d&&"opera"in window,mobileGecko:d&&c,touch:!!O,msPointer:!!p,pointer:!!f,retina:R>1,devicePixelRatio:R,language:navigator.browserLanguage?navigator.browserLanguage:navigator.language,ie9:e&&document.documentMode===9,ie10:e&&document.documentMode===10,webgl:V,imageBitMap:S,resizeObserver:Z,btoa:G,decodeImageInWorker:W,monitorDPRChange:!0,supportsPassive:k,proxy:A,requestIdleCallback:K,checkDevicePixelRatio:()=>{if(typeof window<"u"&&Kr.monitorDPRChange){const N=yl(),H=N!==Kr.devicePixelRatio;return H&&(Kr.devicePixelRatio=N),H}return!1}}}const Cf=Kr;function Mi(l){return class extends l{constructor(...e){super(...e);T(this,"eventClass",new Qs);T(this,"on",this.eventClass.on.bind(this.eventClass));T(this,"trigger",this.eventClass.trigger.bind(this.eventClass));T(this,"off",this.eventClass.off.bind(this.eventClass));this.eventClass=new Qs}}}function Li(l){return class extends l{constructor(...e){super(...e);T(this,"options");T(this,"_isUpdatingOptions");T(this,"_initHooksCalled");T(this,"_initHooks");const n=Object.getPrototypeOf(this).options||{},r=Hs({},n,e[0]||{});this.setOptions(r),this.callInitHooks(),this._isUpdatingOptions=!1}proxyOptions(){return Cf.proxy?(this.options=new Proxy(this.options,{set:(e,n,r)=>{if(n=n,e[n]===r||(e[n]=r,this._isUpdatingOptions))return!0;const s={};return s[n]=r,this.config(s),!0}}),this):this}callInitHooks(){const e=Object.getPrototypeOf(this);return this._visitInitHooks(e),this}setOptions(e){if((!this.hasOwnProperty("options")||_i(this.options))&&(this.options=this.options?Object.create(this.options):{}),!e)return this;for(const n in e)this.options[n]=e[n];return this}config(e,n){if(this._isUpdatingOptions=!0,e){if(arguments.length===2&&typeof e=="string"){const r={};r[e]=n,e=r}e=e;for(const r in e)this.options[r]=e[r],this[r]&&this[r]instanceof ml&&(e[r]?this[r].enable():this[r].disable());this.onConfig(e),this._isUpdatingOptions=!1}else{const r={};for(const s in this.options)this.options.hasOwnProperty(s)&&(r[s]=this.options[s]);return this._isUpdatingOptions=!1,r}return this}onConfig(e){}_visitInitHooks(e){if(this._initHooksCalled)return;const n=Object.getPrototypeOf(e);n._visitInitHooks&&n._visitInitHooks.call(this,n),this._initHooksCalled=!0;const r=e._initHooks;if(r&&r!==n._initHooks)for(let s=0;s<r.length;s++)r[s].call(this)}static mergeOptions(e){const n=this.prototype,r=Object.getPrototypeOf(n);return n.hasOwnProperty("options")?n.options===r.options&&(n.options=Object.create(n.options)):n.options={},Hs(n.options,e),this}static addInitHook(e,...n){const r=typeof e=="function"?e:function(){this[e].apply(this,n)},s=this.prototype,a=Object.getPrototypeOf(s);return(!s._initHooks||s._initHooks===a._initHooks)&&(s._initHooks=[]),s._initHooks.push(r),this}static include(...e){for(let n=0;n<e.length;n++)Hs(this.prototype,e[n]);return this}}}function Es(l){return class extends l{constructor(...n){super(...n);T(this,"_handlers");this._handlers=[]}addHandler(n,r){if(!r)return this;if(this._handlers||(this._handlers=[]),this[n])return this[n].enable(),this;const s=this[n]=new r(this);return this._handlers.push(s),this.options[n]&&s.enable(),this}removeHandler(n){if(!n)return this;const r=this[n];if(r&&this._handlers){const s=this._handlers.indexOf(r);s>=0&&this._handlers.splice(s,1),this[n].remove(),delete this[n]}return this}_clearHandlers(){if(this._handlers){for(let n=0,r=this._handlers.length;n<r;n++)this._handlers[n].remove();this._handlers=[]}}}}const Vf={attribution:"",visible:!0,opacity:1,zIndex:0,isSceneLayer:!1,altitude:0};class Si extends Es(Mi(Li(m.Group))){constructor(e,n){super();T(this,"_id");T(this,"opacity",1);T(this,"_animationCallbacks",new Set);T(this,"isSceneLayer",!1);T(this,"_altitude",0);Ns(e,"id","图层ID必须指定"),n&&(this.opacity=n.opacity||1,this.isSceneLayer=n.isSceneLayer??!1,n.altitude!==void 0&&this.setAltitude(n.altitude)),this._id=e,typeof this.animate=="function"&&this._registerAnimate()}getId(){return this._id}addTo(e){return e.addLayer(this),this}getZIndex(){return 0}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e,this.traverse(n=>{"material"in n&&(Array.isArray(n.material)?n.material:[n.material]).forEach(s=>{"opacity"in s&&(s.transparent=e<1,s.opacity=e,s.needsUpdate=!0)}),n instanceof m.Sprite&&(n.material.opacity=e,n.material.transparent=e<1,n.material.needsUpdate=!0)})}getMap(){return this.map?this.map:null}show(){return this.visible||(this.visible=!0,this.options.visible=!0,this.getMap()),this}hide(){return this.visible&&(this.visible=!1,this.options.visible=!1,this.getMap()),this}setAltitude(e){return this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0),this}getAltitude(){return this.position.y}_bindMap(e){e&&(this.map=e,typeof this.animate=="function"&&this._registerAnimate())}_registerAnimate(){const e=this.getMap();if(!e?.viewer)return;const n=e.viewer.addAnimationCallback((r,s,a)=>{this.animate?.(r,s,a)});this._animationCallbacks.add(n)}_clearAnimationCallbacks(){this._animationCallbacks.forEach(e=>e()),this._animationCallbacks.clear()}getOptions(){return{...this.options}}}Si.mergeOptions(Vf);const Fi=class Fi{constructor(t){T(this,"_cache",new Map);T(this,"_gltfLoader");T(this,"_fbxLoader");T(this,"_dracoLoader");this._gltfLoader=new sd(t),this._fbxLoader=new jd(t)}static init(t){return this._instance||(this._instance=new Fi(t)),this._instance}async load(t){const e=`${t.type}:${t.url}`;if(this._cache.has(e))return this._cloneCachedModel(e,t);t.type==="gltf"&&t.dracoOptions?.enable&&this._initDracoLoader(t.dracoOptions.decoderPath);let n,r;try{if(t.type==="gltf"){const s=await this._gltfLoader.loadAsync(t.url);n=s.scene,r=s.animations}else n=await this._fbxLoader.loadAsync(t.url),r=n.animations;return this._cache.set(e,{model:n,animations:r}),{model:this._processModel(n.clone(),t),animations:r?.map(s=>({...s,name:s.name||"unnamed"}))||[]}}catch(s){throw console.error(`加载${t.type}模型失败:`,t.url,s),s}}_initDracoLoader(t="/draco/"){this._dracoLoader||(this._dracoLoader=new af,this._dracoLoader.setDecoderPath(t),this._gltfLoader.setDRACOLoader(this._dracoLoader))}_cloneCachedModel(t,e){const r=this._cache.get(t).model.clone();return this._processModel(r,e)}_processModel(t,e){return e.position&&t.position.copy(e.position),e.scale&&(typeof e.scale=="number"?t.scale.setScalar(e.scale):e.scale.x!==void 0||e.scale.y!==void 0||e.scale.z!==void 0?(e.scale.x!==void 0&&(t.scale.x=e.scale.x),e.scale.y!==void 0&&(t.scale.y=e.scale.y),e.scale.z!==void 0&&(t.scale.z=e.scale.z)):t.scale.copy(e.scale)),e.rotation&&t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.materialOverrides&&t.traverse(n=>{if(n instanceof m.Mesh&&n.material){const r=e.materialOverrides[n.name];r&&(n.material=r)}}),t.traverse(n=>{n instanceof m.Mesh&&n.material}),t}};T(Fi,"_instance");let qs=Fi;const $s=(l,t)=>{"updateRanges"in l?l.updateRanges[0]=t:l.updateRange=t},vl=new m.Matrix4,Zi=new m.Vector3,Ti=new m.Quaternion,wl=new m.Vector3,xl=new m.Quaternion,Rr=new m.Vector3,Af=l=>class extends l{constructor(){super();const t=parseInt(m.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=e=>{e.vertexShader=`attribute float cloudOpacity;
|
|
510
|
+
`,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(e){!!e!="USE_DASH"in this.defines&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(e){!!e!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}const Rs=new m.Vector4,ul=new m.Vector3,hl=new m.Vector3,Ee=new m.Vector4,qe=new m.Vector4,qt=new m.Vector4,Ks=new m.Vector3,Ys=new m.Matrix4,$e=new m.Line3,dl=new m.Vector3,br=new m.Box3,_r=new m.Sphere,$t=new m.Vector4;let en,Un;function fl(a,t,e){return $t.set(0,0,-t,1).applyMatrix4(a.projectionMatrix),$t.multiplyScalar(1/$t.w),$t.x=Un/e.width,$t.y=Un/e.height,$t.applyMatrix4(a.projectionMatrixInverse),$t.multiplyScalar(1/$t.w),Math.abs(Math.max($t.x,$t.y))}function pf(a,t){const e=a.matrixWorld,n=a.geometry,i=n.attributes.instanceStart,s=n.attributes.instanceEnd,l=Math.min(n.instanceCount,i.count);for(let u=0,c=l;u<c;u++){$e.start.fromBufferAttribute(i,u),$e.end.fromBufferAttribute(s,u),$e.applyMatrix4(e);const d=new m.Vector3,p=new m.Vector3;en.distanceSqToSegment($e.start,$e.end,p,d),p.distanceTo(d)<Un*.5&&t.push({point:p,pointOnLine:d,distance:en.origin.distanceTo(p),object:a,face:null,faceIndex:u,uv:null,[Gs]:null})}}function mf(a,t,e){const n=t.projectionMatrix,s=a.material.resolution,l=a.matrixWorld,u=a.geometry,c=u.attributes.instanceStart,d=u.attributes.instanceEnd,p=Math.min(u.instanceCount,c.count),f=-t.near;en.at(1,qt),qt.w=1,qt.applyMatrix4(t.matrixWorldInverse),qt.applyMatrix4(n),qt.multiplyScalar(1/qt.w),qt.x*=s.x/2,qt.y*=s.y/2,qt.z=0,Ks.copy(qt),Ys.multiplyMatrices(t.matrixWorldInverse,l);for(let y=0,v=p;y<v;y++){if(Ee.fromBufferAttribute(c,y),qe.fromBufferAttribute(d,y),Ee.w=1,qe.w=1,Ee.applyMatrix4(Ys),qe.applyMatrix4(Ys),Ee.z>f&&qe.z>f)continue;if(Ee.z>f){const G=Ee.z-qe.z,A=(Ee.z-f)/G;Ee.lerp(qe,A)}else if(qe.z>f){const G=qe.z-Ee.z,A=(qe.z-f)/G;qe.lerp(Ee,A)}Ee.applyMatrix4(n),qe.applyMatrix4(n),Ee.multiplyScalar(1/Ee.w),qe.multiplyScalar(1/qe.w),Ee.x*=s.x/2,Ee.y*=s.y/2,qe.x*=s.x/2,qe.y*=s.y/2,$e.start.copy(Ee),$e.start.z=0,$e.end.copy(qe),$e.end.z=0;const S=$e.closestPointToPointParameter(Ks,!0);$e.at(S,dl);const _=m.MathUtils.lerp(Ee.z,qe.z,S),Z=_>=-1&&_<=1,M=Ks.distanceTo(dl)<Un*.5;if(Z&&M){$e.start.fromBufferAttribute(c,y),$e.end.fromBufferAttribute(d,y),$e.start.applyMatrix4(l),$e.end.applyMatrix4(l);const G=new m.Vector3,A=new m.Vector3;en.distanceSqToSegment($e.start,$e.end,A,G),e.push({point:A,pointOnLine:G,distance:en.origin.distanceTo(A),object:a,face:null,faceIndex:y,uv:null,[Gs]:null})}}}class gf extends m.Mesh{constructor(t=new cl,e=new zi({color:Math.random()*16777215})){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,i=new Float32Array(2*e.count);for(let l=0,u=0,c=e.count;l<c;l++,u+=2)ul.fromBufferAttribute(e,l),hl.fromBufferAttribute(n,l),i[u]=u===0?0:i[u-1],i[u+1]=i[u]+ul.distanceTo(hl);const s=new m.InstancedInterleavedBuffer(i,2,1);return t.setAttribute("instanceDistanceStart",new m.InterleavedBufferAttribute(s,1,0)),t.setAttribute("instanceDistanceEnd",new m.InterleavedBufferAttribute(s,1,1)),this}raycast(t,e){const n=this.material.worldUnits,i=t.camera;i===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=t.params.Line2!==void 0&&t.params.Line2.threshold||0;en=t.ray;const l=this.matrixWorld,u=this.geometry,c=this.material;Un=c.linewidth+s,u.boundingSphere===null&&u.computeBoundingSphere(),_r.copy(u.boundingSphere).applyMatrix4(l);let d;if(n)d=Un*.5;else{const f=Math.max(i.near,_r.distanceToPoint(en.origin));d=fl(i,f,c.resolution)}if(_r.radius+=d,en.intersectsSphere(_r)===!1)return;u.boundingBox===null&&u.computeBoundingBox(),br.copy(u.boundingBox).applyMatrix4(l);let p;if(n)p=Un*.5;else{const f=Math.max(i.near,br.distanceToPoint(en.origin));p=fl(i,f,c.resolution)}br.expandByScalar(p),en.intersectsBox(br)!==!1&&(n?pf(this,e):mf(this,i,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Rs),this.material.uniforms.resolution.value.set(Rs.z,Rs.w))}}class Us extends gf{constructor(t=new xr,e=new zi({color:Math.random()*16777215})){super(t,e),this.isLine2=!0,this.type="Line2"}}var Sn=Object.freeze({Linear:Object.freeze({None:function(a){return a},In:function(a){return this.None(a)},Out:function(a){return this.None(a)},InOut:function(a){return this.None(a)}}),Quadratic:Object.freeze({In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}}),Cubic:Object.freeze({In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}}),Quartic:Object.freeze({In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}}),Quintic:Object.freeze({In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}}),Sinusoidal:Object.freeze({In:function(a){return 1-Math.sin((1-a)*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return .5*(1-Math.sin(Math.PI*(.5-a)))}}),Exponential:Object.freeze({In:function(a){return a===0?0:Math.pow(1024,a-1)},Out:function(a){return a===1?1:1-Math.pow(2,-10*a)},InOut:function(a){return a===0?0:a===1?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}}),Circular:Object.freeze({In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}}),Elastic:Object.freeze({In:function(a){return a===0?0:a===1?1:-Math.pow(2,10*(a-1))*Math.sin((a-1.1)*5*Math.PI)},Out:function(a){return a===0?0:a===1?1:Math.pow(2,-10*a)*Math.sin((a-.1)*5*Math.PI)+1},InOut:function(a){return a===0?0:a===1?1:(a*=2,a<1?-.5*Math.pow(2,10*(a-1))*Math.sin((a-1.1)*5*Math.PI):.5*Math.pow(2,-10*(a-1))*Math.sin((a-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(a){var t=1.70158;return a===1?1:a*a*((t+1)*a-t)},Out:function(a){var t=1.70158;return a===0?0:--a*a*((t+1)*a+t)+1},InOut:function(a){var t=2.5949095;return(a*=2)<1?.5*(a*a*((t+1)*a-t)):.5*((a-=2)*a*((t+1)*a+t)+2)}}),Bounce:Object.freeze({In:function(a){return 1-Sn.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return a<.5?Sn.Bounce.In(a*2)*.5:Sn.Bounce.Out(a*2-1)*.5+.5}}),generatePow:function(a){return a===void 0&&(a=4),a=a<Number.EPSILON?Number.EPSILON:a,a=a>1e4?1e4:a,{In:function(t){return Math.pow(t,a)},Out:function(t){return 1-Math.pow(1-t,a)},InOut:function(t){return t<.5?Math.pow(t*2,a)/2:(1-Math.pow(2-t*2,a))/2+.5}}}}),Di=function(){return performance.now()},yf=function(){function a(){this._tweens={},this._tweensAddedDuringUpdate={}}return a.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},a.prototype.removeAll=function(){this._tweens={}},a.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},a.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},a.prototype.update=function(t,e){t===void 0&&(t=Di()),e===void 0&&(e=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],l=!e;s&&s.update(t,l)===!1&&!e&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},a}(),Bs={Linear:function(a,t){var e=a.length-1,n=e*t,i=Math.floor(n),s=Bs.Utils.Linear;return t<0?s(a[0],a[1],n):t>1?s(a[e],a[e-1],e-n):s(a[i],a[i+1>e?e:i+1],n-i)},Utils:{Linear:function(a,t,e){return(t-a)*e+a}}},pl=function(){function a(){}return a.nextId=function(){return a._nextId++},a._nextId=0,a}(),Ns=new yf,Mr=function(){function a(t,e){e===void 0&&(e=Ns),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Sn.Linear.None,this._interpolationFunction=Bs.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=pl.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return a.prototype.getId=function(){return this._id},a.prototype.isPlaying=function(){return this._isPlaying},a.prototype.isPaused=function(){return this._isPaused},a.prototype.getDuration=function(){return this._duration},a.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},a.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},a.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},a.prototype.start=function(t,e){if(t===void 0&&(t=Di()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},a.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},a.prototype._setupProperties=function(t,e,n,i,s){for(var l in n){var u=t[l],c=Array.isArray(u),d=c?"array":typeof u,p=!c&&Array.isArray(n[l]);if(!(d==="undefined"||d==="function")){if(p){var f=n[l];if(f.length===0)continue;for(var y=[u],v=0,x=f.length;v<x;v+=1){var S=this._handleRelativeValue(u,f[v]);if(isNaN(S)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}y.push(S)}p&&(n[l]=y)}if((d==="object"||c)&&u&&!p){e[l]=c?[]:{};var _=u;for(var Z in _)e[l][Z]=_[Z];i[l]=c?[]:{};var f=n[l];if(!this._isDynamic){var M={};for(var Z in f)M[Z]=f[Z];n[l]=f=M}this._setupProperties(_,e[l],f,i[l],s)}else(typeof e[l]>"u"||s)&&(e[l]=u),c||(e[l]*=1),p?i[l]=n[l].slice().reverse():i[l]=e[l]||0}}},a.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},a.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},a.prototype.pause=function(t){return t===void 0&&(t=Di()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},a.prototype.resume=function(t){return t===void 0&&(t=Di()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},a.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},a.prototype.group=function(t){return t===void 0&&(t=Ns),this._group=t,this},a.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},a.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},a.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},a.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},a.prototype.easing=function(t){return t===void 0&&(t=Sn.Linear.None),this._easingFunction=t,this},a.prototype.interpolation=function(t){return t===void 0&&(t=Bs.Linear),this._interpolationFunction=t,this},a.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},a.prototype.onStart=function(t){return this._onStartCallback=t,this},a.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},a.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},a.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},a.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},a.prototype.onStop=function(t){return this._onStopCallback=t,this},a.prototype.update=function(t,e){var n=this,i;if(t===void 0&&(t=Di()),e===void 0&&(e=!0),this._isPaused)return!0;var s,l=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>l)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var u=t-this._startTime,c=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),d=this._duration+this._repeat*c,p=function(){if(n._duration===0||u>d)return 1;var _=Math.trunc(u/c),Z=u-_*c,M=Math.min(Z/n._duration,1);return M===0&&u===n._duration?1:M},f=p(),y=this._easingFunction(f);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,y),this._onUpdateCallback&&this._onUpdateCallback(this._object,f),this._duration===0||u>=this._duration)if(this._repeat>0){var v=Math.min(Math.trunc((u-this._duration)/c)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=v);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=c*v,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var x=0,S=this._chainedTweens.length;x<S;x++)this._chainedTweens[x].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},a.prototype._updateProperties=function(t,e,n,i){for(var s in n)if(e[s]!==void 0){var l=e[s]||0,u=n[s],c=Array.isArray(t[s]),d=Array.isArray(u),p=!c&&d;p?t[s]=this._interpolationFunction(u,i):typeof u=="object"&&u?this._updateProperties(t[s],l,u,i):(u=this._handleRelativeValue(l,u),typeof u=="number"&&(t[s]=l+(u-l)*i))}},a.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},a.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];typeof n=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(n):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},a}();pl.nextId;var tn=Ns;tn.getAll.bind(tn),tn.removeAll.bind(tn),tn.add.bind(tn),tn.remove.bind(tn);var vf=tn.update.bind(tn);function js(a,t,e){if(a==null||a==="")throw new Error(e||`Parameter "${t}" is required but received: ${a}`);return a}function ml(a,t,e){const n=t.split(".");let i=a;for(const s of n){if(i[s]===void 0||i[s]===null)throw new Error(`Property "${t}" is required but missing at path: "${s}"`);i=i[s]}return i}function wf(a,t,e,n=0,i=1){const s=(a-t)*(i-n)/(e-t)+n,l=Math.min(n,i),u=Math.max(n,i);return s<l?l:s>u?u:s||0}class gl extends m.EventDispatcher{constructor(e,n={}){super();T(this,"scene");T(this,"renderer");T(this,"camera");T(this,"controls");T(this,"ambLight");T(this,"dirLight");T(this,"auxDirLight");T(this,"clouds",null);T(this,"container");T(this,"_clock",new m.Clock);T(this,"stats");T(this,"_animationCallbacks",new Set);T(this,"_fogFactor",1);T(this,"_sceneSize",5e4*2);T(this,"gorund");T(this,"map");T(this,"centerPostion");T(this,"_isInteracting",!1);T(this,"debug",!1);T(this,"flyTween",null);T(this,"calculateCameraPosition",(e,n,i,s)=>{const l=new m.Vector3(0,n*Math.cos(i),n*Math.sin(i));return l.applyAxisAngle(new m.Vector3(0,1,0),s),new m.Vector3(e.x+l.x,e.y+l.y,e.z+l.z)});const{antialias:i=!1,stencil:s=!0,logarithmicDepthBuffer:l=!0,skybox:u,map:c}=n;this.map=c,this.centerPostion=this.map.geo2world(new m.Vector3(this.map.center[0],this.map.center[1],0)),this.renderer=this._createRenderer(i,s,l),this.scene=this._createScene(u),this.camera=this._createCamera(),e&&this.addTo(e),this.controls=this._createControls(),this.ambLight=this._createAmbLight(),this.scene.add(this.ambLight),this.dirLight=this._createDirLight(),this.scene.add(this.dirLight),this.scene.add(this.dirLight.target),this.auxDirLight=this._createAuxDirLight(),this.gorund=this._createGorund(),this.scene.add(this.gorund),this.renderer.setAnimationLoop(this.animate.bind(this)),this.debug=n.debug||!1,this.flyTween=null,this.debug&&(this.stats=new Vi,document.body.appendChild(this.stats.dom))}get fogFactor(){return this._fogFactor}get isInteracting(){return this._isInteracting}set fogFactor(e){this._fogFactor=e,this.controls.dispatchEvent({type:"change",target:this.controls})}get width(){return this.container?.clientWidth||0}get height(){return this.container?.clientHeight||0}addTo(e){const n=typeof e=="string"?document.querySelector(e):e;if(n instanceof HTMLElement)this.container=n,n.appendChild(this.renderer.domElement),new ResizeObserver(this.resize.bind(this)).observe(n);else throw`${e} not found!}`;return this}_createScene(e){const n=new m.Scene,i=e?.defaultColor||"rgb(21,48,94)";if(n.background=new m.Color(i),n.fog=new m.FogExp2(i,2e-4),e?.files){const s=new m.CubeTextureLoader;e.path&&s.setPath(e.path),s.load(e.files,l=>{n.background=l},void 0,l=>{console.error("Error loading skybox:",l),n.background=new m.Color(i)})}else e?.hdr&&this._loadHDRWithPMREM(n,e);return n}async _loadHDRWithPMREM(e,n){try{if(n){const s=await new hf().setPath(n.path||"").setDataType(m.FloatType).loadAsync(n.hdr);s.colorSpace=this.renderer.outputColorSpace,s.mapping=303,s.needsUpdate=!0,e.background=s,e.environment=s}}catch(i){console.error("加载HDR失败:",i),e.background=new m.Color(n?.defaultColor||14414079)}}_createRenderer(e,n,i){const s=new m.WebGLRenderer({antialias:e,logarithmicDepthBuffer:i,stencil:n,alpha:!0,precision:"highp",powerPreference:"high-performance",failIfMajorPerformanceCaveat:!0});return s.debug.checkShaderErrors=!0,s.sortObjects=!0,s.setPixelRatio(window.devicePixelRatio),s.domElement.tabIndex=0,s.shadowMap.enabled=!0,s.shadowMap.needsUpdate=!0,s.shadowMap.type=m.PCFSoftShadowMap,s.toneMapping=m.ACESFilmicToneMapping,s.toneMappingExposure=1,s}_createCamera(){return new m.PerspectiveCamera(45,this.getAspect(),.1,this._sceneSize*2)}_createControls(){const e=new ld(this.camera,this.renderer.domElement),n=Math.PI/2.1;return e.screenSpacePanning=!1,e.minDistance=.1,e.maxDistance=3e4*2,e.maxPolarAngle=n,e.enableDamping=!0,e.dampingFactor=.08,e.keyPanSpeed=1,e.listenToKeyEvents(this.renderer.domElement),e.addEventListener("change",()=>{const i=Math.max(e.getPolarAngle(),.1),s=Math.max(e.getDistance(),100);e.zoomSpeed=Math.max(Math.log(s/1e3),1)+3;const l=3e5*2;e.maxDistance>l*.95&&(e.maxDistance=l*.95),this.camera.far=m.MathUtils.clamp(s/i*8,100,l),this.camera.near=m.MathUtils.clamp(this.camera.far/1e3,.001,1),this.camera.updateProjectionMatrix(),this.scene.fog instanceof m.FogExp2&&(this.scene.fog.density=i/(s+5)*this.fogFactor*.1);const c=s>6e4;e.minAzimuthAngle=c?0:-1/0,e.maxAzimuthAngle=c?0:1/0,e.maxPolarAngle=wf(e.getDistance(),0,7e4,n,0),this.map?.trigger("control-change",{type:"control-change",control:e,camera:this.camera,target:this.map})}),e.addEventListener("start",()=>{this._isInteracting=!0,this.map?.trigger("control-start",{type:"control-start",control:e,camera:this.camera,target:this.map})}),e.addEventListener("end",()=>{this._isInteracting=!1,this.map?.trigger("control-end",{type:"control-end",control:e,camera:this.camera,target:this.map})}),e}_createAmbLight(){return new m.AmbientLight(16777215,.1)}_createDirLight(){const y=new m.DirectionalLight("rgb(255, 255, 255)",3);y.position.set(this.centerPostion.x+55e3*1.2,55e3*2,this.centerPostion.z+55e3*1);const v=new m.Object3D;if(v.position.copy(this.centerPostion),this.scene.add(v),y.target=v,y.castShadow=!0,y.shadow.mapSize.width=1024*10,y.shadow.mapSize.height=1024*10,y.shadow.camera.near=1,y.shadow.camera.far=192500,y.shadow.camera.left=-55e3,y.shadow.camera.bottom=-55e3,y.shadow.camera.top=55e3,y.shadow.camera.right=55e3,y.shadow.radius=1,y.shadow.bias=-0,this.debug){const x=new m.CameraHelper(y.shadow.camera);x.name="dirLightCameraHelper",this.scene.add(x)}return y}_createAuxDirLight(){const u=this._createAuxLightInstance(this.centerPostion.x+-66e3,82500,this.centerPostion.z+-55e3,.5);u.name="AuxDirLight_BackFill",this.scene.add(u),this.scene.add(u.target);const f=this._createAuxLightInstance(this.centerPostion.x+55e3*-1,55e3*1.5,this.centerPostion.z+55e3*1.2,.5);f.name="AuxDirLight_LeftRim",this.scene.add(f),this.scene.add(f.target);const S=this._createAuxLightInstance(this.centerPostion.x+55e3*1,55e3*1.5,this.centerPostion.z+55e3*-1.2,.5);return S.name="AuxDirLight_RightRim",this.scene.add(S),this.scene.add(S.target),u}_createAuxLightInstance(e,n,i,s){const l=new m.DirectionalLight(16777215,s);l.position.set(e,n,i);const u=new m.Object3D;return u.position.copy(this.centerPostion),this.scene.add(u),l.target=u,l.castShadow=!1,l}resize(){const e=this.width,n=this.height;return this.renderer.setSize(e,n),this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this}addAnimationCallback(e){return this._animationCallbacks.add(e),()=>this._animationCallbacks.delete(e)}animate(){const e=this._clock.getDelta(),n=this._clock.getElapsedTime();this._animationCallbacks.forEach(i=>i(e,n,this)),this.controls.update(),this.renderer.render(this.scene,this.camera),vf(),this.stats&&this.stats.update(),this.dispatchEvent({type:"update",delta:e})}flyTo(e,n,i=!0,s){if(this.controls.target.copy(e),i){const l=this.camera.position;new Mr(l).to({y:2e7,z:0},500).chain(new Mr(l).to(n,2e3).easing(Sn.Quintic.Out).onComplete(u=>s&&s(u))).start()}else this.camera.position.copy(n)}flyToAdvanced(e){const n=this.camera,i=this.controls,s=e.center,l=e.cameraCoord,u=e.duration??2e3,c=e.delay??0,d=e.complete,p=!!e.curvePath;if(!s||!l)return;const f=this.map.geo2world(new m.Vector3(s[0],s[1],0)),y=this.map.geo2world(new m.Vector3(l[0],l[1],l[2]));if(!n||!i||!f||!y)return;const v=i.target.clone(),x=n.position.clone(),S=new m.Vector3(f.x,f.y,f.z),_=new m.Vector3(y.x,y.y,y.z);if(this.flyTween&&(this.flyTween.stop(),this.flyTween=null),p){const Z=[x,x.clone().lerp(_,.33),x.clone().lerp(_,.67),_],M=new m.CubicBezierCurve3(...Z),G={t:0,x:v.x,y:v.y,z:v.z};this.flyTween=new Mr(G).to({t:1,x:S.x,y:S.y,z:S.z},u).easing(Sn.Quadratic.InOut).onUpdate(()=>{const A=M.getPoint(G.t),R=new m.Vector3(G.x,G.y,G.z);n.position.copy(A),n.lookAt(R),n.updateProjectionMatrix(),i.target.copy(R),i.update()})}else{const Z={tx:v.x,ty:v.y,tz:v.z,px:x.x,py:x.y,pz:x.z};this.flyTween=new Mr(Z).to({tx:S.x,ty:S.y,tz:S.z,px:_.x,py:_.y,pz:_.z},u).easing(Sn.Quadratic.InOut).onUpdate(()=>{const M=new m.Vector3(Z.tx,Z.ty,Z.tz),G=new m.Vector3(Z.px,Z.py,Z.pz);n.position.copy(G),n.lookAt(M),i.target.copy(M),i.update()})}this.flyTween&&(this.flyTween.onComplete(()=>{this.flyTween&&(this.flyTween.stop(),this.flyTween=null),d&&d()}),c>0?setTimeout(()=>{this.flyTween&&this.flyTween.start()},c):this.flyTween.start())}flyToPoint(e){const{controls:n}=this,i=e.center,s=e.duration??2e3,l=typeof e.distance=="number"?e.distance:typeof e.altitude=="number"?e.altitude:n.getDistance(),u=S=>S*Math.PI/180,c=typeof e.polarDeg=="number"?u(e.polarDeg):e.polarAngle||n.getPolarAngle(),d=typeof e.azimuthDeg=="number"?u(e.azimuthDeg):e.azimuthAngle||n.getAzimuthalAngle(),p=e.complete,f=!!e.curvePath,y=this.map.geo2world(new m.Vector3(i[0],i[1],0)),v=this.calculateCameraPosition(y,l,c,d),x=this.map.world2geo(v);this.flyToAdvanced({center:[i[0],i[1],0],cameraCoord:[x.x,x.y,x.z||0],duration:s,complete:p,curvePath:f})}getState(){return{centerPosition:this.controls.target,cameraPosition:this.camera.position}}_bindMap(e){e&&(this.map=e)}getMap(){return this.map?this.map:null}getAspect(){const[e,n]=this.getWidthHeight();return e/n}getWidthHeight(){let e=window.innerWidth,n=window.innerHeight;return[e,n]}_createGorund(){const e=this.centerPostion,n=new m.MeshStandardMaterial({transparent:!1,color:new m.Color("rgb(45,52,60)").multiplyScalar(.7),metalness:.2,roughness:1}),i=new m.PlaneGeometry(this._sceneSize*2,this._sceneSize*2),s=new m.Mesh(i,n);return s.name="地面",s.castShadow=!1,s.receiveShadow=!1,s.position.y=0,s.position.add(e),s.rotateX(-Math.PI/2),s.visible=!1,s}}var ki=(a=>(a[a.none=0]="none",a[a.create=1]="create",a[a.remove=2]="remove",a))(ki||{});function xf(a,t){const e=a.position.clone().setZ(a.maxZ).applyMatrix4(a.matrixWorld);return t.distanceTo(e)}function bf(a){const t=a.scale,e=new m.Vector3(-t.x,-t.y,0).applyMatrix4(a.matrixWorld),n=new m.Vector3(t.x,t.y,0).applyMatrix4(a.matrixWorld);return e.sub(n).length()}function _f(a){return a.distToCamera/a.sizeInWorld*.8}function Mf(a,t,e,n){const i=_f(a);if(a.isLeaf){if(a.inFrustum&&a.z<e&&(a.z<t||a.showing)&&(a.z<t||i<n))return 1}else if(a.z>=t&&(a.z>e||i>n))return 2;return 0}function Lf(a,t,e,n){const i=[],s=n+1,l=t*2,u=0,c=.25;{const d=e*2,p=new m.Vector3(.5,.5,1),f=new nn(l,d,s),y=new nn(l+1,d,s),v=new nn(l,d+1,s),x=new nn(l+1,d+1,s);f.position.set(-c,c,u),f.scale.copy(p),y.position.set(c,c,u),y.scale.copy(p),v.position.set(-c,-c,u),v.scale.copy(p),x.position.set(c,-c,u),x.scale.copy(p),i.push(f,y,v,x)}return i}const Sf=10,Tf=new m.InstancedBufferGeometry,Zf=new m.Vector3,Gf=new m.Matrix4,Wf=new m.Box3(new m.Vector3(-.5,-.5,0),new m.Vector3(.5,.5,1)),yl=new m.Frustum,jn=class jn extends m.Mesh{constructor(e=0,n=0,i=0){super(Tf,[]);T(this,"_dataOnlyMode",!1);T(this,"vectorData",null);T(this,"x");T(this,"y");T(this,"z");T(this,"isTile",!0);T(this,"parent",null);T(this,"children",[]);T(this,"_ready",!1);T(this,"_isDummy",!1);T(this,"_showing",!1);T(this,"_maxZ",0);T(this,"distToCamera",0);T(this,"sizeInWorld",0);T(this,"_loaded",!1);T(this,"_inFrustum",!1);this.x=e,this.y=n,this.z=i,this.name=`Tile ${i}-${e}-${n}`,this.up.set(0,0,1),this.matrixAutoUpdate=!1}setDataOnlyMode(e){return this._dataOnlyMode=e,e&&(this.visible=!1),this}isDataOnlyMode(){return this._dataOnlyMode}getVectorData(){return this.vectorData}static get downloadThreads(){return jn._downloadThreads}get isDummy(){return this._isDummy}get showing(){return this._showing}set showing(e){const n=this._showing;this._showing=e,this.material.forEach(i=>i.visible=e),n===!1&&this._showing===!0&&this._loaded&&this.dispatchEvent({type:"tile-shown",tile:this}),n===!0&&this._showing===!1&&this.dispatchEvent({type:"tile-hidden",tile:this})}get maxZ(){return this._maxZ}set maxZ(e){this._maxZ=e}get index(){return this.parent?this.parent.children.indexOf(this):-1}get loaded(){return this._loaded}get inFrustum(){return this._inFrustum}set inFrustum(e){this._inFrustum=e}get isLeaf(){return this.children.filter(e=>e.isTile).length===0}traverse(e){e(this),this.children.forEach(n=>{n.isTile&&n.traverse(e)})}traverseVisible(e){this.visible&&(e(this),this.children.forEach(n=>{n.isTile&&n.traverseVisible(e)}))}raycast(e,n){this.showing&&this.loaded&&this.isTile&&super.raycast(e,n)}LOD(e){if(jn.downloadThreads>Sf)return{action:ki.none};let n=[];const{loader:i,minLevel:s,maxLevel:l,LODThreshold:u}=e,c=Mf(this,s,l,u);return c===ki.create&&(n=Lf(i,this.x,this.y,this.z),this.add(...n)),{action:c,newTiles:n}}_checkVisible(){const e=this.parent;if(e&&e.isTile){const n=e.children.filter(s=>s.isTile),i=n.every(s=>s.loaded);e.showing=!i,n.forEach(s=>s.showing=i)}return this}async _load(e){jn._downloadThreads++;const{x:n,y:i,z:s}=this;if(this._dataOnlyMode)try{const l=await e.load({x:n,y:i,z:s,bounds:[-1/0,-1/0,1/0,1/0]});this.vectorData=l.geometry?.userData||{},this._loaded=!0,this.dispatchEvent({type:"vector-data-loaded",data:this.vectorData,tile:this})}catch(l){console.error(`数据模式加载失败 ${s}/${n}/${i}:`,l),this._loaded=!1}else{const l=await e.load({x:n,y:i,z:s,bounds:[-1/0,-1/0,1/0,1/0]});this.material=l.materials,this.geometry=l.geometry,this.maxZ=this.geometry.boundingBox?.max.z||0,this._loaded=!0}return jn._downloadThreads--,this}_init(){this.updateMatrix(),this.updateMatrixWorld(),this.sizeInWorld=bf(this)}update(e){if(console.assert(this.z===0),!this.parent)return this;yl.setFromProjectionMatrix(Gf.multiplyMatrices(e.camera.projectionMatrix,e.camera.matrixWorldInverse));const n=e.camera.getWorldPosition(Zf);return this.traverse(i=>{i.receiveShadow=this.receiveShadow,i.castShadow=this.castShadow;const s=Wf.clone().applyMatrix4(i.matrixWorld);s.max.setY(9e3),i.inFrustum=yl.intersectsBox(s),i.distToCamera=xf(i,n);const{action:l,newTiles:u}=i.LOD(e);this._doAction(i,l,u,e)}),this._checkReady(),this}_doAction(e,n,i,s){return n===ki.create?i?.forEach(l=>{l._init(),l._isDummy=l.z<s.minLevel,this.dispatchEvent({type:"tile-created",tile:l}),l.isDummy||l._load(s.loader).then(()=>{l._checkVisible(),this.dispatchEvent({type:"tile-loaded",tile:l})})}):n===ki.remove&&(e.showing=!0,e._unLoad(!1,s.loader),this.dispatchEvent({type:"tile-unload",tile:e})),this}reload(e){return this._unLoad(!0,e),this}_checkReady(){return this._ready||(this._ready=!0,this.traverse(e=>{if(e.isLeaf&&e.loaded&&!e.isDummy){this._ready=!1;return}}),this._ready&&this.dispatchEvent({type:"ready"})),this}_unLoad(e,n){return e&&this.isTile&&!this.isDummy&&(this.dispatchEvent({type:"unload"}),n?.unload?.(this)),this.children.forEach(i=>i._unLoad(!0,n)),this.clear(),this}};T(jn,"_downloadThreads",0);let nn=jn;class vl{constructor(t=0){T(this,"_lon0",0);this._lon0=t}get lon0(){return this._lon0}getTileXWithCenterLon(t,e){const n=Math.pow(2,e);let i=t+Math.round(n/360*this._lon0);return i>=n?i-=n:i<0&&(i+=n),i}getTileXYZproj(t,e,n){const i=this.mapWidth,s=this.mapHeight/2,l=t/Math.pow(2,n)*i-i/2,u=s-e/Math.pow(2,n)*s*2;return{x:l,y:u}}getProjBoundsFromLonLat(t){const e=t[0]===-180&&t[2]===180,n=this.project(t[0]+(e?this._lon0:0),t[1]),i=this.project(t[2]+(e?this._lon0:0),t[3]);return[Math.min(n.x,i.x),Math.min(n.y,i.y),Math.max(n.x,i.x),Math.max(n.y,i.y)]}getProjBoundsFromXYZ(t,e,n){const i=this.getTileXYZproj(t,e,n),s=this.getTileXYZproj(t+1,e+1,n);return[Math.min(i.x,s.x),Math.min(i.y,s.y),Math.max(i.x,s.x),Math.max(i.y,s.y)]}getLonLatBoundsFromXYZ(t,e,n){const i=this.getProjBoundsFromXYZ(t,e,n),s=this.unProject(i[0],i[1]),l=this.unProject(i[2],i[3]);return[s.lon,s.lat,l.lon,l.lat]}}const Oi=6378e3;class wl extends vl{constructor(){super(...arguments);T(this,"ID","3857");T(this,"mapWidth",2*Math.PI*Oi);T(this,"mapHeight",this.mapWidth);T(this,"mapDepth",1)}project(e,n){const i=(e-this.lon0)*(Math.PI/180),s=n*(Math.PI/180),l=Oi*i,u=Oi*Math.log(Math.tan(Math.PI/4+s/2));return{x:l,y:u}}unProject(e,n){let i=e/Oi*(180/Math.PI)+this.lon0;return i>180&&(i-=360),{lat:(2*Math.atan(Math.exp(n/Oi))-Math.PI/2)*(180/Math.PI),lon:i}}}class Pf extends vl{constructor(){super(...arguments);T(this,"ID","4326");T(this,"mapWidth",36e3);T(this,"mapHeight",18e3);T(this,"mapDepth",1)}project(e,n){return{x:(e-this.lon0)*100,y:n*100}}unProject(e,n){return{lon:e/100+this.lon0,lat:n/100}}}const If={createFromID:(a="3857",t)=>{let e;switch(a){case"3857":e=new wl(t);break;case"4326":e=new Pf(t);break;default:throw new Error(`Projection ID: ${a} is not supported.`)}return e}};function Js(a,t){const e=a.getLayers().find(i=>i.isBaseLayer===!0)?._rootTile,n=t.intersectObjects([e]);for(const i of n)if(i.object instanceof nn){const s=a.worldToLocal(i.point.clone()),l=a.map2geo(s);return Object.assign(i,{location:l})}}function Qs(a,t){const e=new m.Vector3(0,-1,0),n=new m.Vector3(t.x,10*1e3,t.z),i=new m.Raycaster(n,e);return Js(a,i)}function xl(a,t,e){const n=new m.Raycaster;return n.setFromCamera(e,a),Js(t,n)}function Cf(a,t=128){const e=document.createElement("canvas"),n=e.getContext("2d");if(!n)throw new Error("Failed to get canvas context");e.width=t,e.height=t;const i=t/2,s=t/2;return n.imageSmoothingEnabled=!1,n.fillStyle="#000022",n.strokeStyle="DarkGoldenrod",n.lineWidth=5,n.moveTo(i,3),n.lineTo(i,t),n.stroke(),n.closePath(),n.lineWidth=2,n.beginPath(),n.roundRect(2,2,t-4,s-8,10),n.closePath(),n.fill(),n.stroke(),n.font="24px Arial",n.fillStyle="Goldenrod",n.strokeStyle="black",n.textAlign="center",n.textBaseline="top",n.strokeText(a,i,20),n.fillText(a,i,20),e}function Vf(a,t=128){const e=new m.CanvasTexture(Cf(a,t)),n=new m.SpriteMaterial({map:e,sizeAttenuation:!1}),i=new m.Sprite(n);return i.visible=!1,i.center.set(.5,.3),i.scale.setScalar(.11),i.renderOrder=999,i}class Lr extends m.Mesh{constructor(e){super();T(this,"name","map");T(this,"_clock",new m.Clock);T(this,"isLOD",!0);T(this,"autoUpdate",!0);T(this,"updateInterval",100);T(this,"_minLevel",2);T(this,"_layers",new Map);T(this,"_maxLevel",24);T(this,"_projection",new wl(0));T(this,"_LODThreshold",1);this.up.set(0,0,1);const{minLevel:n=2,maxLevel:i=19}=e;this.minLevel=n,this.maxLevel=i}get minLevel(){return this._minLevel}set minLevel(e){this._minLevel=e}get maxLevel(){return this._maxLevel}set maxLevel(e){this._maxLevel=e}get lon0(){return this.projection.lon0}get projection(){return this._projection}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}static create(e){return new Lr(e)}update(e){if(!this.autoUpdate)return;const n=this._clock.getElapsedTime();n>this.updateInterval/1e3&&(this._layers.forEach(i=>{i.enabled&&i.visible&&i.update(e)}),this._clock.start(),this.dispatchEvent({type:"update",delta:n}))}dispose(){this.removeFromParent()}geo2pos(e){return this.geo2map(e)}geo2map(e){const n=this.projection.project(e.x,e.y);return new m.Vector3(n.x,n.y,e.z)}geo2world(e){return this.localToWorld(this.geo2map(e))}pos2geo(e){return this.map2geo(e)}map2geo(e){const n=this.projection.unProject(e.x,e.y);return new m.Vector3(n.lon,n.lat,e.z)}world2geo(e){return this.pos2geo(this.worldToLocal(e.clone()))}getLocalInfoFromGeo(e){const n=this.geo2world(e);return Qs(this,n)}getLocalInfoFromWorld(e){return Qs(this,e)}getLocalInfoFromScreen(e,n){return xl(e,this,n)}get downloading(){return nn.downloadThreads}addLayer(e){return this._layers.has(e.layerId)&&console.warn(`图层 ${e.layerid} 已存在,将被替换`),this._layers.set(e.layerId,e),this.add(e),this}removeLayer(e){const n=this._layers.get(e);return n?(this._layers.delete(e),this.remove(n),n.dispose(),console.log(`✅ 图层 ${e} 移除成功`),!0):(console.warn(`⚠️ 图层 ${e} 不存在`),!1)}getLayer(e){return this._layers.get(e)}getLayerIds(){return Array.from(this._layers.keys())}clearLayers(){return this._layers.forEach(e=>{this.remove(e),e.dispose()}),this._layers.clear(),console.log("✅ 所有图层已清空"),this}getLayers(){return Array.from(this._layers.values())}getApproxZoomLevel(){let e=this.minLevel;const n=this.getLayers().find(s=>s.isBaseLayer===!0);return!n||!n._rootTile||n._rootTile.traverseVisible(s=>{s.showing&&s.inFrustum&&(e=Math.max(e,s.z))}),e}getDataZoom(){let e=this.minLevel;const n=this.getLayers().find(s=>s.isBaseLayer===!0);return!n||!n._rootTile||n._rootTile.traverseVisible(s=>{s.showing&&s.inFrustum&&(e=Math.max(e,s.z))}),e}}class Hs{constructor(){T(this,"_dispatcher",new m.EventDispatcher);T(this,"_listenerMap",new Map)}on(t,e){const n=i=>e(i.data||i);return this._listenerMap.has(t)||this._listenerMap.set(t,new Map),this._listenerMap.get(t).set(e,n),this._dispatcher.addEventListener(t,n),this}once(t,e){const n=i=>{this.off(t,n),e(i.data||i)};return this.on(t,n)}off(t,e){const n=this._listenerMap.get(t);if(!n)return this;const i=n.get(e);return i&&(this._dispatcher.removeEventListener(t,i),n.delete(e),n.size===0&&this._listenerMap.delete(t)),this}trigger(t,e){const n={type:t,data:e};return this._dispatcher.dispatchEvent(n),this}get threeEventDispatcher(){return this._dispatcher}}function Af(a,t){return a.replace(/\{(\w+)\}/g,(e,n)=>{if(t.hasOwnProperty(n)){const i=t[n];return i!==void 0?String(i):e}throw new Error(`缺少必要参数: ${n}`)})}function Es(a,...t){for(let e=0;e<t.length;e++){const n=t[e];for(const i in n)a[i]=n[i]}return a}function Sr(a){return a==null}function Ri(a){return Sr(a)?!1:typeof a=="function"||a.constructor!==null&&a.constructor===Function}function Ff(a=new Date){const t=a.getFullYear().toString(),e=(a.getMonth()+1).toString().padStart(2,"0"),n=a.getDate().toString().padStart(2,"0"),i=a.getHours().toString().padStart(2,"0"),s=a.getMinutes().toString().padStart(2,"0"),l=a.getSeconds().toString().padStart(2,"0");return`${t}-${e}-${n} ${i}:${s}:${l}`}class Xf{}class bl extends Yi(Ui(Xf)){constructor(e){super();T(this,"target");T(this,"dom");T(this,"_enabled",!1);this.target=e}enable(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)}disable(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this}enabled(){return!!this._enabled}remove(){this.disable(),delete this.target,delete this.dom}}const _l=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]"&&!process.versions.electron&&!process.versions.nw&&!process.versions["node-webkit"];let Ki={};function Ml(){return window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI}if(!_l){const a=navigator.userAgent.toLowerCase(),t=document.documentElement||{style:{}},e="ActiveXObject"in window,n=a.indexOf("webkit")!==-1,i=a.indexOf("phantom")!==-1,s=a.search("android [23]")!==-1,l=a.indexOf("chrome")!==-1,u=a.indexOf("gecko")!==-1&&!n&&!("opera"in window)&&!e,c=/iphone/i.test(a)&&/micromessenger/i.test(a),d=typeof orientation<"u"||a.indexOf("mobile")!==-1,p=!window.PointerEvent&&"MSPointerEvent"in window,f=window.PointerEvent&&navigator.pointerEnabled||p,y=e&&"transition"in t.style,v="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!s,x="MozPerspective"in t.style,S="OTransition"in t.style,_=(y||v||x)&&!S&&!i,Z=typeof window<"u"&&Ri(window.createImageBitmap),M=typeof window<"u"&&Ri(window.ResizeObserver),G=typeof window<"u"&&Ri(window.btoa),A=typeof window<"u"&&Ri(window.Proxy),R=typeof window<"u"&&Ri(window.requestIdleCallback);let D=0;if(l){const N=a.match(/chrome\/([\d.]+)/);D=N?N[1]:0}const k=!i&&(f||"ontouchstart"in window||"DocumentTouch"in window&&document instanceof window.DocumentTouch),C=typeof window<"u"&&"WebGLRenderingContext"in window,K=Ml();let I=!1;try{new OffscreenCanvas(2,2).getContext("2d"),I=!0}catch{I=!1}let z=!1;try{window.addEventListener("testPassive",()=>{},{get passive(){return z=!0,!0}})}catch{}Ki={IS_NODE:_l,isTest:!1,ie:e,ielt9:e&&!document.addEventListener,edge:"msLaunchUri"in navigator&&!("documentMode"in document),webkit:n,gecko:u,android:a.indexOf("android")!==-1,android23:s,chrome:l,chromeVersion:D,safari:!l&&a.indexOf("safari")!==-1,phantomjs:i,ie3d:y,webkit3d:v,gecko3d:x,opera12:S,any3d:_,iosWeixin:c,mobile:d,mobileWebkit:d&&n,mobileWebkit3d:d&&v,mobileOpera:d&&"opera"in window,mobileGecko:d&&u,touch:!!k,msPointer:!!p,pointer:!!f,retina:K>1,devicePixelRatio:K,language:navigator.browserLanguage?navigator.browserLanguage:navigator.language,ie9:e&&document.documentMode===9,ie10:e&&document.documentMode===10,webgl:C,imageBitMap:Z,resizeObserver:M,btoa:G,decodeImageInWorker:I,monitorDPRChange:!0,supportsPassive:z,proxy:A,requestIdleCallback:R,checkDevicePixelRatio:()=>{if(typeof window<"u"&&Ki.monitorDPRChange){const N=Ml(),H=N!==Ki.devicePixelRatio;return H&&(Ki.devicePixelRatio=N),H}return!1}}}const zf=Ki;function Yi(a){return class extends a{constructor(...e){super(...e);T(this,"eventClass",new Hs);T(this,"on",this.eventClass.on.bind(this.eventClass));T(this,"trigger",this.eventClass.trigger.bind(this.eventClass));T(this,"off",this.eventClass.off.bind(this.eventClass));this.eventClass=new Hs}}}function Ui(a){return class extends a{constructor(...e){super(...e);T(this,"options");T(this,"_isUpdatingOptions");T(this,"_initHooksCalled");T(this,"_initHooks");const n=Object.getPrototypeOf(this).options||{},i=Es({},n,e[0]||{});this.setOptions(i),this.callInitHooks(),this._isUpdatingOptions=!1}proxyOptions(){return zf.proxy?(this.options=new Proxy(this.options,{set:(e,n,i)=>{if(n=n,e[n]===i||(e[n]=i,this._isUpdatingOptions))return!0;const s={};return s[n]=i,this.config(s),!0}}),this):this}callInitHooks(){const e=Object.getPrototypeOf(this);return this._visitInitHooks(e),this}setOptions(e){if((!this.hasOwnProperty("options")||Sr(this.options))&&(this.options=this.options?Object.create(this.options):{}),!e)return this;for(const n in e)this.options[n]=e[n];return this}config(e,n){if(this._isUpdatingOptions=!0,e){if(arguments.length===2&&typeof e=="string"){const i={};i[e]=n,e=i}e=e;for(const i in e)this.options[i]=e[i],this[i]&&this[i]instanceof bl&&(e[i]?this[i].enable():this[i].disable());this.onConfig(e),this._isUpdatingOptions=!1}else{const i={};for(const s in this.options)this.options.hasOwnProperty(s)&&(i[s]=this.options[s]);return this._isUpdatingOptions=!1,i}return this}onConfig(e){}_visitInitHooks(e){if(this._initHooksCalled)return;const n=Object.getPrototypeOf(e);n._visitInitHooks&&n._visitInitHooks.call(this,n),this._initHooksCalled=!0;const i=e._initHooks;if(i&&i!==n._initHooks)for(let s=0;s<i.length;s++)i[s].call(this)}static mergeOptions(e){const n=this.prototype,i=Object.getPrototypeOf(n);return n.hasOwnProperty("options")?n.options===i.options&&(n.options=Object.create(n.options)):n.options={},Es(n.options,e),this}static addInitHook(e,...n){const i=typeof e=="function"?e:function(){this[e].apply(this,n)},s=this.prototype,l=Object.getPrototypeOf(s);return(!s._initHooks||s._initHooks===l._initHooks)&&(s._initHooks=[]),s._initHooks.push(i),this}static include(...e){for(let n=0;n<e.length;n++)Es(this.prototype,e[n]);return this}}}function qs(a){return class extends a{constructor(...n){super(...n);T(this,"_handlers");this._handlers=[]}addHandler(n,i){if(!i)return this;if(this._handlers||(this._handlers=[]),this[n])return this[n].enable(),this;const s=this[n]=new i(this);return this._handlers.push(s),this.options[n]&&s.enable(),this}removeHandler(n){if(!n)return this;const i=this[n];if(i&&this._handlers){const s=this._handlers.indexOf(i);s>=0&&this._handlers.splice(s,1),this[n].remove(),delete this[n]}return this}_clearHandlers(){if(this._handlers){for(let n=0,i=this._handlers.length;n<i;n++)this._handlers[n].remove();this._handlers=[]}}}}const Df={attribution:"",visible:!0,opacity:1,zIndex:0,isSceneLayer:!1,altitude:0};class Tr extends qs(Yi(Ui(m.Group))){constructor(e,n){super();T(this,"_id");T(this,"opacity",1);T(this,"_animationCallbacks",new Set);T(this,"isSceneLayer",!1);T(this,"_altitude",0);T(this,"depthOffset");T(this,"_regionOverlays",[]);js(e,"id","图层ID必须指定"),n&&(this.setOptions(n),this.opacity=n.opacity||1,this.isSceneLayer=n.isSceneLayer??!1,n.altitude!==void 0&&this.setAltitude(n.altitude)),this._id=e,typeof this.animate=="function"&&this._registerAnimate()}getId(){return this._id}addTo(e){return e.addLayer(this),this}getZIndex(){const e=this.options||{};return typeof e.zIndex=="number"?e.zIndex:0}getDepthOffset(){const e=this.options||{};return typeof e.depthOffset=="number"?e.depthOffset:0}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e,this.traverse(n=>{"material"in n&&(Array.isArray(n.material)?n.material:[n.material]).forEach(s=>{"opacity"in s&&(s.transparent=e<1,s.opacity=e,s.needsUpdate=!0)}),n instanceof m.Sprite&&(n.material.opacity=e,n.material.transparent=e<1,n.material.needsUpdate=!0)})}getMap(){return this.map?this.map:null}show(){return this.visible||(this.visible=!0,this.options.visible=!0,this.getMap()),this}hide(){return this.visible&&(this.visible=!1,this.options.visible=!1,this.getMap()),this}setAltitude(e){return this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0),this}getAltitude(){return this.position.y}_bindMap(e){e&&(this.map=e,typeof this.animate=="function"&&this._registerAnimate())}_registerAnimate(){const e=this.getMap();if(!e?.viewer)return;const n=e.viewer.addAnimationCallback((i,s,l)=>{this.animate?.(i,s,l)});this._animationCallbacks.add(n)}_clearAnimationCallbacks(){this._animationCallbacks.forEach(e=>e()),this._animationCallbacks.clear()}getOptions(){return{...this.options}}setRegionOverlays(e){return this._regionOverlays=(e||[]).map(n=>({id:n.id??this._generateRegionOverlayId(),color:n.color??"#00FF88",opacity:n.opacity??.3,mode:n.mode??"overlay",zIndex:n.zIndex??0,geometry:n.geometry,feature:n.feature})),this}addRegionOverlay(e){const n=e.id??this._generateRegionOverlayId(),i={id:n,color:e.color??"#00FF88",opacity:e.opacity??.3,mode:e.mode??"overlay",zIndex:e.zIndex??0,geometry:e.geometry,feature:e.feature};return this._regionOverlays.push(i),n}removeRegionOverlay(e){return this._regionOverlays=this._regionOverlays.filter(n=>n.id!==e),this}clearRegionOverlays(){return this._regionOverlays=[],this}getRegionOverlays(){return this._regionOverlays.slice()}_generateRegionOverlayId(){return`region-overlay-${Date.now()}-${Math.random().toString(16).slice(2)}`}}Tr.mergeOptions(Df);const Xr=class Xr{constructor(t){T(this,"_cache",new Map);T(this,"_gltfLoader");T(this,"_fbxLoader");T(this,"_dracoLoader");this._gltfLoader=new ud(t),this._fbxLoader=new qd(t)}static init(t){return this._instance||(this._instance=new Xr(t)),this._instance}async load(t){const e=`${t.type}:${t.url}`;if(this._cache.has(e))return this._cloneCachedModel(e,t);t.type==="gltf"&&t.dracoOptions?.enable&&this._initDracoLoader(t.dracoOptions.decoderPath);let n,i;try{if(t.type==="gltf"){const s=await this._gltfLoader.loadAsync(t.url);n=s.scene,i=s.animations}else n=await this._fbxLoader.loadAsync(t.url),i=n.animations;return this._cache.set(e,{model:n,animations:i}),{model:this._processModel(n.clone(),t),animations:i?.map(s=>({...s,name:s.name||"unnamed"}))||[]}}catch(s){throw console.error(`加载${t.type}模型失败:`,t.url,s),s}}_initDracoLoader(t="/draco/"){this._dracoLoader||(this._dracoLoader=new df,this._dracoLoader.setDecoderPath(t),this._gltfLoader.setDRACOLoader(this._dracoLoader))}_cloneCachedModel(t,e){const i=this._cache.get(t).model.clone();return this._processModel(i,e)}_processModel(t,e){return e.position&&t.position.copy(e.position),e.scale&&(typeof e.scale=="number"?t.scale.setScalar(e.scale):e.scale.x!==void 0||e.scale.y!==void 0||e.scale.z!==void 0?(e.scale.x!==void 0&&(t.scale.x=e.scale.x),e.scale.y!==void 0&&(t.scale.y=e.scale.y),e.scale.z!==void 0&&(t.scale.z=e.scale.z)):t.scale.copy(e.scale)),e.rotation&&t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.materialOverrides&&t.traverse(n=>{if(n instanceof m.Mesh&&n.material){const i=e.materialOverrides[n.name];i&&(n.material=i)}}),t.traverse(n=>{n instanceof m.Mesh&&n.material}),t}};T(Xr,"_instance");let $s=Xr;const eo=(a,t)=>{"updateRanges"in a?a.updateRanges[0]=t:a.updateRange=t},Ll=new m.Matrix4,Zr=new m.Vector3,Gr=new m.Quaternion,Sl=new m.Vector3,Tl=new m.Quaternion,Bi=new m.Vector3,kf=a=>class extends a{constructor(){super();const t=parseInt(m.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=e=>{e.vertexShader=`attribute float cloudOpacity;
|
|
511
511
|
varying float vOpacity;
|
|
512
512
|
`+e.vertexShader.replace("#include <fog_vertex>",`#include <fog_vertex>
|
|
513
513
|
vOpacity = cloudOpacity;
|
|
514
514
|
`),e.fragmentShader=`varying float vOpacity;
|
|
515
515
|
`+e.fragmentShader.replace(`#include <${t}>`,`#include <${t}>
|
|
516
516
|
gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);
|
|
517
|
-
`)}}};class
|
|
517
|
+
`)}}};class Of extends m.Group{constructor({limit:t=200,range:e,material:n=m.MeshLambertMaterial,texture:i,frustumCulled:s=!0}={}){super(),this.name="Clouds",this.ref=this;const l=this,u=new m.PlaneGeometry(1,1),c=new Float32Array(Array.from({length:t},()=>1)),d=new Float32Array(Array.from({length:t},()=>[1,1,1]).flat()),p=new m.InstancedBufferAttribute(c,1);p.setUsage(m.DynamicDrawUsage),u.setAttribute("cloudOpacity",p);const f=kf(n),y=new f;y.map=i,y.transparent=!0,y.depthWrite=!1,y.needsUpdate=!0,this.cloudMaterial=y,this.instance=new m.InstancedMesh(u,y,t);const v=this.instance;v.matrixAutoUpdate=!1,v.frustumCulled=s,v.instanceColor=new m.InstancedBufferAttribute(d,3),v.instanceColor.setUsage(m.DynamicDrawUsage),l.add(v);const x=[],S=()=>{const k=x.length;let C=0;for(let K=0;K<this.ref.children.length;K++){const I=this.ref.children[K];I.cloudStateArray&&(C+=I.cloudStateArray.length)}if(k===C)return x;x.length=0;for(let K=0;K<this.ref.children.length;K++){const I=this.ref.children[K];I.cloudStateArray&&x.push(...I.cloudStateArray)}return _(),x},_=()=>{const k=Math.min(t,e!==void 0?e:t,x.length);v.count=k,eo(v.instanceMatrix,{offset:0,count:k*16}),v.instanceColor&&eo(v.instanceColor,{offset:0,count:k*3}),eo(v.geometry.attributes.cloudOpacity,{offset:0,count:k})};let Z=0,M=0,G;const A=new m.Quaternion,R=new m.Vector3(0,0,1),D=new m.Vector3;this.update=(k,C,K)=>{Z=C,Ll.copy(v.matrixWorld).invert(),k.matrixWorld.decompose(Sl,Tl,Bi);const I=S();for(M=0;M<I.length;M++)G=I[M],G.ref.matrixWorld.decompose(Zr,Gr,Bi),Zr.add(D.copy(G.position).applyQuaternion(Gr).multiply(Bi)),Gr.copy(Tl).multiply(A.setFromAxisAngle(R,G.rotation+=K*G.rotationFactor)),Bi.multiplyScalar(G.volume+(1+Math.sin(Z*G.density*G.speed))/2*G.growth),G.matrix.compose(Zr,Gr,Bi).premultiply(Ll),G.dist=Zr.distanceTo(Sl);for(I.sort((z,N)=>N.dist-z.dist),M=0;M<I.length;M++)G=I[M],c[M]=G.opacity*(G.dist<G.fade-1?G.dist/G.fade:1),v.setMatrixAt(M,G.matrix),v.setColorAt(M,G.color);v.geometry.attributes.cloudOpacity.needsUpdate=!0,v.instanceMatrix.needsUpdate=!0,v.instanceColor&&(v.instanceColor.needsUpdate=!0)}}}let Rf=0;class Kf extends m.Group{constructor({opacity:t=1,speed:e=0,bounds:n=new m.Vector3().fromArray([5,1,1]),segments:i=20,color:s=new m.Color("#ffffff"),fade:l=10,volume:u=6,smallestVolume:c=.25,distribute:d=null,growth:p=4,concentrate:f="inside",seed:y=Math.random()}={}){super(),this.name="cloud_"+Rf++,this.seed=y,this.segments=i,this.bounds=n,this.concentrate=f,this.volume=u,this.smallestVolume=c,this.distribute=d,this.growth=p,this.speed=e,this.fade=l,this.opacity=t,this.color=s,this.ref=this,this.cloudStateArray=[],this.updateCloud()}updateCloudStateArray(){if(this.cloudStateArray.length===this.segments)return;const{segments:t,uuid:e}=this;if(this.cloudStateArray.length>this.segments)this.cloudStateArray.splice(0,this.cloudStateArray.length-this.segments);else for(let n=this.cloudStateArray.length;n<t;n++)this.cloudStateArray.push({segments:t,bounds:new m.Vector3(1,1,1),position:new m.Vector3,uuid:e,index:n,ref:this,dist:0,matrix:new m.Matrix4,volume:0,length:0,speed:0,growth:0,opacity:1,fade:0,density:0,rotation:n*(Math.PI/t),rotationFactor:0,color:new m.Color})}updateCloud(){const{volume:t,color:e,speed:n,growth:i,opacity:s,fade:l,bounds:u,seed:c,cloudStateArray:d,distribute:p,segments:f,concentrate:y,smallestVolume:v}=this;this.updateCloudStateArray();let x=0;function S(){const _=Math.sin(c+x)*1e4;return x++,_-Math.floor(_)}d.forEach((_,Z)=>{_.segments=f,_.volume=t,_.color=e,_.speed=n,_.growth=i,_.opacity=s,_.fade=l,_.bounds.copy(u),_.density=Math.max(.5,S()),_.rotationFactor=Math.max(.2,.5*S())*n;const M=p?.(_,Z);if(M||f>1){var G;_.position.copy(_.bounds).multiply((G=M?.point)!==null&&G!==void 0?G:{x:S()*2-1,y:S()*2-1,z:S()*2-1})}const A=Math.abs(_.position.x),R=Math.abs(_.position.y),D=Math.abs(_.position.z),k=Math.max(A,R,D);_.length=1,A===k&&(_.length-=A/_.bounds.x),R===k&&(_.length-=R/_.bounds.y),D===k&&(_.length-=D/_.bounds.z),_.volume=(M?.volume!==void 0?M.volume:Math.max(Math.max(0,v),y==="random"?S():y==="inside"?_.length:1-_.length))*t})}}class to{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t<this.pool;t++)if(!(this.workerStatus&1<<t))return t;return-1}_onMessage(t,e){const n=this.workersResolve[t];if(n&&n(e),this.queue.length){const{resolve:i,msg:s,transfer:l}=this.queue.shift();this.workersResolve[t]=i,this.workers[t].postMessage(s,l)}else this.workerStatus^=1<<t}setWorkerCreator(t){this.workerCreator=t}setWorkerLimit(t){this.pool=t}postMessage(t,e){return new Promise(n=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(t,e)):this.queue.push({resolve:n,msg:t,transfer:e})})}dispose(){this.workers.forEach(t=>t.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}function Zl(a,t){const e=new m.BufferGeometry;e.setAttribute("position",new m.BufferAttribute(new Float32Array([0,0,0]),3));const n=new m.Points(e,new m.PointsMaterial({size:a.size,color:a.color||16777215,sizeAttenuation:!a.glow,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}));return n.position.copy(t),n}async function Gl(a,t){let e=null;try{e=await Wt._loadTexture(a.url)}catch(d){console.error("IconPoint texture load failed:",a.url,d)}const n=new m.SpriteMaterial({map:e??null,color:a.color||16777215,transparent:!0,opacity:a.opacity??1,sizeAttenuation:a.sizeAttenuation??!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),i=new m.Sprite(n),s=.002,l=a.size,[u,c]=Array.isArray(l)?l:[l,l];return i.scale.set(u*s,c*s,1),a.rotation&&(i.rotation.z=a.rotation),a.anchor&&i.center.set(a.anchor[0],a.anchor[1]),i.position.copy(t),i}function Wr(a,t){let e;t instanceof Float32Array?e=Array.from(t):Array.isArray(t)&&typeof t[0]=="number"?e=t:e=t.flatMap(s=>[s.x,s.y,s.z]);const n=new xr;n.setPositions(e);const i=new zi({color:new m.Color(a.color??16777215).getHex(),linewidth:a.width??2,transparent:a.opacity!==void 0&&a.opacity<1,opacity:a.opacity??1,dashed:!!a.dashArray,dashScale:a.dashArray?.[0]??1,dashSize:a.dashArray?.[0]??1,gapSize:a.dashArray?.[1]??0,resolution:new m.Vector2(window.innerWidth,window.innerHeight),alphaToCoverage:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0});return window.addEventListener("resize",()=>{i.resolution.set(window.innerWidth,window.innerHeight)}),new Us(n,i)}async function Yf(a,t){const e=a.type||(a.url.toLowerCase().endsWith(".fbx")?"fbx":"gltf");return await $s.init().load({...a,type:e,position:t})}function Uf(a,t){const{geometry:e,center:n,avgY:i}=no(t),s=a.depthOffset??0,l=s!==0,u=new m.MeshBasicMaterial({color:new m.Color(a.color??16777215),transparent:a.opacity!==void 0&&a.opacity<1,opacity:a.opacity??1,wireframe:a.wireframe??!1,side:a.side==="back"?m.BackSide:a.side==="double"?m.DoubleSide:m.FrontSide,polygonOffset:l,polygonOffsetFactor:l?s:0,polygonOffsetUnits:l?s:0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),c=new m.Mesh(e,u);if(c.rotation.x=-Math.PI/2,c.position.set(n.x,i,n.z),(a.borderWidth??0)>0){const f={color:a.borderColor??a.color??0,width:a.borderWidth,opacity:a.opacity},y=[];for(let x=0;x<t.length;x+=3){const S=t[x],_=t[x+2];y.push(S-n.x,-(_-n.z),0)}const v=Wr(f,y);v.position.z+=.1,c.add(v)}return c}function Bf(a,t){const e=a.extrude?.height||2e3,n=[],i=[],s=[];for(let f=0;f<t.length;f+=3){const y=t[f],v=t[f+1],x=t[f+2];i.push(new m.Vector3(y,v,x)),s.push(new m.Vector3(y,v+e,x))}n.push(...i,...s);const l=new m.BufferGeometry;l.setFromPoints(n);const u=[],c=i.length;for(let f=0;f<c;f++){const y=(f+1)%c;u.push(f,f+c,y),u.push(y,f+c,y+c)}for(let f=2;f<c;f++)u.push(0,f-1,f),u.push(c,c+f-1,c+f);l.setIndex(u),l.computeVertexNormals();const d=new m.ShaderMaterial({uniforms:{uColor:{value:new m.Color(a.color??16777215)},uOpacity:{value:a.opacity??1},uBrightness:{value:1.2}},vertexShader:`
|
|
518
518
|
varying vec3 vWorldPosition;
|
|
519
519
|
varying vec3 vNormal;
|
|
520
520
|
void main() {
|
|
@@ -536,33 +536,33 @@
|
|
|
536
536
|
gl_FragColor = vec4(finalColor, uOpacity);
|
|
537
537
|
if (uOpacity >= 0.99) gl_FragDepthEXT = gl_FragCoord.z;
|
|
538
538
|
}
|
|
539
|
-
`,transparent:!0,side:m.DoubleSide,depthWrite:!0}),p=new m.Mesh(a,d);return p.renderOrder=5e3,p}function Kf(l,t,e){const{geometry:n,center:r,avgY:s}=Ml(e),a=new Jh(n,{textureWidth:512,textureHeight:512,waterNormals:new m.TextureLoader().load(l.normalMap,function(d){d.wrapS=d.wrapT=m.RepeatWrapping}),waterColor:l.color||"#19AAEE",sunColor:l.sunColor||"#05FFF8",distortionScale:1,alpha:l.opacity||.8}),c=a.onBeforeRender,u=a.onAfterRender;return a.onBeforeRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!1,c.call(a,d,p,f,y,v,x)},a.onAfterRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!0,u.call(a,d,p,f,y,v,x)},a.material.uniforms.size.value=.1,a.rotation.x=-Math.PI/2,a.position.set(r.x,s,r.z),t.viewer.addEventListener("update",()=>{a.material.uniforms.time.value+=1/60}),a}function Ml(l){let t=0;for(let a=1;a<l.length;a+=3)t+=l[a];t/=l.length/3;const e={x:0,z:0},n=[];for(let a=0;a<l.length;a+=3)e.x+=l[a],e.z+=l[a+2];e.x/=l.length/3,e.z/=l.length/3;for(let a=0;a<l.length;a+=3)n.push(new m.Vector2(l[a]-e.x,-(l[a+2]-e.z)));const r=new m.Shape(n);return{geometry:new m.ShapeGeometry(r),center:e,avgY:t}}async function Rf(l,t){const{geometry:e,center:n,avgY:r}=Ml(t),s=await Pt._loadTexture(l.normalMap),a=await Pt._loadTexture(l.normalMap);s.wrapS=s.wrapT=m.RepeatWrapping,a.wrapS=a.wrapT=m.RepeatWrapping,s.repeat.set(.015,.015),a.repeat.set(.005,.005);const c=new m.MeshStandardMaterial({color:new m.Color(l.color).multiplyScalar(3.5),roughness:.1,metalness:.8,transparent:!0,opacity:.9,fog:!1,normalMap:s,normalScale:new m.Vector2(1.5,1.5),envMapIntensity:2}),u=new m.Mesh(e,c);u.rotation.x=-Math.PI/2,u.position.set(n.x,r+.15,n.z),u.castShadow=!1,u.receiveShadow=!0;let d=0;return u.onBeforeRender=()=>{const p=performance.now(),f=d?(p-d)/1e3:.016;s.offset.x+=f*.08,s.offset.y+=f*.03,a.offset.x-=f*.12,a.offset.y+=f*.02,u.position.y=r+.5+Math.sin(p*.02)*.02,d=p},u}function Yf(l,t){l.color=new m.Color(l.hexcolor),l.boundstext&&(l.bounds=new m.Vector3(l.boundstext.x,l.boundstext.y,l.boundstext.z));const e=new kf(l);return e.castShadow=!0,e.scale.setScalar(50),e.position.copy(t),e}async function Uf(l,t){const n={...{fontSize:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,fixedSize:50},...l};n.fontSize=Math.min(Math.max(n.fontSize,8),128);const r=document.createElement("canvas"),s=r.getContext("2d");if(!s)throw new Error("canvas context is null");const a=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`;s.font=a;const c=n.showBackground?20:0,u=100,d=50,p=s.measureText(n.text),f=Math.max(u,p.width+c*2),y=Math.max(d,n.fontSize*1.5+c*2);r.width=Math.min(f,2048),r.height=Math.min(y,2048),s.clearRect(0,0,r.width,r.height),s.font=a,n.showBackground&&(n.bgStyle===1?(s.fillStyle=n.bgColor,s.globalAlpha=n.bgOpacity,s.beginPath(),Ll(s,c/2,c/2,r.width-c,r.height-c,n.roundRectRadius),s.fill(),s.globalAlpha=1,s.shadowColor=n.shadowColor,s.shadowBlur=n.shadowBlur,s.shadowOffsetX=n.shadowOffsetX,s.shadowOffsetY=n.shadowOffsetY):(s.fillStyle=n.bgColor,s.globalAlpha=n.bgOpacity,s.beginPath(),Sl(s,r.width/2,r.height/2,r.width*.8,r.height*.8,n.roundRectRadius,n.bubblePointerHeight,n.bubblePointerWidth),s.fill(),s.globalAlpha=1,s.strokeStyle=n.bubbleBorderColor,s.lineWidth=n.bubbleBorderWidth,s.stroke())),s.textAlign="center",s.textBaseline="middle",n.strokeWidth>0&&(s.strokeStyle=n.strokeColor,s.lineWidth=n.strokeWidth,s.lineJoin="round",s.strokeText(n.text,r.width/2,r.height/2)),s.fillStyle=n.textColor,s.fillText(n.text,r.width/2,r.height/2),s.shadowColor="transparent";const v=new m.CanvasTexture(r);v.magFilter=m.NearestFilter,v.minFilter=m.LinearMipmapLinearFilter,v.anisotropy=16;const x=new m.SpriteMaterial({map:v,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1}),L=new m.Sprite(x),_=n.fixedSize;return L.scale.set(r.width*_/100,r.height*_/100,1),t&&L.position.copy(t),L.renderOrder=9999,L}async function Bf(l,t,e){const r={...{fontSize:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,maxVisibleDistance:1/0},...l};r.fontSize=Math.min(Math.max(r.fontSize,8),128);const s=document.createElement("canvas"),a=s.getContext("2d");if(!a)throw new Error("Failed to get canvas context");const c=`${r.fontStyle} ${r.fontWeight} ${r.fontSize}px ${r.fontFamily}`;a.font=c;const u=r.showBackground?20:0,d=100,p=50,f=a.measureText(r.text),y=Math.max(d,f.width+u*2),v=Math.max(p,r.fontSize*1.5+u*2);s.width=Math.min(y,2048),s.height=Math.min(v,2048),a.clearRect(0,0,s.width,s.height),a.font=c,r.showBackground&&(r.bgStyle===1?(a.fillStyle=r.bgColor,a.globalAlpha=r.bgOpacity,a.beginPath(),Ll(a,u/2,u/2,s.width-u,s.height-u,r.roundRectRadius),a.fill(),a.globalAlpha=1,a.shadowColor=r.shadowColor,a.shadowBlur=r.shadowBlur,a.shadowOffsetX=r.shadowOffsetX,a.shadowOffsetY=r.shadowOffsetY):(a.fillStyle=r.bgColor,a.globalAlpha=r.bgOpacity,a.beginPath(),Sl(a,s.width/2,s.height/2,s.width*.8,s.height*.8,r.roundRectRadius,r.bubblePointerHeight,r.bubblePointerWidth),a.fill(),a.globalAlpha=1,a.strokeStyle=r.bubbleBorderColor,a.lineWidth=r.bubbleBorderWidth,a.stroke())),a.textAlign="center",a.textBaseline="middle",r.strokeWidth>0&&(a.strokeStyle=r.strokeColor,a.lineWidth=r.strokeWidth,a.lineJoin="round",a.strokeText(r.text,s.width/2,s.height/2)),a.fillStyle=r.textColor,a.fillText(r.text,s.width/2,s.height/2),a.shadowColor="transparent";const x=new m.CanvasTexture(s),L=new m.SpriteMaterial({map:x,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1}),_=new m.Sprite(L);_.position.copy(t),_.renderOrder=9999,_.userData.isLabel=!0;const S=()=>{if(!_.visible)return;const G=e.viewer.camera.position.distanceTo(_.position);if(G>r.maxVisibleDistance){_.visible=!1;return}_.visible=!0;const A=new m.Vector2;e.viewer.renderer.getSize(A);const K=A.height,D=r.screenSpaceSize/s.height*(G/Math.tan(m.MathUtils.degToRad(e.viewer.camera.fov)/2))*(2/K);_.scale.set(D*s.width,D*s.height,1),_.lookAt(e.viewer.camera.position)};S();const Z=()=>S();return _.addEventListener("dispose",()=>{e.viewer.renderer.domElement.removeEventListener("resize",S)}),e.viewer.renderer.domElement.addEventListener("resize",S),e.viewer.camera.addEventListener("change",S),_.onBeforeRender=Z,_}function Ll(l,t,e,n,r,s){l.beginPath(),l.moveTo(t+s,e),l.lineTo(t+n-s,e),l.quadraticCurveTo(t+n,e,t+n,e+s),l.lineTo(t+n,e+r-s),l.quadraticCurveTo(t+n,e+r,t+n-s,e+r),l.lineTo(t+s,e+r),l.quadraticCurveTo(t,e+r,t,e+r-s),l.lineTo(t,e+s),l.quadraticCurveTo(t,e,t+s,e),l.closePath()}function Sl(l,t,e,n,r,s,a,c){if(n<=0)throw new Error("Width must be positive");if(r<=0)throw new Error("Height must be positive");if(s<0)throw new Error("Radius cannot be negative");const u=n,d=r,p=Math.min(s,n/2,r/2),f=a??10,y=c??15;l.beginPath(),l.moveTo(t-u/2+p,e-d/2),l.lineTo(t+u/2-p,e-d/2),l.quadraticCurveTo(t+u/2,e-d/2,t+u/2,e-d/2+p),l.lineTo(t+u/2,e+d/2-p),l.quadraticCurveTo(t+u/2,e+d/2,t+u/2-p,e+d/2),l.lineTo(t+y/2,e+d/2),l.lineTo(t,e+d/2+f),l.lineTo(t-y/2,e+d/2),l.lineTo(t-u/2+p,e+d/2),l.quadraticCurveTo(t-u/2,e+d/2,t-u/2,e+d/2-p),l.lineTo(t-u/2,e-d/2+p),l.quadraticCurveTo(t-u/2,e-d/2,t-u/2+p,e-d/2),l.closePath()}async function Nf(l,t,e){const{text:n,iconUrl:r,fontSize:s=30,iconSize:a=60,fontFamily:c="Arial",padding:u={},bgColor:d="rgba(0,0,0,0.0)",textColor:p="rgb(255,255,255)",strokeColor:f="rgb(0,0,0)",strokeWidth:y=s/9,iconScale:v=.8,canvasScale:x=1,renderbg:L=!0,textOffset:_={x:0,y:0}}=l,S={top:0,right:1,bottom:0,left:0,...u};let Z=null;r&&(Z=await Jf(r));const{canvas:G,width:A,height:K,center:D}=await jf({text:n,iconImage:Z,fontSize:s,iconSize:a,fontFamily:c,padding:S,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:L,textOffset:_},t),O=new m.Texture(G);O.needsUpdate=!0;const V=new m.SpriteMaterial({map:O,transparent:!0,depthTest:!0,depthWrite:!0,blending:m.NormalBlending,sizeAttenuation:!1,alphaTest:.01}),R=new m.Sprite(V),W=.001;return R.scale.set(A*W,K*W,1),R.center.set(D[0],D[1]),e&&R.position.copy(e),R.renderOrder=999,R}async function jf(l,t){return new Promise(e=>{const{text:n,iconImage:r,fontSize:s,iconSize:a,fontFamily:c,padding:u,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:L,textOffset:_={x:0,y:0}}=l,Z=document.createElement("canvas").getContext("2d");if(!Z)throw new Error("Could not get temp canvas context");Z.font=`500 ${s}px ${c}`;const G=Z.measureText(n),A=G.width,K=G.actualBoundingBoxAscent||s*.8,D=G.actualBoundingBoxDescent||s*.2,O=r!==null;let V=0,R=0,W=0,k=0;if(O){V=0,R=0,W=a,k=a;const he=a/2+_.x,ve=a/2+_.y,ke=he,Ye=he+A,je=ve-K,Je=ve+D;V=Math.min(V,ke),W=Math.max(W,Ye),R=Math.min(R,je),k=Math.max(k,Je)}else{const he=_.x,ve=_.x+A,ke=_.y-K,Ye=_.y+D;V=he,W=ve,R=ke,k=Ye}const N=W-V,H=k-R,j=Math.ceil(N+u.left+u.right)*x,q=Math.ceil(H+u.top+u.bottom)*x,J=u.left-V,oe=u.top-R,ie=t._getCanvas(j,q,n);ie.width=j,ie.height=q;const te=ie.getContext("2d");if(!te)throw new Error("Could not get canvas context");te.clearRect(0,0,j,q),te.globalCompositeOperation="source-over",te.save(),te.scale(x,x);const me=j/x,be=q/x;if(L&&(te.fillStyle=d,te.fillRect(0,0,me,be)),r){const he=J,ve=oe,ke=a*v,Ye=(a-ke)/2,je=(a-ke)/2;te.imageSmoothingEnabled=!1,te.drawImage(r,he+Ye,ve+je,ke,ke),te.font=`500 ${s}px ${c}`,te.textBaseline="alphabetic",te.textAlign="left";const Je=J+a/2+_.x,Qe=oe+a/2+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,Je,Qe)),te.fillStyle=p,te.fillText(n,Je,Qe)}else{te.font=`500 ${s}px ${c}`,te.textBaseline="alphabetic",te.textAlign="left";const he=J+_.x,ve=oe+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,he,ve)),te.fillStyle=p,te.fillText(n,he,ve)}te.restore(),e({canvas:ie,width:me,height:be,center:[(a*.5+u.left)/me,(1-v)*.5]})})}function Jf(l){return new Promise((t,e)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>t(n),n.onerror=r=>e(new Error(`Failed to load image: ${l} ${r}`)),n.src=l})}async function Qf(l,t,e){const r=new m.CylinderGeometry(.2,.2,24,12),s=new m.MeshBasicMaterial({color:l.color}),a=await Pt._loadTexture(l.icon),c=new m.PointsMaterial({size:80*window.innerHeight/window.innerHeight,fog:!1,opacity:1,transparent:!0,toneMapped:!1,blending:m.AdditiveBlending,map:a,sizeAttenuation:!0,depthTest:!0,depthWrite:!1}),u=new m.InstancedMesh(r,s,t.length);u.position.add(e.prjcenter),u.castShadow=!0,u.renderOrder=1;const d=new m.Object3D,p=[];for(let x=0;x<t.length;x++){const L=t[x],_=new m.Vector3(L.coordinates[0],L.coordinates[1],L.coordinates[2]||0),Z=e.geo2world(_).sub(e.prjcenter);d.position.copy(Z),d.updateMatrix(),u.setMatrixAt(x,d.matrix),p.push(Z.x,0,Z.z)}const f=new Float32Array(p),y=new m.BufferGeometry;y.setAttribute("position",new m.BufferAttribute(f,3));const v=new m.Points(y,c);return v.position.add(e.prjcenter),v.position.y=1.5*10,v.renderOrder=99999999,v.visible=!0,console.log(e,"map"),{points:v,InstancedCol:u}}const Yt=class Yt{constructor(t){this.config=t}async applyTo(t){if(!t)return!1;try{switch(t.visible=this.config.visible!==!1,this.config.zIndex&&(t.renderOrder=this.config.zIndex),this.config.type){case"basic-point":case"icon-point":case"icon-label-point":return this._applyPointStyle(t);case"basic-line":return this._applyLineStyle(t);case"gltf":case"fbx":return this._applyModelStyle(t);case"basic-polygon":return this._applyPolygonStyle(t);case"extrude-polygon":return this._applyExtrudeStyle(t);case"water":case"base-water":return this._applyWaterStyle(t);case"cloud":return this._applyCloudStyle(t);case"canvas-label":case"canvas-label-fixed":return this._applyTextSpriteStyle(t);case"light":return this._applyLightStyle(t);case"custom":return this._applyCustomStyle(t);default:throw new Error("Unknown style type")}}catch(e){return console.error("Style apply failed:",e),t.visible=!1,!1}}async _applyPointStyle(t){const e=this.config;return e.type==="icon-point"?await this._applyIconPoint(t,e):e.type==="basic-point"?this._applyBasicPoint(t,e):e.type==="icon-label-point"&&this._applyIconLabelPoint(t,e),!0}async _applyIconPoint(t,e){let n;if(t instanceof m.Sprite)n=t;else if(n=await _l(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.renderOrder=999,t.parent){let u=t.parent;u._threeGeometry=n,u._updateGeometry()}const r=e.size,[s,a]=Array.isArray(r)?r:[r,r];if(s<=0||a<=0){console.error("Invalid sprite size:",e.size),n.visible=!1;return}const c=n.material;try{if(c.map=await Yt._loadTexture(e.url),!c.map)throw new Error("Texture failed to load");c.needsUpdate=!0,n.scale.set(s,a,1),e.rotation!==void 0&&(n.rotation.z=e.rotation)}catch(u){console.error("Failed to load texture:",e.url,u),n.visible=!1}}_applyBasicPoint(t,e){let n;if(t instanceof m.Points)n=t;else if(n=bl(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.renderOrder=999,t.parent){let s=t.parent;s._threeGeometry=n,s._updateGeometry()}const r=n.material;r.size=e.size,e.color&&r.color.set(e.color),e.glow&&(r.sizeAttenuation=!1)}_applyIconLabelPoint(t,e){return!0}_applyLineStyle(t){const e=this.config;if(t.parent){let n=t.parent;n._threeGeometry=Gi(e,n._vertexPoints),n._updateGeometry()}return!0}_applyPolygonStyle(t){return!0}_applyExtrudeStyle(t){return!0}_applyWaterStyle(t){return!0}_applyCloudStyle(t){return!0}_applyTextSpriteStyle(t){return!0}_applyLightStyle(t){return!0}async _applyModelStyle(t){return!0}async _applyCustomStyle(t){const n=await this.config.build();return t instanceof m.Group&&(t.clear(),t.add(n)),!0}static async _loadTexture(t){if(Yt._textureCache.has(t))return Yt._textureCache.get(t);const e=await new Promise((n,r)=>{Yt._textureLoader.load(t,n,void 0,r)});return e.premultiplyAlpha=!0,Yt._textureCache.set(t,e),e}static create(t){return t instanceof Yt?t:new Yt(t)}};T(Yt,"_textureCache",new Map),T(Yt,"_textureLoader",new m.TextureLoader);let Pt=Yt;const et=[];for(let l=0;l<256;++l)et.push((l+256).toString(16).slice(1));function Hf(l,t=0){return(et[l[t+0]]+et[l[t+1]]+et[l[t+2]]+et[l[t+3]]+"-"+et[l[t+4]]+et[l[t+5]]+"-"+et[l[t+6]]+et[l[t+7]]+"-"+et[l[t+8]]+et[l[t+9]]+"-"+et[l[t+10]]+et[l[t+11]]+et[l[t+12]]+et[l[t+13]]+et[l[t+14]]+et[l[t+15]]).toLowerCase()}let to;const Ef=new Uint8Array(16);function qf(){if(!to){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");to=crypto.getRandomValues.bind(crypto)}return to(Ef)}const Zl={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function $f(l,t,e){if(Zl.randomUUID&&!l)return Zl.randomUUID();l=l||{};const n=l.random??l.rng?.()??qf();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Hf(n)}var Tl=(l=>(l.POINT="point",l.LINE_VERTEX="line_vertex",l.POLYGON_CENTER="polygon_center",l.LABEL="label",l.ICON="icon",l.CLUSTER="cluster",l))(Tl||{}),rn=(l=>(l.NO_COLLISION="no_collision",l.PRIORITY_LOST="priority_lost",l.OUT_OF_VIEWPORT="out_of_viewport",l.ZOOM_FILTERED="zoom_filtered",l.MANUAL_HIDDEN="manual_hidden",l.GROUP_COLLISION="group_collision",l))(rn||{});class Sn extends Es(Mi(Li(m.Object3D))){constructor(e){super();T(this,"_position");T(this,"_threeGeometry");T(this,"_geometry");T(this,"_layer");T(this,"_style");T(this,"_id");T(this,"_styleQueue",[]);T(this,"_isApplyingStyle",!1);T(this,"_isGeometryInitializing",!1);T(this,"_collisionState",{visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:Date.now()});T(this,"_collisionConfig",{enabled:!0,priority:50,padding:4,minZoom:0,maxZoom:24});T(this,"_animationRef",null);Ns(e.geometry,"geometry","geometry must be specified"),this._geometry=e.geometry,this._position=new m.Vector3(0,0,0),this._threeGeometry=new m.Object3D,e.userData&&(this.userData=Object.assign({},JSON.parse(JSON.stringify(e.userData)))),e.style&&this.setStyle(e.style),e.id?this._id=e.id:this._id=$f()}async initializeGeometry(){if(!(this._isGeometryInitializing||this._threeGeometry)){this._isGeometryInitializing=!0;try{await this._toThreeJSGeometry(),this._processStyleQueue()}finally{this._isGeometryInitializing=!1}}}setStyle(e){const n=e instanceof Pt?e:new Pt(e);this._style=n;const r=JSON.parse(JSON.stringify(n.config));return this._styleQueue.push(r),this._tryProcessQueue(),this}getStyle(){return this._style}async _applyStyleWithRetry(e,n=3,r=100){let s=null;for(let a=1;a<=n;a++)try{this._threeGeometry.parent||(this.add(this._threeGeometry),await new Promise(c=>requestAnimationFrame(c))),await e.applyTo(this._threeGeometry);return}catch(c){if(s=c,a<n){const u=r*Math.pow(2,a-1);await new Promise(d=>setTimeout(d,u))}}throw s||new Error("样式应用失败,重试次数耗尽")}async _processStyleQueue(){if(!this._threeGeometry||this._isApplyingStyle||this._styleQueue.length===0)return;this._isApplyingStyle=!0;const e=this._styleQueue[0];try{const n=new Pt(JSON.parse(JSON.stringify(e)));await this._applyStyleWithRetry(n),this._styleQueue.shift(),this._styleQueue.length>0&&await this._processStyleQueue()}catch(n){throw n}finally{this._isApplyingStyle=!1,this._styleQueue.length>0&&this._tryProcessQueue()}}_tryProcessQueue(){this._threeGeometry&&!this._isApplyingStyle&&this._styleQueue.length>0?this._processStyleQueue().catch(n=>{this._isApplyingStyle=!1,this._tryProcessQueue(),console.warn(n)}):!this._threeGeometry&&!this._isGeometryInitializing&&this.initializeGeometry()}addTo(e){return e.addFeature(this),this}getLayer(){return this._layer||null}getMap(){return this._layer?.getMap()||null}_bindLayer(e){if(this._layer&&this._layer!==e)throw new Error("Feature cannot be added to multiple layers");this._layer=e}_updateGeometry(){this._disposeGeometry(),this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry.renderOrder=999,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue())}_remove(){return this.getLayer()?(this._unbind(),this):this}_unbind(){const e=this.getLayer();e&&(e.onRemoveFeature&&e.onRemoveFeature(this),delete this._layer)}_disposeGeometry(){this._threeGeometry&&(this.clear(),"traverse"in this&&this._threeGeometry.traverse(e=>{e instanceof m.Mesh?(e.geometry?.dispose(),Array.isArray(e.material)?e.material.forEach(n=>n.dispose()):e.material?.dispose()):"isLine"in e&&e.isLine&&(e.geometry?.dispose(),e.material?.dispose())}))}get collidable(){return this._collisionConfig.enabled}get collisionType(){return Tl.POINT}getCollisionPriority(){return this.userData.collisionPriority??this._style?.config.collisionPriority??this._collisionConfig.priority}getScreenBoundingBox(e,n){if(!this.collidable)return null;try{const r=new m.Vector3;this._threeGeometry.getWorldPosition(r);const s=r.clone().project(e);if(!(s.x>=-1.1&&s.x<=1.1&&s.y>=-1.1&&s.y<=1.1&&s.z>=-1&&s.z<=1))return null;const{width:c,height:u}=n.domElement,d=(s.x*.5+.5)*c,p=(-s.y*.5+.5)*u,f=this._calculateCollisionBoundingBox(e,n);return f?{id:this._id,x:d+f.offsetX,y:p+f.offsetY,width:20+this._collisionConfig.padding*2,height:20+this._collisionConfig.padding*2,priority:this.getCollisionPriority(),featureId:this._id,layerId:this._layer?.getId()||"unknown",type:this.collisionType,data:this.getCollisionData()}:null}catch(r){return console.warn(`Feature ${this._id} 包围盒计算失败:`,r),null}}setCollisionVisibility(e,n=rn.MANUAL_HIDDEN){this._collisionState.visible!==e&&(this._animationRef!==null&&(cancelAnimationFrame(this._animationRef),this._animationRef=null),this.visible=e,this._applyFinalAlpha(e?1:0),this._collisionState={visible:e,reason:n,collidedWith:e?[]:this._collisionState.collidedWith,timestamp:Date.now()})}getCollisionVisibility(){return this._collisionState.visible}setCollisionConfig(e){return Object.assign(this._collisionConfig,e),this}enableCollision(){return this._collisionConfig.enabled=!0,this}disableCollision(){return this._collisionConfig.enabled=!1,this.setCollisionVisibility(!0,rn.MANUAL_HIDDEN),this}_applyVisibilityAlpha(e){this.traverse(n=>{n instanceof m.Mesh&&(Array.isArray(n.material)?n.material.forEach(r=>{r.opacity!==void 0&&(r.opacity=e)}):n.material.opacity!==void 0&&(n.material.opacity=e))})}_applyFinalAlpha(e){this._applyVisibilityAlpha(e),this.traverse(n=>{n instanceof m.Mesh&&(n.material.needsUpdate=!0)})}getCollisionData(){return{featureType:this.constructor.name,userData:this.userData,styleConfig:this._style?.config}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{const r=new m.Box3().setFromObject(this._threeGeometry);if(r.isEmpty())return this._getFallbackBoundingBox();const s=[new m.Vector3(r.min.x,r.min.y,r.min.z),new m.Vector3(r.max.x,r.min.y,r.min.z),new m.Vector3(r.min.x,r.max.y,r.min.z),new m.Vector3(r.max.x,r.max.y,r.min.z),new m.Vector3(r.min.x,r.min.y,r.max.z),new m.Vector3(r.max.x,r.min.y,r.max.z),new m.Vector3(r.min.x,r.max.y,r.max.z),new m.Vector3(r.max.x,r.max.y,r.max.z)],{width:a,height:c}=n.domElement,u=[];s.forEach(D=>{const O=D.clone().project(e),V=(O.x*.5+.5)*a,R=(-O.y*.5+.5)*c;u.push(new m.Vector2(V,R))});let d=1/0,p=-1/0,f=1/0,y=-1/0;u.forEach(D=>{d=Math.min(d,D.x),p=Math.max(p,D.x),f=Math.min(f,D.y),y=Math.max(y,D.y)});const v=p-d,x=y-f,L=4,_=Math.max(v,L),S=Math.max(x,L),Z=new m.Vector3;r.getCenter(Z);const G=Z.clone().project(e),A=(G.x*.5+.5)*a,K=(-G.y*.5+.5)*c;return{width:_,height:S,offsetX:d-A,offsetY:f-K}}catch(r){return console.warn("包围盒计算失败:",r),this._getFallbackBoundingBox()}}_getFallbackBoundingBox(){return{width:20,height:20,offsetX:-10,offsetY:-10}}_tileCoordToLocalWorld(e,n,r,s){const{tileZ:a,tileX:c,tileY:u,extent:d,tileSize:p}=r,f=(e/d-.5)*p,y=(.5-n/d)*p;return s.tileIDToWorldCenter(a,c,u).clone().add(new m.Vector3(f,y,0)).sub(s.prjcenter)}}class Bn extends Si{constructor(e,n){super(e,n);T(this,"_feaList");T(this,"_collision",!1);this._feaList=[],n?.collision&&(this._collision=!0)}addFeature(e){const n=Array.isArray(e)?e:[e];for(const r of n)if(!(!r||!(r instanceof Sn))&&!r.getLayer()){if(!this.validateFeature(r)){console.error(`Feature ${r.id} does not match the layer's type requirements`);continue}r._bindLayer(this),this._feaList.push(r),r.getMap()&&r._toThreeJSGeometry(),this._clouds&&(this.map.viewer.scene.add(this._clouds),console.log("我是云朵被添加cloud",this.map.viewer.scene)),this.add(r)}return this}getFeatures(e,n){if(!e)return this._feaList.slice(0);const r=[];let s,a;for(let c=0,u=this._feaList.length;c<u;c++)s=this._feaList[c],n?a=e.call(n,s):a=e(s),a&&r.push(s);return r}getCount(){return this._feaList.length}isEmpty(){return!this._feaList.length}removeFeature(e){if(!Array.isArray(e))return this.removeFeature([e]);for(let n=e.length-1;n>=0;n--)e[n]instanceof Sn||(e[n]=this.removeFeature(e[n])),!(!e[n]||this!==e[n].getLayer())&&e[n]._remove();return this}clear(){const e=this._feaList.slice();for(const n of e)n._remove();return this}onRemoveFeature(e){if(!e)return;const n=e.getLayer();if(!n||n!==this)return;const r=this._findInList(e);r>=0&&this._feaList.splice(r,1),e.parent&&e.parent===this?this.remove(e):console.warn("Feature parent mismatch:",e.parent),this._disposeFeatureResources(e)}_findInList(e){const n=this._feaList.length;if(n===0)return-1;let r=0,s=n-1,a;for(;r<=s;){if(a=Math.floor((r+s)/2),this._feaList[a]===e)return a;r=a+1}return-1}_disposeFeatureResources(e){try{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>n.dispose?.()):e.material.dispose&&e.material.dispose()),e instanceof m.Object3D&&e.traverse(n=>{n!==e&&this._disposeFeatureResources(n)})}catch(n){console.error("Error disposing feature resources:",n)}}_mergedGeometry(){this.traverse(e=>{e.isMesh&&e.geometry&&e.material&&console.log("几何体合并中",e)})}setCollisionEngine(e){return this._collisionEngine=e,this}}class ep extends m.Group{constructor(){super(...arguments);T(this,"_layers",new Set);T(this,"_layerids",new Set)}add(...e){return e.forEach(n=>{if(!(n instanceof Si))throw new Error("LayerContainer只能包含Layer实例!");const r=n.getId();if(this._layerids.has(r))throw new Error(`ID为'${r}'的图层已存在于容器中!`);this._layers.add(n),this._layerids.add(r),super.add(n)}),this}remove(...e){return e.forEach(n=>{this._layers.delete(n),this._layerids.delete(n.getId()),super.remove(n)}),this}getLayers(){return Array.from(this._layers)}getLayerById(e){for(const n of this._layers)if(n.getId()===e)return n}clearLayers(){return this._layers.clear(),this._layerids.clear(),super.clear(),this}}class tp{constructor(){T(this,"canvasDict",{})}getCanvas(t=40,e=30,n=1,r){const s=Math.ceil(t*n),a=Math.ceil(e*n),c=r?`${s}_${a}_${r}`:`${s}_${a}`;if(!this.canvasDict[c]){const p=document.createElement("canvas");p.width=s,p.height=a,this.canvasDict[c]=p}const u=this.canvasDict[c],d=u.getContext("2d");return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),d.scale(n,n),u}}function np(l){const t=+this._x.call(null,l),e=+this._y.call(null,l);return Gl(this.cover(t,e),t,e,l)}function Gl(l,t,e,n){if(isNaN(t)||isNaN(e))return l;var r,s=l._root,a={data:n},c=l._x0,u=l._y0,d=l._x1,p=l._y1,f,y,v,x,L,_,S,Z;if(!s)return l._root=a,l;for(;s.length;)if((L=t>=(f=(c+d)/2))?c=f:d=f,(_=e>=(y=(u+p)/2))?u=y:p=y,r=s,!(s=s[S=_<<1|L]))return r[S]=a,l;if(v=+l._x.call(null,s.data),x=+l._y.call(null,s.data),t===v&&e===x)return a.next=s,r?r[S]=a:l._root=a,l;do r=r?r[S]=new Array(4):l._root=new Array(4),(L=t>=(f=(c+d)/2))?c=f:d=f,(_=e>=(y=(u+p)/2))?u=y:p=y;while((S=_<<1|L)===(Z=(x>=y)<<1|v>=f));return r[Z]=s,r[S]=a,l}function rp(l){var t,e,n=l.length,r,s,a=new Array(n),c=new Array(n),u=1/0,d=1/0,p=-1/0,f=-1/0;for(e=0;e<n;++e)isNaN(r=+this._x.call(null,t=l[e]))||isNaN(s=+this._y.call(null,t))||(a[e]=r,c[e]=s,r<u&&(u=r),r>p&&(p=r),s<d&&(d=s),s>f&&(f=s));if(u>p||d>f)return this;for(this.cover(u,d).cover(p,f),e=0;e<n;++e)Gl(this,a[e],c[e],l[e]);return this}function ip(l,t){if(isNaN(l=+l)||isNaN(t=+t))return this;var e=this._x0,n=this._y0,r=this._x1,s=this._y1;if(isNaN(e))r=(e=Math.floor(l))+1,s=(n=Math.floor(t))+1;else{for(var a=r-e||1,c=this._root,u,d;e>l||l>=r||n>t||t>=s;)switch(d=(t<n)<<1|l<e,u=new Array(4),u[d]=c,c=u,a*=2,d){case 0:r=e+a,s=n+a;break;case 1:e=r-a,s=n+a;break;case 2:r=e+a,n=s-a;break;case 3:e=r-a,n=s-a;break}this._root&&this._root.length&&(this._root=c)}return this._x0=e,this._y0=n,this._x1=r,this._y1=s,this}function sp(){var l=[];return this.visit(function(t){if(!t.length)do l.push(t.data);while(t=t.next)}),l}function op(l){return arguments.length?this.cover(+l[0][0],+l[0][1]).cover(+l[1][0],+l[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function at(l,t,e,n,r){this.node=l,this.x0=t,this.y0=e,this.x1=n,this.y1=r}function ap(l,t,e){var n,r=this._x0,s=this._y0,a,c,u,d,p=this._x1,f=this._y1,y=[],v=this._root,x,L;for(v&&y.push(new at(v,r,s,p,f)),e==null?e=1/0:(r=l-e,s=t-e,p=l+e,f=t+e,e*=e);x=y.pop();)if(!(!(v=x.node)||(a=x.x0)>p||(c=x.y0)>f||(u=x.x1)<r||(d=x.y1)<s))if(v.length){var _=(a+u)/2,S=(c+d)/2;y.push(new at(v[3],_,S,u,d),new at(v[2],a,S,_,d),new at(v[1],_,c,u,S),new at(v[0],a,c,_,S)),(L=(t>=S)<<1|l>=_)&&(x=y[y.length-1],y[y.length-1]=y[y.length-1-L],y[y.length-1-L]=x)}else{var Z=l-+this._x.call(null,v.data),G=t-+this._y.call(null,v.data),A=Z*Z+G*G;if(A<e){var K=Math.sqrt(e=A);r=l-K,s=t-K,p=l+K,f=t+K,n=v.data}}return n}function lp(l){if(isNaN(p=+this._x.call(null,l))||isNaN(f=+this._y.call(null,l)))return this;var t,e=this._root,n,r,s,a=this._x0,c=this._y0,u=this._x1,d=this._y1,p,f,y,v,x,L,_,S;if(!e)return this;if(e.length)for(;;){if((x=p>=(y=(a+u)/2))?a=y:u=y,(L=f>=(v=(c+d)/2))?c=v:d=v,t=e,!(e=e[_=L<<1|x]))return this;if(!e.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(n=t,S=_)}for(;e.data!==l;)if(r=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,r?(s?r.next=s:delete r.next,this):t?(s?t[_]=s:delete t[_],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(n?n[S]=e:this._root=e),this):(this._root=s,this)}function cp(l){for(var t=0,e=l.length;t<e;++t)this.remove(l[t]);return this}function up(){return this._root}function hp(){var l=0;return this.visit(function(t){if(!t.length)do++l;while(t=t.next)}),l}function dp(l){var t=[],e,n=this._root,r,s,a,c,u;for(n&&t.push(new at(n,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!l(n=e.node,s=e.x0,a=e.y0,c=e.x1,u=e.y1)&&n.length){var d=(s+c)/2,p=(a+u)/2;(r=n[3])&&t.push(new at(r,d,p,c,u)),(r=n[2])&&t.push(new at(r,s,p,d,u)),(r=n[1])&&t.push(new at(r,d,a,c,p)),(r=n[0])&&t.push(new at(r,s,a,d,p))}return this}function fp(l){var t=[],e=[],n;for(this._root&&t.push(new at(this._root,this._x0,this._y0,this._x1,this._y1));n=t.pop();){var r=n.node;if(r.length){var s,a=n.x0,c=n.y0,u=n.x1,d=n.y1,p=(a+u)/2,f=(c+d)/2;(s=r[0])&&t.push(new at(s,a,c,p,f)),(s=r[1])&&t.push(new at(s,p,c,u,f)),(s=r[2])&&t.push(new at(s,a,f,p,d)),(s=r[3])&&t.push(new at(s,p,f,u,d))}e.push(n)}for(;n=e.pop();)l(n.node,n.x0,n.y0,n.x1,n.y1);return this}function pp(l){return l[0]}function mp(l){return arguments.length?(this._x=l,this):this._x}function gp(l){return l[1]}function yp(l){return arguments.length?(this._y=l,this):this._y}function Pl(l,t,e){var n=new no(t??pp,e??gp,NaN,NaN,NaN,NaN);return l==null?n:n.addAll(l)}function no(l,t,e,n,r,s){this._x=l,this._y=t,this._x0=e,this._y0=n,this._x1=r,this._y1=s,this._root=void 0}function Il(l){for(var t={data:l.data},e=t;l=l.next;)e=e.next={data:l.data};return t}var lt=Pl.prototype=no.prototype;lt.copy=function(){var l=new no(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,n;if(!t)return l;if(!t.length)return l._root=Il(t),l;for(e=[{source:t,target:l._root=new Array(4)}];t=e.pop();)for(var r=0;r<4;++r)(n=t.source[r])&&(n.length?e.push({source:n,target:t.target[r]=new Array(4)}):t.target[r]=Il(n));return l},lt.add=np,lt.addAll=rp,lt.cover=ip,lt.data=sp,lt.extent=op,lt.find=ap,lt.remove=lp,lt.removeAll=cp,lt.root=up,lt.size=hp,lt.visit=dp,lt.visitAfter=fp,lt.x=mp,lt.y=yp;class Wl{constructor(t){T(this,"_quadtree");T(this,"_viewport");this._viewport=t,this._rebuildQuadTree()}updateViewport(t){(t.width!==this._viewport.width||t.height!==this._viewport.height)&&(this._viewport=t,this._rebuildQuadTree())}addBoxes(t){t.forEach(e=>{this._isBoxInViewport(e)&&this._quadtree.add(e)})}findCollisions(t){const e=[],n=this._getSearchBounds(t);return this._quadtree.visit((r,s,a,c,u)=>this._checkNodeCollision(n,s,a,c,u)?(r.length||this._getNodeData(r).forEach(p=>{p.id!==t.id&&this._checkBoxCollision(t,p)&&e.push(p)}),!1):void 0),e}clear(){this._rebuildQuadTree()}getAllBoxes(){const t=[];return this._quadtree.visit(e=>{if(!e.length){const n=this._getNodeData(e);t.push(...n)}return!1}),t}_rebuildQuadTree(){this._quadtree=Pl().x(t=>t.x).y(t=>t.y).extent([[0,0],[this._viewport.width,this._viewport.height]])}_isBoxInViewport(t){const e=t.width/2,n=t.height/2;return t.x+e>=0&&t.x-e<=this._viewport.width&&t.y+n>=0&&t.y-n<=this._viewport.height}_getSearchBounds(t){return{x:t.x,y:t.y,width:t.width*2,height:t.height*2}}_checkNodeCollision(t,e,n,r,s){const a=(e+r)/2,c=(n+s)/2,u=r-e,d=s-n;return Math.abs(t.x-a)*2<t.width+u&&Math.abs(t.y-c)*2<t.height+d}_checkBoxCollision(t,e){return Math.abs(t.x-e.x)*2<t.width+e.width&&Math.abs(t.y-e.y)*2<t.height+e.height}_getNodeData(t){return t?Array.isArray(t.data)?t.data:t.data?[t.data]:[]:[]}removeBox(t){const n=this.getAllBoxes().filter(r=>r.id!==t);this.clear(),n.length>0&&this.addBoxes(n)}}class vp{constructor(){T(this,"_strategies",new Map);T(this,"_executionOrder",[])}registerStrategy(t,e){return this._strategies.set(t.name,t),e!==void 0?this._executionOrder.splice(e,0,t.name):this._executionOrder.push(t.name),this}async executeStrategies(t,e){const n=new Map;t.forEach(r=>{n.set(r._id,{featureId:r._id,visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})});for(const r of this._executionOrder){const s=this._strategies.get(r);if(s?.enabled)try{const a=await s.execute(t,e,n);this._mergeResults(n,a)}catch(a){console.error(`策略 ${r} 执行失败:`,a)}}return n}_mergeResults(t,e){e.forEach(n=>{const r=t.get(n.featureId);r&&!r.visible||t.set(n.featureId,n)})}}class wp{constructor(){T(this,"frameStats",new Map);T(this,"summaryStats",{totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0});T(this,"sampleWindowSize",60);T(this,"currentFrameId",0);T(this,"lastReportTime",0);T(this,"reportInterval",5e3);T(this,"performanceThresholds",{criticalFrameTime:33,warningFrameTime:16,idealFrameTime:8});this.lastReportTime=Date.now()}startFrame(t){this.currentFrameId=t;const e={frameId:t,startTime:performance.now(),endTime:0,duration:0,featureCount:0,visibleCount:0,hiddenCount:0,collisionChecks:0,memoryUsage:0,strategyTimes:new Map};this.frameStats.set(t,e),this.cleanupOldFrames()}endFrame(t,e){const n=this.frameStats.get(t);if(!n)return;const r=performance.now();n.endTime=r,n.duration=r-n.startTime,e&&Object.assign(n,e),"memory"in performance&&(n.memoryUsage=performance.memory.usedJSHeapSize),this.updateSummaryStats(n),this.maybeOutputReport()}recordStrategyTime(t,e){const n=this.frameStats.get(this.currentFrameId);n&&n.strategyTimes.set(t,e)}recordCollisionChecks(t){const e=this.frameStats.get(this.currentFrameId);e&&(e.collisionChecks+=t)}getStats(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.calculateFPS(t),n=this.calculateAverageFrameTime(t);return{summary:{...this.summaryStats},recent:{fps:e,frameTime:n,frameTimeStdDev:this.calculateFrameTimeStdDev(t),averageFeaturesPerFrame:this.calculateAverageFeatures(t),performanceLevel:this.getPerformanceLevel(n)},currentFrame:this.frameStats.get(this.currentFrameId)||null,strategies:this.getStrategyPerformance(t),warnings:this.getPerformanceWarnings(t)}}getDetailedReport(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.getStats();return{...e,frameHistory:Array.from(t.values()),trends:this.calculateTrends(t),recommendations:this.getPerformanceRecommendations(e)}}reset(){this.frameStats.clear(),this.summaryStats={totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0},this.currentFrameId=0,this.lastReportTime=Date.now()}cleanupOldFrames(){this.frameStats.size>this.sampleWindowSize*2&&Array.from(this.frameStats.keys()).sort((e,n)=>e-n).slice(0,this.frameStats.size-this.sampleWindowSize).forEach(e=>{this.frameStats.delete(e)})}updateSummaryStats(t){this.summaryStats.totalFrames++,this.summaryStats.totalFeaturesProcessed+=t.featureCount||0,this.summaryStats.averageFrameTime=(this.summaryStats.averageFrameTime*(this.summaryStats.totalFrames-1)+t.duration)/this.summaryStats.totalFrames,this.summaryStats.minFrameTime=Math.min(this.summaryStats.minFrameTime,t.duration),this.summaryStats.maxFrameTime=Math.max(this.summaryStats.maxFrameTime,t.duration),this.summaryStats.averageFPS=1e3/this.summaryStats.averageFrameTime}maybeOutputReport(){const t=Date.now();if(t-this.lastReportTime>=this.reportInterval){const e=this.getStats();e.warnings.length>0?console.warn("避让系统性能报告:",e):console.log("避让系统性能正常:",e),this.lastReportTime=t}}getRecentFrames(t){return Array.from(this.frameStats.values()).slice(-t).filter(n=>n.duration>0)}calculateFPS(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t);return e>0?1e3/e:0}calculateAverageFrameTime(t){return t.length===0?0:t.reduce((e,n)=>e+n.duration,0)/t.length}calculateFrameTimeStdDev(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t),n=t.map(r=>Math.pow(r.duration-e,2));return Math.sqrt(n.reduce((r,s)=>r+s,0)/t.length)}calculateAverageFeatures(t){return t.length===0?0:t.reduce((e,n)=>e+(n.featureCount||0),0)/t.length}getPerformanceLevel(t){return t>this.performanceThresholds.criticalFrameTime?"critical":t>this.performanceThresholds.warningFrameTime?"warning":t>this.performanceThresholds.idealFrameTime?"good":"excellent"}getStrategyPerformance(t){const e=new Map;return t.forEach(n=>{n.strategyTimes.forEach((r,s)=>{e.has(s)||e.set(s,[]),e.get(s).push(r)})}),Array.from(e.entries()).map(([n,r])=>({name:n,averageTime:r.reduce((s,a)=>s+a,0)/r.length,maxTime:Math.max(...r),minTime:Math.min(...r),callCount:r.length}))}getPerformanceWarnings(t){const e=[],n=t.slice(-30);if(n.length===0)return e;const r=this.calculateAverageFrameTime(n);r>this.performanceThresholds.criticalFrameTime?e.push({type:"critical",message:`帧率过低: ${Math.round(1e3/r)}fps`,suggestion:"考虑减少要素数量或简化避让策略"}):r>this.performanceThresholds.warningFrameTime&&e.push({type:"warning",message:`帧率较低: ${Math.round(1e3/r)}fps`,suggestion:"建议优化避让算法或增加更新间隔"});const s=n.map(a=>a.memoryUsage).filter(a=>a>0);if(s.length>0){const a=s.reduce((c,u)=>c+u,0)/s.length;a>100*1024*1024&&e.push({type:"warning",message:`内存使用较高: ${(a/1024/1024).toFixed(1)}MB`,suggestion:"检查内存泄漏,及时清理无用资源"})}return e}calculateTrends(t){if(t.length<2)return{frameTime:"stable",fps:"stable",features:"stable"};const e=t.slice(0,Math.floor(t.length/2)),n=t.slice(Math.floor(t.length/2)),r=this.calculateAverageFrameTime(e),a=(this.calculateAverageFrameTime(n)-r)/r*100;return{frameTime:Math.abs(a)<5?"stable":a>0?"worsening":"improving",fps:Math.abs(a)<5?"stable":a>0?"improving":"worsening",features:"stable"}}getPerformanceRecommendations(t){const e=[];return t.recent.performanceLevel==="critical"&&(e.push("建议启用要素抽样或聚合显示"),e.push("考虑增加避让更新间隔时间"),e.push("检查是否有不必要的避让策略")),t.recent.averageFeaturesPerFrame>5e3&&e.push("要素数量过多,建议启用LOD分级"),t.strategies.forEach(n=>{n.averageTime>10&&e.push(`策略 "${n.name}" 执行时间较长,考虑优化`)}),e}}class xp{constructor(){T(this,"name","priority");T(this,"enabled",!0);T(this,"weight",1);T(this,"description","基于优先级的避让策略,数值越小优先级越高")}async execute(t,e,n){const r=[],s=new Wl(e.viewport),a=[],c=new Map;return t.forEach(u=>{if(!u.collidable)return;const d=u.getScreenBoundingBox(e.camera,e.renderer);d&&(a.push(d),c.set(u._id,u),n?.get(u._id)?.visible)}),a.sort((u,d)=>u.priority-d.priority),a.forEach(u=>{const d=s.findCollisions(u);d.length===0?(s.addBoxes([u]),r.push({featureId:u.featureId,visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})):d.some(f=>f.priority<u.priority)?r.push({featureId:u.featureId,visible:!1,reason:rn.PRIORITY_LOST,collidedWith:d.map(f=>f.featureId),timestamp:e.timestamp}):(s.addBoxes([u]),r.push({featureId:u.featureId,visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp}),d.forEach(f=>{r.push({featureId:f.featureId,visible:!1,reason:rn.PRIORITY_LOST,collidedWith:[u.featureId],timestamp:e.timestamp})}))}),r}}class bp{constructor(t,e={}){T(this,"_quadTreeManager");T(this,"_strategyOrchestrator");T(this,"_performanceMonitor");T(this,"_layers",new Set);T(this,"_config");T(this,"_isUpdating",!1);T(this,"_lastUpdateTime",0);T(this,"_frameCount",0);this.renderer=t,this._config={enabled:!0,padding:4,updateInterval:0,animationDuration:300,maxFeaturesPerFrame:2e3,viewportMargin:50,strategies:{priority:!0,grouping:!1,proximity:!1},...e},this._initializeComponents(),this._setupPerformanceMonitoring()}async update(t){if(!this._config.enabled||this._isUpdating)return;const e=Date.now();if(!(this._config.updateInterval>0&&e-this._lastUpdateTime<this._config.updateInterval)){this._isUpdating=!0,this._frameCount++;try{this._resetAllFeaturesVisibility();const n=this._createCollisionContext(t,e),r=this._collectCollidableFeatures();if(r.length===0)return;this._performanceMonitor.startFrame(this._frameCount);const s=await this._strategyOrchestrator.executeStrategies(r,n);await this._applyCollisionResults(s,r),this._performanceMonitor.endFrame(this._frameCount,{featureCount:r.length,visibleCount:Array.from(s.values()).filter(a=>a.visible).length,hiddenCount:Array.from(s.values()).filter(a=>!a.visible).length}),this._lastUpdateTime=e}catch(n){console.error("避让引擎更新失败:",n)}finally{this._isUpdating=!1}}}_resetAllFeaturesVisibility(){this._layers.forEach(t=>{t.getFeatures().filter(n=>n.collidable).forEach(n=>{n.setCollisionVisibility(!0,rn.NO_COLLISION)})})}registerLayer(t){return this._layers.add(t),this}unregisterLayer(t){return this._layers.delete(t),this}setConfig(t){return Object.assign(this._config,t),this}getPerformanceStats(){return this._performanceMonitor.getStats()}_initializeComponents(){const t={width:this.renderer.domElement.width,height:this.renderer.domElement.height};this._quadTreeManager=new Wl(t),this._strategyOrchestrator=new vp,this._performanceMonitor=new wp,this._strategyOrchestrator.registerStrategy(new xp,0),this._setupViewportResizeHandler()}_createCollisionContext(t,e){return{camera:t,renderer:this.renderer,viewport:{width:this.renderer.domElement.width,height:this.renderer.domElement.height},zoomLevel:t.position.z,timestamp:e,frameNumber:this._frameCount}}_collectCollidableFeatures(){const t=[];return this._layers.forEach(e=>{const n=e.getFeatures().filter(r=>r.collidable&&r instanceof Sn);if(t.length+n.length>this._config.maxFeaturesPerFrame){console.warn(`达到每帧最大要素处理限制: ${this._config.maxFeaturesPerFrame}`);return}t.push(...n)}),t}async _applyCollisionResults(t,e){const n=e.map(r=>{const s=t.get(r._id);return s&&r.setCollisionVisibility(s.visible,s.reason),Promise.resolve()});await Promise.all(n)}_setupViewportResizeHandler(){new ResizeObserver(e=>{e.forEach(n=>{const{width:r,height:s}=n.contentRect;this._quadTreeManager.updateViewport({width:r,height:s})})}).observe(this.renderer.domElement)}_setupPerformanceMonitoring(){setInterval(()=>{const t=this.getPerformanceStats();t.frameRate<30&&console.warn("避让系统性能警告:",t)},5e3)}}var Yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Pi={exports:{}};/**
|
|
539
|
+
`,transparent:!0,side:m.DoubleSide,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0});return new m.Mesh(l,d)}function Nf(a,t,e){const{geometry:n,center:i,avgY:s}=no(e),l=new $h(n,{textureWidth:512,textureHeight:512,waterNormals:new m.TextureLoader().load(a.normalMap,function(d){d.wrapS=d.wrapT=m.RepeatWrapping}),waterColor:a.color||"#19AAEE",sunColor:a.sunColor||"#05FFF8",distortionScale:1,alpha:a.opacity||.8}),u=l.onBeforeRender,c=l.onAfterRender;return l.onBeforeRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!1,u.call(l,d,p,f,y,v,x)},l.onAfterRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!0,c.call(l,d,p,f,y,v,x)},l.material.uniforms.size.value=.1,l.rotation.x=-Math.PI/2,l.position.set(i.x,s,i.z),t.viewer.addEventListener("update",()=>{l.material.uniforms.time.value+=1/60}),l}function no(a){let t=0;for(let l=1;l<a.length;l+=3)t+=a[l];t/=a.length/3;const e={x:0,z:0},n=[];for(let l=0;l<a.length;l+=3)e.x+=a[l],e.z+=a[l+2];e.x/=a.length/3,e.z/=a.length/3;for(let l=0;l<a.length;l+=3)n.push(new m.Vector2(a[l]-e.x,-(a[l+2]-e.z)));const i=new m.Shape(n);return{geometry:new m.ShapeGeometry(i),center:e,avgY:t}}async function jf(a,t){const{geometry:e,center:n,avgY:i}=no(t),s=await Wt._loadTexture(a.normalMap),l=await Wt._loadTexture(a.normalMap);s.wrapS=s.wrapT=m.RepeatWrapping,l.wrapS=l.wrapT=m.RepeatWrapping,s.repeat.set(.015,.015),l.repeat.set(.005,.005);const u=new m.MeshStandardMaterial({color:new m.Color(a.color).multiplyScalar(3.5),roughness:.1,metalness:.8,transparent:!0,opacity:.9,fog:!1,normalMap:s,normalScale:new m.Vector2(1.5,1.5),envMapIntensity:2,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),c=new m.Mesh(e,u);c.rotation.x=-Math.PI/2,c.position.set(n.x,i+.15,n.z),c.castShadow=!1,c.receiveShadow=!0;let d=0;return c.onBeforeRender=()=>{const p=performance.now(),f=d?(p-d)/1e3:.016;s.offset.x+=f*.08,s.offset.y+=f*.03,l.offset.x-=f*.12,l.offset.y+=f*.02,c.position.y=i+.5+Math.sin(p*.02)*.02,d=p},c}function Jf(a,t){a.color=new m.Color(a.hexcolor),a.boundstext&&(a.bounds=new m.Vector3(a.boundstext.x,a.boundstext.y,a.boundstext.z));const e=new Kf(a);return e.castShadow=!0,e.scale.setScalar(50),e.position.copy(t),e}async function Qf(a,t){const n={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,fixedSize:50},...a};n.screenSpaceSize==null&&n.fixedSize!=null&&(n.screenSpaceSize=n.fixedSize);const s=(typeof window<"u"&&window.devicePixelRatio||1)*4,l=a.screenSpaceSize!=null||a.fixedSize!=null;if(a.fontSizeDpi==null&&l){const A=a.screenSpaceSize??a.fixedSize??n.screenSpaceSize;n.fontSizeDpi=A*s}n.fontSizeDpi=Math.min(Math.max(n.fontSizeDpi,8),128);const u=document.createElement("canvas"),c=u.getContext("2d");if(!c)throw new Error("canvas context is null");const d=`${n.fontStyle} ${n.fontWeight} ${n.fontSizeDpi}px ${n.fontFamily}`;c.font=d;const p=n.showBackground?20:0,f=100,y=50,v=c.measureText(n.text),x=Math.max(f,v.width+p*2),S=Math.max(y,n.fontSizeDpi*1.5+p*2);u.width=Math.min(x,2048),u.height=Math.min(S,2048),c.clearRect(0,0,u.width,u.height),c.font=d,n.showBackground&&(n.bgStyle===1?(c.fillStyle=n.bgColor,c.globalAlpha=n.bgOpacity,c.beginPath(),Wl(c,p/2,p/2,u.width-p,u.height-p,n.roundRectRadius),c.fill(),c.globalAlpha=1,c.shadowColor=n.shadowColor,c.shadowBlur=n.shadowBlur,c.shadowOffsetX=n.shadowOffsetX,c.shadowOffsetY=n.shadowOffsetY):(c.fillStyle=n.bgColor,c.globalAlpha=n.bgOpacity,c.beginPath(),Pl(c,u.width/2,u.height/2,u.width*.8,u.height*.8,n.roundRectRadius,n.bubblePointerHeight,n.bubblePointerWidth),c.fill(),c.globalAlpha=1,c.strokeStyle=n.bubbleBorderColor,c.lineWidth=n.bubbleBorderWidth,c.stroke())),c.textAlign="center",c.textBaseline="middle",n.strokeWidth>0&&(c.strokeStyle=n.strokeColor,c.lineWidth=n.strokeWidth,c.lineJoin="round",c.strokeText(n.text,u.width/2,u.height/2)),c.fillStyle=n.textColor,c.fillText(n.text,u.width/2,u.height/2),c.shadowColor="transparent";const _=new m.CanvasTexture(u);_.magFilter=m.NearestFilter,_.minFilter=m.LinearMipmapLinearFilter,_.anisotropy=16;const Z=new m.SpriteMaterial({map:_,transparent:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,fog:!1}),M=new m.Sprite(Z),G=n.screenSpaceSize??n.fixedSize;return M.scale.set(u.width*G/100,u.height*G/100,1),t&&M.position.copy(t),M}async function Hf(a,t,e){const i={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,maxVisibleDistance:1/0},...a};i.screenSpaceSize==null&&a.fixedSize!=null&&(i.screenSpaceSize=a.fixedSize);const l=(typeof window<"u"&&window.devicePixelRatio||1)*4;a.fontSizeDpi==null&&(i.fontSizeDpi=i.screenSpaceSize*l),i.fontSizeDpi=Math.max(i.fontSizeDpi,8);const u=document.createElement("canvas"),c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");const d=`${i.fontStyle} ${i.fontWeight} ${i.fontSizeDpi}px ${i.fontFamily}`;c.font=d;const p=i.showBackground?20:0,f=100,y=50,v=c.measureText(i.text),x=Math.max(f,v.width+p*2),S=Math.max(y,i.fontSizeDpi*1.5+p*2);u.width=Math.min(x,2048),u.height=Math.min(S,2048),c.clearRect(0,0,u.width,u.height),c.font=d,i.showBackground&&(i.bgStyle===1?(c.fillStyle=i.bgColor,c.globalAlpha=i.bgOpacity,c.beginPath(),Wl(c,p/2,p/2,u.width-p,u.height-p,i.roundRectRadius),c.fill(),c.globalAlpha=1,c.shadowColor=i.shadowColor,c.shadowBlur=i.shadowBlur,c.shadowOffsetX=i.shadowOffsetX,c.shadowOffsetY=i.shadowOffsetY):(c.fillStyle=i.bgColor,c.globalAlpha=i.bgOpacity,c.beginPath(),Pl(c,u.width/2,u.height/2,u.width*.8,u.height*.8,i.roundRectRadius,i.bubblePointerHeight,i.bubblePointerWidth),c.fill(),c.globalAlpha=1,c.strokeStyle=i.bubbleBorderColor,c.lineWidth=i.bubbleBorderWidth,c.stroke())),c.textAlign="center",c.textBaseline="middle",i.strokeWidth>0&&(c.strokeStyle=i.strokeColor,c.lineWidth=i.strokeWidth,c.lineJoin="round",c.strokeText(i.text,u.width/2,u.height/2)),c.fillStyle=i.textColor,c.fillText(i.text,u.width/2,u.height/2),c.shadowColor="transparent";const _=new m.CanvasTexture(u),Z=new m.SpriteMaterial({map:_,transparent:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,fog:!1}),M=new m.Sprite(Z);M.position.copy(t),M.userData.isLabel=!0;const G=()=>{if(!M.visible)return;const R=e.viewer.camera.position.distanceTo(M.position);if(R>i.maxVisibleDistance){M.visible=!1;return}M.visible=!0;const D=new m.Vector2;e.viewer.renderer.getSize(D);const k=D.height,C=m.MathUtils.degToRad(e.viewer.camera.fov),K=typeof window<"u"&&window.devicePixelRatio||1,z=i.screenSpaceSize*K/u.height*(2*R*Math.tan(C/2)/k);M.scale.set(z*u.width,z*u.height,1),M.lookAt(e.viewer.camera.position)};G();const A=()=>G();return M.addEventListener("dispose",()=>{e.viewer.renderer.domElement.removeEventListener("resize",G)}),e.viewer.renderer.domElement.addEventListener("resize",G),e.viewer.camera.addEventListener("change",G),M.onBeforeRender=A,M}function Wl(a,t,e,n,i,s){a.beginPath(),a.moveTo(t+s,e),a.lineTo(t+n-s,e),a.quadraticCurveTo(t+n,e,t+n,e+s),a.lineTo(t+n,e+i-s),a.quadraticCurveTo(t+n,e+i,t+n-s,e+i),a.lineTo(t+s,e+i),a.quadraticCurveTo(t,e+i,t,e+i-s),a.lineTo(t,e+s),a.quadraticCurveTo(t,e,t+s,e),a.closePath()}function Pl(a,t,e,n,i,s,l,u){if(n<=0)throw new Error("Width must be positive");if(i<=0)throw new Error("Height must be positive");if(s<0)throw new Error("Radius cannot be negative");const c=n,d=i,p=Math.min(s,n/2,i/2),f=l??10,y=u??15;a.beginPath(),a.moveTo(t-c/2+p,e-d/2),a.lineTo(t+c/2-p,e-d/2),a.quadraticCurveTo(t+c/2,e-d/2,t+c/2,e-d/2+p),a.lineTo(t+c/2,e+d/2-p),a.quadraticCurveTo(t+c/2,e+d/2,t+c/2-p,e+d/2),a.lineTo(t+y/2,e+d/2),a.lineTo(t,e+d/2+f),a.lineTo(t-y/2,e+d/2),a.lineTo(t-c/2+p,e+d/2),a.quadraticCurveTo(t-c/2,e+d/2,t-c/2,e+d/2-p),a.lineTo(t-c/2,e-d/2+p),a.quadraticCurveTo(t-c/2,e-d/2,t-c/2+p,e-d/2),a.closePath()}async function Ef(a,t,e){const{text:n,iconUrl:i,fontSize:s=30,iconSize:l=60,fontFamily:u="Arial",padding:c={},bgColor:d="rgba(0,0,0,0.0)",textColor:p="rgb(255,255,255)",strokeColor:f="rgb(0,0,0)",strokeWidth:y=s/9,iconScale:v=.8,canvasScale:x=1,renderbg:S=!0,textOffset:_={x:0,y:0}}=a,Z={top:0,right:1,bottom:0,left:0,...c};let M=null;i&&(M=await $f(i));const{canvas:G,width:A,height:R,center:D}=await qf({text:n,iconImage:M,fontSize:s,iconSize:l,fontFamily:u,padding:Z,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:S,textOffset:_},t),k=new m.Texture(G);k.needsUpdate=!0;const C=new m.SpriteMaterial({map:k,transparent:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,blending:m.NormalBlending,sizeAttenuation:!1,alphaTest:.01}),K=new m.Sprite(C),I=.001;return K.scale.set(A*I,R*I,1),K.center.set(D[0],D[1]),e&&K.position.copy(e),K}async function qf(a,t){return new Promise(e=>{const{text:n,iconImage:i,fontSize:s,iconSize:l,fontFamily:u,padding:c,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:S,textOffset:_={x:0,y:0}}=a,M=document.createElement("canvas").getContext("2d");if(!M)throw new Error("Could not get temp canvas context");M.font=`500 ${s}px ${u}`;const G=M.measureText(n),A=G.width,R=G.actualBoundingBoxAscent||s*.8,D=G.actualBoundingBoxDescent||s*.2,k=i!==null;let C=0,K=0,I=0,z=0;if(k){C=0,K=0,I=l,z=l;const he=l/2+_.x,ve=l/2+_.y,ze=he,Ye=he+A,je=ve-R,Je=ve+D;C=Math.min(C,ze),I=Math.max(I,Ye),K=Math.min(K,je),z=Math.max(z,Je)}else{const he=_.x,ve=_.x+A,ze=_.y-R,Ye=_.y+D;C=he,I=ve,K=ze,z=Ye}const N=I-C,H=z-K,j=Math.ceil(N+c.left+c.right)*x,q=Math.ceil(H+c.top+c.bottom)*x,J=c.left-C,oe=c.top-K,re=t._getCanvas(j,q,n);re.width=j,re.height=q;const te=re.getContext("2d");if(!te)throw new Error("Could not get canvas context");te.clearRect(0,0,j,q),te.globalCompositeOperation="source-over",te.save(),te.scale(x,x);const me=j/x,be=q/x;if(S&&(te.fillStyle=d,te.fillRect(0,0,me,be)),i){const he=J,ve=oe,ze=l*v,Ye=(l-ze)/2,je=(l-ze)/2;te.imageSmoothingEnabled=!1,te.drawImage(i,he+Ye,ve+je,ze,ze),te.font=`500 ${s}px ${u}`,te.textBaseline="alphabetic",te.textAlign="left";const Je=J+l/2+_.x,Qe=oe+l/2+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,Je,Qe)),te.fillStyle=p,te.fillText(n,Je,Qe)}else{te.font=`500 ${s}px ${u}`,te.textBaseline="alphabetic",te.textAlign="left";const he=J+_.x,ve=oe+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,he,ve)),te.fillStyle=p,te.fillText(n,he,ve)}te.restore(),e({canvas:re,width:me,height:be,center:[(l*.5+c.left)/me,(1-v)*.5]})})}function $f(a){return new Promise((t,e)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>t(n),n.onerror=i=>e(new Error(`Failed to load image: ${a} ${i}`)),n.src=a})}async function ep(a,t,e){const i=new m.CylinderGeometry(.2,.2,24,12),s=new m.MeshBasicMaterial({color:a.color}),l=await Wt._loadTexture(a.icon),u=new m.PointsMaterial({size:80*window.innerHeight/window.innerHeight,fog:!1,opacity:1,transparent:!0,toneMapped:!1,blending:m.AdditiveBlending,map:l,sizeAttenuation:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!1}),c=new m.InstancedMesh(i,s,t.length);c.position.add(e.prjcenter),c.castShadow=!0;const d=new m.Object3D,p=[];for(let x=0;x<t.length;x++){const S=t[x],_=new m.Vector3(S.coordinates[0],S.coordinates[1],S.coordinates[2]||0),M=e.geo2world(_).sub(e.prjcenter);d.position.copy(M),d.updateMatrix(),c.setMatrixAt(x,d.matrix),p.push(M.x,0,M.z)}const f=new Float32Array(p),y=new m.BufferGeometry;y.setAttribute("position",new m.BufferAttribute(f,3));const v=new m.Points(y,u);return v.position.add(e.prjcenter),v.position.y=1.5*10,v.renderOrder=99999999,v.visible=!0,console.log(e,"map"),{points:v,InstancedCol:c}}const Yt=class Yt{constructor(t){this.config=t}async applyTo(t){if(!t)return!1;try{switch(t.visible=this.config.visible!==!1,this.config.type){case"basic-point":case"icon-point":case"icon-label-point":return this._applyPointStyle(t);case"basic-line":return this._applyLineStyle(t);case"gltf":case"fbx":return this._applyModelStyle(t);case"basic-polygon":return this._applyPolygonStyle(t);case"extrude-polygon":return this._applyExtrudeStyle(t);case"water":case"base-water":return this._applyWaterStyle(t);case"cloud":return this._applyCloudStyle(t);case"canvas-label":case"canvas-label-fixed":return this._applyTextSpriteStyle(t);case"light":return this._applyLightStyle(t);case"custom":return this._applyCustomStyle(t);default:throw new Error("Unknown style type")}}catch(e){return console.error("Style apply failed:",e),t.visible=!1,!1}}async _applyPointStyle(t){const e=this.config;return e.type==="icon-point"?await this._applyIconPoint(t,e):e.type==="basic-point"?this._applyBasicPoint(t,e):e.type==="icon-label-point"&&this._applyIconLabelPoint(t,e),!0}async _applyIconPoint(t,e){let n;if(t instanceof m.Sprite)n=t;else if(n=await Gl(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),t.parent){let c=t.parent;c._threeGeometry=n,c._updateGeometry()}const i=e.size,[s,l]=Array.isArray(i)?i:[i,i];if(s<=0||l<=0){console.error("Invalid sprite size:",e.size),n.visible=!1;return}const u=n.material;try{if(u.map=await Yt._loadTexture(e.url),!u.map)throw new Error("Texture failed to load");u.needsUpdate=!0,n.scale.set(s,l,1),e.rotation!==void 0&&(n.rotation.z=e.rotation)}catch(c){console.error("Failed to load texture:",e.url,c),n.visible=!1}}_applyBasicPoint(t,e){let n;if(t instanceof m.Points)n=t;else if(n=Zl(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),t.parent){let s=t.parent;s._threeGeometry=n,s._updateGeometry()}const i=n.material;i.size=e.size,e.color&&i.color.set(e.color),e.glow&&(i.sizeAttenuation=!1)}_applyIconLabelPoint(t,e){return!0}_applyLineStyle(t){const e=this.config;if(t.parent){let n=t.parent;n._threeGeometry=Wr(e,n._vertexPoints),n._updateGeometry()}return!0}_applyPolygonStyle(t){return!0}_applyExtrudeStyle(t){return!0}_applyWaterStyle(t){return!0}_applyCloudStyle(t){return!0}_applyTextSpriteStyle(t){return!0}_applyLightStyle(t){return!0}async _applyModelStyle(t){return!0}async _applyCustomStyle(t){const n=await this.config.build();return t instanceof m.Group&&(t.clear(),t.add(n)),!0}static async _loadTexture(t){if(Yt._textureCache.has(t))return Yt._textureCache.get(t);const e=await new Promise((n,i)=>{Yt._textureLoader.load(t,n,void 0,i)});return e.premultiplyAlpha=!0,Yt._textureCache.set(t,e),e}static create(t){return t instanceof Yt?t:new Yt(t)}};T(Yt,"_textureCache",new Map),T(Yt,"_textureLoader",new m.TextureLoader);let Wt=Yt;const et=[];for(let a=0;a<256;++a)et.push((a+256).toString(16).slice(1));function tp(a,t=0){return(et[a[t+0]]+et[a[t+1]]+et[a[t+2]]+et[a[t+3]]+"-"+et[a[t+4]]+et[a[t+5]]+"-"+et[a[t+6]]+et[a[t+7]]+"-"+et[a[t+8]]+et[a[t+9]]+"-"+et[a[t+10]]+et[a[t+11]]+et[a[t+12]]+et[a[t+13]]+et[a[t+14]]+et[a[t+15]]).toLowerCase()}let io;const np=new Uint8Array(16);function ip(){if(!io){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");io=crypto.getRandomValues.bind(crypto)}return io(np)}const Il={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rp(a,t,e){if(Il.randomUUID&&!a)return Il.randomUUID();a=a||{};const n=a.random??a.rng?.()??ip();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,tp(n)}var Cl=(a=>(a.POINT="point",a.LINE_VERTEX="line_vertex",a.POLYGON_CENTER="polygon_center",a.LABEL="label",a.ICON="icon",a.CLUSTER="cluster",a))(Cl||{}),rn=(a=>(a.NO_COLLISION="no_collision",a.PRIORITY_LOST="priority_lost",a.OUT_OF_VIEWPORT="out_of_viewport",a.ZOOM_FILTERED="zoom_filtered",a.MANUAL_HIDDEN="manual_hidden",a.GROUP_COLLISION="group_collision",a))(rn||{});class hn extends qs(Yi(Ui(m.Object3D))){constructor(e){super();T(this,"_position");T(this,"_threeGeometry");T(this,"_geometry");T(this,"_layer");T(this,"_style");T(this,"_id");T(this,"_styleQueue",[]);T(this,"_isApplyingStyle",!1);T(this,"_isGeometryInitializing",!1);T(this,"_collisionState",{visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:Date.now()});T(this,"_collisionConfig",{enabled:!0,priority:50,padding:4,minZoom:0,maxZoom:24});T(this,"_animationRef",null);js(e.geometry,"geometry","geometry must be specified"),this._geometry=e.geometry,this._position=new m.Vector3(0,0,0),this._threeGeometry=new m.Object3D,e.userData&&(this.userData=Object.assign({},JSON.parse(JSON.stringify(e.userData)))),e.style&&this.setStyle(e.style),e.id?this._id=e.id:this._id=rp()}async initializeGeometry(){if(!(this._isGeometryInitializing||this._threeGeometry)){this._isGeometryInitializing=!0;try{await this._toThreeJSGeometry(),this._processStyleQueue()}finally{this._isGeometryInitializing=!1}}}setStyle(e){const n=e instanceof Wt?e:new Wt(e);this._style=n;const i=JSON.parse(JSON.stringify(n.config));return this._styleQueue.push(i),this._tryProcessQueue(),this}getStyle(){return this._style}async _applyStyleWithRetry(e,n=3,i=100){let s=null;for(let l=1;l<=n;l++)try{this._threeGeometry.parent||(this.add(this._threeGeometry),await new Promise(u=>requestAnimationFrame(u))),await e.applyTo(this._threeGeometry);return}catch(u){if(s=u,l<n){const c=i*Math.pow(2,l-1);await new Promise(d=>setTimeout(d,c))}}throw s||new Error("样式应用失败,重试次数耗尽")}async _processStyleQueue(){if(!this._threeGeometry||this._isApplyingStyle||this._styleQueue.length===0)return;this._isApplyingStyle=!0;const e=this._styleQueue[0];try{const n=new Wt(JSON.parse(JSON.stringify(e)));await this._applyStyleWithRetry(n),this._styleQueue.shift(),this._styleQueue.length>0&&await this._processStyleQueue()}catch(n){throw n}finally{this._isApplyingStyle=!1,this._styleQueue.length>0&&this._tryProcessQueue()}}_tryProcessQueue(){this._threeGeometry&&!this._isApplyingStyle&&this._styleQueue.length>0?this._processStyleQueue().catch(n=>{this._isApplyingStyle=!1,this._tryProcessQueue(),console.warn(n)}):!this._threeGeometry&&!this._isGeometryInitializing&&this.initializeGeometry()}addTo(e){return e.addFeature(this),this}getLayer(){return this._layer||null}getMap(){return this._layer?.getMap()||null}_bindLayer(e){if(this._layer&&this._layer!==e)throw new Error("Feature cannot be added to multiple layers");this._layer=e}_updateGeometry(){this._disposeGeometry(),this._threeGeometry&&(this._threeGeometry.position.copy(this._position),console.log(this._threeGeometry,"threeGeometry"),this._threeGeometry?.userData?._type==="Model"?this._threeGeometry.renderOrder=0:this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue())}_remove(){return this.getLayer()?(this._unbind(),this):this}_unbind(){const e=this.getLayer();e&&(e.onRemoveFeature&&e.onRemoveFeature(this),delete this._layer)}_disposeGeometry(){this._threeGeometry&&(this.clear(),"traverse"in this&&this._threeGeometry.traverse(e=>{e instanceof m.Mesh?(e.geometry?.dispose(),Array.isArray(e.material)?e.material.forEach(n=>n.dispose()):e.material?.dispose()):"isLine"in e&&e.isLine&&(e.geometry?.dispose(),e.material?.dispose())}))}get collidable(){return this._collisionConfig.enabled}get collisionType(){return Cl.POINT}getCollisionPriority(){return this.userData.collisionPriority??this._style?.config.collisionPriority??this._collisionConfig.priority}getScreenBoundingBox(e,n){if(!this.collidable)return null;try{const i=new m.Vector3;this._threeGeometry.getWorldPosition(i);const s=i.clone().project(e);if(!(s.x>=-1.1&&s.x<=1.1&&s.y>=-1.1&&s.y<=1.1&&s.z>=-1&&s.z<=1))return null;const{width:u,height:c}=n.domElement,d=(s.x*.5+.5)*u,p=(-s.y*.5+.5)*c,f=this._calculateCollisionBoundingBox(e,n);return f?{id:this._id,x:d+f.offsetX,y:p+f.offsetY,width:20+this._collisionConfig.padding*2,height:20+this._collisionConfig.padding*2,priority:this.getCollisionPriority(),featureId:this._id,layerId:this._layer?.getId()||"unknown",type:this.collisionType,data:this.getCollisionData()}:null}catch(i){return console.warn(`Feature ${this._id} 包围盒计算失败:`,i),null}}setCollisionVisibility(e,n=rn.MANUAL_HIDDEN){this._collisionState.visible!==e&&(this._animationRef!==null&&(cancelAnimationFrame(this._animationRef),this._animationRef=null),this.visible=e,this._applyFinalAlpha(e?1:0),this._collisionState={visible:e,reason:n,collidedWith:e?[]:this._collisionState.collidedWith,timestamp:Date.now()})}getCollisionVisibility(){return this._collisionState.visible}setCollisionConfig(e){return Object.assign(this._collisionConfig,e),this}enableCollision(){return this._collisionConfig.enabled=!0,this}disableCollision(){return this._collisionConfig.enabled=!1,this.setCollisionVisibility(!0,rn.MANUAL_HIDDEN),this}_applyVisibilityAlpha(e){this.traverse(n=>{n instanceof m.Mesh&&(Array.isArray(n.material)?n.material.forEach(i=>{i.opacity!==void 0&&(i.opacity=e)}):n.material.opacity!==void 0&&(n.material.opacity=e))})}_applyFinalAlpha(e){this._applyVisibilityAlpha(e),this.traverse(n=>{n instanceof m.Mesh&&(n.material.needsUpdate=!0)})}getCollisionData(){return{featureType:this.constructor.name,userData:this.userData,styleConfig:this._style?.config}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{const i=new m.Box3().setFromObject(this._threeGeometry);if(i.isEmpty())return this._getFallbackBoundingBox();const s=[new m.Vector3(i.min.x,i.min.y,i.min.z),new m.Vector3(i.max.x,i.min.y,i.min.z),new m.Vector3(i.min.x,i.max.y,i.min.z),new m.Vector3(i.max.x,i.max.y,i.min.z),new m.Vector3(i.min.x,i.min.y,i.max.z),new m.Vector3(i.max.x,i.min.y,i.max.z),new m.Vector3(i.min.x,i.max.y,i.max.z),new m.Vector3(i.max.x,i.max.y,i.max.z)],{width:l,height:u}=n.domElement,c=[];s.forEach(D=>{const k=D.clone().project(e),C=(k.x*.5+.5)*l,K=(-k.y*.5+.5)*u;c.push(new m.Vector2(C,K))});let d=1/0,p=-1/0,f=1/0,y=-1/0;c.forEach(D=>{d=Math.min(d,D.x),p=Math.max(p,D.x),f=Math.min(f,D.y),y=Math.max(y,D.y)});const v=p-d,x=y-f,S=4,_=Math.max(v,S),Z=Math.max(x,S),M=new m.Vector3;i.getCenter(M);const G=M.clone().project(e),A=(G.x*.5+.5)*l,R=(-G.y*.5+.5)*u;return{width:_,height:Z,offsetX:d-A,offsetY:f-R}}catch(i){return console.warn("包围盒计算失败:",i),this._getFallbackBoundingBox()}}_getFallbackBoundingBox(){return{width:20,height:20,offsetX:-10,offsetY:-10}}_tileCoordToLocalWorld(e,n,i,s){const{tileZ:l,tileX:u,tileY:c,extent:d,tileSize:p}=i,f=(e/d-.5)*p,y=(.5-n/d)*p;return s.tileIDToWorldCenter(l,u,c).clone().add(new m.Vector3(f,y,0)).sub(s.prjcenter)}}class Bn extends Tr{constructor(e,n){super(e,n);T(this,"_feaList");T(this,"_collision",!1);this._feaList=[],n?.collision&&(this._collision=!0)}addFeature(e){const n=Array.isArray(e)?e:[e];for(const i of n)if(!(!i||!(i instanceof hn))&&!i.getLayer()){if(!this.validateFeature(i)){console.error(`Feature ${i.id} does not match the layer's type requirements`);continue}i._bindLayer(this),this._feaList.push(i),i.getMap()&&i._toThreeJSGeometry(),this._clouds&&(this.map.viewer.scene.add(this._clouds),console.log("我是云朵被添加cloud",this.map.viewer.scene)),this.add(i)}return this}getFeatures(e,n){if(!e)return this._feaList.slice(0);const i=[];let s,l;for(let u=0,c=this._feaList.length;u<c;u++)s=this._feaList[u],n?l=e.call(n,s):l=e(s),l&&i.push(s);return i}getCount(){return this._feaList.length}isEmpty(){return!this._feaList.length}removeFeature(e){if(!Array.isArray(e))return this.removeFeature([e]);for(let n=e.length-1;n>=0;n--)e[n]instanceof hn||(e[n]=this.removeFeature(e[n])),!(!e[n]||this!==e[n].getLayer())&&e[n]._remove();return this}clear(){const e=this._feaList.slice();for(const n of e)n._remove();return this}onRemoveFeature(e){if(!e)return;const n=e.getLayer();if(!n||n!==this)return;const i=this._findInList(e);i>=0&&this._feaList.splice(i,1),e.parent&&e.parent===this?this.remove(e):console.warn("Feature parent mismatch:",e.parent),this._disposeFeatureResources(e)}_findInList(e){const n=this._feaList.length;if(n===0)return-1;let i=0,s=n-1,l;for(;i<=s;){if(l=Math.floor((i+s)/2),this._feaList[l]===e)return l;i=l+1}return-1}_disposeFeatureResources(e){try{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>n.dispose?.()):e.material.dispose&&e.material.dispose()),e instanceof m.Object3D&&e.traverse(n=>{n!==e&&this._disposeFeatureResources(n)})}catch(n){console.error("Error disposing feature resources:",n)}}_mergedGeometry(){this.traverse(e=>{e.isMesh&&e.geometry&&e.material&&console.log("几何体合并中",e)})}setCollisionEngine(e){return this._collisionEngine=e,this}}class sp extends m.Group{constructor(){super(...arguments);T(this,"_layers",new Set);T(this,"_layerids",new Set)}add(...e){return e.forEach(n=>{if(!(n instanceof Tr))throw new Error("LayerContainer只能包含Layer实例!");const i=n.getId();if(this._layerids.has(i))throw new Error(`ID为'${i}'的图层已存在于容器中!`);this._layers.add(n),this._layerids.add(i),super.add(n)}),this}remove(...e){return e.forEach(n=>{this._layers.delete(n),this._layerids.delete(n.getId()),super.remove(n)}),this}getLayers(){return Array.from(this._layers)}getLayerById(e){for(const n of this._layers)if(n.getId()===e)return n}clearLayers(){return this._layers.clear(),this._layerids.clear(),super.clear(),this}}class op{constructor(){T(this,"canvasDict",{})}getCanvas(t=40,e=30,n=1,i){const s=Math.ceil(t*n),l=Math.ceil(e*n),u=i?`${s}_${l}_${i}`:`${s}_${l}`;if(!this.canvasDict[u]){const p=document.createElement("canvas");p.width=s,p.height=l,this.canvasDict[u]=p}const c=this.canvasDict[u],d=c.getContext("2d");return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.scale(n,n),c}}function ap(a){const t=+this._x.call(null,a),e=+this._y.call(null,a);return Vl(this.cover(t,e),t,e,a)}function Vl(a,t,e,n){if(isNaN(t)||isNaN(e))return a;var i,s=a._root,l={data:n},u=a._x0,c=a._y0,d=a._x1,p=a._y1,f,y,v,x,S,_,Z,M;if(!s)return a._root=l,a;for(;s.length;)if((S=t>=(f=(u+d)/2))?u=f:d=f,(_=e>=(y=(c+p)/2))?c=y:p=y,i=s,!(s=s[Z=_<<1|S]))return i[Z]=l,a;if(v=+a._x.call(null,s.data),x=+a._y.call(null,s.data),t===v&&e===x)return l.next=s,i?i[Z]=l:a._root=l,a;do i=i?i[Z]=new Array(4):a._root=new Array(4),(S=t>=(f=(u+d)/2))?u=f:d=f,(_=e>=(y=(c+p)/2))?c=y:p=y;while((Z=_<<1|S)===(M=(x>=y)<<1|v>=f));return i[M]=s,i[Z]=l,a}function lp(a){var t,e,n=a.length,i,s,l=new Array(n),u=new Array(n),c=1/0,d=1/0,p=-1/0,f=-1/0;for(e=0;e<n;++e)isNaN(i=+this._x.call(null,t=a[e]))||isNaN(s=+this._y.call(null,t))||(l[e]=i,u[e]=s,i<c&&(c=i),i>p&&(p=i),s<d&&(d=s),s>f&&(f=s));if(c>p||d>f)return this;for(this.cover(c,d).cover(p,f),e=0;e<n;++e)Vl(this,l[e],u[e],a[e]);return this}function cp(a,t){if(isNaN(a=+a)||isNaN(t=+t))return this;var e=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(e))i=(e=Math.floor(a))+1,s=(n=Math.floor(t))+1;else{for(var l=i-e||1,u=this._root,c,d;e>a||a>=i||n>t||t>=s;)switch(d=(t<n)<<1|a<e,c=new Array(4),c[d]=u,u=c,l*=2,d){case 0:i=e+l,s=n+l;break;case 1:e=i-l,s=n+l;break;case 2:i=e+l,n=s-l;break;case 3:e=i-l,n=s-l;break}this._root&&this._root.length&&(this._root=u)}return this._x0=e,this._y0=n,this._x1=i,this._y1=s,this}function up(){var a=[];return this.visit(function(t){if(!t.length)do a.push(t.data);while(t=t.next)}),a}function hp(a){return arguments.length?this.cover(+a[0][0],+a[0][1]).cover(+a[1][0],+a[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function lt(a,t,e,n,i){this.node=a,this.x0=t,this.y0=e,this.x1=n,this.y1=i}function dp(a,t,e){var n,i=this._x0,s=this._y0,l,u,c,d,p=this._x1,f=this._y1,y=[],v=this._root,x,S;for(v&&y.push(new lt(v,i,s,p,f)),e==null?e=1/0:(i=a-e,s=t-e,p=a+e,f=t+e,e*=e);x=y.pop();)if(!(!(v=x.node)||(l=x.x0)>p||(u=x.y0)>f||(c=x.x1)<i||(d=x.y1)<s))if(v.length){var _=(l+c)/2,Z=(u+d)/2;y.push(new lt(v[3],_,Z,c,d),new lt(v[2],l,Z,_,d),new lt(v[1],_,u,c,Z),new lt(v[0],l,u,_,Z)),(S=(t>=Z)<<1|a>=_)&&(x=y[y.length-1],y[y.length-1]=y[y.length-1-S],y[y.length-1-S]=x)}else{var M=a-+this._x.call(null,v.data),G=t-+this._y.call(null,v.data),A=M*M+G*G;if(A<e){var R=Math.sqrt(e=A);i=a-R,s=t-R,p=a+R,f=t+R,n=v.data}}return n}function fp(a){if(isNaN(p=+this._x.call(null,a))||isNaN(f=+this._y.call(null,a)))return this;var t,e=this._root,n,i,s,l=this._x0,u=this._y0,c=this._x1,d=this._y1,p,f,y,v,x,S,_,Z;if(!e)return this;if(e.length)for(;;){if((x=p>=(y=(l+c)/2))?l=y:c=y,(S=f>=(v=(u+d)/2))?u=v:d=v,t=e,!(e=e[_=S<<1|x]))return this;if(!e.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(n=t,Z=_)}for(;e.data!==a;)if(i=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,i?(s?i.next=s:delete i.next,this):t?(s?t[_]=s:delete t[_],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(n?n[Z]=e:this._root=e),this):(this._root=s,this)}function pp(a){for(var t=0,e=a.length;t<e;++t)this.remove(a[t]);return this}function mp(){return this._root}function gp(){var a=0;return this.visit(function(t){if(!t.length)do++a;while(t=t.next)}),a}function yp(a){var t=[],e,n=this._root,i,s,l,u,c;for(n&&t.push(new lt(n,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!a(n=e.node,s=e.x0,l=e.y0,u=e.x1,c=e.y1)&&n.length){var d=(s+u)/2,p=(l+c)/2;(i=n[3])&&t.push(new lt(i,d,p,u,c)),(i=n[2])&&t.push(new lt(i,s,p,d,c)),(i=n[1])&&t.push(new lt(i,d,l,u,p)),(i=n[0])&&t.push(new lt(i,s,l,d,p))}return this}function vp(a){var t=[],e=[],n;for(this._root&&t.push(new lt(this._root,this._x0,this._y0,this._x1,this._y1));n=t.pop();){var i=n.node;if(i.length){var s,l=n.x0,u=n.y0,c=n.x1,d=n.y1,p=(l+c)/2,f=(u+d)/2;(s=i[0])&&t.push(new lt(s,l,u,p,f)),(s=i[1])&&t.push(new lt(s,p,u,c,f)),(s=i[2])&&t.push(new lt(s,l,f,p,d)),(s=i[3])&&t.push(new lt(s,p,f,c,d))}e.push(n)}for(;n=e.pop();)a(n.node,n.x0,n.y0,n.x1,n.y1);return this}function wp(a){return a[0]}function xp(a){return arguments.length?(this._x=a,this):this._x}function bp(a){return a[1]}function _p(a){return arguments.length?(this._y=a,this):this._y}function Al(a,t,e){var n=new ro(t??wp,e??bp,NaN,NaN,NaN,NaN);return a==null?n:n.addAll(a)}function ro(a,t,e,n,i,s){this._x=a,this._y=t,this._x0=e,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function Fl(a){for(var t={data:a.data},e=t;a=a.next;)e=e.next={data:a.data};return t}var ct=Al.prototype=ro.prototype;ct.copy=function(){var a=new ro(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,n;if(!t)return a;if(!t.length)return a._root=Fl(t),a;for(e=[{source:t,target:a._root=new Array(4)}];t=e.pop();)for(var i=0;i<4;++i)(n=t.source[i])&&(n.length?e.push({source:n,target:t.target[i]=new Array(4)}):t.target[i]=Fl(n));return a},ct.add=ap,ct.addAll=lp,ct.cover=cp,ct.data=up,ct.extent=hp,ct.find=dp,ct.remove=fp,ct.removeAll=pp,ct.root=mp,ct.size=gp,ct.visit=yp,ct.visitAfter=vp,ct.x=xp,ct.y=_p;class Xl{constructor(t){T(this,"_quadtree");T(this,"_viewport");this._viewport=t,this._rebuildQuadTree()}updateViewport(t){(t.width!==this._viewport.width||t.height!==this._viewport.height)&&(this._viewport=t,this._rebuildQuadTree())}addBoxes(t){t.forEach(e=>{this._isBoxInViewport(e)&&this._quadtree.add(e)})}findCollisions(t){const e=[],n=this._getSearchBounds(t);return this._quadtree.visit((i,s,l,u,c)=>this._checkNodeCollision(n,s,l,u,c)?(i.length||this._getNodeData(i).forEach(p=>{p.id!==t.id&&this._checkBoxCollision(t,p)&&e.push(p)}),!1):void 0),e}clear(){this._rebuildQuadTree()}getAllBoxes(){const t=[];return this._quadtree.visit(e=>{if(!e.length){const n=this._getNodeData(e);t.push(...n)}return!1}),t}_rebuildQuadTree(){this._quadtree=Al().x(t=>t.x).y(t=>t.y).extent([[0,0],[this._viewport.width,this._viewport.height]])}_isBoxInViewport(t){const e=t.width/2,n=t.height/2;return t.x+e>=0&&t.x-e<=this._viewport.width&&t.y+n>=0&&t.y-n<=this._viewport.height}_getSearchBounds(t){return{x:t.x,y:t.y,width:t.width*2,height:t.height*2}}_checkNodeCollision(t,e,n,i,s){const l=(e+i)/2,u=(n+s)/2,c=i-e,d=s-n;return Math.abs(t.x-l)*2<t.width+c&&Math.abs(t.y-u)*2<t.height+d}_checkBoxCollision(t,e){return Math.abs(t.x-e.x)*2<t.width+e.width&&Math.abs(t.y-e.y)*2<t.height+e.height}_getNodeData(t){return t?Array.isArray(t.data)?t.data:t.data?[t.data]:[]:[]}removeBox(t){const n=this.getAllBoxes().filter(i=>i.id!==t);this.clear(),n.length>0&&this.addBoxes(n)}}class Mp{constructor(){T(this,"_strategies",new Map);T(this,"_executionOrder",[])}registerStrategy(t,e){return this._strategies.set(t.name,t),e!==void 0?this._executionOrder.splice(e,0,t.name):this._executionOrder.push(t.name),this}async executeStrategies(t,e){const n=new Map;t.forEach(i=>{n.set(i._id,{featureId:i._id,visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})});for(const i of this._executionOrder){const s=this._strategies.get(i);if(s?.enabled)try{const l=await s.execute(t,e,n);this._mergeResults(n,l)}catch(l){console.error(`策略 ${i} 执行失败:`,l)}}return n}_mergeResults(t,e){e.forEach(n=>{const i=t.get(n.featureId);i&&!i.visible||t.set(n.featureId,n)})}}class Lp{constructor(){T(this,"frameStats",new Map);T(this,"summaryStats",{totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0});T(this,"sampleWindowSize",60);T(this,"currentFrameId",0);T(this,"lastReportTime",0);T(this,"reportInterval",5e3);T(this,"performanceThresholds",{criticalFrameTime:33,warningFrameTime:16,idealFrameTime:8});this.lastReportTime=Date.now()}startFrame(t){this.currentFrameId=t;const e={frameId:t,startTime:performance.now(),endTime:0,duration:0,featureCount:0,visibleCount:0,hiddenCount:0,collisionChecks:0,memoryUsage:0,strategyTimes:new Map};this.frameStats.set(t,e),this.cleanupOldFrames()}endFrame(t,e){const n=this.frameStats.get(t);if(!n)return;const i=performance.now();n.endTime=i,n.duration=i-n.startTime,e&&Object.assign(n,e),"memory"in performance&&(n.memoryUsage=performance.memory.usedJSHeapSize),this.updateSummaryStats(n),this.maybeOutputReport()}recordStrategyTime(t,e){const n=this.frameStats.get(this.currentFrameId);n&&n.strategyTimes.set(t,e)}recordCollisionChecks(t){const e=this.frameStats.get(this.currentFrameId);e&&(e.collisionChecks+=t)}getStats(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.calculateFPS(t),n=this.calculateAverageFrameTime(t);return{summary:{...this.summaryStats},recent:{fps:e,frameTime:n,frameTimeStdDev:this.calculateFrameTimeStdDev(t),averageFeaturesPerFrame:this.calculateAverageFeatures(t),performanceLevel:this.getPerformanceLevel(n)},currentFrame:this.frameStats.get(this.currentFrameId)||null,strategies:this.getStrategyPerformance(t),warnings:this.getPerformanceWarnings(t)}}getDetailedReport(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.getStats();return{...e,frameHistory:Array.from(t.values()),trends:this.calculateTrends(t),recommendations:this.getPerformanceRecommendations(e)}}reset(){this.frameStats.clear(),this.summaryStats={totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0},this.currentFrameId=0,this.lastReportTime=Date.now()}cleanupOldFrames(){this.frameStats.size>this.sampleWindowSize*2&&Array.from(this.frameStats.keys()).sort((e,n)=>e-n).slice(0,this.frameStats.size-this.sampleWindowSize).forEach(e=>{this.frameStats.delete(e)})}updateSummaryStats(t){this.summaryStats.totalFrames++,this.summaryStats.totalFeaturesProcessed+=t.featureCount||0,this.summaryStats.averageFrameTime=(this.summaryStats.averageFrameTime*(this.summaryStats.totalFrames-1)+t.duration)/this.summaryStats.totalFrames,this.summaryStats.minFrameTime=Math.min(this.summaryStats.minFrameTime,t.duration),this.summaryStats.maxFrameTime=Math.max(this.summaryStats.maxFrameTime,t.duration),this.summaryStats.averageFPS=1e3/this.summaryStats.averageFrameTime}maybeOutputReport(){const t=Date.now();if(t-this.lastReportTime>=this.reportInterval){const e=this.getStats();e.warnings.length>0?console.warn("避让系统性能报告:",e):console.log("避让系统性能正常:",e),this.lastReportTime=t}}getRecentFrames(t){return Array.from(this.frameStats.values()).slice(-t).filter(n=>n.duration>0)}calculateFPS(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t);return e>0?1e3/e:0}calculateAverageFrameTime(t){return t.length===0?0:t.reduce((e,n)=>e+n.duration,0)/t.length}calculateFrameTimeStdDev(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t),n=t.map(i=>Math.pow(i.duration-e,2));return Math.sqrt(n.reduce((i,s)=>i+s,0)/t.length)}calculateAverageFeatures(t){return t.length===0?0:t.reduce((e,n)=>e+(n.featureCount||0),0)/t.length}getPerformanceLevel(t){return t>this.performanceThresholds.criticalFrameTime?"critical":t>this.performanceThresholds.warningFrameTime?"warning":t>this.performanceThresholds.idealFrameTime?"good":"excellent"}getStrategyPerformance(t){const e=new Map;return t.forEach(n=>{n.strategyTimes.forEach((i,s)=>{e.has(s)||e.set(s,[]),e.get(s).push(i)})}),Array.from(e.entries()).map(([n,i])=>({name:n,averageTime:i.reduce((s,l)=>s+l,0)/i.length,maxTime:Math.max(...i),minTime:Math.min(...i),callCount:i.length}))}getPerformanceWarnings(t){const e=[],n=t.slice(-30);if(n.length===0)return e;const i=this.calculateAverageFrameTime(n);i>this.performanceThresholds.criticalFrameTime?e.push({type:"critical",message:`帧率过低: ${Math.round(1e3/i)}fps`,suggestion:"考虑减少要素数量或简化避让策略"}):i>this.performanceThresholds.warningFrameTime&&e.push({type:"warning",message:`帧率较低: ${Math.round(1e3/i)}fps`,suggestion:"建议优化避让算法或增加更新间隔"});const s=n.map(l=>l.memoryUsage).filter(l=>l>0);if(s.length>0){const l=s.reduce((u,c)=>u+c,0)/s.length;l>100*1024*1024&&e.push({type:"warning",message:`内存使用较高: ${(l/1024/1024).toFixed(1)}MB`,suggestion:"检查内存泄漏,及时清理无用资源"})}return e}calculateTrends(t){if(t.length<2)return{frameTime:"stable",fps:"stable",features:"stable"};const e=t.slice(0,Math.floor(t.length/2)),n=t.slice(Math.floor(t.length/2)),i=this.calculateAverageFrameTime(e),l=(this.calculateAverageFrameTime(n)-i)/i*100;return{frameTime:Math.abs(l)<5?"stable":l>0?"worsening":"improving",fps:Math.abs(l)<5?"stable":l>0?"improving":"worsening",features:"stable"}}getPerformanceRecommendations(t){const e=[];return t.recent.performanceLevel==="critical"&&(e.push("建议启用要素抽样或聚合显示"),e.push("考虑增加避让更新间隔时间"),e.push("检查是否有不必要的避让策略")),t.recent.averageFeaturesPerFrame>5e3&&e.push("要素数量过多,建议启用LOD分级"),t.strategies.forEach(n=>{n.averageTime>10&&e.push(`策略 "${n.name}" 执行时间较长,考虑优化`)}),e}}class Sp{constructor(){T(this,"name","priority");T(this,"enabled",!0);T(this,"weight",1);T(this,"description","基于优先级的避让策略,数值越小优先级越高")}async execute(t,e,n){const i=[],s=new Xl(e.viewport),l=[],u=new Map;return t.forEach(c=>{if(!c.collidable)return;const d=c.getScreenBoundingBox(e.camera,e.renderer);d&&(l.push(d),u.set(c._id,c),n?.get(c._id)?.visible)}),l.sort((c,d)=>c.priority-d.priority),l.forEach(c=>{const d=s.findCollisions(c);d.length===0?(s.addBoxes([c]),i.push({featureId:c.featureId,visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})):d.some(f=>f.priority<c.priority)?i.push({featureId:c.featureId,visible:!1,reason:rn.PRIORITY_LOST,collidedWith:d.map(f=>f.featureId),timestamp:e.timestamp}):(s.addBoxes([c]),i.push({featureId:c.featureId,visible:!0,reason:rn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp}),d.forEach(f=>{i.push({featureId:f.featureId,visible:!1,reason:rn.PRIORITY_LOST,collidedWith:[c.featureId],timestamp:e.timestamp})}))}),i}}class Tp{constructor(t,e={}){T(this,"_quadTreeManager");T(this,"_strategyOrchestrator");T(this,"_performanceMonitor");T(this,"_layers",new Set);T(this,"_config");T(this,"_isUpdating",!1);T(this,"_lastUpdateTime",0);T(this,"_frameCount",0);this.renderer=t,this._config={enabled:!0,padding:4,updateInterval:0,animationDuration:300,maxFeaturesPerFrame:2e3,viewportMargin:50,strategies:{priority:!0,grouping:!1,proximity:!1},...e},this._initializeComponents(),this._setupPerformanceMonitoring()}async update(t){if(!this._config.enabled||this._isUpdating)return;const e=Date.now();if(!(this._config.updateInterval>0&&e-this._lastUpdateTime<this._config.updateInterval)){this._isUpdating=!0,this._frameCount++;try{this._resetAllFeaturesVisibility();const n=this._createCollisionContext(t,e),i=this._collectCollidableFeatures();if(i.length===0)return;this._performanceMonitor.startFrame(this._frameCount);const s=await this._strategyOrchestrator.executeStrategies(i,n);await this._applyCollisionResults(s,i),this._performanceMonitor.endFrame(this._frameCount,{featureCount:i.length,visibleCount:Array.from(s.values()).filter(l=>l.visible).length,hiddenCount:Array.from(s.values()).filter(l=>!l.visible).length}),this._lastUpdateTime=e}catch(n){console.error("避让引擎更新失败:",n)}finally{this._isUpdating=!1}}}_resetAllFeaturesVisibility(){this._layers.forEach(t=>{t.getFeatures().filter(n=>n.collidable).forEach(n=>{n.setCollisionVisibility(!0,rn.NO_COLLISION)})})}registerLayer(t){return this._layers.add(t),this}unregisterLayer(t){return this._layers.delete(t),this}setConfig(t){return Object.assign(this._config,t),this}getPerformanceStats(){return this._performanceMonitor.getStats()}_initializeComponents(){const t={width:this.renderer.domElement.width,height:this.renderer.domElement.height};this._quadTreeManager=new Xl(t),this._strategyOrchestrator=new Mp,this._performanceMonitor=new Lp,this._strategyOrchestrator.registerStrategy(new Sp,0),this._setupViewportResizeHandler()}_createCollisionContext(t,e){return{camera:t,renderer:this.renderer,viewport:{width:this.renderer.domElement.width,height:this.renderer.domElement.height},zoomLevel:t.position.z,timestamp:e,frameNumber:this._frameCount}}_collectCollidableFeatures(){const t=[];return this._layers.forEach(e=>{const n=e.getFeatures().filter(i=>i.collidable&&i instanceof hn);if(t.length+n.length>this._config.maxFeaturesPerFrame){console.warn(`达到每帧最大要素处理限制: ${this._config.maxFeaturesPerFrame}`);return}t.push(...n)}),t}async _applyCollisionResults(t,e){const n=e.map(i=>{const s=t.get(i._id);return s&&i.setCollisionVisibility(s.visible,s.reason),Promise.resolve()});await Promise.all(n)}_setupViewportResizeHandler(){new ResizeObserver(e=>{e.forEach(n=>{const{width:i,height:s}=n.contentRect;this._quadTreeManager.updateViewport({width:i,height:s})})}).observe(this.renderer.domElement)}_setupPerformanceMonitoring(){setInterval(()=>{const t=this.getPerformanceStats();t.frameRate<30&&console.warn("避让系统性能警告:",t)},5e3)}}var Ni=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Pr={exports:{}};/**
|
|
540
540
|
* @license
|
|
541
541
|
* Lodash <https://lodash.com/>
|
|
542
542
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
543
543
|
* Released under MIT license <https://lodash.com/license>
|
|
544
544
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
545
545
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
546
|
-
*/Pi.exports,function(l,t){(function(){var e,n="4.17.21",r=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",c="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,p="__lodash_placeholder__",f=1,y=2,v=4,x=1,L=2,_=1,S=2,Z=4,G=8,A=16,K=32,D=64,O=128,V=256,R=512,W=30,k="...",N=800,H=16,j=1,q=2,J=3,oe=1/0,ie=9007199254740991,te=17976931348623157e292,me=NaN,be=4294967295,he=be-1,ve=be>>>1,ke=[["ary",O],["bind",_],["bindKey",S],["curry",G],["curryRight",A],["flip",R],["partial",K],["partialRight",D],["rearg",V]],Ye="[object Arguments]",je="[object Array]",Je="[object AsyncFunction]",Qe="[object Boolean]",ct="[object Date]",pt="[object DOMException]",Ue="[object Error]",hn="[object Function]",Gn="[object GeneratorFunction]",Ae="[object Map]",Ut="[object Number]",It="[object Null]",Wt="[object Object]",jr="[object Promise]",Xi="[object Proxy]",Jn="[object RegExp]",xt="[object Set]",Pn="[object String]",In="[object Symbol]",Qn="[object Undefined]",Hn="[object WeakMap]",vo="[object WeakSet]",Wn="[object ArrayBuffer]",sn="[object DataView]",Jr="[object Float32Array]",Qr="[object Float64Array]",mr="[object Int8Array]",Hr="[object Int16Array]",Er="[object Int32Array]",gr="[object Uint8Array]",En="[object Uint8ClampedArray]",X="[object Uint16Array]",E="[object Uint32Array]",ue=/\b__p \+= '';/g,Se=/\b(__p \+=) '' \+/g,Re=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ct=/&(?:amp|lt|gt|quot|#39);/g,Bt=/[&<>"']/g,sc=RegExp(Ct.source),ki=RegExp(Bt.source),Nt=/<%-([\s\S]+?)%>/g,jt=/<%([\s\S]+?)%>/g,Cn=/<%=([\s\S]+?)%>/g,qn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$n=/^\w*$/,yr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,wo=/[\\^$.*+?()[\]{}|]/g,h0=RegExp(wo.source),xo=/^\s+/,d0=/\s/,f0=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,p0=/\{\n\/\* \[wrapped with (.+)\] \*/,m0=/,? & /,g0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,y0=/[()=,{}\[\]\/\s]/,v0=/\\(\\)?/g,w0=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,oc=/\w*$/,x0=/^[-+]0x[0-9a-f]+$/i,b0=/^0b[01]+$/i,_0=/^\[object .+?Constructor\]$/,M0=/^0o[0-7]+$/i,L0=/^(?:0|[1-9]\d*)$/,S0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Di=/($^)/,Z0=/['\n\r\u2028\u2029\\]/g,zi="\\ud800-\\udfff",T0="\\u0300-\\u036f",G0="\\ufe20-\\ufe2f",P0="\\u20d0-\\u20ff",ac=T0+G0+P0,lc="\\u2700-\\u27bf",cc="a-z\\xdf-\\xf6\\xf8-\\xff",I0="\\xac\\xb1\\xd7\\xf7",W0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",C0="\\u2000-\\u206f",V0=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",uc="A-Z\\xc0-\\xd6\\xd8-\\xde",hc="\\ufe0e\\ufe0f",dc=I0+W0+C0+V0,bo="['’]",A0="["+zi+"]",fc="["+dc+"]",Oi="["+ac+"]",pc="\\d+",F0="["+lc+"]",mc="["+cc+"]",gc="[^"+zi+dc+pc+lc+cc+uc+"]",_o="\\ud83c[\\udffb-\\udfff]",X0="(?:"+Oi+"|"+_o+")",yc="[^"+zi+"]",Mo="(?:\\ud83c[\\udde6-\\uddff]){2}",Lo="[\\ud800-\\udbff][\\udc00-\\udfff]",vr="["+uc+"]",vc="\\u200d",wc="(?:"+mc+"|"+gc+")",k0="(?:"+vr+"|"+gc+")",xc="(?:"+bo+"(?:d|ll|m|re|s|t|ve))?",bc="(?:"+bo+"(?:D|LL|M|RE|S|T|VE))?",_c=X0+"?",Mc="["+hc+"]?",D0="(?:"+vc+"(?:"+[yc,Mo,Lo].join("|")+")"+Mc+_c+")*",z0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",O0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Lc=Mc+_c+D0,K0="(?:"+[F0,Mo,Lo].join("|")+")"+Lc,R0="(?:"+[yc+Oi+"?",Oi,Mo,Lo,A0].join("|")+")",Y0=RegExp(bo,"g"),U0=RegExp(Oi,"g"),So=RegExp(_o+"(?="+_o+")|"+R0+Lc,"g"),B0=RegExp([vr+"?"+mc+"+"+xc+"(?="+[fc,vr,"$"].join("|")+")",k0+"+"+bc+"(?="+[fc,vr+wc,"$"].join("|")+")",vr+"?"+wc+"+"+xc,vr+"+"+bc,O0,z0,pc,K0].join("|"),"g"),N0=RegExp("["+vc+zi+ac+hc+"]"),j0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,J0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map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===Object&&self,nt=Sc||ng||Function("return this")(),Zo=t&&!t.nodeType&&t,er=Zo&&!0&&l&&!l.nodeType&&l,Zc=er&&er.exports===Zo,To=Zc&&Sc.process,Vt=function(){try{var C=er&&er.require&&er.require("util").types;return C||To&&To.binding&&To.binding("util")}catch{}}(),Tc=Vt&&Vt.isArrayBuffer,Gc=Vt&&Vt.isDate,Pc=Vt&&Vt.isMap,Ic=Vt&&Vt.isRegExp,Wc=Vt&&Vt.isSet,Cc=Vt&&Vt.isTypedArray;function bt(C,Y,z){switch(z.length){case 0:return C.call(Y);case 1:return C.call(Y,z[0]);case 2:return C.call(Y,z[0],z[1]);case 3:return C.call(Y,z[0],z[1],z[2])}return C.apply(Y,z)}function rg(C,Y,z,ne){for(var de=-1,Ze=C==null?0:C.length;++de<Ze;){var Be=C[de];Y(ne,Be,z(Be),C)}return ne}function At(C,Y){for(var z=-1,ne=C==null?0:C.length;++z<ne&&Y(C[z],z,C)!==!1;);return C}function ig(C,Y){for(var z=C==null?0:C.length;z--&&Y(C[z],z,C)!==!1;);return C}function Vc(C,Y){for(var z=-1,ne=C==null?0:C.length;++z<ne;)if(!Y(C[z],z,C))return!1;return!0}function Vn(C,Y){for(var z=-1,ne=C==null?0:C.length,de=0,Ze=[];++z<ne;){var Be=C[z];Y(Be,z,C)&&(Ze[de++]=Be)}return Ze}function Ki(C,Y){var z=C==null?0:C.length;return!!z&&wr(C,Y,0)>-1}function Go(C,Y,z){for(var ne=-1,de=C==null?0:C.length;++ne<de;)if(z(Y,C[ne]))return!0;return!1}function Ve(C,Y){for(var z=-1,ne=C==null?0:C.length,de=Array(ne);++z<ne;)de[z]=Y(C[z],z,C);return de}function An(C,Y){for(var z=-1,ne=Y.length,de=C.length;++z<ne;)C[de+z]=Y[z];return C}function Po(C,Y,z,ne){var de=-1,Ze=C==null?0:C.length;for(ne&&Ze&&(z=C[++de]);++de<Ze;)z=Y(z,C[de],de,C);return z}function sg(C,Y,z,ne){var de=C==null?0:C.length;for(ne&&de&&(z=C[--de]);de--;)z=Y(z,C[de],de,C);return z}function Io(C,Y){for(var z=-1,ne=C==null?0:C.length;++z<ne;)if(Y(C[z],z,C))return!0;return!1}var og=Wo("length");function ag(C){return C.split("")}function lg(C){return C.match(g0)||[]}function Ac(C,Y,z){var ne;return z(C,function(de,Ze,Be){if(Y(de,Ze,Be))return ne=Ze,!1}),ne}function Ri(C,Y,z,ne){for(var de=C.length,Ze=z+(ne?1:-1);ne?Ze--:++Ze<de;)if(Y(C[Ze],Ze,C))return Ze;return-1}function wr(C,Y,z){return Y===Y?xg(C,Y,z):Ri(C,Fc,z)}function cg(C,Y,z,ne){for(var de=z-1,Ze=C.length;++de<Ze;)if(ne(C[de],Y))return de;return-1}function Fc(C){return C!==C}function Xc(C,Y){var z=C==null?0:C.length;return z?Vo(C,Y)/z:me}function Wo(C){return function(Y){return Y==null?e:Y[C]}}function Co(C){return function(Y){return C==null?e:C[Y]}}function kc(C,Y,z,ne,de){return de(C,function(Ze,Be,Pe){z=ne?(ne=!1,Ze):Y(z,Ze,Be,Pe)}),z}function ug(C,Y){var z=C.length;for(C.sort(Y);z--;)C[z]=C[z].value;return C}function Vo(C,Y){for(var z,ne=-1,de=C.length;++ne<de;){var Ze=Y(C[ne]);Ze!==e&&(z=z===e?Ze:z+Ze)}return z}function Ao(C,Y){for(var z=-1,ne=Array(C);++z<C;)ne[z]=Y(z);return ne}function hg(C,Y){return Ve(Y,function(z){return[z,C[z]]})}function Dc(C){return C&&C.slice(0,Rc(C)+1).replace(xo,"")}function _t(C){return function(Y){return C(Y)}}function Fo(C,Y){return Ve(Y,function(z){return C[z]})}function qr(C,Y){return C.has(Y)}function zc(C,Y){for(var z=-1,ne=C.length;++z<ne&&wr(Y,C[z],0)>-1;);return z}function Oc(C,Y){for(var z=C.length;z--&&wr(Y,C[z],0)>-1;);return z}function dg(C,Y){for(var z=C.length,ne=0;z--;)C[z]===Y&&++ne;return ne}var fg=Co(H0),pg=Co(E0);function mg(C){return"\\"+$0[C]}function gg(C,Y){return C==null?e:C[Y]}function xr(C){return N0.test(C)}function yg(C){return j0.test(C)}function vg(C){for(var Y,z=[];!(Y=C.next()).done;)z.push(Y.value);return z}function Xo(C){var Y=-1,z=Array(C.size);return C.forEach(function(ne,de){z[++Y]=[de,ne]}),z}function Kc(C,Y){return function(z){return C(Y(z))}}function Fn(C,Y){for(var z=-1,ne=C.length,de=0,Ze=[];++z<ne;){var Be=C[z];(Be===Y||Be===p)&&(C[z]=p,Ze[de++]=z)}return Ze}function Yi(C){var Y=-1,z=Array(C.size);return C.forEach(function(ne){z[++Y]=ne}),z}function wg(C){var Y=-1,z=Array(C.size);return C.forEach(function(ne){z[++Y]=[ne,ne]}),z}function xg(C,Y,z){for(var ne=z-1,de=C.length;++ne<de;)if(C[ne]===Y)return ne;return-1}function bg(C,Y,z){for(var ne=z+1;ne--;)if(C[ne]===Y)return ne;return ne}function br(C){return xr(C)?Mg(C):og(C)}function Jt(C){return xr(C)?Lg(C):ag(C)}function Rc(C){for(var Y=C.length;Y--&&d0.test(C.charAt(Y)););return Y}var _g=Co(q0);function Mg(C){for(var Y=So.lastIndex=0;So.test(C);)++Y;return Y}function Lg(C){return C.match(So)||[]}function Sg(C){return C.match(B0)||[]}var Zg=function C(Y){Y=Y==null?nt:_r.defaults(nt.Object(),Y,_r.pick(nt,J0));var z=Y.Array,ne=Y.Date,de=Y.Error,Ze=Y.Function,Be=Y.Math,Pe=Y.Object,ko=Y.RegExp,Tg=Y.String,Ft=Y.TypeError,Ui=z.prototype,Gg=Ze.prototype,Mr=Pe.prototype,Bi=Y["__core-js_shared__"],Ni=Gg.toString,Ge=Mr.hasOwnProperty,Pg=0,Yc=function(){var i=/[^.]+$/.exec(Bi&&Bi.keys&&Bi.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),ji=Mr.toString,Ig=Ni.call(Pe),Wg=nt._,Cg=ko("^"+Ni.call(Ge).replace(wo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ji=Zc?Y.Buffer:e,Xn=Y.Symbol,Qi=Y.Uint8Array,Uc=Ji?Ji.allocUnsafe:e,Hi=Kc(Pe.getPrototypeOf,Pe),Bc=Pe.create,Nc=Mr.propertyIsEnumerable,Ei=Ui.splice,jc=Xn?Xn.isConcatSpreadable:e,$r=Xn?Xn.iterator:e,tr=Xn?Xn.toStringTag:e,qi=function(){try{var i=or(Pe,"defineProperty");return i({},"",{}),i}catch{}}(),Vg=Y.clearTimeout!==nt.clearTimeout&&Y.clearTimeout,Ag=ne&&ne.now!==nt.Date.now&&ne.now,Fg=Y.setTimeout!==nt.setTimeout&&Y.setTimeout,$i=Be.ceil,es=Be.floor,Do=Pe.getOwnPropertySymbols,Xg=Ji?Ji.isBuffer:e,Jc=Y.isFinite,kg=Ui.join,Dg=Kc(Pe.keys,Pe),Ne=Be.max,st=Be.min,zg=ne.now,Og=Y.parseInt,Qc=Be.random,Kg=Ui.reverse,zo=or(Y,"DataView"),ei=or(Y,"Map"),Oo=or(Y,"Promise"),Lr=or(Y,"Set"),ti=or(Y,"WeakMap"),ni=or(Pe,"create"),ts=ti&&new ti,Sr={},Rg=ar(zo),Yg=ar(ei),Ug=ar(Oo),Bg=ar(Lr),Ng=ar(ti),ns=Xn?Xn.prototype:e,ri=ns?ns.valueOf:e,Hc=ns?ns.toString:e;function b(i){if(De(i)&&!fe(i)&&!(i instanceof Me)){if(i instanceof Xt)return i;if(Ge.call(i,"__wrapped__"))return Eu(i)}return new Xt(i)}var Zr=function(){function i(){}return function(o){if(!Fe(o))return{};if(Bc)return Bc(o);i.prototype=o;var h=new i;return i.prototype=e,h}}();function rs(){}function Xt(i,o){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=e}b.templateSettings={escape:Nt,evaluate:jt,interpolate:Cn,variable:"",imports:{_:b}},b.prototype=rs.prototype,b.prototype.constructor=b,Xt.prototype=Zr(rs.prototype),Xt.prototype.constructor=Xt;function Me(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=be,this.__views__=[]}function jg(){var i=new Me(this.__wrapped__);return i.__actions__=mt(this.__actions__),i.__dir__=this.__dir__,i.__filtered__=this.__filtered__,i.__iteratees__=mt(this.__iteratees__),i.__takeCount__=this.__takeCount__,i.__views__=mt(this.__views__),i}function Jg(){if(this.__filtered__){var i=new Me(this);i.__dir__=-1,i.__filtered__=!0}else i=this.clone(),i.__dir__*=-1;return i}function Qg(){var i=this.__wrapped__.value(),o=this.__dir__,h=fe(i),g=o<0,w=h?i.length:0,M=av(0,w,this.__views__),P=M.start,I=M.end,F=I-P,U=g?I:P-1,B=this.__iteratees__,Q=B.length,$=0,re=st(F,this.__takeCount__);if(!h||!g&&w==F&&re==F)return xu(i,this.__actions__);var le=[];e:for(;F--&&$<re;){U+=o;for(var ge=-1,ce=i[U];++ge<Q;){var _e=B[ge],Le=_e.iteratee,St=_e.type,dt=Le(ce);if(St==q)ce=dt;else if(!dt){if(St==j)continue e;break e}}le[$++]=ce}return le}Me.prototype=Zr(rs.prototype),Me.prototype.constructor=Me;function nr(i){var o=-1,h=i==null?0:i.length;for(this.clear();++o<h;){var g=i[o];this.set(g[0],g[1])}}function Hg(){this.__data__=ni?ni(null):{},this.size=0}function Eg(i){var o=this.has(i)&&delete this.__data__[i];return this.size-=o?1:0,o}function qg(i){var o=this.__data__;if(ni){var h=o[i];return h===u?e:h}return Ge.call(o,i)?o[i]:e}function $g(i){var o=this.__data__;return ni?o[i]!==e:Ge.call(o,i)}function ey(i,o){var h=this.__data__;return this.size+=this.has(i)?0:1,h[i]=ni&&o===e?u:o,this}nr.prototype.clear=Hg,nr.prototype.delete=Eg,nr.prototype.get=qg,nr.prototype.has=$g,nr.prototype.set=ey;function dn(i){var o=-1,h=i==null?0:i.length;for(this.clear();++o<h;){var g=i[o];this.set(g[0],g[1])}}function ty(){this.__data__=[],this.size=0}function ny(i){var o=this.__data__,h=is(o,i);if(h<0)return!1;var g=o.length-1;return h==g?o.pop():Ei.call(o,h,1),--this.size,!0}function ry(i){var o=this.__data__,h=is(o,i);return h<0?e:o[h][1]}function iy(i){return is(this.__data__,i)>-1}function sy(i,o){var h=this.__data__,g=is(h,i);return g<0?(++this.size,h.push([i,o])):h[g][1]=o,this}dn.prototype.clear=ty,dn.prototype.delete=ny,dn.prototype.get=ry,dn.prototype.has=iy,dn.prototype.set=sy;function fn(i){var o=-1,h=i==null?0:i.length;for(this.clear();++o<h;){var g=i[o];this.set(g[0],g[1])}}function oy(){this.size=0,this.__data__={hash:new nr,map:new(ei||dn),string:new nr}}function ay(i){var o=gs(this,i).delete(i);return this.size-=o?1:0,o}function ly(i){return gs(this,i).get(i)}function cy(i){return gs(this,i).has(i)}function uy(i,o){var h=gs(this,i),g=h.size;return h.set(i,o),this.size+=h.size==g?0:1,this}fn.prototype.clear=oy,fn.prototype.delete=ay,fn.prototype.get=ly,fn.prototype.has=cy,fn.prototype.set=uy;function rr(i){var o=-1,h=i==null?0:i.length;for(this.__data__=new fn;++o<h;)this.add(i[o])}function hy(i){return this.__data__.set(i,u),this}function dy(i){return this.__data__.has(i)}rr.prototype.add=rr.prototype.push=hy,rr.prototype.has=dy;function Qt(i){var o=this.__data__=new dn(i);this.size=o.size}function fy(){this.__data__=new dn,this.size=0}function py(i){var o=this.__data__,h=o.delete(i);return this.size=o.size,h}function my(i){return this.__data__.get(i)}function gy(i){return this.__data__.has(i)}function yy(i,o){var h=this.__data__;if(h instanceof dn){var g=h.__data__;if(!ei||g.length<r-1)return g.push([i,o]),this.size=++h.size,this;h=this.__data__=new fn(g)}return h.set(i,o),this.size=h.size,this}Qt.prototype.clear=fy,Qt.prototype.delete=py,Qt.prototype.get=my,Qt.prototype.has=gy,Qt.prototype.set=yy;function Ec(i,o){var h=fe(i),g=!h&&lr(i),w=!h&&!g&&Kn(i),M=!h&&!g&&!w&&Ir(i),P=h||g||w||M,I=P?Ao(i.length,Tg):[],F=I.length;for(var U in i)(o||Ge.call(i,U))&&!(P&&(U=="length"||w&&(U=="offset"||U=="parent")||M&&(U=="buffer"||U=="byteLength"||U=="byteOffset")||yn(U,F)))&&I.push(U);return I}function qc(i){var o=i.length;return o?i[Eo(0,o-1)]:e}function vy(i,o){return ys(mt(i),ir(o,0,i.length))}function wy(i){return ys(mt(i))}function Ko(i,o,h){(h!==e&&!Ht(i[o],h)||h===e&&!(o in i))&&pn(i,o,h)}function ii(i,o,h){var g=i[o];(!(Ge.call(i,o)&&Ht(g,h))||h===e&&!(o in i))&&pn(i,o,h)}function is(i,o){for(var h=i.length;h--;)if(Ht(i[h][0],o))return h;return-1}function xy(i,o,h,g){return kn(i,function(w,M,P){o(g,w,h(w),P)}),g}function $c(i,o){return i&&an(o,He(o),i)}function by(i,o){return i&&an(o,yt(o),i)}function pn(i,o,h){o=="__proto__"&&qi?qi(i,o,{configurable:!0,enumerable:!0,value:h,writable:!0}):i[o]=h}function Ro(i,o){for(var h=-1,g=o.length,w=z(g),M=i==null;++h<g;)w[h]=M?e:_a(i,o[h]);return w}function ir(i,o,h){return i===i&&(h!==e&&(i=i<=h?i:h),o!==e&&(i=i>=o?i:o)),i}function kt(i,o,h,g,w,M){var P,I=o&f,F=o&y,U=o&v;if(h&&(P=w?h(i,g,w,M):h(i)),P!==e)return P;if(!Fe(i))return i;var B=fe(i);if(B){if(P=cv(i),!I)return mt(i,P)}else{var Q=ot(i),$=Q==hn||Q==Gn;if(Kn(i))return Mu(i,I);if(Q==Wt||Q==Ye||$&&!w){if(P=F||$?{}:Ru(i),!I)return F?qy(i,by(P,i)):Ey(i,$c(P,i))}else{if(!Ie[Q])return w?i:{};P=uv(i,Q,I)}}M||(M=new Qt);var re=M.get(i);if(re)return re;M.set(i,P),yh(i)?i.forEach(function(ce){P.add(kt(ce,o,h,ce,i,M))}):mh(i)&&i.forEach(function(ce,_e){P.set(_e,kt(ce,o,h,_e,i,M))});var le=U?F?la:aa:F?yt:He,ge=B?e:le(i);return At(ge||i,function(ce,_e){ge&&(_e=ce,ce=i[_e]),ii(P,_e,kt(ce,o,h,_e,i,M))}),P}function _y(i){var o=He(i);return function(h){return eu(h,i,o)}}function eu(i,o,h){var g=h.length;if(i==null)return!g;for(i=Pe(i);g--;){var w=h[g],M=o[w],P=i[w];if(P===e&&!(w in i)||!M(P))return!1}return!0}function tu(i,o,h){if(typeof i!="function")throw new Ft(a);return hi(function(){i.apply(e,h)},o)}function si(i,o,h,g){var w=-1,M=Ki,P=!0,I=i.length,F=[],U=o.length;if(!I)return F;h&&(o=Ve(o,_t(h))),g?(M=Go,P=!1):o.length>=r&&(M=qr,P=!1,o=new rr(o));e:for(;++w<I;){var B=i[w],Q=h==null?B:h(B);if(B=g||B!==0?B:0,P&&Q===Q){for(var $=U;$--;)if(o[$]===Q)continue e;F.push(B)}else M(o,Q,g)||F.push(B)}return F}var kn=Gu(on),nu=Gu(Uo,!0);function My(i,o){var h=!0;return kn(i,function(g,w,M){return h=!!o(g,w,M),h}),h}function ss(i,o,h){for(var g=-1,w=i.length;++g<w;){var M=i[g],P=o(M);if(P!=null&&(I===e?P===P&&!Lt(P):h(P,I)))var I=P,F=M}return F}function Ly(i,o,h,g){var w=i.length;for(h=pe(h),h<0&&(h=-h>w?0:w+h),g=g===e||g>w?w:pe(g),g<0&&(g+=w),g=h>g?0:wh(g);h<g;)i[h++]=o;return i}function ru(i,o){var h=[];return kn(i,function(g,w,M){o(g,w,M)&&h.push(g)}),h}function rt(i,o,h,g,w){var M=-1,P=i.length;for(h||(h=dv),w||(w=[]);++M<P;){var I=i[M];o>0&&h(I)?o>1?rt(I,o-1,h,g,w):An(w,I):g||(w[w.length]=I)}return w}var Yo=Pu(),iu=Pu(!0);function on(i,o){return i&&Yo(i,o,He)}function Uo(i,o){return i&&iu(i,o,He)}function os(i,o){return Vn(o,function(h){return vn(i[h])})}function sr(i,o){o=zn(o,i);for(var h=0,g=o.length;i!=null&&h<g;)i=i[ln(o[h++])];return h&&h==g?i:e}function su(i,o,h){var g=o(i);return fe(i)?g:An(g,h(i))}function ut(i){return i==null?i===e?Qn:It:tr&&tr in Pe(i)?ov(i):wv(i)}function Bo(i,o){return i>o}function Sy(i,o){return i!=null&&Ge.call(i,o)}function Zy(i,o){return i!=null&&o in Pe(i)}function Ty(i,o,h){return i>=st(o,h)&&i<Ne(o,h)}function No(i,o,h){for(var g=h?Go:Ki,w=i[0].length,M=i.length,P=M,I=z(M),F=1/0,U=[];P--;){var B=i[P];P&&o&&(B=Ve(B,_t(o))),F=st(B.length,F),I[P]=!h&&(o||w>=120&&B.length>=120)?new rr(P&&B):e}B=i[0];var Q=-1,$=I[0];e:for(;++Q<w&&U.length<F;){var re=B[Q],le=o?o(re):re;if(re=h||re!==0?re:0,!($?qr($,le):g(U,le,h))){for(P=M;--P;){var ge=I[P];if(!(ge?qr(ge,le):g(i[P],le,h)))continue e}$&&$.push(le),U.push(re)}}return U}function Gy(i,o,h,g){return on(i,function(w,M,P){o(g,h(w),M,P)}),g}function oi(i,o,h){o=zn(o,i),i=Nu(i,o);var g=i==null?i:i[ln(zt(o))];return g==null?e:bt(g,i,h)}function ou(i){return De(i)&&ut(i)==Ye}function Py(i){return De(i)&&ut(i)==Wn}function Iy(i){return De(i)&&ut(i)==ct}function ai(i,o,h,g,w){return i===o?!0:i==null||o==null||!De(i)&&!De(o)?i!==i&&o!==o:Wy(i,o,h,g,ai,w)}function Wy(i,o,h,g,w,M){var P=fe(i),I=fe(o),F=P?je:ot(i),U=I?je:ot(o);F=F==Ye?Wt:F,U=U==Ye?Wt:U;var B=F==Wt,Q=U==Wt,$=F==U;if($&&Kn(i)){if(!Kn(o))return!1;P=!0,B=!1}if($&&!B)return M||(M=new Qt),P||Ir(i)?zu(i,o,h,g,w,M):iv(i,o,F,h,g,w,M);if(!(h&x)){var re=B&&Ge.call(i,"__wrapped__"),le=Q&&Ge.call(o,"__wrapped__");if(re||le){var ge=re?i.value():i,ce=le?o.value():o;return M||(M=new Qt),w(ge,ce,h,g,M)}}return $?(M||(M=new Qt),sv(i,o,h,g,w,M)):!1}function Cy(i){return De(i)&&ot(i)==Ae}function jo(i,o,h,g){var w=h.length,M=w,P=!g;if(i==null)return!M;for(i=Pe(i);w--;){var I=h[w];if(P&&I[2]?I[1]!==i[I[0]]:!(I[0]in i))return!1}for(;++w<M;){I=h[w];var F=I[0],U=i[F],B=I[1];if(P&&I[2]){if(U===e&&!(F in i))return!1}else{var Q=new Qt;if(g)var $=g(U,B,F,i,o,Q);if(!($===e?ai(B,U,x|L,g,Q):$))return!1}}return!0}function au(i){if(!Fe(i)||pv(i))return!1;var o=vn(i)?Cg:_0;return o.test(ar(i))}function Vy(i){return De(i)&&ut(i)==Jn}function Ay(i){return De(i)&&ot(i)==xt}function Fy(i){return De(i)&&Ms(i.length)&&!!Ce[ut(i)]}function lu(i){return typeof i=="function"?i:i==null?vt:typeof i=="object"?fe(i)?hu(i[0],i[1]):uu(i):Ih(i)}function Jo(i){if(!ui(i))return Dg(i);var o=[];for(var h in Pe(i))Ge.call(i,h)&&h!="constructor"&&o.push(h);return o}function Xy(i){if(!Fe(i))return vv(i);var o=ui(i),h=[];for(var g in i)g=="constructor"&&(o||!Ge.call(i,g))||h.push(g);return h}function Qo(i,o){return i<o}function cu(i,o){var h=-1,g=gt(i)?z(i.length):[];return kn(i,function(w,M,P){g[++h]=o(w,M,P)}),g}function uu(i){var o=ua(i);return o.length==1&&o[0][2]?Uu(o[0][0],o[0][1]):function(h){return h===i||jo(h,i,o)}}function hu(i,o){return da(i)&&Yu(o)?Uu(ln(i),o):function(h){var g=_a(h,i);return g===e&&g===o?Ma(h,i):ai(o,g,x|L)}}function as(i,o,h,g,w){i!==o&&Yo(o,function(M,P){if(w||(w=new Qt),Fe(M))ky(i,o,P,h,as,g,w);else{var I=g?g(pa(i,P),M,P+"",i,o,w):e;I===e&&(I=M),Ko(i,P,I)}},yt)}function ky(i,o,h,g,w,M,P){var I=pa(i,h),F=pa(o,h),U=P.get(F);if(U){Ko(i,h,U);return}var B=M?M(I,F,h+"",i,o,P):e,Q=B===e;if(Q){var $=fe(F),re=!$&&Kn(F),le=!$&&!re&&Ir(F);B=F,$||re||le?fe(I)?B=I:Oe(I)?B=mt(I):re?(Q=!1,B=Mu(F,!0)):le?(Q=!1,B=Lu(F,!0)):B=[]:di(F)||lr(F)?(B=I,lr(I)?B=xh(I):(!Fe(I)||vn(I))&&(B=Ru(F))):Q=!1}Q&&(P.set(F,B),w(B,F,g,M,P),P.delete(F)),Ko(i,h,B)}function du(i,o){var h=i.length;if(h)return o+=o<0?h:0,yn(o,h)?i[o]:e}function fu(i,o,h){o.length?o=Ve(o,function(M){return fe(M)?function(P){return sr(P,M.length===1?M[0]:M)}:M}):o=[vt];var g=-1;o=Ve(o,_t(ae()));var w=cu(i,function(M,P,I){var F=Ve(o,function(U){return U(M)});return{criteria:F,index:++g,value:M}});return ug(w,function(M,P){return Hy(M,P,h)})}function Dy(i,o){return pu(i,o,function(h,g){return Ma(i,g)})}function pu(i,o,h){for(var g=-1,w=o.length,M={};++g<w;){var P=o[g],I=sr(i,P);h(I,P)&&li(M,zn(P,i),I)}return M}function zy(i){return function(o){return sr(o,i)}}function Ho(i,o,h,g){var w=g?cg:wr,M=-1,P=o.length,I=i;for(i===o&&(o=mt(o)),h&&(I=Ve(i,_t(h)));++M<P;)for(var F=0,U=o[M],B=h?h(U):U;(F=w(I,B,F,g))>-1;)I!==i&&Ei.call(I,F,1),Ei.call(i,F,1);return i}function mu(i,o){for(var h=i?o.length:0,g=h-1;h--;){var w=o[h];if(h==g||w!==M){var M=w;yn(w)?Ei.call(i,w,1):ea(i,w)}}return i}function Eo(i,o){return i+es(Qc()*(o-i+1))}function Oy(i,o,h,g){for(var w=-1,M=Ne($i((o-i)/(h||1)),0),P=z(M);M--;)P[g?M:++w]=i,i+=h;return P}function qo(i,o){var h="";if(!i||o<1||o>ie)return h;do o%2&&(h+=i),o=es(o/2),o&&(i+=i);while(o);return h}function ye(i,o){return ma(Bu(i,o,vt),i+"")}function Ky(i){return qc(Wr(i))}function Ry(i,o){var h=Wr(i);return ys(h,ir(o,0,h.length))}function li(i,o,h,g){if(!Fe(i))return i;o=zn(o,i);for(var w=-1,M=o.length,P=M-1,I=i;I!=null&&++w<M;){var F=ln(o[w]),U=h;if(F==="__proto__"||F==="constructor"||F==="prototype")return i;if(w!=P){var B=I[F];U=g?g(B,F,I):e,U===e&&(U=Fe(B)?B:yn(o[w+1])?[]:{})}ii(I,F,U),I=I[F]}return i}var gu=ts?function(i,o){return ts.set(i,o),i}:vt,Yy=qi?function(i,o){return qi(i,"toString",{configurable:!0,enumerable:!1,value:Sa(o),writable:!0})}:vt;function Uy(i){return ys(Wr(i))}function Dt(i,o,h){var g=-1,w=i.length;o<0&&(o=-o>w?0:w+o),h=h>w?w:h,h<0&&(h+=w),w=o>h?0:h-o>>>0,o>>>=0;for(var M=z(w);++g<w;)M[g]=i[g+o];return M}function By(i,o){var h;return kn(i,function(g,w,M){return h=o(g,w,M),!h}),!!h}function ls(i,o,h){var g=0,w=i==null?g:i.length;if(typeof o=="number"&&o===o&&w<=ve){for(;g<w;){var M=g+w>>>1,P=i[M];P!==null&&!Lt(P)&&(h?P<=o:P<o)?g=M+1:w=M}return w}return $o(i,o,vt,h)}function $o(i,o,h,g){var w=0,M=i==null?0:i.length;if(M===0)return 0;o=h(o);for(var P=o!==o,I=o===null,F=Lt(o),U=o===e;w<M;){var B=es((w+M)/2),Q=h(i[B]),$=Q!==e,re=Q===null,le=Q===Q,ge=Lt(Q);if(P)var ce=g||le;else U?ce=le&&(g||$):I?ce=le&&$&&(g||!re):F?ce=le&&$&&!re&&(g||!ge):re||ge?ce=!1:ce=g?Q<=o:Q<o;ce?w=B+1:M=B}return st(M,he)}function yu(i,o){for(var h=-1,g=i.length,w=0,M=[];++h<g;){var P=i[h],I=o?o(P):P;if(!h||!Ht(I,F)){var F=I;M[w++]=P===0?0:P}}return M}function vu(i){return typeof i=="number"?i:Lt(i)?me:+i}function Mt(i){if(typeof i=="string")return i;if(fe(i))return Ve(i,Mt)+"";if(Lt(i))return Hc?Hc.call(i):"";var o=i+"";return o=="0"&&1/i==-oe?"-0":o}function Dn(i,o,h){var g=-1,w=Ki,M=i.length,P=!0,I=[],F=I;if(h)P=!1,w=Go;else if(M>=r){var U=o?null:nv(i);if(U)return Yi(U);P=!1,w=qr,F=new rr}else F=o?[]:I;e:for(;++g<M;){var B=i[g],Q=o?o(B):B;if(B=h||B!==0?B:0,P&&Q===Q){for(var $=F.length;$--;)if(F[$]===Q)continue e;o&&F.push(Q),I.push(B)}else w(F,Q,h)||(F!==I&&F.push(Q),I.push(B))}return I}function ea(i,o){return o=zn(o,i),i=Nu(i,o),i==null||delete i[ln(zt(o))]}function wu(i,o,h,g){return li(i,o,h(sr(i,o)),g)}function cs(i,o,h,g){for(var w=i.length,M=g?w:-1;(g?M--:++M<w)&&o(i[M],M,i););return h?Dt(i,g?0:M,g?M+1:w):Dt(i,g?M+1:0,g?w:M)}function xu(i,o){var h=i;return h instanceof Me&&(h=h.value()),Po(o,function(g,w){return w.func.apply(w.thisArg,An([g],w.args))},h)}function ta(i,o,h){var g=i.length;if(g<2)return g?Dn(i[0]):[];for(var w=-1,M=z(g);++w<g;)for(var P=i[w],I=-1;++I<g;)I!=w&&(M[w]=si(M[w]||P,i[I],o,h));return Dn(rt(M,1),o,h)}function bu(i,o,h){for(var g=-1,w=i.length,M=o.length,P={};++g<w;){var I=g<M?o[g]:e;h(P,i[g],I)}return P}function na(i){return Oe(i)?i:[]}function ra(i){return typeof i=="function"?i:vt}function zn(i,o){return fe(i)?i:da(i,o)?[i]:Hu(Te(i))}var Ny=ye;function On(i,o,h){var g=i.length;return h=h===e?g:h,!o&&h>=g?i:Dt(i,o,h)}var _u=Vg||function(i){return nt.clearTimeout(i)};function Mu(i,o){if(o)return i.slice();var h=i.length,g=Uc?Uc(h):new i.constructor(h);return i.copy(g),g}function ia(i){var o=new i.constructor(i.byteLength);return new Qi(o).set(new Qi(i)),o}function jy(i,o){var h=o?ia(i.buffer):i.buffer;return new i.constructor(h,i.byteOffset,i.byteLength)}function Jy(i){var o=new i.constructor(i.source,oc.exec(i));return o.lastIndex=i.lastIndex,o}function Qy(i){return ri?Pe(ri.call(i)):{}}function Lu(i,o){var h=o?ia(i.buffer):i.buffer;return new i.constructor(h,i.byteOffset,i.length)}function Su(i,o){if(i!==o){var h=i!==e,g=i===null,w=i===i,M=Lt(i),P=o!==e,I=o===null,F=o===o,U=Lt(o);if(!I&&!U&&!M&&i>o||M&&P&&F&&!I&&!U||g&&P&&F||!h&&F||!w)return 1;if(!g&&!M&&!U&&i<o||U&&h&&w&&!g&&!M||I&&h&&w||!P&&w||!F)return-1}return 0}function Hy(i,o,h){for(var g=-1,w=i.criteria,M=o.criteria,P=w.length,I=h.length;++g<P;){var F=Su(w[g],M[g]);if(F){if(g>=I)return F;var U=h[g];return F*(U=="desc"?-1:1)}}return i.index-o.index}function Zu(i,o,h,g){for(var w=-1,M=i.length,P=h.length,I=-1,F=o.length,U=Ne(M-P,0),B=z(F+U),Q=!g;++I<F;)B[I]=o[I];for(;++w<P;)(Q||w<M)&&(B[h[w]]=i[w]);for(;U--;)B[I++]=i[w++];return B}function Tu(i,o,h,g){for(var w=-1,M=i.length,P=-1,I=h.length,F=-1,U=o.length,B=Ne(M-I,0),Q=z(B+U),$=!g;++w<B;)Q[w]=i[w];for(var re=w;++F<U;)Q[re+F]=o[F];for(;++P<I;)($||w<M)&&(Q[re+h[P]]=i[w++]);return Q}function mt(i,o){var h=-1,g=i.length;for(o||(o=z(g));++h<g;)o[h]=i[h];return o}function an(i,o,h,g){var w=!h;h||(h={});for(var M=-1,P=o.length;++M<P;){var I=o[M],F=g?g(h[I],i[I],I,h,i):e;F===e&&(F=i[I]),w?pn(h,I,F):ii(h,I,F)}return h}function Ey(i,o){return an(i,ha(i),o)}function qy(i,o){return an(i,Ou(i),o)}function us(i,o){return function(h,g){var w=fe(h)?rg:xy,M=o?o():{};return w(h,i,ae(g,2),M)}}function Tr(i){return ye(function(o,h){var g=-1,w=h.length,M=w>1?h[w-1]:e,P=w>2?h[2]:e;for(M=i.length>3&&typeof M=="function"?(w--,M):e,P&&ht(h[0],h[1],P)&&(M=w<3?e:M,w=1),o=Pe(o);++g<w;){var I=h[g];I&&i(o,I,g,M)}return o})}function Gu(i,o){return function(h,g){if(h==null)return h;if(!gt(h))return i(h,g);for(var w=h.length,M=o?w:-1,P=Pe(h);(o?M--:++M<w)&&g(P[M],M,P)!==!1;);return h}}function Pu(i){return function(o,h,g){for(var w=-1,M=Pe(o),P=g(o),I=P.length;I--;){var F=P[i?I:++w];if(h(M[F],F,M)===!1)break}return o}}function $y(i,o,h){var g=o&_,w=ci(i);function M(){var P=this&&this!==nt&&this instanceof M?w:i;return P.apply(g?h:this,arguments)}return M}function Iu(i){return function(o){o=Te(o);var h=xr(o)?Jt(o):e,g=h?h[0]:o.charAt(0),w=h?On(h,1).join(""):o.slice(1);return g[i]()+w}}function Gr(i){return function(o){return Po(Gh(Th(o).replace(Y0,"")),i,"")}}function ci(i){return function(){var o=arguments;switch(o.length){case 0:return new i;case 1:return new i(o[0]);case 2:return new i(o[0],o[1]);case 3:return new i(o[0],o[1],o[2]);case 4:return new i(o[0],o[1],o[2],o[3]);case 5:return new i(o[0],o[1],o[2],o[3],o[4]);case 6:return new i(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new i(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var h=Zr(i.prototype),g=i.apply(h,o);return Fe(g)?g:h}}function ev(i,o,h){var g=ci(i);function w(){for(var M=arguments.length,P=z(M),I=M,F=Pr(w);I--;)P[I]=arguments[I];var U=M<3&&P[0]!==F&&P[M-1]!==F?[]:Fn(P,F);if(M-=U.length,M<h)return Fu(i,o,hs,w.placeholder,e,P,U,e,e,h-M);var B=this&&this!==nt&&this instanceof w?g:i;return bt(B,this,P)}return w}function Wu(i){return function(o,h,g){var w=Pe(o);if(!gt(o)){var M=ae(h,3);o=He(o),h=function(I){return M(w[I],I,w)}}var P=i(o,h,g);return P>-1?w[M?o[P]:P]:e}}function Cu(i){return gn(function(o){var h=o.length,g=h,w=Xt.prototype.thru;for(i&&o.reverse();g--;){var M=o[g];if(typeof M!="function")throw new Ft(a);if(w&&!P&&ms(M)=="wrapper")var P=new Xt([],!0)}for(g=P?g:h;++g<h;){M=o[g];var I=ms(M),F=I=="wrapper"?ca(M):e;F&&fa(F[0])&&F[1]==(O|G|K|V)&&!F[4].length&&F[9]==1?P=P[ms(F[0])].apply(P,F[3]):P=M.length==1&&fa(M)?P[I]():P.thru(M)}return function(){var U=arguments,B=U[0];if(P&&U.length==1&&fe(B))return P.plant(B).value();for(var Q=0,$=h?o[Q].apply(this,U):B;++Q<h;)$=o[Q].call(this,$);return $}})}function hs(i,o,h,g,w,M,P,I,F,U){var B=o&O,Q=o&_,$=o&S,re=o&(G|A),le=o&R,ge=$?e:ci(i);function ce(){for(var _e=arguments.length,Le=z(_e),St=_e;St--;)Le[St]=arguments[St];if(re)var dt=Pr(ce),Zt=dg(Le,dt);if(g&&(Le=Zu(Le,g,w,re)),M&&(Le=Tu(Le,M,P,re)),_e-=Zt,re&&_e<U){var Ke=Fn(Le,dt);return Fu(i,o,hs,ce.placeholder,h,Le,Ke,I,F,U-_e)}var Et=Q?h:this,xn=$?Et[i]:i;return _e=Le.length,I?Le=xv(Le,I):le&&_e>1&&Le.reverse(),B&&F<_e&&(Le.length=F),this&&this!==nt&&this instanceof ce&&(xn=ge||ci(xn)),xn.apply(Et,Le)}return ce}function Vu(i,o){return function(h,g){return Gy(h,i,o(g),{})}}function ds(i,o){return function(h,g){var w;if(h===e&&g===e)return o;if(h!==e&&(w=h),g!==e){if(w===e)return g;typeof h=="string"||typeof g=="string"?(h=Mt(h),g=Mt(g)):(h=vu(h),g=vu(g)),w=i(h,g)}return w}}function sa(i){return gn(function(o){return o=Ve(o,_t(ae())),ye(function(h){var g=this;return i(o,function(w){return bt(w,g,h)})})})}function fs(i,o){o=o===e?" ":Mt(o);var h=o.length;if(h<2)return h?qo(o,i):o;var g=qo(o,$i(i/br(o)));return xr(o)?On(Jt(g),0,i).join(""):g.slice(0,i)}function tv(i,o,h,g){var w=o&_,M=ci(i);function P(){for(var I=-1,F=arguments.length,U=-1,B=g.length,Q=z(B+F),$=this&&this!==nt&&this instanceof P?M:i;++U<B;)Q[U]=g[U];for(;F--;)Q[U++]=arguments[++I];return bt($,w?h:this,Q)}return P}function Au(i){return function(o,h,g){return g&&typeof g!="number"&&ht(o,h,g)&&(h=g=e),o=wn(o),h===e?(h=o,o=0):h=wn(h),g=g===e?o<h?1:-1:wn(g),Oy(o,h,g,i)}}function ps(i){return function(o,h){return typeof o=="string"&&typeof h=="string"||(o=Ot(o),h=Ot(h)),i(o,h)}}function Fu(i,o,h,g,w,M,P,I,F,U){var B=o&G,Q=B?P:e,$=B?e:P,re=B?M:e,le=B?e:M;o|=B?K:D,o&=~(B?D:K),o&Z||(o&=-4);var ge=[i,o,w,re,Q,le,$,I,F,U],ce=h.apply(e,ge);return fa(i)&&ju(ce,ge),ce.placeholder=g,Ju(ce,i,o)}function oa(i){var o=Be[i];return function(h,g){if(h=Ot(h),g=g==null?0:st(pe(g),292),g&&Jc(h)){var w=(Te(h)+"e").split("e"),M=o(w[0]+"e"+(+w[1]+g));return w=(Te(M)+"e").split("e"),+(w[0]+"e"+(+w[1]-g))}return o(h)}}var nv=Lr&&1/Yi(new Lr([,-0]))[1]==oe?function(i){return new Lr(i)}:Ga;function Xu(i){return function(o){var h=ot(o);return h==Ae?Xo(o):h==xt?wg(o):hg(o,i(o))}}function mn(i,o,h,g,w,M,P,I){var F=o&S;if(!F&&typeof i!="function")throw new Ft(a);var U=g?g.length:0;if(U||(o&=-97,g=w=e),P=P===e?P:Ne(pe(P),0),I=I===e?I:pe(I),U-=w?w.length:0,o&D){var B=g,Q=w;g=w=e}var $=F?e:ca(i),re=[i,o,h,g,w,B,Q,M,P,I];if($&&yv(re,$),i=re[0],o=re[1],h=re[2],g=re[3],w=re[4],I=re[9]=re[9]===e?F?0:i.length:Ne(re[9]-U,0),!I&&o&(G|A)&&(o&=-25),!o||o==_)var le=$y(i,o,h);else o==G||o==A?le=ev(i,o,I):(o==K||o==(_|K))&&!w.length?le=tv(i,o,h,g):le=hs.apply(e,re);var ge=$?gu:ju;return Ju(ge(le,re),i,o)}function ku(i,o,h,g){return i===e||Ht(i,Mr[h])&&!Ge.call(g,h)?o:i}function Du(i,o,h,g,w,M){return Fe(i)&&Fe(o)&&(M.set(o,i),as(i,o,e,Du,M),M.delete(o)),i}function rv(i){return di(i)?e:i}function zu(i,o,h,g,w,M){var P=h&x,I=i.length,F=o.length;if(I!=F&&!(P&&F>I))return!1;var U=M.get(i),B=M.get(o);if(U&&B)return U==o&&B==i;var Q=-1,$=!0,re=h&L?new rr:e;for(M.set(i,o),M.set(o,i);++Q<I;){var le=i[Q],ge=o[Q];if(g)var ce=P?g(ge,le,Q,o,i,M):g(le,ge,Q,i,o,M);if(ce!==e){if(ce)continue;$=!1;break}if(re){if(!Io(o,function(_e,Le){if(!qr(re,Le)&&(le===_e||w(le,_e,h,g,M)))return re.push(Le)})){$=!1;break}}else if(!(le===ge||w(le,ge,h,g,M))){$=!1;break}}return M.delete(i),M.delete(o),$}function iv(i,o,h,g,w,M,P){switch(h){case sn:if(i.byteLength!=o.byteLength||i.byteOffset!=o.byteOffset)return!1;i=i.buffer,o=o.buffer;case Wn:return!(i.byteLength!=o.byteLength||!M(new Qi(i),new Qi(o)));case Qe:case ct:case Ut:return Ht(+i,+o);case Ue:return i.name==o.name&&i.message==o.message;case Jn:case Pn:return i==o+"";case Ae:var I=Xo;case xt:var F=g&x;if(I||(I=Yi),i.size!=o.size&&!F)return!1;var U=P.get(i);if(U)return U==o;g|=L,P.set(i,o);var B=zu(I(i),I(o),g,w,M,P);return P.delete(i),B;case In:if(ri)return ri.call(i)==ri.call(o)}return!1}function sv(i,o,h,g,w,M){var P=h&x,I=aa(i),F=I.length,U=aa(o),B=U.length;if(F!=B&&!P)return!1;for(var Q=F;Q--;){var $=I[Q];if(!(P?$ in o:Ge.call(o,$)))return!1}var re=M.get(i),le=M.get(o);if(re&&le)return re==o&&le==i;var ge=!0;M.set(i,o),M.set(o,i);for(var ce=P;++Q<F;){$=I[Q];var _e=i[$],Le=o[$];if(g)var St=P?g(Le,_e,$,o,i,M):g(_e,Le,$,i,o,M);if(!(St===e?_e===Le||w(_e,Le,h,g,M):St)){ge=!1;break}ce||(ce=$=="constructor")}if(ge&&!ce){var dt=i.constructor,Zt=o.constructor;dt!=Zt&&"constructor"in i&&"constructor"in o&&!(typeof dt=="function"&&dt instanceof dt&&typeof Zt=="function"&&Zt instanceof Zt)&&(ge=!1)}return M.delete(i),M.delete(o),ge}function gn(i){return ma(Bu(i,e,eh),i+"")}function aa(i){return su(i,He,ha)}function la(i){return su(i,yt,Ou)}var ca=ts?function(i){return ts.get(i)}:Ga;function ms(i){for(var o=i.name+"",h=Sr[o],g=Ge.call(Sr,o)?h.length:0;g--;){var w=h[g],M=w.func;if(M==null||M==i)return w.name}return o}function Pr(i){var o=Ge.call(b,"placeholder")?b:i;return o.placeholder}function ae(){var i=b.iteratee||Za;return i=i===Za?lu:i,arguments.length?i(arguments[0],arguments[1]):i}function gs(i,o){var h=i.__data__;return fv(o)?h[typeof o=="string"?"string":"hash"]:h.map}function ua(i){for(var o=He(i),h=o.length;h--;){var g=o[h],w=i[g];o[h]=[g,w,Yu(w)]}return o}function or(i,o){var h=gg(i,o);return au(h)?h:e}function ov(i){var o=Ge.call(i,tr),h=i[tr];try{i[tr]=e;var g=!0}catch{}var w=ji.call(i);return g&&(o?i[tr]=h:delete i[tr]),w}var ha=Do?function(i){return i==null?[]:(i=Pe(i),Vn(Do(i),function(o){return Nc.call(i,o)}))}:Pa,Ou=Do?function(i){for(var o=[];i;)An(o,ha(i)),i=Hi(i);return o}:Pa,ot=ut;(zo&&ot(new zo(new ArrayBuffer(1)))!=sn||ei&&ot(new ei)!=Ae||Oo&&ot(Oo.resolve())!=jr||Lr&&ot(new Lr)!=xt||ti&&ot(new ti)!=Hn)&&(ot=function(i){var o=ut(i),h=o==Wt?i.constructor:e,g=h?ar(h):"";if(g)switch(g){case Rg:return sn;case Yg:return Ae;case Ug:return jr;case Bg:return xt;case Ng:return Hn}return o});function av(i,o,h){for(var g=-1,w=h.length;++g<w;){var M=h[g],P=M.size;switch(M.type){case"drop":i+=P;break;case"dropRight":o-=P;break;case"take":o=st(o,i+P);break;case"takeRight":i=Ne(i,o-P);break}}return{start:i,end:o}}function lv(i){var o=i.match(p0);return o?o[1].split(m0):[]}function Ku(i,o,h){o=zn(o,i);for(var g=-1,w=o.length,M=!1;++g<w;){var P=ln(o[g]);if(!(M=i!=null&&h(i,P)))break;i=i[P]}return M||++g!=w?M:(w=i==null?0:i.length,!!w&&Ms(w)&&yn(P,w)&&(fe(i)||lr(i)))}function cv(i){var o=i.length,h=new i.constructor(o);return o&&typeof i[0]=="string"&&Ge.call(i,"index")&&(h.index=i.index,h.input=i.input),h}function Ru(i){return typeof i.constructor=="function"&&!ui(i)?Zr(Hi(i)):{}}function uv(i,o,h){var g=i.constructor;switch(o){case Wn:return ia(i);case Qe:case ct:return new g(+i);case sn:return jy(i,h);case Jr:case Qr:case mr:case Hr:case Er:case gr:case En:case X:case E:return Lu(i,h);case Ae:return new g;case Ut:case Pn:return new g(i);case Jn:return Jy(i);case xt:return new g;case In:return Qy(i)}}function hv(i,o){var h=o.length;if(!h)return i;var g=h-1;return o[g]=(h>1?"& ":"")+o[g],o=o.join(h>2?", ":" "),i.replace(f0,`{
|
|
546
|
+
*/Pr.exports,function(a,t){(function(){var e,n="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",u="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",d=500,p="__lodash_placeholder__",f=1,y=2,v=4,x=1,S=2,_=1,Z=2,M=4,G=8,A=16,R=32,D=64,k=128,C=256,K=512,I=30,z="...",N=800,H=16,j=1,q=2,J=3,oe=1/0,re=9007199254740991,te=17976931348623157e292,me=NaN,be=4294967295,he=be-1,ve=be>>>1,ze=[["ary",k],["bind",_],["bindKey",Z],["curry",G],["curryRight",A],["flip",K],["partial",R],["partialRight",D],["rearg",C]],Ye="[object Arguments]",je="[object Array]",Je="[object AsyncFunction]",Qe="[object Boolean]",ut="[object Date]",mt="[object DOMException]",Ue="[object Error]",dn="[object Function]",Gn="[object GeneratorFunction]",Ae="[object Map]",Ut="[object Number]",Pt="[object Null]",It="[object Object]",Hi="[object Promise]",zr="[object Proxy]",Jn="[object RegExp]",xt="[object Set]",Wn="[object String]",Pn="[object Symbol]",Qn="[object Undefined]",Hn="[object WeakMap]",Lo="[object WeakSet]",In="[object ArrayBuffer]",sn="[object DataView]",Ei="[object Float32Array]",qi="[object Float64Array]",gi="[object Int8Array]",$i="[object Int16Array]",er="[object Int32Array]",yi="[object Uint8Array]",En="[object Uint8ClampedArray]",X="[object Uint16Array]",E="[object Uint32Array]",ue=/\b__p \+= '';/g,Se=/\b(__p \+=) '' \+/g,Ke=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ct=/&(?:amp|lt|gt|quot|#39);/g,Bt=/[&<>"']/g,uc=RegExp(Ct.source),Dr=RegExp(Bt.source),Nt=/<%-([\s\S]+?)%>/g,jt=/<%([\s\S]+?)%>/g,Cn=/<%=([\s\S]+?)%>/g,qn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$n=/^\w*$/,vi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,So=/[\\^$.*+?()[\]{}|]/g,g0=RegExp(So.source),To=/^\s+/,y0=/\s/,v0=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,w0=/\{\n\/\* \[wrapped with (.+)\] \*/,x0=/,? & /,b0=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_0=/[()=,{}\[\]\/\s]/,M0=/\\(\\)?/g,L0=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,hc=/\w*$/,S0=/^[-+]0x[0-9a-f]+$/i,T0=/^0b[01]+$/i,Z0=/^\[object .+?Constructor\]$/,G0=/^0o[0-7]+$/i,W0=/^(?:0|[1-9]\d*)$/,P0=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,kr=/($^)/,I0=/['\n\r\u2028\u2029\\]/g,Or="\\ud800-\\udfff",C0="\\u0300-\\u036f",V0="\\ufe20-\\ufe2f",A0="\\u20d0-\\u20ff",dc=C0+V0+A0,fc="\\u2700-\\u27bf",pc="a-z\\xdf-\\xf6\\xf8-\\xff",F0="\\xac\\xb1\\xd7\\xf7",X0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",z0="\\u2000-\\u206f",D0=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",mc="A-Z\\xc0-\\xd6\\xd8-\\xde",gc="\\ufe0e\\ufe0f",yc=F0+X0+z0+D0,Zo="['’]",k0="["+Or+"]",vc="["+yc+"]",Rr="["+dc+"]",wc="\\d+",O0="["+fc+"]",xc="["+pc+"]",bc="[^"+Or+yc+wc+fc+pc+mc+"]",Go="\\ud83c[\\udffb-\\udfff]",R0="(?:"+Rr+"|"+Go+")",_c="[^"+Or+"]",Wo="(?:\\ud83c[\\udde6-\\uddff]){2}",Po="[\\ud800-\\udbff][\\udc00-\\udfff]",wi="["+mc+"]",Mc="\\u200d",Lc="(?:"+xc+"|"+bc+")",K0="(?:"+wi+"|"+bc+")",Sc="(?:"+Zo+"(?:d|ll|m|re|s|t|ve))?",Tc="(?:"+Zo+"(?:D|LL|M|RE|S|T|VE))?",Zc=R0+"?",Gc="["+gc+"]?",Y0="(?:"+Mc+"(?:"+[_c,Wo,Po].join("|")+")"+Gc+Zc+")*",U0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",B0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Wc=Gc+Zc+Y0,N0="(?:"+[O0,Wo,Po].join("|")+")"+Wc,j0="(?:"+[_c+Rr+"?",Rr,Wo,Po,k0].join("|")+")",J0=RegExp(Zo,"g"),Q0=RegExp(Rr,"g"),Io=RegExp(Go+"(?="+Go+")|"+j0+Wc,"g"),H0=RegExp([wi+"?"+xc+"+"+Sc+"(?="+[vc,wi,"$"].join("|")+")",K0+"+"+Tc+"(?="+[vc,wi+Lc,"$"].join("|")+")",wi+"?"+Lc+"+"+Sc,wi+"+"+Tc,B0,U0,wc,N0].join("|"),"g"),E0=RegExp("["+Mc+Or+dc+gc+"]"),q0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,$0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],eg=-1,Ce={};Ce[Ei]=Ce[qi]=Ce[gi]=Ce[$i]=Ce[er]=Ce[yi]=Ce[En]=Ce[X]=Ce[E]=!0,Ce[Ye]=Ce[je]=Ce[In]=Ce[Qe]=Ce[sn]=Ce[ut]=Ce[Ue]=Ce[dn]=Ce[Ae]=Ce[Ut]=Ce[It]=Ce[Jn]=Ce[xt]=Ce[Wn]=Ce[Hn]=!1;var Pe={};Pe[Ye]=Pe[je]=Pe[In]=Pe[sn]=Pe[Qe]=Pe[ut]=Pe[Ei]=Pe[qi]=Pe[gi]=Pe[$i]=Pe[er]=Pe[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"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ng={"&":"&","<":"<",">":">",'"':""","'":"'"},ig={"&":"&","<":"<",">":">",""":'"',"'":"'"},rg={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},sg=parseFloat,og=parseInt,Pc=typeof Ni=="object"&&Ni&&Ni.Object===Object&&Ni,ag=typeof self=="object"&&self&&self.Object===Object&&self,nt=Pc||ag||Function("return this")(),Co=t&&!t.nodeType&&t,ei=Co&&!0&&a&&!a.nodeType&&a,Ic=ei&&ei.exports===Co,Vo=Ic&&Pc.process,Vt=function(){try{var V=ei&&ei.require&&ei.require("util").types;return V||Vo&&Vo.binding&&Vo.binding("util")}catch{}}(),Cc=Vt&&Vt.isArrayBuffer,Vc=Vt&&Vt.isDate,Ac=Vt&&Vt.isMap,Fc=Vt&&Vt.isRegExp,Xc=Vt&&Vt.isSet,zc=Vt&&Vt.isTypedArray;function bt(V,Y,O){switch(O.length){case 0:return V.call(Y);case 1:return V.call(Y,O[0]);case 2:return V.call(Y,O[0],O[1]);case 3:return V.call(Y,O[0],O[1],O[2])}return V.apply(Y,O)}function lg(V,Y,O,ne){for(var de=-1,Te=V==null?0:V.length;++de<Te;){var Be=V[de];Y(ne,Be,O(Be),V)}return ne}function At(V,Y){for(var O=-1,ne=V==null?0:V.length;++O<ne&&Y(V[O],O,V)!==!1;);return V}function cg(V,Y){for(var O=V==null?0:V.length;O--&&Y(V[O],O,V)!==!1;);return V}function Dc(V,Y){for(var O=-1,ne=V==null?0:V.length;++O<ne;)if(!Y(V[O],O,V))return!1;return!0}function Vn(V,Y){for(var O=-1,ne=V==null?0:V.length,de=0,Te=[];++O<ne;){var Be=V[O];Y(Be,O,V)&&(Te[de++]=Be)}return Te}function Kr(V,Y){var O=V==null?0:V.length;return!!O&&xi(V,Y,0)>-1}function Ao(V,Y,O){for(var ne=-1,de=V==null?0:V.length;++ne<de;)if(O(Y,V[ne]))return!0;return!1}function Ve(V,Y){for(var O=-1,ne=V==null?0:V.length,de=Array(ne);++O<ne;)de[O]=Y(V[O],O,V);return de}function An(V,Y){for(var O=-1,ne=Y.length,de=V.length;++O<ne;)V[de+O]=Y[O];return V}function Fo(V,Y,O,ne){var de=-1,Te=V==null?0:V.length;for(ne&&Te&&(O=V[++de]);++de<Te;)O=Y(O,V[de],de,V);return O}function ug(V,Y,O,ne){var de=V==null?0:V.length;for(ne&&de&&(O=V[--de]);de--;)O=Y(O,V[de],de,V);return O}function Xo(V,Y){for(var O=-1,ne=V==null?0:V.length;++O<ne;)if(Y(V[O],O,V))return!0;return!1}var hg=zo("length");function dg(V){return V.split("")}function fg(V){return V.match(b0)||[]}function kc(V,Y,O){var ne;return O(V,function(de,Te,Be){if(Y(de,Te,Be))return ne=Te,!1}),ne}function Yr(V,Y,O,ne){for(var de=V.length,Te=O+(ne?1:-1);ne?Te--:++Te<de;)if(Y(V[Te],Te,V))return Te;return-1}function xi(V,Y,O){return Y===Y?Sg(V,Y,O):Yr(V,Oc,O)}function pg(V,Y,O,ne){for(var de=O-1,Te=V.length;++de<Te;)if(ne(V[de],Y))return de;return-1}function Oc(V){return V!==V}function Rc(V,Y){var O=V==null?0:V.length;return O?ko(V,Y)/O:me}function zo(V){return function(Y){return Y==null?e:Y[V]}}function Do(V){return function(Y){return V==null?e:V[Y]}}function Kc(V,Y,O,ne,de){return de(V,function(Te,Be,We){O=ne?(ne=!1,Te):Y(O,Te,Be,We)}),O}function mg(V,Y){var O=V.length;for(V.sort(Y);O--;)V[O]=V[O].value;return V}function ko(V,Y){for(var O,ne=-1,de=V.length;++ne<de;){var Te=Y(V[ne]);Te!==e&&(O=O===e?Te:O+Te)}return O}function Oo(V,Y){for(var O=-1,ne=Array(V);++O<V;)ne[O]=Y(O);return ne}function gg(V,Y){return Ve(Y,function(O){return[O,V[O]]})}function Yc(V){return V&&V.slice(0,jc(V)+1).replace(To,"")}function _t(V){return function(Y){return V(Y)}}function Ro(V,Y){return Ve(Y,function(O){return V[O]})}function tr(V,Y){return V.has(Y)}function Uc(V,Y){for(var O=-1,ne=V.length;++O<ne&&xi(Y,V[O],0)>-1;);return O}function Bc(V,Y){for(var O=V.length;O--&&xi(Y,V[O],0)>-1;);return O}function yg(V,Y){for(var O=V.length,ne=0;O--;)V[O]===Y&&++ne;return ne}var vg=Do(tg),wg=Do(ng);function xg(V){return"\\"+rg[V]}function bg(V,Y){return V==null?e:V[Y]}function bi(V){return E0.test(V)}function _g(V){return q0.test(V)}function Mg(V){for(var Y,O=[];!(Y=V.next()).done;)O.push(Y.value);return O}function Ko(V){var Y=-1,O=Array(V.size);return V.forEach(function(ne,de){O[++Y]=[de,ne]}),O}function Nc(V,Y){return function(O){return V(Y(O))}}function Fn(V,Y){for(var O=-1,ne=V.length,de=0,Te=[];++O<ne;){var Be=V[O];(Be===Y||Be===p)&&(V[O]=p,Te[de++]=O)}return Te}function Ur(V){var Y=-1,O=Array(V.size);return V.forEach(function(ne){O[++Y]=ne}),O}function Lg(V){var Y=-1,O=Array(V.size);return V.forEach(function(ne){O[++Y]=[ne,ne]}),O}function Sg(V,Y,O){for(var ne=O-1,de=V.length;++ne<de;)if(V[ne]===Y)return ne;return-1}function Tg(V,Y,O){for(var ne=O+1;ne--;)if(V[ne]===Y)return ne;return ne}function _i(V){return bi(V)?Gg(V):hg(V)}function Jt(V){return bi(V)?Wg(V):dg(V)}function jc(V){for(var Y=V.length;Y--&&y0.test(V.charAt(Y)););return Y}var Zg=Do(ig);function Gg(V){for(var Y=Io.lastIndex=0;Io.test(V);)++Y;return Y}function Wg(V){return V.match(Io)||[]}function Pg(V){return V.match(H0)||[]}var Ig=function V(Y){Y=Y==null?nt:Mi.defaults(nt.Object(),Y,Mi.pick(nt,$0));var O=Y.Array,ne=Y.Date,de=Y.Error,Te=Y.Function,Be=Y.Math,We=Y.Object,Yo=Y.RegExp,Cg=Y.String,Ft=Y.TypeError,Br=O.prototype,Vg=Te.prototype,Li=We.prototype,Nr=Y["__core-js_shared__"],jr=Vg.toString,Ge=Li.hasOwnProperty,Ag=0,Jc=function(){var r=/[^.]+$/.exec(Nr&&Nr.keys&&Nr.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),Jr=Li.toString,Fg=jr.call(We),Xg=nt._,zg=Yo("^"+jr.call(Ge).replace(So,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Qr=Ic?Y.Buffer:e,Xn=Y.Symbol,Hr=Y.Uint8Array,Qc=Qr?Qr.allocUnsafe:e,Er=Nc(We.getPrototypeOf,We),Hc=We.create,Ec=Li.propertyIsEnumerable,qr=Br.splice,qc=Xn?Xn.isConcatSpreadable:e,nr=Xn?Xn.iterator:e,ti=Xn?Xn.toStringTag:e,$r=function(){try{var r=oi(We,"defineProperty");return r({},"",{}),r}catch{}}(),Dg=Y.clearTimeout!==nt.clearTimeout&&Y.clearTimeout,kg=ne&&ne.now!==nt.Date.now&&ne.now,Og=Y.setTimeout!==nt.setTimeout&&Y.setTimeout,es=Be.ceil,ts=Be.floor,Uo=We.getOwnPropertySymbols,Rg=Qr?Qr.isBuffer:e,$c=Y.isFinite,Kg=Br.join,Yg=Nc(We.keys,We),Ne=Be.max,ot=Be.min,Ug=ne.now,Bg=Y.parseInt,eu=Be.random,Ng=Br.reverse,Bo=oi(Y,"DataView"),ir=oi(Y,"Map"),No=oi(Y,"Promise"),Si=oi(Y,"Set"),rr=oi(Y,"WeakMap"),sr=oi(We,"create"),ns=rr&&new rr,Ti={},jg=ai(Bo),Jg=ai(ir),Qg=ai(No),Hg=ai(Si),Eg=ai(rr),is=Xn?Xn.prototype:e,or=is?is.valueOf:e,tu=is?is.toString:e;function b(r){if(De(r)&&!fe(r)&&!(r instanceof Me)){if(r instanceof Xt)return r;if(Ge.call(r,"__wrapped__"))return nh(r)}return new Xt(r)}var Zi=function(){function r(){}return function(o){if(!Fe(o))return{};if(Hc)return Hc(o);r.prototype=o;var h=new r;return r.prototype=e,h}}();function rs(){}function Xt(r,o){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=e}b.templateSettings={escape:Nt,evaluate:jt,interpolate:Cn,variable:"",imports:{_:b}},b.prototype=rs.prototype,b.prototype.constructor=b,Xt.prototype=Zi(rs.prototype),Xt.prototype.constructor=Xt;function Me(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=be,this.__views__=[]}function qg(){var r=new Me(this.__wrapped__);return r.__actions__=gt(this.__actions__),r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=gt(this.__iteratees__),r.__takeCount__=this.__takeCount__,r.__views__=gt(this.__views__),r}function $g(){if(this.__filtered__){var r=new Me(this);r.__dir__=-1,r.__filtered__=!0}else r=this.clone(),r.__dir__*=-1;return r}function ey(){var r=this.__wrapped__.value(),o=this.__dir__,h=fe(r),g=o<0,w=h?r.length:0,L=dv(0,w,this.__views__),W=L.start,P=L.end,F=P-W,U=g?P:W-1,B=this.__iteratees__,Q=B.length,$=0,ie=ot(F,this.__takeCount__);if(!h||!g&&w==F&&ie==F)return Su(r,this.__actions__);var le=[];e:for(;F--&&$<ie;){U+=o;for(var ge=-1,ce=r[U];++ge<Q;){var _e=B[ge],Le=_e.iteratee,St=_e.type,ft=Le(ce);if(St==q)ce=ft;else if(!ft){if(St==j)continue e;break e}}le[$++]=ce}return le}Me.prototype=Zi(rs.prototype),Me.prototype.constructor=Me;function ni(r){var o=-1,h=r==null?0:r.length;for(this.clear();++o<h;){var g=r[o];this.set(g[0],g[1])}}function ty(){this.__data__=sr?sr(null):{},this.size=0}function ny(r){var o=this.has(r)&&delete this.__data__[r];return this.size-=o?1:0,o}function iy(r){var o=this.__data__;if(sr){var h=o[r];return h===c?e:h}return Ge.call(o,r)?o[r]:e}function ry(r){var o=this.__data__;return sr?o[r]!==e:Ge.call(o,r)}function sy(r,o){var h=this.__data__;return this.size+=this.has(r)?0:1,h[r]=sr&&o===e?c:o,this}ni.prototype.clear=ty,ni.prototype.delete=ny,ni.prototype.get=iy,ni.prototype.has=ry,ni.prototype.set=sy;function fn(r){var o=-1,h=r==null?0:r.length;for(this.clear();++o<h;){var g=r[o];this.set(g[0],g[1])}}function oy(){this.__data__=[],this.size=0}function ay(r){var o=this.__data__,h=ss(o,r);if(h<0)return!1;var g=o.length-1;return h==g?o.pop():qr.call(o,h,1),--this.size,!0}function ly(r){var o=this.__data__,h=ss(o,r);return h<0?e:o[h][1]}function cy(r){return ss(this.__data__,r)>-1}function uy(r,o){var h=this.__data__,g=ss(h,r);return g<0?(++this.size,h.push([r,o])):h[g][1]=o,this}fn.prototype.clear=oy,fn.prototype.delete=ay,fn.prototype.get=ly,fn.prototype.has=cy,fn.prototype.set=uy;function pn(r){var o=-1,h=r==null?0:r.length;for(this.clear();++o<h;){var g=r[o];this.set(g[0],g[1])}}function hy(){this.size=0,this.__data__={hash:new ni,map:new(ir||fn),string:new ni}}function dy(r){var o=ys(this,r).delete(r);return this.size-=o?1:0,o}function fy(r){return ys(this,r).get(r)}function py(r){return ys(this,r).has(r)}function my(r,o){var h=ys(this,r),g=h.size;return h.set(r,o),this.size+=h.size==g?0:1,this}pn.prototype.clear=hy,pn.prototype.delete=dy,pn.prototype.get=fy,pn.prototype.has=py,pn.prototype.set=my;function ii(r){var o=-1,h=r==null?0:r.length;for(this.__data__=new pn;++o<h;)this.add(r[o])}function gy(r){return this.__data__.set(r,c),this}function yy(r){return this.__data__.has(r)}ii.prototype.add=ii.prototype.push=gy,ii.prototype.has=yy;function Qt(r){var o=this.__data__=new fn(r);this.size=o.size}function vy(){this.__data__=new fn,this.size=0}function wy(r){var o=this.__data__,h=o.delete(r);return this.size=o.size,h}function xy(r){return this.__data__.get(r)}function by(r){return this.__data__.has(r)}function _y(r,o){var h=this.__data__;if(h instanceof fn){var g=h.__data__;if(!ir||g.length<i-1)return g.push([r,o]),this.size=++h.size,this;h=this.__data__=new pn(g)}return h.set(r,o),this.size=h.size,this}Qt.prototype.clear=vy,Qt.prototype.delete=wy,Qt.prototype.get=xy,Qt.prototype.has=by,Qt.prototype.set=_y;function nu(r,o){var h=fe(r),g=!h&&li(r),w=!h&&!g&&Rn(r),L=!h&&!g&&!w&&Ii(r),W=h||g||w||L,P=W?Oo(r.length,Cg):[],F=P.length;for(var U in r)(o||Ge.call(r,U))&&!(W&&(U=="length"||w&&(U=="offset"||U=="parent")||L&&(U=="buffer"||U=="byteLength"||U=="byteOffset")||vn(U,F)))&&P.push(U);return P}function iu(r){var o=r.length;return o?r[ia(0,o-1)]:e}function My(r,o){return vs(gt(r),ri(o,0,r.length))}function Ly(r){return vs(gt(r))}function jo(r,o,h){(h!==e&&!Ht(r[o],h)||h===e&&!(o in r))&&mn(r,o,h)}function ar(r,o,h){var g=r[o];(!(Ge.call(r,o)&&Ht(g,h))||h===e&&!(o in r))&&mn(r,o,h)}function ss(r,o){for(var h=r.length;h--;)if(Ht(r[h][0],o))return h;return-1}function Sy(r,o,h,g){return zn(r,function(w,L,W){o(g,w,h(w),W)}),g}function ru(r,o){return r&&an(o,He(o),r)}function Ty(r,o){return r&&an(o,vt(o),r)}function mn(r,o,h){o=="__proto__"&&$r?$r(r,o,{configurable:!0,enumerable:!0,value:h,writable:!0}):r[o]=h}function Jo(r,o){for(var h=-1,g=o.length,w=O(g),L=r==null;++h<g;)w[h]=L?e:Ga(r,o[h]);return w}function ri(r,o,h){return r===r&&(h!==e&&(r=r<=h?r:h),o!==e&&(r=r>=o?r:o)),r}function zt(r,o,h,g,w,L){var W,P=o&f,F=o&y,U=o&v;if(h&&(W=w?h(r,g,w,L):h(r)),W!==e)return W;if(!Fe(r))return r;var B=fe(r);if(B){if(W=pv(r),!P)return gt(r,W)}else{var Q=at(r),$=Q==dn||Q==Gn;if(Rn(r))return Gu(r,P);if(Q==It||Q==Ye||$&&!w){if(W=F||$?{}:ju(r),!P)return F?iv(r,Ty(W,r)):nv(r,ru(W,r))}else{if(!Pe[Q])return w?r:{};W=mv(r,Q,P)}}L||(L=new Qt);var ie=L.get(r);if(ie)return ie;L.set(r,W),_h(r)?r.forEach(function(ce){W.add(zt(ce,o,h,ce,r,L))}):xh(r)&&r.forEach(function(ce,_e){W.set(_e,zt(ce,o,h,_e,r,L))});var le=U?F?pa:fa:F?vt:He,ge=B?e:le(r);return At(ge||r,function(ce,_e){ge&&(_e=ce,ce=r[_e]),ar(W,_e,zt(ce,o,h,_e,r,L))}),W}function Zy(r){var o=He(r);return function(h){return su(h,r,o)}}function su(r,o,h){var g=h.length;if(r==null)return!g;for(r=We(r);g--;){var w=h[g],L=o[w],W=r[w];if(W===e&&!(w in r)||!L(W))return!1}return!0}function ou(r,o,h){if(typeof r!="function")throw new Ft(l);return pr(function(){r.apply(e,h)},o)}function lr(r,o,h,g){var w=-1,L=Kr,W=!0,P=r.length,F=[],U=o.length;if(!P)return F;h&&(o=Ve(o,_t(h))),g?(L=Ao,W=!1):o.length>=i&&(L=tr,W=!1,o=new ii(o));e:for(;++w<P;){var B=r[w],Q=h==null?B:h(B);if(B=g||B!==0?B:0,W&&Q===Q){for(var $=U;$--;)if(o[$]===Q)continue e;F.push(B)}else L(o,Q,g)||F.push(B)}return F}var zn=Vu(on),au=Vu(Ho,!0);function Gy(r,o){var h=!0;return zn(r,function(g,w,L){return h=!!o(g,w,L),h}),h}function os(r,o,h){for(var g=-1,w=r.length;++g<w;){var L=r[g],W=o(L);if(W!=null&&(P===e?W===W&&!Lt(W):h(W,P)))var P=W,F=L}return F}function Wy(r,o,h,g){var w=r.length;for(h=pe(h),h<0&&(h=-h>w?0:w+h),g=g===e||g>w?w:pe(g),g<0&&(g+=w),g=h>g?0:Lh(g);h<g;)r[h++]=o;return r}function lu(r,o){var h=[];return zn(r,function(g,w,L){o(g,w,L)&&h.push(g)}),h}function it(r,o,h,g,w){var L=-1,W=r.length;for(h||(h=yv),w||(w=[]);++L<W;){var P=r[L];o>0&&h(P)?o>1?it(P,o-1,h,g,w):An(w,P):g||(w[w.length]=P)}return w}var Qo=Au(),cu=Au(!0);function on(r,o){return r&&Qo(r,o,He)}function Ho(r,o){return r&&cu(r,o,He)}function as(r,o){return Vn(o,function(h){return wn(r[h])})}function si(r,o){o=kn(o,r);for(var h=0,g=o.length;r!=null&&h<g;)r=r[ln(o[h++])];return h&&h==g?r:e}function uu(r,o,h){var g=o(r);return fe(r)?g:An(g,h(r))}function ht(r){return r==null?r===e?Qn:Pt:ti&&ti in We(r)?hv(r):Lv(r)}function Eo(r,o){return r>o}function Py(r,o){return r!=null&&Ge.call(r,o)}function Iy(r,o){return r!=null&&o in We(r)}function Cy(r,o,h){return r>=ot(o,h)&&r<Ne(o,h)}function qo(r,o,h){for(var g=h?Ao:Kr,w=r[0].length,L=r.length,W=L,P=O(L),F=1/0,U=[];W--;){var B=r[W];W&&o&&(B=Ve(B,_t(o))),F=ot(B.length,F),P[W]=!h&&(o||w>=120&&B.length>=120)?new ii(W&&B):e}B=r[0];var Q=-1,$=P[0];e:for(;++Q<w&&U.length<F;){var ie=B[Q],le=o?o(ie):ie;if(ie=h||ie!==0?ie:0,!($?tr($,le):g(U,le,h))){for(W=L;--W;){var ge=P[W];if(!(ge?tr(ge,le):g(r[W],le,h)))continue e}$&&$.push(le),U.push(ie)}}return U}function Vy(r,o,h,g){return on(r,function(w,L,W){o(g,h(w),L,W)}),g}function cr(r,o,h){o=kn(o,r),r=Eu(r,o);var g=r==null?r:r[ln(kt(o))];return g==null?e:bt(g,r,h)}function hu(r){return De(r)&&ht(r)==Ye}function Ay(r){return De(r)&&ht(r)==In}function Fy(r){return De(r)&&ht(r)==ut}function ur(r,o,h,g,w){return r===o?!0:r==null||o==null||!De(r)&&!De(o)?r!==r&&o!==o:Xy(r,o,h,g,ur,w)}function Xy(r,o,h,g,w,L){var W=fe(r),P=fe(o),F=W?je:at(r),U=P?je:at(o);F=F==Ye?It:F,U=U==Ye?It:U;var B=F==It,Q=U==It,$=F==U;if($&&Rn(r)){if(!Rn(o))return!1;W=!0,B=!1}if($&&!B)return L||(L=new Qt),W||Ii(r)?Uu(r,o,h,g,w,L):cv(r,o,F,h,g,w,L);if(!(h&x)){var ie=B&&Ge.call(r,"__wrapped__"),le=Q&&Ge.call(o,"__wrapped__");if(ie||le){var ge=ie?r.value():r,ce=le?o.value():o;return L||(L=new Qt),w(ge,ce,h,g,L)}}return $?(L||(L=new Qt),uv(r,o,h,g,w,L)):!1}function zy(r){return De(r)&&at(r)==Ae}function $o(r,o,h,g){var w=h.length,L=w,W=!g;if(r==null)return!L;for(r=We(r);w--;){var P=h[w];if(W&&P[2]?P[1]!==r[P[0]]:!(P[0]in r))return!1}for(;++w<L;){P=h[w];var F=P[0],U=r[F],B=P[1];if(W&&P[2]){if(U===e&&!(F in r))return!1}else{var Q=new Qt;if(g)var $=g(U,B,F,r,o,Q);if(!($===e?ur(B,U,x|S,g,Q):$))return!1}}return!0}function du(r){if(!Fe(r)||wv(r))return!1;var o=wn(r)?zg:Z0;return o.test(ai(r))}function Dy(r){return De(r)&&ht(r)==Jn}function ky(r){return De(r)&&at(r)==xt}function Oy(r){return De(r)&&Ls(r.length)&&!!Ce[ht(r)]}function fu(r){return typeof r=="function"?r:r==null?wt:typeof r=="object"?fe(r)?gu(r[0],r[1]):mu(r):Fh(r)}function ea(r){if(!fr(r))return Yg(r);var o=[];for(var h in We(r))Ge.call(r,h)&&h!="constructor"&&o.push(h);return o}function Ry(r){if(!Fe(r))return Mv(r);var o=fr(r),h=[];for(var g in r)g=="constructor"&&(o||!Ge.call(r,g))||h.push(g);return h}function ta(r,o){return r<o}function pu(r,o){var h=-1,g=yt(r)?O(r.length):[];return zn(r,function(w,L,W){g[++h]=o(w,L,W)}),g}function mu(r){var o=ga(r);return o.length==1&&o[0][2]?Qu(o[0][0],o[0][1]):function(h){return h===r||$o(h,r,o)}}function gu(r,o){return va(r)&&Ju(o)?Qu(ln(r),o):function(h){var g=Ga(h,r);return g===e&&g===o?Wa(h,r):ur(o,g,x|S)}}function ls(r,o,h,g,w){r!==o&&Qo(o,function(L,W){if(w||(w=new Qt),Fe(L))Ky(r,o,W,h,ls,g,w);else{var P=g?g(xa(r,W),L,W+"",r,o,w):e;P===e&&(P=L),jo(r,W,P)}},vt)}function Ky(r,o,h,g,w,L,W){var P=xa(r,h),F=xa(o,h),U=W.get(F);if(U){jo(r,h,U);return}var B=L?L(P,F,h+"",r,o,W):e,Q=B===e;if(Q){var $=fe(F),ie=!$&&Rn(F),le=!$&&!ie&&Ii(F);B=F,$||ie||le?fe(P)?B=P:Oe(P)?B=gt(P):ie?(Q=!1,B=Gu(F,!0)):le?(Q=!1,B=Wu(F,!0)):B=[]:mr(F)||li(F)?(B=P,li(P)?B=Sh(P):(!Fe(P)||wn(P))&&(B=ju(F))):Q=!1}Q&&(W.set(F,B),w(B,F,g,L,W),W.delete(F)),jo(r,h,B)}function yu(r,o){var h=r.length;if(h)return o+=o<0?h:0,vn(o,h)?r[o]:e}function vu(r,o,h){o.length?o=Ve(o,function(L){return fe(L)?function(W){return si(W,L.length===1?L[0]:L)}:L}):o=[wt];var g=-1;o=Ve(o,_t(ae()));var w=pu(r,function(L,W,P){var F=Ve(o,function(U){return U(L)});return{criteria:F,index:++g,value:L}});return mg(w,function(L,W){return tv(L,W,h)})}function Yy(r,o){return wu(r,o,function(h,g){return Wa(r,g)})}function wu(r,o,h){for(var g=-1,w=o.length,L={};++g<w;){var W=o[g],P=si(r,W);h(P,W)&&hr(L,kn(W,r),P)}return L}function Uy(r){return function(o){return si(o,r)}}function na(r,o,h,g){var w=g?pg:xi,L=-1,W=o.length,P=r;for(r===o&&(o=gt(o)),h&&(P=Ve(r,_t(h)));++L<W;)for(var F=0,U=o[L],B=h?h(U):U;(F=w(P,B,F,g))>-1;)P!==r&&qr.call(P,F,1),qr.call(r,F,1);return r}function xu(r,o){for(var h=r?o.length:0,g=h-1;h--;){var w=o[h];if(h==g||w!==L){var L=w;vn(w)?qr.call(r,w,1):oa(r,w)}}return r}function ia(r,o){return r+ts(eu()*(o-r+1))}function By(r,o,h,g){for(var w=-1,L=Ne(es((o-r)/(h||1)),0),W=O(L);L--;)W[g?L:++w]=r,r+=h;return W}function ra(r,o){var h="";if(!r||o<1||o>re)return h;do o%2&&(h+=r),o=ts(o/2),o&&(r+=r);while(o);return h}function ye(r,o){return ba(Hu(r,o,wt),r+"")}function Ny(r){return iu(Ci(r))}function jy(r,o){var h=Ci(r);return vs(h,ri(o,0,h.length))}function hr(r,o,h,g){if(!Fe(r))return r;o=kn(o,r);for(var w=-1,L=o.length,W=L-1,P=r;P!=null&&++w<L;){var F=ln(o[w]),U=h;if(F==="__proto__"||F==="constructor"||F==="prototype")return r;if(w!=W){var B=P[F];U=g?g(B,F,P):e,U===e&&(U=Fe(B)?B:vn(o[w+1])?[]:{})}ar(P,F,U),P=P[F]}return r}var bu=ns?function(r,o){return ns.set(r,o),r}:wt,Jy=$r?function(r,o){return $r(r,"toString",{configurable:!0,enumerable:!1,value:Ia(o),writable:!0})}:wt;function Qy(r){return vs(Ci(r))}function Dt(r,o,h){var g=-1,w=r.length;o<0&&(o=-o>w?0:w+o),h=h>w?w:h,h<0&&(h+=w),w=o>h?0:h-o>>>0,o>>>=0;for(var L=O(w);++g<w;)L[g]=r[g+o];return L}function Hy(r,o){var h;return zn(r,function(g,w,L){return h=o(g,w,L),!h}),!!h}function cs(r,o,h){var g=0,w=r==null?g:r.length;if(typeof o=="number"&&o===o&&w<=ve){for(;g<w;){var L=g+w>>>1,W=r[L];W!==null&&!Lt(W)&&(h?W<=o:W<o)?g=L+1:w=L}return w}return sa(r,o,wt,h)}function sa(r,o,h,g){var w=0,L=r==null?0:r.length;if(L===0)return 0;o=h(o);for(var W=o!==o,P=o===null,F=Lt(o),U=o===e;w<L;){var B=ts((w+L)/2),Q=h(r[B]),$=Q!==e,ie=Q===null,le=Q===Q,ge=Lt(Q);if(W)var ce=g||le;else U?ce=le&&(g||$):P?ce=le&&$&&(g||!ie):F?ce=le&&$&&!ie&&(g||!ge):ie||ge?ce=!1:ce=g?Q<=o:Q<o;ce?w=B+1:L=B}return ot(L,he)}function _u(r,o){for(var h=-1,g=r.length,w=0,L=[];++h<g;){var W=r[h],P=o?o(W):W;if(!h||!Ht(P,F)){var F=P;L[w++]=W===0?0:W}}return L}function Mu(r){return typeof r=="number"?r:Lt(r)?me:+r}function Mt(r){if(typeof r=="string")return r;if(fe(r))return Ve(r,Mt)+"";if(Lt(r))return tu?tu.call(r):"";var o=r+"";return o=="0"&&1/r==-oe?"-0":o}function Dn(r,o,h){var g=-1,w=Kr,L=r.length,W=!0,P=[],F=P;if(h)W=!1,w=Ao;else if(L>=i){var U=o?null:av(r);if(U)return Ur(U);W=!1,w=tr,F=new ii}else F=o?[]:P;e:for(;++g<L;){var B=r[g],Q=o?o(B):B;if(B=h||B!==0?B:0,W&&Q===Q){for(var $=F.length;$--;)if(F[$]===Q)continue e;o&&F.push(Q),P.push(B)}else w(F,Q,h)||(F!==P&&F.push(Q),P.push(B))}return P}function oa(r,o){return o=kn(o,r),r=Eu(r,o),r==null||delete r[ln(kt(o))]}function Lu(r,o,h,g){return hr(r,o,h(si(r,o)),g)}function us(r,o,h,g){for(var w=r.length,L=g?w:-1;(g?L--:++L<w)&&o(r[L],L,r););return h?Dt(r,g?0:L,g?L+1:w):Dt(r,g?L+1:0,g?w:L)}function Su(r,o){var h=r;return h instanceof Me&&(h=h.value()),Fo(o,function(g,w){return w.func.apply(w.thisArg,An([g],w.args))},h)}function aa(r,o,h){var g=r.length;if(g<2)return g?Dn(r[0]):[];for(var w=-1,L=O(g);++w<g;)for(var W=r[w],P=-1;++P<g;)P!=w&&(L[w]=lr(L[w]||W,r[P],o,h));return Dn(it(L,1),o,h)}function Tu(r,o,h){for(var g=-1,w=r.length,L=o.length,W={};++g<w;){var P=g<L?o[g]:e;h(W,r[g],P)}return W}function la(r){return Oe(r)?r:[]}function ca(r){return typeof r=="function"?r:wt}function kn(r,o){return fe(r)?r:va(r,o)?[r]:th(Ze(r))}var Ey=ye;function On(r,o,h){var g=r.length;return h=h===e?g:h,!o&&h>=g?r:Dt(r,o,h)}var Zu=Dg||function(r){return nt.clearTimeout(r)};function Gu(r,o){if(o)return r.slice();var h=r.length,g=Qc?Qc(h):new r.constructor(h);return r.copy(g),g}function ua(r){var o=new r.constructor(r.byteLength);return new Hr(o).set(new Hr(r)),o}function qy(r,o){var h=o?ua(r.buffer):r.buffer;return new r.constructor(h,r.byteOffset,r.byteLength)}function $y(r){var o=new r.constructor(r.source,hc.exec(r));return o.lastIndex=r.lastIndex,o}function ev(r){return or?We(or.call(r)):{}}function Wu(r,o){var h=o?ua(r.buffer):r.buffer;return new r.constructor(h,r.byteOffset,r.length)}function Pu(r,o){if(r!==o){var h=r!==e,g=r===null,w=r===r,L=Lt(r),W=o!==e,P=o===null,F=o===o,U=Lt(o);if(!P&&!U&&!L&&r>o||L&&W&&F&&!P&&!U||g&&W&&F||!h&&F||!w)return 1;if(!g&&!L&&!U&&r<o||U&&h&&w&&!g&&!L||P&&h&&w||!W&&w||!F)return-1}return 0}function tv(r,o,h){for(var g=-1,w=r.criteria,L=o.criteria,W=w.length,P=h.length;++g<W;){var F=Pu(w[g],L[g]);if(F){if(g>=P)return F;var U=h[g];return F*(U=="desc"?-1:1)}}return r.index-o.index}function Iu(r,o,h,g){for(var w=-1,L=r.length,W=h.length,P=-1,F=o.length,U=Ne(L-W,0),B=O(F+U),Q=!g;++P<F;)B[P]=o[P];for(;++w<W;)(Q||w<L)&&(B[h[w]]=r[w]);for(;U--;)B[P++]=r[w++];return B}function Cu(r,o,h,g){for(var w=-1,L=r.length,W=-1,P=h.length,F=-1,U=o.length,B=Ne(L-P,0),Q=O(B+U),$=!g;++w<B;)Q[w]=r[w];for(var ie=w;++F<U;)Q[ie+F]=o[F];for(;++W<P;)($||w<L)&&(Q[ie+h[W]]=r[w++]);return Q}function gt(r,o){var h=-1,g=r.length;for(o||(o=O(g));++h<g;)o[h]=r[h];return o}function an(r,o,h,g){var w=!h;h||(h={});for(var L=-1,W=o.length;++L<W;){var P=o[L],F=g?g(h[P],r[P],P,h,r):e;F===e&&(F=r[P]),w?mn(h,P,F):ar(h,P,F)}return h}function nv(r,o){return an(r,ya(r),o)}function iv(r,o){return an(r,Bu(r),o)}function hs(r,o){return function(h,g){var w=fe(h)?lg:Sy,L=o?o():{};return w(h,r,ae(g,2),L)}}function Gi(r){return ye(function(o,h){var g=-1,w=h.length,L=w>1?h[w-1]:e,W=w>2?h[2]:e;for(L=r.length>3&&typeof L=="function"?(w--,L):e,W&&dt(h[0],h[1],W)&&(L=w<3?e:L,w=1),o=We(o);++g<w;){var P=h[g];P&&r(o,P,g,L)}return o})}function Vu(r,o){return function(h,g){if(h==null)return h;if(!yt(h))return r(h,g);for(var w=h.length,L=o?w:-1,W=We(h);(o?L--:++L<w)&&g(W[L],L,W)!==!1;);return h}}function Au(r){return function(o,h,g){for(var w=-1,L=We(o),W=g(o),P=W.length;P--;){var F=W[r?P:++w];if(h(L[F],F,L)===!1)break}return o}}function rv(r,o,h){var g=o&_,w=dr(r);function L(){var W=this&&this!==nt&&this instanceof L?w:r;return W.apply(g?h:this,arguments)}return L}function Fu(r){return function(o){o=Ze(o);var h=bi(o)?Jt(o):e,g=h?h[0]:o.charAt(0),w=h?On(h,1).join(""):o.slice(1);return g[r]()+w}}function Wi(r){return function(o){return Fo(Vh(Ch(o).replace(J0,"")),r,"")}}function dr(r){return function(){var o=arguments;switch(o.length){case 0:return new r;case 1:return new r(o[0]);case 2:return new r(o[0],o[1]);case 3:return new r(o[0],o[1],o[2]);case 4:return new r(o[0],o[1],o[2],o[3]);case 5:return new r(o[0],o[1],o[2],o[3],o[4]);case 6:return new r(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new r(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var h=Zi(r.prototype),g=r.apply(h,o);return Fe(g)?g:h}}function sv(r,o,h){var g=dr(r);function w(){for(var L=arguments.length,W=O(L),P=L,F=Pi(w);P--;)W[P]=arguments[P];var U=L<3&&W[0]!==F&&W[L-1]!==F?[]:Fn(W,F);if(L-=U.length,L<h)return Ou(r,o,ds,w.placeholder,e,W,U,e,e,h-L);var B=this&&this!==nt&&this instanceof w?g:r;return bt(B,this,W)}return w}function Xu(r){return function(o,h,g){var w=We(o);if(!yt(o)){var L=ae(h,3);o=He(o),h=function(P){return L(w[P],P,w)}}var W=r(o,h,g);return W>-1?w[L?o[W]:W]:e}}function zu(r){return yn(function(o){var h=o.length,g=h,w=Xt.prototype.thru;for(r&&o.reverse();g--;){var L=o[g];if(typeof L!="function")throw new Ft(l);if(w&&!W&&gs(L)=="wrapper")var W=new Xt([],!0)}for(g=W?g:h;++g<h;){L=o[g];var P=gs(L),F=P=="wrapper"?ma(L):e;F&&wa(F[0])&&F[1]==(k|G|R|C)&&!F[4].length&&F[9]==1?W=W[gs(F[0])].apply(W,F[3]):W=L.length==1&&wa(L)?W[P]():W.thru(L)}return function(){var U=arguments,B=U[0];if(W&&U.length==1&&fe(B))return W.plant(B).value();for(var Q=0,$=h?o[Q].apply(this,U):B;++Q<h;)$=o[Q].call(this,$);return $}})}function ds(r,o,h,g,w,L,W,P,F,U){var B=o&k,Q=o&_,$=o&Z,ie=o&(G|A),le=o&K,ge=$?e:dr(r);function ce(){for(var _e=arguments.length,Le=O(_e),St=_e;St--;)Le[St]=arguments[St];if(ie)var ft=Pi(ce),Tt=yg(Le,ft);if(g&&(Le=Iu(Le,g,w,ie)),L&&(Le=Cu(Le,L,W,ie)),_e-=Tt,ie&&_e<U){var Re=Fn(Le,ft);return Ou(r,o,ds,ce.placeholder,h,Le,Re,P,F,U-_e)}var Et=Q?h:this,bn=$?Et[r]:r;return _e=Le.length,P?Le=Sv(Le,P):le&&_e>1&&Le.reverse(),B&&F<_e&&(Le.length=F),this&&this!==nt&&this instanceof ce&&(bn=ge||dr(bn)),bn.apply(Et,Le)}return ce}function Du(r,o){return function(h,g){return Vy(h,r,o(g),{})}}function fs(r,o){return function(h,g){var w;if(h===e&&g===e)return o;if(h!==e&&(w=h),g!==e){if(w===e)return g;typeof h=="string"||typeof g=="string"?(h=Mt(h),g=Mt(g)):(h=Mu(h),g=Mu(g)),w=r(h,g)}return w}}function ha(r){return yn(function(o){return o=Ve(o,_t(ae())),ye(function(h){var g=this;return r(o,function(w){return bt(w,g,h)})})})}function ps(r,o){o=o===e?" ":Mt(o);var h=o.length;if(h<2)return h?ra(o,r):o;var g=ra(o,es(r/_i(o)));return bi(o)?On(Jt(g),0,r).join(""):g.slice(0,r)}function ov(r,o,h,g){var w=o&_,L=dr(r);function W(){for(var P=-1,F=arguments.length,U=-1,B=g.length,Q=O(B+F),$=this&&this!==nt&&this instanceof W?L:r;++U<B;)Q[U]=g[U];for(;F--;)Q[U++]=arguments[++P];return bt($,w?h:this,Q)}return W}function ku(r){return function(o,h,g){return g&&typeof g!="number"&&dt(o,h,g)&&(h=g=e),o=xn(o),h===e?(h=o,o=0):h=xn(h),g=g===e?o<h?1:-1:xn(g),By(o,h,g,r)}}function ms(r){return function(o,h){return typeof o=="string"&&typeof h=="string"||(o=Ot(o),h=Ot(h)),r(o,h)}}function Ou(r,o,h,g,w,L,W,P,F,U){var B=o&G,Q=B?W:e,$=B?e:W,ie=B?L:e,le=B?e:L;o|=B?R:D,o&=~(B?D:R),o&M||(o&=-4);var ge=[r,o,w,ie,Q,le,$,P,F,U],ce=h.apply(e,ge);return wa(r)&&qu(ce,ge),ce.placeholder=g,$u(ce,r,o)}function da(r){var o=Be[r];return function(h,g){if(h=Ot(h),g=g==null?0:ot(pe(g),292),g&&$c(h)){var w=(Ze(h)+"e").split("e"),L=o(w[0]+"e"+(+w[1]+g));return w=(Ze(L)+"e").split("e"),+(w[0]+"e"+(+w[1]-g))}return o(h)}}var av=Si&&1/Ur(new Si([,-0]))[1]==oe?function(r){return new Si(r)}:Aa;function Ru(r){return function(o){var h=at(o);return h==Ae?Ko(o):h==xt?Lg(o):gg(o,r(o))}}function gn(r,o,h,g,w,L,W,P){var F=o&Z;if(!F&&typeof r!="function")throw new Ft(l);var U=g?g.length:0;if(U||(o&=-97,g=w=e),W=W===e?W:Ne(pe(W),0),P=P===e?P:pe(P),U-=w?w.length:0,o&D){var B=g,Q=w;g=w=e}var $=F?e:ma(r),ie=[r,o,h,g,w,B,Q,L,W,P];if($&&_v(ie,$),r=ie[0],o=ie[1],h=ie[2],g=ie[3],w=ie[4],P=ie[9]=ie[9]===e?F?0:r.length:Ne(ie[9]-U,0),!P&&o&(G|A)&&(o&=-25),!o||o==_)var le=rv(r,o,h);else o==G||o==A?le=sv(r,o,P):(o==R||o==(_|R))&&!w.length?le=ov(r,o,h,g):le=ds.apply(e,ie);var ge=$?bu:qu;return $u(ge(le,ie),r,o)}function Ku(r,o,h,g){return r===e||Ht(r,Li[h])&&!Ge.call(g,h)?o:r}function Yu(r,o,h,g,w,L){return Fe(r)&&Fe(o)&&(L.set(o,r),ls(r,o,e,Yu,L),L.delete(o)),r}function lv(r){return mr(r)?e:r}function Uu(r,o,h,g,w,L){var W=h&x,P=r.length,F=o.length;if(P!=F&&!(W&&F>P))return!1;var U=L.get(r),B=L.get(o);if(U&&B)return U==o&&B==r;var Q=-1,$=!0,ie=h&S?new ii:e;for(L.set(r,o),L.set(o,r);++Q<P;){var le=r[Q],ge=o[Q];if(g)var ce=W?g(ge,le,Q,o,r,L):g(le,ge,Q,r,o,L);if(ce!==e){if(ce)continue;$=!1;break}if(ie){if(!Xo(o,function(_e,Le){if(!tr(ie,Le)&&(le===_e||w(le,_e,h,g,L)))return ie.push(Le)})){$=!1;break}}else if(!(le===ge||w(le,ge,h,g,L))){$=!1;break}}return L.delete(r),L.delete(o),$}function cv(r,o,h,g,w,L,W){switch(h){case sn:if(r.byteLength!=o.byteLength||r.byteOffset!=o.byteOffset)return!1;r=r.buffer,o=o.buffer;case In:return!(r.byteLength!=o.byteLength||!L(new Hr(r),new Hr(o)));case Qe:case ut:case Ut:return Ht(+r,+o);case Ue:return r.name==o.name&&r.message==o.message;case Jn:case Wn:return r==o+"";case Ae:var P=Ko;case xt:var F=g&x;if(P||(P=Ur),r.size!=o.size&&!F)return!1;var U=W.get(r);if(U)return U==o;g|=S,W.set(r,o);var B=Uu(P(r),P(o),g,w,L,W);return W.delete(r),B;case Pn:if(or)return or.call(r)==or.call(o)}return!1}function uv(r,o,h,g,w,L){var W=h&x,P=fa(r),F=P.length,U=fa(o),B=U.length;if(F!=B&&!W)return!1;for(var Q=F;Q--;){var $=P[Q];if(!(W?$ in o:Ge.call(o,$)))return!1}var ie=L.get(r),le=L.get(o);if(ie&&le)return ie==o&&le==r;var ge=!0;L.set(r,o),L.set(o,r);for(var ce=W;++Q<F;){$=P[Q];var _e=r[$],Le=o[$];if(g)var St=W?g(Le,_e,$,o,r,L):g(_e,Le,$,r,o,L);if(!(St===e?_e===Le||w(_e,Le,h,g,L):St)){ge=!1;break}ce||(ce=$=="constructor")}if(ge&&!ce){var ft=r.constructor,Tt=o.constructor;ft!=Tt&&"constructor"in r&&"constructor"in o&&!(typeof ft=="function"&&ft instanceof ft&&typeof Tt=="function"&&Tt instanceof Tt)&&(ge=!1)}return L.delete(r),L.delete(o),ge}function yn(r){return ba(Hu(r,e,sh),r+"")}function fa(r){return uu(r,He,ya)}function pa(r){return uu(r,vt,Bu)}var ma=ns?function(r){return ns.get(r)}:Aa;function gs(r){for(var o=r.name+"",h=Ti[o],g=Ge.call(Ti,o)?h.length:0;g--;){var w=h[g],L=w.func;if(L==null||L==r)return w.name}return o}function Pi(r){var o=Ge.call(b,"placeholder")?b:r;return o.placeholder}function ae(){var r=b.iteratee||Ca;return r=r===Ca?fu:r,arguments.length?r(arguments[0],arguments[1]):r}function ys(r,o){var h=r.__data__;return vv(o)?h[typeof o=="string"?"string":"hash"]:h.map}function ga(r){for(var o=He(r),h=o.length;h--;){var g=o[h],w=r[g];o[h]=[g,w,Ju(w)]}return o}function oi(r,o){var h=bg(r,o);return du(h)?h:e}function hv(r){var o=Ge.call(r,ti),h=r[ti];try{r[ti]=e;var g=!0}catch{}var w=Jr.call(r);return g&&(o?r[ti]=h:delete r[ti]),w}var ya=Uo?function(r){return r==null?[]:(r=We(r),Vn(Uo(r),function(o){return Ec.call(r,o)}))}:Fa,Bu=Uo?function(r){for(var o=[];r;)An(o,ya(r)),r=Er(r);return o}:Fa,at=ht;(Bo&&at(new Bo(new ArrayBuffer(1)))!=sn||ir&&at(new ir)!=Ae||No&&at(No.resolve())!=Hi||Si&&at(new Si)!=xt||rr&&at(new rr)!=Hn)&&(at=function(r){var o=ht(r),h=o==It?r.constructor:e,g=h?ai(h):"";if(g)switch(g){case jg:return sn;case Jg:return Ae;case Qg:return Hi;case Hg:return xt;case Eg:return Hn}return o});function dv(r,o,h){for(var g=-1,w=h.length;++g<w;){var L=h[g],W=L.size;switch(L.type){case"drop":r+=W;break;case"dropRight":o-=W;break;case"take":o=ot(o,r+W);break;case"takeRight":r=Ne(r,o-W);break}}return{start:r,end:o}}function fv(r){var o=r.match(w0);return o?o[1].split(x0):[]}function Nu(r,o,h){o=kn(o,r);for(var g=-1,w=o.length,L=!1;++g<w;){var W=ln(o[g]);if(!(L=r!=null&&h(r,W)))break;r=r[W]}return L||++g!=w?L:(w=r==null?0:r.length,!!w&&Ls(w)&&vn(W,w)&&(fe(r)||li(r)))}function pv(r){var o=r.length,h=new r.constructor(o);return o&&typeof r[0]=="string"&&Ge.call(r,"index")&&(h.index=r.index,h.input=r.input),h}function ju(r){return typeof r.constructor=="function"&&!fr(r)?Zi(Er(r)):{}}function mv(r,o,h){var g=r.constructor;switch(o){case In:return ua(r);case Qe:case ut:return new g(+r);case sn:return qy(r,h);case Ei:case qi:case gi:case $i:case er:case yi:case En:case X:case E:return Wu(r,h);case Ae:return new g;case Ut:case Wn:return new g(r);case Jn:return $y(r);case xt:return new g;case Pn:return ev(r)}}function gv(r,o){var h=o.length;if(!h)return r;var g=h-1;return o[g]=(h>1?"& ":"")+o[g],o=o.join(h>2?", ":" "),r.replace(v0,`{
|
|
547
547
|
/* [wrapped with `+o+`] */
|
|
548
|
-
`)}function dv(i){return fe(i)||lr(i)||!!(jc&&i&&i[jc])}function yn(i,o){var h=typeof i;return o=o??ie,!!o&&(h=="number"||h!="symbol"&&L0.test(i))&&i>-1&&i%1==0&&i<o}function ht(i,o,h){if(!Fe(h))return!1;var g=typeof o;return(g=="number"?gt(h)&&yn(o,h.length):g=="string"&&o in h)?Ht(h[o],i):!1}function da(i,o){if(fe(i))return!1;var h=typeof i;return h=="number"||h=="symbol"||h=="boolean"||i==null||Lt(i)?!0:$n.test(i)||!qn.test(i)||o!=null&&i in Pe(o)}function fv(i){var o=typeof i;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?i!=="__proto__":i===null}function fa(i){var o=ms(i),h=b[o];if(typeof h!="function"||!(o in Me.prototype))return!1;if(i===h)return!0;var g=ca(h);return!!g&&i===g[0]}function pv(i){return!!Yc&&Yc in i}var mv=Bi?vn:Ia;function ui(i){var o=i&&i.constructor,h=typeof o=="function"&&o.prototype||Mr;return i===h}function Yu(i){return i===i&&!Fe(i)}function Uu(i,o){return function(h){return h==null?!1:h[i]===o&&(o!==e||i in Pe(h))}}function gv(i){var o=bs(i,function(g){return h.size===d&&h.clear(),g}),h=o.cache;return o}function yv(i,o){var h=i[1],g=o[1],w=h|g,M=w<(_|S|O),P=g==O&&h==G||g==O&&h==V&&i[7].length<=o[8]||g==(O|V)&&o[7].length<=o[8]&&h==G;if(!(M||P))return i;g&_&&(i[2]=o[2],w|=h&_?0:Z);var I=o[3];if(I){var F=i[3];i[3]=F?Zu(F,I,o[4]):I,i[4]=F?Fn(i[3],p):o[4]}return I=o[5],I&&(F=i[5],i[5]=F?Tu(F,I,o[6]):I,i[6]=F?Fn(i[5],p):o[6]),I=o[7],I&&(i[7]=I),g&O&&(i[8]=i[8]==null?o[8]:st(i[8],o[8])),i[9]==null&&(i[9]=o[9]),i[0]=o[0],i[1]=w,i}function vv(i){var o=[];if(i!=null)for(var h in Pe(i))o.push(h);return o}function wv(i){return ji.call(i)}function Bu(i,o,h){return o=Ne(o===e?i.length-1:o,0),function(){for(var g=arguments,w=-1,M=Ne(g.length-o,0),P=z(M);++w<M;)P[w]=g[o+w];w=-1;for(var I=z(o+1);++w<o;)I[w]=g[w];return I[o]=h(P),bt(i,this,I)}}function Nu(i,o){return o.length<2?i:sr(i,Dt(o,0,-1))}function xv(i,o){for(var h=i.length,g=st(o.length,h),w=mt(i);g--;){var M=o[g];i[g]=yn(M,h)?w[M]:e}return i}function pa(i,o){if(!(o==="constructor"&&typeof i[o]=="function")&&o!="__proto__")return i[o]}var ju=Qu(gu),hi=Fg||function(i,o){return nt.setTimeout(i,o)},ma=Qu(Yy);function Ju(i,o,h){var g=o+"";return ma(i,hv(g,bv(lv(g),h)))}function Qu(i){var o=0,h=0;return function(){var g=zg(),w=H-(g-h);if(h=g,w>0){if(++o>=N)return arguments[0]}else o=0;return i.apply(e,arguments)}}function ys(i,o){var h=-1,g=i.length,w=g-1;for(o=o===e?g:o;++h<o;){var M=Eo(h,w),P=i[M];i[M]=i[h],i[h]=P}return i.length=o,i}var Hu=gv(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(yr,function(h,g,w,M){o.push(w?M.replace(v0,"$1"):g||h)}),o});function ln(i){if(typeof i=="string"||Lt(i))return i;var o=i+"";return o=="0"&&1/i==-oe?"-0":o}function ar(i){if(i!=null){try{return Ni.call(i)}catch{}try{return i+""}catch{}}return""}function bv(i,o){return At(ke,function(h){var g="_."+h[0];o&h[1]&&!Ki(i,g)&&i.push(g)}),i.sort()}function Eu(i){if(i instanceof Me)return i.clone();var o=new Xt(i.__wrapped__,i.__chain__);return o.__actions__=mt(i.__actions__),o.__index__=i.__index__,o.__values__=i.__values__,o}function _v(i,o,h){(h?ht(i,o,h):o===e)?o=1:o=Ne(pe(o),0);var g=i==null?0:i.length;if(!g||o<1)return[];for(var w=0,M=0,P=z($i(g/o));w<g;)P[M++]=Dt(i,w,w+=o);return P}function Mv(i){for(var o=-1,h=i==null?0:i.length,g=0,w=[];++o<h;){var M=i[o];M&&(w[g++]=M)}return w}function Lv(){var i=arguments.length;if(!i)return[];for(var o=z(i-1),h=arguments[0],g=i;g--;)o[g-1]=arguments[g];return An(fe(h)?mt(h):[h],rt(o,1))}var Sv=ye(function(i,o){return Oe(i)?si(i,rt(o,1,Oe,!0)):[]}),Zv=ye(function(i,o){var h=zt(o);return Oe(h)&&(h=e),Oe(i)?si(i,rt(o,1,Oe,!0),ae(h,2)):[]}),Tv=ye(function(i,o){var h=zt(o);return Oe(h)&&(h=e),Oe(i)?si(i,rt(o,1,Oe,!0),e,h):[]});function Gv(i,o,h){var g=i==null?0:i.length;return g?(o=h||o===e?1:pe(o),Dt(i,o<0?0:o,g)):[]}function Pv(i,o,h){var g=i==null?0:i.length;return g?(o=h||o===e?1:pe(o),o=g-o,Dt(i,0,o<0?0:o)):[]}function Iv(i,o){return i&&i.length?cs(i,ae(o,3),!0,!0):[]}function Wv(i,o){return i&&i.length?cs(i,ae(o,3),!0):[]}function Cv(i,o,h,g){var w=i==null?0:i.length;return w?(h&&typeof h!="number"&&ht(i,o,h)&&(h=0,g=w),Ly(i,o,h,g)):[]}function qu(i,o,h){var g=i==null?0:i.length;if(!g)return-1;var w=h==null?0:pe(h);return w<0&&(w=Ne(g+w,0)),Ri(i,ae(o,3),w)}function $u(i,o,h){var g=i==null?0:i.length;if(!g)return-1;var w=g-1;return h!==e&&(w=pe(h),w=h<0?Ne(g+w,0):st(w,g-1)),Ri(i,ae(o,3),w,!0)}function eh(i){var o=i==null?0:i.length;return o?rt(i,1):[]}function Vv(i){var o=i==null?0:i.length;return o?rt(i,oe):[]}function Av(i,o){var h=i==null?0:i.length;return h?(o=o===e?1:pe(o),rt(i,o)):[]}function Fv(i){for(var o=-1,h=i==null?0:i.length,g={};++o<h;){var w=i[o];g[w[0]]=w[1]}return g}function th(i){return i&&i.length?i[0]:e}function Xv(i,o,h){var g=i==null?0:i.length;if(!g)return-1;var w=h==null?0:pe(h);return w<0&&(w=Ne(g+w,0)),wr(i,o,w)}function kv(i){var o=i==null?0:i.length;return o?Dt(i,0,-1):[]}var Dv=ye(function(i){var o=Ve(i,na);return o.length&&o[0]===i[0]?No(o):[]}),zv=ye(function(i){var o=zt(i),h=Ve(i,na);return o===zt(h)?o=e:h.pop(),h.length&&h[0]===i[0]?No(h,ae(o,2)):[]}),Ov=ye(function(i){var o=zt(i),h=Ve(i,na);return o=typeof o=="function"?o:e,o&&h.pop(),h.length&&h[0]===i[0]?No(h,e,o):[]});function Kv(i,o){return i==null?"":kg.call(i,o)}function zt(i){var o=i==null?0:i.length;return o?i[o-1]:e}function Rv(i,o,h){var g=i==null?0:i.length;if(!g)return-1;var w=g;return h!==e&&(w=pe(h),w=w<0?Ne(g+w,0):st(w,g-1)),o===o?bg(i,o,w):Ri(i,Fc,w,!0)}function Yv(i,o){return i&&i.length?du(i,pe(o)):e}var Uv=ye(nh);function nh(i,o){return i&&i.length&&o&&o.length?Ho(i,o):i}function Bv(i,o,h){return i&&i.length&&o&&o.length?Ho(i,o,ae(h,2)):i}function Nv(i,o,h){return i&&i.length&&o&&o.length?Ho(i,o,e,h):i}var jv=gn(function(i,o){var h=i==null?0:i.length,g=Ro(i,o);return mu(i,Ve(o,function(w){return yn(w,h)?+w:w}).sort(Su)),g});function Jv(i,o){var h=[];if(!(i&&i.length))return h;var g=-1,w=[],M=i.length;for(o=ae(o,3);++g<M;){var P=i[g];o(P,g,i)&&(h.push(P),w.push(g))}return mu(i,w),h}function ga(i){return i==null?i:Kg.call(i)}function Qv(i,o,h){var g=i==null?0:i.length;return g?(h&&typeof h!="number"&&ht(i,o,h)?(o=0,h=g):(o=o==null?0:pe(o),h=h===e?g:pe(h)),Dt(i,o,h)):[]}function Hv(i,o){return ls(i,o)}function Ev(i,o,h){return $o(i,o,ae(h,2))}function qv(i,o){var h=i==null?0:i.length;if(h){var g=ls(i,o);if(g<h&&Ht(i[g],o))return g}return-1}function $v(i,o){return ls(i,o,!0)}function ew(i,o,h){return $o(i,o,ae(h,2),!0)}function tw(i,o){var h=i==null?0:i.length;if(h){var g=ls(i,o,!0)-1;if(Ht(i[g],o))return g}return-1}function nw(i){return i&&i.length?yu(i):[]}function rw(i,o){return i&&i.length?yu(i,ae(o,2)):[]}function iw(i){var o=i==null?0:i.length;return o?Dt(i,1,o):[]}function sw(i,o,h){return i&&i.length?(o=h||o===e?1:pe(o),Dt(i,0,o<0?0:o)):[]}function ow(i,o,h){var g=i==null?0:i.length;return g?(o=h||o===e?1:pe(o),o=g-o,Dt(i,o<0?0:o,g)):[]}function aw(i,o){return i&&i.length?cs(i,ae(o,3),!1,!0):[]}function lw(i,o){return i&&i.length?cs(i,ae(o,3)):[]}var cw=ye(function(i){return Dn(rt(i,1,Oe,!0))}),uw=ye(function(i){var o=zt(i);return Oe(o)&&(o=e),Dn(rt(i,1,Oe,!0),ae(o,2))}),hw=ye(function(i){var o=zt(i);return o=typeof o=="function"?o:e,Dn(rt(i,1,Oe,!0),e,o)});function dw(i){return i&&i.length?Dn(i):[]}function fw(i,o){return i&&i.length?Dn(i,ae(o,2)):[]}function pw(i,o){return o=typeof o=="function"?o:e,i&&i.length?Dn(i,e,o):[]}function ya(i){if(!(i&&i.length))return[];var o=0;return i=Vn(i,function(h){if(Oe(h))return o=Ne(h.length,o),!0}),Ao(o,function(h){return Ve(i,Wo(h))})}function rh(i,o){if(!(i&&i.length))return[];var h=ya(i);return o==null?h:Ve(h,function(g){return bt(o,e,g)})}var mw=ye(function(i,o){return Oe(i)?si(i,o):[]}),gw=ye(function(i){return ta(Vn(i,Oe))}),yw=ye(function(i){var o=zt(i);return Oe(o)&&(o=e),ta(Vn(i,Oe),ae(o,2))}),vw=ye(function(i){var o=zt(i);return o=typeof o=="function"?o:e,ta(Vn(i,Oe),e,o)}),ww=ye(ya);function xw(i,o){return bu(i||[],o||[],ii)}function bw(i,o){return bu(i||[],o||[],li)}var _w=ye(function(i){var o=i.length,h=o>1?i[o-1]:e;return h=typeof h=="function"?(i.pop(),h):e,rh(i,h)});function ih(i){var o=b(i);return o.__chain__=!0,o}function Mw(i,o){return o(i),i}function vs(i,o){return o(i)}var Lw=gn(function(i){var o=i.length,h=o?i[0]:0,g=this.__wrapped__,w=function(M){return Ro(M,i)};return o>1||this.__actions__.length||!(g instanceof Me)||!yn(h)?this.thru(w):(g=g.slice(h,+h+(o?1:0)),g.__actions__.push({func:vs,args:[w],thisArg:e}),new Xt(g,this.__chain__).thru(function(M){return o&&!M.length&&M.push(e),M}))});function Sw(){return ih(this)}function Zw(){return new Xt(this.value(),this.__chain__)}function Tw(){this.__values__===e&&(this.__values__=vh(this.value()));var i=this.__index__>=this.__values__.length,o=i?e:this.__values__[this.__index__++];return{done:i,value:o}}function Gw(){return this}function Pw(i){for(var o,h=this;h instanceof rs;){var g=Eu(h);g.__index__=0,g.__values__=e,o?w.__wrapped__=g:o=g;var w=g;h=h.__wrapped__}return w.__wrapped__=i,o}function Iw(){var i=this.__wrapped__;if(i instanceof Me){var o=i;return this.__actions__.length&&(o=new Me(this)),o=o.reverse(),o.__actions__.push({func:vs,args:[ga],thisArg:e}),new Xt(o,this.__chain__)}return this.thru(ga)}function Ww(){return xu(this.__wrapped__,this.__actions__)}var Cw=us(function(i,o,h){Ge.call(i,h)?++i[h]:pn(i,h,1)});function Vw(i,o,h){var g=fe(i)?Vc:My;return h&&ht(i,o,h)&&(o=e),g(i,ae(o,3))}function Aw(i,o){var h=fe(i)?Vn:ru;return h(i,ae(o,3))}var Fw=Wu(qu),Xw=Wu($u);function kw(i,o){return rt(ws(i,o),1)}function Dw(i,o){return rt(ws(i,o),oe)}function zw(i,o,h){return h=h===e?1:pe(h),rt(ws(i,o),h)}function sh(i,o){var h=fe(i)?At:kn;return h(i,ae(o,3))}function oh(i,o){var h=fe(i)?ig:nu;return h(i,ae(o,3))}var Ow=us(function(i,o,h){Ge.call(i,h)?i[h].push(o):pn(i,h,[o])});function Kw(i,o,h,g){i=gt(i)?i:Wr(i),h=h&&!g?pe(h):0;var w=i.length;return h<0&&(h=Ne(w+h,0)),Ls(i)?h<=w&&i.indexOf(o,h)>-1:!!w&&wr(i,o,h)>-1}var Rw=ye(function(i,o,h){var g=-1,w=typeof o=="function",M=gt(i)?z(i.length):[];return kn(i,function(P){M[++g]=w?bt(o,P,h):oi(P,o,h)}),M}),Yw=us(function(i,o,h){pn(i,h,o)});function ws(i,o){var h=fe(i)?Ve:cu;return h(i,ae(o,3))}function Uw(i,o,h,g){return i==null?[]:(fe(o)||(o=o==null?[]:[o]),h=g?e:h,fe(h)||(h=h==null?[]:[h]),fu(i,o,h))}var Bw=us(function(i,o,h){i[h?0:1].push(o)},function(){return[[],[]]});function Nw(i,o,h){var g=fe(i)?Po:kc,w=arguments.length<3;return g(i,ae(o,4),h,w,kn)}function jw(i,o,h){var g=fe(i)?sg:kc,w=arguments.length<3;return g(i,ae(o,4),h,w,nu)}function Jw(i,o){var h=fe(i)?Vn:ru;return h(i,_s(ae(o,3)))}function Qw(i){var o=fe(i)?qc:Ky;return o(i)}function Hw(i,o,h){(h?ht(i,o,h):o===e)?o=1:o=pe(o);var g=fe(i)?vy:Ry;return g(i,o)}function Ew(i){var o=fe(i)?wy:Uy;return o(i)}function qw(i){if(i==null)return 0;if(gt(i))return Ls(i)?br(i):i.length;var o=ot(i);return o==Ae||o==xt?i.size:Jo(i).length}function $w(i,o,h){var g=fe(i)?Io:By;return h&&ht(i,o,h)&&(o=e),g(i,ae(o,3))}var e1=ye(function(i,o){if(i==null)return[];var h=o.length;return h>1&&ht(i,o[0],o[1])?o=[]:h>2&&ht(o[0],o[1],o[2])&&(o=[o[0]]),fu(i,rt(o,1),[])}),xs=Ag||function(){return nt.Date.now()};function t1(i,o){if(typeof o!="function")throw new Ft(a);return i=pe(i),function(){if(--i<1)return o.apply(this,arguments)}}function ah(i,o,h){return o=h?e:o,o=i&&o==null?i.length:o,mn(i,O,e,e,e,e,o)}function lh(i,o){var h;if(typeof o!="function")throw new Ft(a);return i=pe(i),function(){return--i>0&&(h=o.apply(this,arguments)),i<=1&&(o=e),h}}var va=ye(function(i,o,h){var g=_;if(h.length){var w=Fn(h,Pr(va));g|=K}return mn(i,g,o,h,w)}),ch=ye(function(i,o,h){var g=_|S;if(h.length){var w=Fn(h,Pr(ch));g|=K}return mn(o,g,i,h,w)});function uh(i,o,h){o=h?e:o;var g=mn(i,G,e,e,e,e,e,o);return g.placeholder=uh.placeholder,g}function hh(i,o,h){o=h?e:o;var g=mn(i,A,e,e,e,e,e,o);return g.placeholder=hh.placeholder,g}function dh(i,o,h){var g,w,M,P,I,F,U=0,B=!1,Q=!1,$=!0;if(typeof i!="function")throw new Ft(a);o=Ot(o)||0,Fe(h)&&(B=!!h.leading,Q="maxWait"in h,M=Q?Ne(Ot(h.maxWait)||0,o):M,$="trailing"in h?!!h.trailing:$);function re(Ke){var Et=g,xn=w;return g=w=e,U=Ke,P=i.apply(xn,Et),P}function le(Ke){return U=Ke,I=hi(_e,o),B?re(Ke):P}function ge(Ke){var Et=Ke-F,xn=Ke-U,Wh=o-Et;return Q?st(Wh,M-xn):Wh}function ce(Ke){var Et=Ke-F,xn=Ke-U;return F===e||Et>=o||Et<0||Q&&xn>=M}function _e(){var Ke=xs();if(ce(Ke))return Le(Ke);I=hi(_e,ge(Ke))}function Le(Ke){return I=e,$&&g?re(Ke):(g=w=e,P)}function St(){I!==e&&_u(I),U=0,g=F=w=I=e}function dt(){return I===e?P:Le(xs())}function Zt(){var Ke=xs(),Et=ce(Ke);if(g=arguments,w=this,F=Ke,Et){if(I===e)return le(F);if(Q)return _u(I),I=hi(_e,o),re(F)}return I===e&&(I=hi(_e,o)),P}return Zt.cancel=St,Zt.flush=dt,Zt}var n1=ye(function(i,o){return tu(i,1,o)}),r1=ye(function(i,o,h){return tu(i,Ot(o)||0,h)});function i1(i){return mn(i,R)}function bs(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new Ft(a);var h=function(){var g=arguments,w=o?o.apply(this,g):g[0],M=h.cache;if(M.has(w))return M.get(w);var P=i.apply(this,g);return h.cache=M.set(w,P)||M,P};return h.cache=new(bs.Cache||fn),h}bs.Cache=fn;function _s(i){if(typeof i!="function")throw new Ft(a);return function(){var o=arguments;switch(o.length){case 0:return!i.call(this);case 1:return!i.call(this,o[0]);case 2:return!i.call(this,o[0],o[1]);case 3:return!i.call(this,o[0],o[1],o[2])}return!i.apply(this,o)}}function s1(i){return lh(2,i)}var o1=Ny(function(i,o){o=o.length==1&&fe(o[0])?Ve(o[0],_t(ae())):Ve(rt(o,1),_t(ae()));var h=o.length;return ye(function(g){for(var w=-1,M=st(g.length,h);++w<M;)g[w]=o[w].call(this,g[w]);return bt(i,this,g)})}),wa=ye(function(i,o){var h=Fn(o,Pr(wa));return mn(i,K,e,o,h)}),fh=ye(function(i,o){var h=Fn(o,Pr(fh));return mn(i,D,e,o,h)}),a1=gn(function(i,o){return mn(i,V,e,e,e,o)});function l1(i,o){if(typeof i!="function")throw new Ft(a);return o=o===e?o:pe(o),ye(i,o)}function c1(i,o){if(typeof i!="function")throw new Ft(a);return o=o==null?0:Ne(pe(o),0),ye(function(h){var g=h[o],w=On(h,0,o);return g&&An(w,g),bt(i,this,w)})}function u1(i,o,h){var g=!0,w=!0;if(typeof i!="function")throw new Ft(a);return Fe(h)&&(g="leading"in h?!!h.leading:g,w="trailing"in h?!!h.trailing:w),dh(i,o,{leading:g,maxWait:o,trailing:w})}function h1(i){return ah(i,1)}function d1(i,o){return wa(ra(o),i)}function f1(){if(!arguments.length)return[];var i=arguments[0];return fe(i)?i:[i]}function p1(i){return kt(i,v)}function m1(i,o){return o=typeof o=="function"?o:e,kt(i,v,o)}function g1(i){return kt(i,f|v)}function y1(i,o){return o=typeof o=="function"?o:e,kt(i,f|v,o)}function v1(i,o){return o==null||eu(i,o,He(o))}function Ht(i,o){return i===o||i!==i&&o!==o}var w1=ps(Bo),x1=ps(function(i,o){return i>=o}),lr=ou(function(){return arguments}())?ou:function(i){return De(i)&&Ge.call(i,"callee")&&!Nc.call(i,"callee")},fe=z.isArray,b1=Tc?_t(Tc):Py;function gt(i){return i!=null&&Ms(i.length)&&!vn(i)}function Oe(i){return De(i)&>(i)}function _1(i){return i===!0||i===!1||De(i)&&ut(i)==Qe}var Kn=Xg||Ia,M1=Gc?_t(Gc):Iy;function L1(i){return De(i)&&i.nodeType===1&&!di(i)}function S1(i){if(i==null)return!0;if(gt(i)&&(fe(i)||typeof i=="string"||typeof i.splice=="function"||Kn(i)||Ir(i)||lr(i)))return!i.length;var o=ot(i);if(o==Ae||o==xt)return!i.size;if(ui(i))return!Jo(i).length;for(var h in i)if(Ge.call(i,h))return!1;return!0}function Z1(i,o){return ai(i,o)}function T1(i,o,h){h=typeof h=="function"?h:e;var g=h?h(i,o):e;return g===e?ai(i,o,e,h):!!g}function xa(i){if(!De(i))return!1;var o=ut(i);return o==Ue||o==pt||typeof i.message=="string"&&typeof i.name=="string"&&!di(i)}function G1(i){return typeof i=="number"&&Jc(i)}function vn(i){if(!Fe(i))return!1;var o=ut(i);return o==hn||o==Gn||o==Je||o==Xi}function ph(i){return typeof i=="number"&&i==pe(i)}function Ms(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=ie}function Fe(i){var o=typeof i;return i!=null&&(o=="object"||o=="function")}function De(i){return i!=null&&typeof i=="object"}var mh=Pc?_t(Pc):Cy;function P1(i,o){return i===o||jo(i,o,ua(o))}function I1(i,o,h){return h=typeof h=="function"?h:e,jo(i,o,ua(o),h)}function W1(i){return gh(i)&&i!=+i}function C1(i){if(mv(i))throw new de(s);return au(i)}function V1(i){return i===null}function A1(i){return i==null}function gh(i){return typeof i=="number"||De(i)&&ut(i)==Ut}function di(i){if(!De(i)||ut(i)!=Wt)return!1;var o=Hi(i);if(o===null)return!0;var h=Ge.call(o,"constructor")&&o.constructor;return typeof h=="function"&&h instanceof h&&Ni.call(h)==Ig}var ba=Ic?_t(Ic):Vy;function F1(i){return ph(i)&&i>=-ie&&i<=ie}var yh=Wc?_t(Wc):Ay;function Ls(i){return typeof i=="string"||!fe(i)&&De(i)&&ut(i)==Pn}function Lt(i){return typeof i=="symbol"||De(i)&&ut(i)==In}var Ir=Cc?_t(Cc):Fy;function X1(i){return i===e}function k1(i){return De(i)&&ot(i)==Hn}function D1(i){return De(i)&&ut(i)==vo}var z1=ps(Qo),O1=ps(function(i,o){return i<=o});function vh(i){if(!i)return[];if(gt(i))return Ls(i)?Jt(i):mt(i);if($r&&i[$r])return vg(i[$r]());var o=ot(i),h=o==Ae?Xo:o==xt?Yi:Wr;return h(i)}function wn(i){if(!i)return i===0?i:0;if(i=Ot(i),i===oe||i===-oe){var o=i<0?-1:1;return o*te}return i===i?i:0}function pe(i){var o=wn(i),h=o%1;return o===o?h?o-h:o:0}function wh(i){return i?ir(pe(i),0,be):0}function Ot(i){if(typeof i=="number")return i;if(Lt(i))return me;if(Fe(i)){var o=typeof i.valueOf=="function"?i.valueOf():i;i=Fe(o)?o+"":o}if(typeof i!="string")return i===0?i:+i;i=Dc(i);var h=b0.test(i);return h||M0.test(i)?tg(i.slice(2),h?2:8):x0.test(i)?me:+i}function xh(i){return an(i,yt(i))}function K1(i){return i?ir(pe(i),-ie,ie):i===0?i:0}function Te(i){return i==null?"":Mt(i)}var R1=Tr(function(i,o){if(ui(o)||gt(o)){an(o,He(o),i);return}for(var h in o)Ge.call(o,h)&&ii(i,h,o[h])}),bh=Tr(function(i,o){an(o,yt(o),i)}),Ss=Tr(function(i,o,h,g){an(o,yt(o),i,g)}),Y1=Tr(function(i,o,h,g){an(o,He(o),i,g)}),U1=gn(Ro);function B1(i,o){var h=Zr(i);return o==null?h:$c(h,o)}var N1=ye(function(i,o){i=Pe(i);var h=-1,g=o.length,w=g>2?o[2]:e;for(w&&ht(o[0],o[1],w)&&(g=1);++h<g;)for(var M=o[h],P=yt(M),I=-1,F=P.length;++I<F;){var U=P[I],B=i[U];(B===e||Ht(B,Mr[U])&&!Ge.call(i,U))&&(i[U]=M[U])}return i}),j1=ye(function(i){return i.push(e,Du),bt(_h,e,i)});function J1(i,o){return Ac(i,ae(o,3),on)}function Q1(i,o){return Ac(i,ae(o,3),Uo)}function H1(i,o){return i==null?i:Yo(i,ae(o,3),yt)}function E1(i,o){return i==null?i:iu(i,ae(o,3),yt)}function q1(i,o){return i&&on(i,ae(o,3))}function $1(i,o){return i&&Uo(i,ae(o,3))}function ex(i){return i==null?[]:os(i,He(i))}function tx(i){return i==null?[]:os(i,yt(i))}function _a(i,o,h){var g=i==null?e:sr(i,o);return g===e?h:g}function nx(i,o){return i!=null&&Ku(i,o,Sy)}function Ma(i,o){return i!=null&&Ku(i,o,Zy)}var rx=Vu(function(i,o,h){o!=null&&typeof o.toString!="function"&&(o=ji.call(o)),i[o]=h},Sa(vt)),ix=Vu(function(i,o,h){o!=null&&typeof o.toString!="function"&&(o=ji.call(o)),Ge.call(i,o)?i[o].push(h):i[o]=[h]},ae),sx=ye(oi);function He(i){return gt(i)?Ec(i):Jo(i)}function yt(i){return gt(i)?Ec(i,!0):Xy(i)}function ox(i,o){var h={};return o=ae(o,3),on(i,function(g,w,M){pn(h,o(g,w,M),g)}),h}function ax(i,o){var h={};return o=ae(o,3),on(i,function(g,w,M){pn(h,w,o(g,w,M))}),h}var lx=Tr(function(i,o,h){as(i,o,h)}),_h=Tr(function(i,o,h,g){as(i,o,h,g)}),cx=gn(function(i,o){var h={};if(i==null)return h;var g=!1;o=Ve(o,function(M){return M=zn(M,i),g||(g=M.length>1),M}),an(i,la(i),h),g&&(h=kt(h,f|y|v,rv));for(var w=o.length;w--;)ea(h,o[w]);return h});function ux(i,o){return Mh(i,_s(ae(o)))}var hx=gn(function(i,o){return i==null?{}:Dy(i,o)});function Mh(i,o){if(i==null)return{};var h=Ve(la(i),function(g){return[g]});return o=ae(o),pu(i,h,function(g,w){return o(g,w[0])})}function dx(i,o,h){o=zn(o,i);var g=-1,w=o.length;for(w||(w=1,i=e);++g<w;){var M=i==null?e:i[ln(o[g])];M===e&&(g=w,M=h),i=vn(M)?M.call(i):M}return i}function fx(i,o,h){return i==null?i:li(i,o,h)}function px(i,o,h,g){return g=typeof g=="function"?g:e,i==null?i:li(i,o,h,g)}var Lh=Xu(He),Sh=Xu(yt);function mx(i,o,h){var g=fe(i),w=g||Kn(i)||Ir(i);if(o=ae(o,4),h==null){var M=i&&i.constructor;w?h=g?new M:[]:Fe(i)?h=vn(M)?Zr(Hi(i)):{}:h={}}return(w?At:on)(i,function(P,I,F){return o(h,P,I,F)}),h}function gx(i,o){return i==null?!0:ea(i,o)}function yx(i,o,h){return i==null?i:wu(i,o,ra(h))}function vx(i,o,h,g){return g=typeof g=="function"?g:e,i==null?i:wu(i,o,ra(h),g)}function Wr(i){return i==null?[]:Fo(i,He(i))}function wx(i){return i==null?[]:Fo(i,yt(i))}function xx(i,o,h){return h===e&&(h=o,o=e),h!==e&&(h=Ot(h),h=h===h?h:0),o!==e&&(o=Ot(o),o=o===o?o:0),ir(Ot(i),o,h)}function bx(i,o,h){return o=wn(o),h===e?(h=o,o=0):h=wn(h),i=Ot(i),Ty(i,o,h)}function _x(i,o,h){if(h&&typeof h!="boolean"&&ht(i,o,h)&&(o=h=e),h===e&&(typeof o=="boolean"?(h=o,o=e):typeof i=="boolean"&&(h=i,i=e)),i===e&&o===e?(i=0,o=1):(i=wn(i),o===e?(o=i,i=0):o=wn(o)),i>o){var g=i;i=o,o=g}if(h||i%1||o%1){var w=Qc();return st(i+w*(o-i+eg("1e-"+((w+"").length-1))),o)}return Eo(i,o)}var Mx=Gr(function(i,o,h){return o=o.toLowerCase(),i+(h?Zh(o):o)});function Zh(i){return La(Te(i).toLowerCase())}function Th(i){return i=Te(i),i&&i.replace(S0,fg).replace(U0,"")}function Lx(i,o,h){i=Te(i),o=Mt(o);var g=i.length;h=h===e?g:ir(pe(h),0,g);var w=h;return h-=o.length,h>=0&&i.slice(h,w)==o}function Sx(i){return i=Te(i),i&&ki.test(i)?i.replace(Bt,pg):i}function Zx(i){return i=Te(i),i&&h0.test(i)?i.replace(wo,"\\$&"):i}var Tx=Gr(function(i,o,h){return i+(h?"-":"")+o.toLowerCase()}),Gx=Gr(function(i,o,h){return i+(h?" ":"")+o.toLowerCase()}),Px=Iu("toLowerCase");function Ix(i,o,h){i=Te(i),o=pe(o);var g=o?br(i):0;if(!o||g>=o)return i;var w=(o-g)/2;return fs(es(w),h)+i+fs($i(w),h)}function Wx(i,o,h){i=Te(i),o=pe(o);var g=o?br(i):0;return o&&g<o?i+fs(o-g,h):i}function Cx(i,o,h){i=Te(i),o=pe(o);var g=o?br(i):0;return o&&g<o?fs(o-g,h)+i:i}function Vx(i,o,h){return h||o==null?o=0:o&&(o=+o),Og(Te(i).replace(xo,""),o||0)}function Ax(i,o,h){return(h?ht(i,o,h):o===e)?o=1:o=pe(o),qo(Te(i),o)}function Fx(){var i=arguments,o=Te(i[0]);return i.length<3?o:o.replace(i[1],i[2])}var Xx=Gr(function(i,o,h){return i+(h?"_":"")+o.toLowerCase()});function kx(i,o,h){return h&&typeof h!="number"&&ht(i,o,h)&&(o=h=e),h=h===e?be:h>>>0,h?(i=Te(i),i&&(typeof o=="string"||o!=null&&!ba(o))&&(o=Mt(o),!o&&xr(i))?On(Jt(i),0,h):i.split(o,h)):[]}var Dx=Gr(function(i,o,h){return i+(h?" ":"")+La(o)});function zx(i,o,h){return i=Te(i),h=h==null?0:ir(pe(h),0,i.length),o=Mt(o),i.slice(h,h+o.length)==o}function Ox(i,o,h){var g=b.templateSettings;h&&ht(i,o,h)&&(o=e),i=Te(i),o=Ss({},o,g,ku);var w=Ss({},o.imports,g.imports,ku),M=He(w),P=Fo(w,M),I,F,U=0,B=o.interpolate||Di,Q="__p += '",$=ko((o.escape||Di).source+"|"+B.source+"|"+(B===Cn?w0:Di).source+"|"+(o.evaluate||Di).source+"|$","g"),re="//# sourceURL="+(Ge.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Q0+"]")+`
|
|
549
|
-
`;
|
|
548
|
+
`)}function yv(r){return fe(r)||li(r)||!!(qc&&r&&r[qc])}function vn(r,o){var h=typeof r;return o=o??re,!!o&&(h=="number"||h!="symbol"&&W0.test(r))&&r>-1&&r%1==0&&r<o}function dt(r,o,h){if(!Fe(h))return!1;var g=typeof o;return(g=="number"?yt(h)&&vn(o,h.length):g=="string"&&o in h)?Ht(h[o],r):!1}function va(r,o){if(fe(r))return!1;var h=typeof r;return h=="number"||h=="symbol"||h=="boolean"||r==null||Lt(r)?!0:$n.test(r)||!qn.test(r)||o!=null&&r in We(o)}function vv(r){var o=typeof r;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?r!=="__proto__":r===null}function wa(r){var o=gs(r),h=b[o];if(typeof h!="function"||!(o in Me.prototype))return!1;if(r===h)return!0;var g=ma(h);return!!g&&r===g[0]}function wv(r){return!!Jc&&Jc in r}var xv=Nr?wn:Xa;function fr(r){var o=r&&r.constructor,h=typeof o=="function"&&o.prototype||Li;return r===h}function Ju(r){return r===r&&!Fe(r)}function Qu(r,o){return function(h){return h==null?!1:h[r]===o&&(o!==e||r in We(h))}}function bv(r){var o=_s(r,function(g){return h.size===d&&h.clear(),g}),h=o.cache;return o}function _v(r,o){var h=r[1],g=o[1],w=h|g,L=w<(_|Z|k),W=g==k&&h==G||g==k&&h==C&&r[7].length<=o[8]||g==(k|C)&&o[7].length<=o[8]&&h==G;if(!(L||W))return r;g&_&&(r[2]=o[2],w|=h&_?0:M);var P=o[3];if(P){var F=r[3];r[3]=F?Iu(F,P,o[4]):P,r[4]=F?Fn(r[3],p):o[4]}return P=o[5],P&&(F=r[5],r[5]=F?Cu(F,P,o[6]):P,r[6]=F?Fn(r[5],p):o[6]),P=o[7],P&&(r[7]=P),g&k&&(r[8]=r[8]==null?o[8]:ot(r[8],o[8])),r[9]==null&&(r[9]=o[9]),r[0]=o[0],r[1]=w,r}function Mv(r){var o=[];if(r!=null)for(var h in We(r))o.push(h);return o}function Lv(r){return Jr.call(r)}function Hu(r,o,h){return o=Ne(o===e?r.length-1:o,0),function(){for(var g=arguments,w=-1,L=Ne(g.length-o,0),W=O(L);++w<L;)W[w]=g[o+w];w=-1;for(var P=O(o+1);++w<o;)P[w]=g[w];return P[o]=h(W),bt(r,this,P)}}function Eu(r,o){return o.length<2?r:si(r,Dt(o,0,-1))}function Sv(r,o){for(var h=r.length,g=ot(o.length,h),w=gt(r);g--;){var L=o[g];r[g]=vn(L,h)?w[L]:e}return r}function xa(r,o){if(!(o==="constructor"&&typeof r[o]=="function")&&o!="__proto__")return r[o]}var qu=eh(bu),pr=Og||function(r,o){return nt.setTimeout(r,o)},ba=eh(Jy);function $u(r,o,h){var g=o+"";return ba(r,gv(g,Tv(fv(g),h)))}function eh(r){var o=0,h=0;return function(){var g=Ug(),w=H-(g-h);if(h=g,w>0){if(++o>=N)return arguments[0]}else o=0;return r.apply(e,arguments)}}function vs(r,o){var h=-1,g=r.length,w=g-1;for(o=o===e?g:o;++h<o;){var L=ia(h,w),W=r[L];r[L]=r[h],r[h]=W}return r.length=o,r}var th=bv(function(r){var o=[];return r.charCodeAt(0)===46&&o.push(""),r.replace(vi,function(h,g,w,L){o.push(w?L.replace(M0,"$1"):g||h)}),o});function ln(r){if(typeof r=="string"||Lt(r))return r;var o=r+"";return o=="0"&&1/r==-oe?"-0":o}function ai(r){if(r!=null){try{return jr.call(r)}catch{}try{return r+""}catch{}}return""}function Tv(r,o){return At(ze,function(h){var g="_."+h[0];o&h[1]&&!Kr(r,g)&&r.push(g)}),r.sort()}function nh(r){if(r instanceof Me)return r.clone();var o=new Xt(r.__wrapped__,r.__chain__);return o.__actions__=gt(r.__actions__),o.__index__=r.__index__,o.__values__=r.__values__,o}function Zv(r,o,h){(h?dt(r,o,h):o===e)?o=1:o=Ne(pe(o),0);var g=r==null?0:r.length;if(!g||o<1)return[];for(var w=0,L=0,W=O(es(g/o));w<g;)W[L++]=Dt(r,w,w+=o);return W}function Gv(r){for(var o=-1,h=r==null?0:r.length,g=0,w=[];++o<h;){var L=r[o];L&&(w[g++]=L)}return w}function Wv(){var r=arguments.length;if(!r)return[];for(var o=O(r-1),h=arguments[0],g=r;g--;)o[g-1]=arguments[g];return An(fe(h)?gt(h):[h],it(o,1))}var Pv=ye(function(r,o){return Oe(r)?lr(r,it(o,1,Oe,!0)):[]}),Iv=ye(function(r,o){var h=kt(o);return Oe(h)&&(h=e),Oe(r)?lr(r,it(o,1,Oe,!0),ae(h,2)):[]}),Cv=ye(function(r,o){var h=kt(o);return Oe(h)&&(h=e),Oe(r)?lr(r,it(o,1,Oe,!0),e,h):[]});function Vv(r,o,h){var g=r==null?0:r.length;return g?(o=h||o===e?1:pe(o),Dt(r,o<0?0:o,g)):[]}function Av(r,o,h){var g=r==null?0:r.length;return g?(o=h||o===e?1:pe(o),o=g-o,Dt(r,0,o<0?0:o)):[]}function Fv(r,o){return r&&r.length?us(r,ae(o,3),!0,!0):[]}function Xv(r,o){return r&&r.length?us(r,ae(o,3),!0):[]}function zv(r,o,h,g){var w=r==null?0:r.length;return w?(h&&typeof h!="number"&&dt(r,o,h)&&(h=0,g=w),Wy(r,o,h,g)):[]}function ih(r,o,h){var g=r==null?0:r.length;if(!g)return-1;var w=h==null?0:pe(h);return w<0&&(w=Ne(g+w,0)),Yr(r,ae(o,3),w)}function rh(r,o,h){var g=r==null?0:r.length;if(!g)return-1;var w=g-1;return h!==e&&(w=pe(h),w=h<0?Ne(g+w,0):ot(w,g-1)),Yr(r,ae(o,3),w,!0)}function sh(r){var o=r==null?0:r.length;return o?it(r,1):[]}function Dv(r){var o=r==null?0:r.length;return o?it(r,oe):[]}function kv(r,o){var h=r==null?0:r.length;return h?(o=o===e?1:pe(o),it(r,o)):[]}function Ov(r){for(var o=-1,h=r==null?0:r.length,g={};++o<h;){var w=r[o];g[w[0]]=w[1]}return g}function oh(r){return r&&r.length?r[0]:e}function Rv(r,o,h){var g=r==null?0:r.length;if(!g)return-1;var w=h==null?0:pe(h);return w<0&&(w=Ne(g+w,0)),xi(r,o,w)}function Kv(r){var o=r==null?0:r.length;return o?Dt(r,0,-1):[]}var Yv=ye(function(r){var o=Ve(r,la);return o.length&&o[0]===r[0]?qo(o):[]}),Uv=ye(function(r){var o=kt(r),h=Ve(r,la);return o===kt(h)?o=e:h.pop(),h.length&&h[0]===r[0]?qo(h,ae(o,2)):[]}),Bv=ye(function(r){var o=kt(r),h=Ve(r,la);return o=typeof o=="function"?o:e,o&&h.pop(),h.length&&h[0]===r[0]?qo(h,e,o):[]});function Nv(r,o){return r==null?"":Kg.call(r,o)}function kt(r){var o=r==null?0:r.length;return o?r[o-1]:e}function jv(r,o,h){var g=r==null?0:r.length;if(!g)return-1;var w=g;return h!==e&&(w=pe(h),w=w<0?Ne(g+w,0):ot(w,g-1)),o===o?Tg(r,o,w):Yr(r,Oc,w,!0)}function Jv(r,o){return r&&r.length?yu(r,pe(o)):e}var Qv=ye(ah);function ah(r,o){return r&&r.length&&o&&o.length?na(r,o):r}function Hv(r,o,h){return r&&r.length&&o&&o.length?na(r,o,ae(h,2)):r}function Ev(r,o,h){return r&&r.length&&o&&o.length?na(r,o,e,h):r}var qv=yn(function(r,o){var h=r==null?0:r.length,g=Jo(r,o);return xu(r,Ve(o,function(w){return vn(w,h)?+w:w}).sort(Pu)),g});function $v(r,o){var h=[];if(!(r&&r.length))return h;var g=-1,w=[],L=r.length;for(o=ae(o,3);++g<L;){var W=r[g];o(W,g,r)&&(h.push(W),w.push(g))}return xu(r,w),h}function _a(r){return r==null?r:Ng.call(r)}function ew(r,o,h){var g=r==null?0:r.length;return g?(h&&typeof h!="number"&&dt(r,o,h)?(o=0,h=g):(o=o==null?0:pe(o),h=h===e?g:pe(h)),Dt(r,o,h)):[]}function tw(r,o){return cs(r,o)}function nw(r,o,h){return sa(r,o,ae(h,2))}function iw(r,o){var h=r==null?0:r.length;if(h){var g=cs(r,o);if(g<h&&Ht(r[g],o))return g}return-1}function rw(r,o){return cs(r,o,!0)}function sw(r,o,h){return sa(r,o,ae(h,2),!0)}function ow(r,o){var h=r==null?0:r.length;if(h){var g=cs(r,o,!0)-1;if(Ht(r[g],o))return g}return-1}function aw(r){return r&&r.length?_u(r):[]}function lw(r,o){return r&&r.length?_u(r,ae(o,2)):[]}function cw(r){var o=r==null?0:r.length;return o?Dt(r,1,o):[]}function uw(r,o,h){return r&&r.length?(o=h||o===e?1:pe(o),Dt(r,0,o<0?0:o)):[]}function hw(r,o,h){var g=r==null?0:r.length;return g?(o=h||o===e?1:pe(o),o=g-o,Dt(r,o<0?0:o,g)):[]}function dw(r,o){return r&&r.length?us(r,ae(o,3),!1,!0):[]}function fw(r,o){return r&&r.length?us(r,ae(o,3)):[]}var pw=ye(function(r){return Dn(it(r,1,Oe,!0))}),mw=ye(function(r){var o=kt(r);return Oe(o)&&(o=e),Dn(it(r,1,Oe,!0),ae(o,2))}),gw=ye(function(r){var o=kt(r);return o=typeof o=="function"?o:e,Dn(it(r,1,Oe,!0),e,o)});function yw(r){return r&&r.length?Dn(r):[]}function vw(r,o){return r&&r.length?Dn(r,ae(o,2)):[]}function ww(r,o){return o=typeof o=="function"?o:e,r&&r.length?Dn(r,e,o):[]}function Ma(r){if(!(r&&r.length))return[];var o=0;return r=Vn(r,function(h){if(Oe(h))return o=Ne(h.length,o),!0}),Oo(o,function(h){return Ve(r,zo(h))})}function lh(r,o){if(!(r&&r.length))return[];var h=Ma(r);return o==null?h:Ve(h,function(g){return bt(o,e,g)})}var xw=ye(function(r,o){return Oe(r)?lr(r,o):[]}),bw=ye(function(r){return aa(Vn(r,Oe))}),_w=ye(function(r){var o=kt(r);return Oe(o)&&(o=e),aa(Vn(r,Oe),ae(o,2))}),Mw=ye(function(r){var o=kt(r);return o=typeof o=="function"?o:e,aa(Vn(r,Oe),e,o)}),Lw=ye(Ma);function Sw(r,o){return Tu(r||[],o||[],ar)}function Tw(r,o){return Tu(r||[],o||[],hr)}var Zw=ye(function(r){var o=r.length,h=o>1?r[o-1]:e;return h=typeof h=="function"?(r.pop(),h):e,lh(r,h)});function ch(r){var o=b(r);return o.__chain__=!0,o}function Gw(r,o){return o(r),r}function ws(r,o){return o(r)}var Ww=yn(function(r){var o=r.length,h=o?r[0]:0,g=this.__wrapped__,w=function(L){return Jo(L,r)};return o>1||this.__actions__.length||!(g instanceof Me)||!vn(h)?this.thru(w):(g=g.slice(h,+h+(o?1:0)),g.__actions__.push({func:ws,args:[w],thisArg:e}),new Xt(g,this.__chain__).thru(function(L){return o&&!L.length&&L.push(e),L}))});function Pw(){return ch(this)}function Iw(){return new Xt(this.value(),this.__chain__)}function Cw(){this.__values__===e&&(this.__values__=Mh(this.value()));var r=this.__index__>=this.__values__.length,o=r?e:this.__values__[this.__index__++];return{done:r,value:o}}function Vw(){return this}function Aw(r){for(var o,h=this;h instanceof rs;){var g=nh(h);g.__index__=0,g.__values__=e,o?w.__wrapped__=g:o=g;var w=g;h=h.__wrapped__}return w.__wrapped__=r,o}function Fw(){var r=this.__wrapped__;if(r instanceof Me){var o=r;return this.__actions__.length&&(o=new Me(this)),o=o.reverse(),o.__actions__.push({func:ws,args:[_a],thisArg:e}),new Xt(o,this.__chain__)}return this.thru(_a)}function Xw(){return Su(this.__wrapped__,this.__actions__)}var zw=hs(function(r,o,h){Ge.call(r,h)?++r[h]:mn(r,h,1)});function Dw(r,o,h){var g=fe(r)?Dc:Gy;return h&&dt(r,o,h)&&(o=e),g(r,ae(o,3))}function kw(r,o){var h=fe(r)?Vn:lu;return h(r,ae(o,3))}var Ow=Xu(ih),Rw=Xu(rh);function Kw(r,o){return it(xs(r,o),1)}function Yw(r,o){return it(xs(r,o),oe)}function Uw(r,o,h){return h=h===e?1:pe(h),it(xs(r,o),h)}function uh(r,o){var h=fe(r)?At:zn;return h(r,ae(o,3))}function hh(r,o){var h=fe(r)?cg:au;return h(r,ae(o,3))}var Bw=hs(function(r,o,h){Ge.call(r,h)?r[h].push(o):mn(r,h,[o])});function Nw(r,o,h,g){r=yt(r)?r:Ci(r),h=h&&!g?pe(h):0;var w=r.length;return h<0&&(h=Ne(w+h,0)),Ss(r)?h<=w&&r.indexOf(o,h)>-1:!!w&&xi(r,o,h)>-1}var jw=ye(function(r,o,h){var g=-1,w=typeof o=="function",L=yt(r)?O(r.length):[];return zn(r,function(W){L[++g]=w?bt(o,W,h):cr(W,o,h)}),L}),Jw=hs(function(r,o,h){mn(r,h,o)});function xs(r,o){var h=fe(r)?Ve:pu;return h(r,ae(o,3))}function Qw(r,o,h,g){return r==null?[]:(fe(o)||(o=o==null?[]:[o]),h=g?e:h,fe(h)||(h=h==null?[]:[h]),vu(r,o,h))}var Hw=hs(function(r,o,h){r[h?0:1].push(o)},function(){return[[],[]]});function Ew(r,o,h){var g=fe(r)?Fo:Kc,w=arguments.length<3;return g(r,ae(o,4),h,w,zn)}function qw(r,o,h){var g=fe(r)?ug:Kc,w=arguments.length<3;return g(r,ae(o,4),h,w,au)}function $w(r,o){var h=fe(r)?Vn:lu;return h(r,Ms(ae(o,3)))}function ex(r){var o=fe(r)?iu:Ny;return o(r)}function tx(r,o,h){(h?dt(r,o,h):o===e)?o=1:o=pe(o);var g=fe(r)?My:jy;return g(r,o)}function nx(r){var o=fe(r)?Ly:Qy;return o(r)}function ix(r){if(r==null)return 0;if(yt(r))return Ss(r)?_i(r):r.length;var o=at(r);return o==Ae||o==xt?r.size:ea(r).length}function rx(r,o,h){var g=fe(r)?Xo:Hy;return h&&dt(r,o,h)&&(o=e),g(r,ae(o,3))}var sx=ye(function(r,o){if(r==null)return[];var h=o.length;return h>1&&dt(r,o[0],o[1])?o=[]:h>2&&dt(o[0],o[1],o[2])&&(o=[o[0]]),vu(r,it(o,1),[])}),bs=kg||function(){return nt.Date.now()};function ox(r,o){if(typeof o!="function")throw new Ft(l);return r=pe(r),function(){if(--r<1)return o.apply(this,arguments)}}function dh(r,o,h){return o=h?e:o,o=r&&o==null?r.length:o,gn(r,k,e,e,e,e,o)}function fh(r,o){var h;if(typeof o!="function")throw new Ft(l);return r=pe(r),function(){return--r>0&&(h=o.apply(this,arguments)),r<=1&&(o=e),h}}var La=ye(function(r,o,h){var g=_;if(h.length){var w=Fn(h,Pi(La));g|=R}return gn(r,g,o,h,w)}),ph=ye(function(r,o,h){var g=_|Z;if(h.length){var w=Fn(h,Pi(ph));g|=R}return gn(o,g,r,h,w)});function mh(r,o,h){o=h?e:o;var g=gn(r,G,e,e,e,e,e,o);return g.placeholder=mh.placeholder,g}function gh(r,o,h){o=h?e:o;var g=gn(r,A,e,e,e,e,e,o);return g.placeholder=gh.placeholder,g}function yh(r,o,h){var g,w,L,W,P,F,U=0,B=!1,Q=!1,$=!0;if(typeof r!="function")throw new Ft(l);o=Ot(o)||0,Fe(h)&&(B=!!h.leading,Q="maxWait"in h,L=Q?Ne(Ot(h.maxWait)||0,o):L,$="trailing"in h?!!h.trailing:$);function ie(Re){var Et=g,bn=w;return g=w=e,U=Re,W=r.apply(bn,Et),W}function le(Re){return U=Re,P=pr(_e,o),B?ie(Re):W}function ge(Re){var Et=Re-F,bn=Re-U,Xh=o-Et;return Q?ot(Xh,L-bn):Xh}function ce(Re){var Et=Re-F,bn=Re-U;return F===e||Et>=o||Et<0||Q&&bn>=L}function _e(){var Re=bs();if(ce(Re))return Le(Re);P=pr(_e,ge(Re))}function Le(Re){return P=e,$&&g?ie(Re):(g=w=e,W)}function St(){P!==e&&Zu(P),U=0,g=F=w=P=e}function ft(){return P===e?W:Le(bs())}function Tt(){var Re=bs(),Et=ce(Re);if(g=arguments,w=this,F=Re,Et){if(P===e)return le(F);if(Q)return Zu(P),P=pr(_e,o),ie(F)}return P===e&&(P=pr(_e,o)),W}return Tt.cancel=St,Tt.flush=ft,Tt}var ax=ye(function(r,o){return ou(r,1,o)}),lx=ye(function(r,o,h){return ou(r,Ot(o)||0,h)});function cx(r){return gn(r,K)}function _s(r,o){if(typeof r!="function"||o!=null&&typeof o!="function")throw new Ft(l);var h=function(){var g=arguments,w=o?o.apply(this,g):g[0],L=h.cache;if(L.has(w))return L.get(w);var W=r.apply(this,g);return h.cache=L.set(w,W)||L,W};return h.cache=new(_s.Cache||pn),h}_s.Cache=pn;function Ms(r){if(typeof r!="function")throw new Ft(l);return function(){var o=arguments;switch(o.length){case 0:return!r.call(this);case 1:return!r.call(this,o[0]);case 2:return!r.call(this,o[0],o[1]);case 3:return!r.call(this,o[0],o[1],o[2])}return!r.apply(this,o)}}function ux(r){return fh(2,r)}var hx=Ey(function(r,o){o=o.length==1&&fe(o[0])?Ve(o[0],_t(ae())):Ve(it(o,1),_t(ae()));var h=o.length;return ye(function(g){for(var w=-1,L=ot(g.length,h);++w<L;)g[w]=o[w].call(this,g[w]);return bt(r,this,g)})}),Sa=ye(function(r,o){var h=Fn(o,Pi(Sa));return gn(r,R,e,o,h)}),vh=ye(function(r,o){var h=Fn(o,Pi(vh));return gn(r,D,e,o,h)}),dx=yn(function(r,o){return gn(r,C,e,e,e,o)});function fx(r,o){if(typeof r!="function")throw new Ft(l);return o=o===e?o:pe(o),ye(r,o)}function px(r,o){if(typeof r!="function")throw new Ft(l);return o=o==null?0:Ne(pe(o),0),ye(function(h){var g=h[o],w=On(h,0,o);return g&&An(w,g),bt(r,this,w)})}function mx(r,o,h){var g=!0,w=!0;if(typeof r!="function")throw new Ft(l);return Fe(h)&&(g="leading"in h?!!h.leading:g,w="trailing"in h?!!h.trailing:w),yh(r,o,{leading:g,maxWait:o,trailing:w})}function gx(r){return dh(r,1)}function yx(r,o){return Sa(ca(o),r)}function vx(){if(!arguments.length)return[];var r=arguments[0];return fe(r)?r:[r]}function wx(r){return zt(r,v)}function xx(r,o){return o=typeof o=="function"?o:e,zt(r,v,o)}function bx(r){return zt(r,f|v)}function _x(r,o){return o=typeof o=="function"?o:e,zt(r,f|v,o)}function Mx(r,o){return o==null||su(r,o,He(o))}function Ht(r,o){return r===o||r!==r&&o!==o}var Lx=ms(Eo),Sx=ms(function(r,o){return r>=o}),li=hu(function(){return arguments}())?hu:function(r){return De(r)&&Ge.call(r,"callee")&&!Ec.call(r,"callee")},fe=O.isArray,Tx=Cc?_t(Cc):Ay;function yt(r){return r!=null&&Ls(r.length)&&!wn(r)}function Oe(r){return De(r)&&yt(r)}function Zx(r){return r===!0||r===!1||De(r)&&ht(r)==Qe}var Rn=Rg||Xa,Gx=Vc?_t(Vc):Fy;function Wx(r){return De(r)&&r.nodeType===1&&!mr(r)}function Px(r){if(r==null)return!0;if(yt(r)&&(fe(r)||typeof r=="string"||typeof r.splice=="function"||Rn(r)||Ii(r)||li(r)))return!r.length;var o=at(r);if(o==Ae||o==xt)return!r.size;if(fr(r))return!ea(r).length;for(var h in r)if(Ge.call(r,h))return!1;return!0}function Ix(r,o){return ur(r,o)}function Cx(r,o,h){h=typeof h=="function"?h:e;var g=h?h(r,o):e;return g===e?ur(r,o,e,h):!!g}function Ta(r){if(!De(r))return!1;var o=ht(r);return o==Ue||o==mt||typeof r.message=="string"&&typeof r.name=="string"&&!mr(r)}function Vx(r){return typeof r=="number"&&$c(r)}function wn(r){if(!Fe(r))return!1;var o=ht(r);return o==dn||o==Gn||o==Je||o==zr}function wh(r){return typeof r=="number"&&r==pe(r)}function Ls(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=re}function Fe(r){var o=typeof r;return r!=null&&(o=="object"||o=="function")}function De(r){return r!=null&&typeof r=="object"}var xh=Ac?_t(Ac):zy;function Ax(r,o){return r===o||$o(r,o,ga(o))}function Fx(r,o,h){return h=typeof h=="function"?h:e,$o(r,o,ga(o),h)}function Xx(r){return bh(r)&&r!=+r}function zx(r){if(xv(r))throw new de(s);return du(r)}function Dx(r){return r===null}function kx(r){return r==null}function bh(r){return typeof r=="number"||De(r)&&ht(r)==Ut}function mr(r){if(!De(r)||ht(r)!=It)return!1;var o=Er(r);if(o===null)return!0;var h=Ge.call(o,"constructor")&&o.constructor;return typeof h=="function"&&h instanceof h&&jr.call(h)==Fg}var Za=Fc?_t(Fc):Dy;function Ox(r){return wh(r)&&r>=-re&&r<=re}var _h=Xc?_t(Xc):ky;function Ss(r){return typeof r=="string"||!fe(r)&&De(r)&&ht(r)==Wn}function Lt(r){return typeof r=="symbol"||De(r)&&ht(r)==Pn}var Ii=zc?_t(zc):Oy;function Rx(r){return r===e}function Kx(r){return De(r)&&at(r)==Hn}function Yx(r){return De(r)&&ht(r)==Lo}var Ux=ms(ta),Bx=ms(function(r,o){return r<=o});function Mh(r){if(!r)return[];if(yt(r))return Ss(r)?Jt(r):gt(r);if(nr&&r[nr])return Mg(r[nr]());var o=at(r),h=o==Ae?Ko:o==xt?Ur:Ci;return h(r)}function xn(r){if(!r)return r===0?r:0;if(r=Ot(r),r===oe||r===-oe){var o=r<0?-1:1;return o*te}return r===r?r:0}function pe(r){var o=xn(r),h=o%1;return o===o?h?o-h:o:0}function Lh(r){return r?ri(pe(r),0,be):0}function Ot(r){if(typeof r=="number")return r;if(Lt(r))return me;if(Fe(r)){var o=typeof r.valueOf=="function"?r.valueOf():r;r=Fe(o)?o+"":o}if(typeof r!="string")return r===0?r:+r;r=Yc(r);var h=T0.test(r);return h||G0.test(r)?og(r.slice(2),h?2:8):S0.test(r)?me:+r}function Sh(r){return an(r,vt(r))}function Nx(r){return r?ri(pe(r),-re,re):r===0?r:0}function Ze(r){return r==null?"":Mt(r)}var jx=Gi(function(r,o){if(fr(o)||yt(o)){an(o,He(o),r);return}for(var h in o)Ge.call(o,h)&&ar(r,h,o[h])}),Th=Gi(function(r,o){an(o,vt(o),r)}),Ts=Gi(function(r,o,h,g){an(o,vt(o),r,g)}),Jx=Gi(function(r,o,h,g){an(o,He(o),r,g)}),Qx=yn(Jo);function Hx(r,o){var h=Zi(r);return o==null?h:ru(h,o)}var Ex=ye(function(r,o){r=We(r);var h=-1,g=o.length,w=g>2?o[2]:e;for(w&&dt(o[0],o[1],w)&&(g=1);++h<g;)for(var L=o[h],W=vt(L),P=-1,F=W.length;++P<F;){var U=W[P],B=r[U];(B===e||Ht(B,Li[U])&&!Ge.call(r,U))&&(r[U]=L[U])}return r}),qx=ye(function(r){return r.push(e,Yu),bt(Zh,e,r)});function $x(r,o){return kc(r,ae(o,3),on)}function e1(r,o){return kc(r,ae(o,3),Ho)}function t1(r,o){return r==null?r:Qo(r,ae(o,3),vt)}function n1(r,o){return r==null?r:cu(r,ae(o,3),vt)}function i1(r,o){return r&&on(r,ae(o,3))}function r1(r,o){return r&&Ho(r,ae(o,3))}function s1(r){return r==null?[]:as(r,He(r))}function o1(r){return r==null?[]:as(r,vt(r))}function Ga(r,o,h){var g=r==null?e:si(r,o);return g===e?h:g}function a1(r,o){return r!=null&&Nu(r,o,Py)}function Wa(r,o){return r!=null&&Nu(r,o,Iy)}var l1=Du(function(r,o,h){o!=null&&typeof o.toString!="function"&&(o=Jr.call(o)),r[o]=h},Ia(wt)),c1=Du(function(r,o,h){o!=null&&typeof o.toString!="function"&&(o=Jr.call(o)),Ge.call(r,o)?r[o].push(h):r[o]=[h]},ae),u1=ye(cr);function He(r){return yt(r)?nu(r):ea(r)}function vt(r){return yt(r)?nu(r,!0):Ry(r)}function h1(r,o){var h={};return o=ae(o,3),on(r,function(g,w,L){mn(h,o(g,w,L),g)}),h}function d1(r,o){var h={};return o=ae(o,3),on(r,function(g,w,L){mn(h,w,o(g,w,L))}),h}var f1=Gi(function(r,o,h){ls(r,o,h)}),Zh=Gi(function(r,o,h,g){ls(r,o,h,g)}),p1=yn(function(r,o){var h={};if(r==null)return h;var g=!1;o=Ve(o,function(L){return L=kn(L,r),g||(g=L.length>1),L}),an(r,pa(r),h),g&&(h=zt(h,f|y|v,lv));for(var w=o.length;w--;)oa(h,o[w]);return h});function m1(r,o){return Gh(r,Ms(ae(o)))}var g1=yn(function(r,o){return r==null?{}:Yy(r,o)});function Gh(r,o){if(r==null)return{};var h=Ve(pa(r),function(g){return[g]});return o=ae(o),wu(r,h,function(g,w){return o(g,w[0])})}function y1(r,o,h){o=kn(o,r);var g=-1,w=o.length;for(w||(w=1,r=e);++g<w;){var L=r==null?e:r[ln(o[g])];L===e&&(g=w,L=h),r=wn(L)?L.call(r):L}return r}function v1(r,o,h){return r==null?r:hr(r,o,h)}function w1(r,o,h,g){return g=typeof g=="function"?g:e,r==null?r:hr(r,o,h,g)}var Wh=Ru(He),Ph=Ru(vt);function x1(r,o,h){var g=fe(r),w=g||Rn(r)||Ii(r);if(o=ae(o,4),h==null){var L=r&&r.constructor;w?h=g?new L:[]:Fe(r)?h=wn(L)?Zi(Er(r)):{}:h={}}return(w?At:on)(r,function(W,P,F){return o(h,W,P,F)}),h}function b1(r,o){return r==null?!0:oa(r,o)}function _1(r,o,h){return r==null?r:Lu(r,o,ca(h))}function M1(r,o,h,g){return g=typeof g=="function"?g:e,r==null?r:Lu(r,o,ca(h),g)}function Ci(r){return r==null?[]:Ro(r,He(r))}function L1(r){return r==null?[]:Ro(r,vt(r))}function S1(r,o,h){return h===e&&(h=o,o=e),h!==e&&(h=Ot(h),h=h===h?h:0),o!==e&&(o=Ot(o),o=o===o?o:0),ri(Ot(r),o,h)}function T1(r,o,h){return o=xn(o),h===e?(h=o,o=0):h=xn(h),r=Ot(r),Cy(r,o,h)}function Z1(r,o,h){if(h&&typeof h!="boolean"&&dt(r,o,h)&&(o=h=e),h===e&&(typeof o=="boolean"?(h=o,o=e):typeof r=="boolean"&&(h=r,r=e)),r===e&&o===e?(r=0,o=1):(r=xn(r),o===e?(o=r,r=0):o=xn(o)),r>o){var g=r;r=o,o=g}if(h||r%1||o%1){var w=eu();return ot(r+w*(o-r+sg("1e-"+((w+"").length-1))),o)}return ia(r,o)}var G1=Wi(function(r,o,h){return o=o.toLowerCase(),r+(h?Ih(o):o)});function Ih(r){return Pa(Ze(r).toLowerCase())}function Ch(r){return r=Ze(r),r&&r.replace(P0,vg).replace(Q0,"")}function W1(r,o,h){r=Ze(r),o=Mt(o);var g=r.length;h=h===e?g:ri(pe(h),0,g);var w=h;return h-=o.length,h>=0&&r.slice(h,w)==o}function P1(r){return r=Ze(r),r&&Dr.test(r)?r.replace(Bt,wg):r}function I1(r){return r=Ze(r),r&&g0.test(r)?r.replace(So,"\\$&"):r}var C1=Wi(function(r,o,h){return r+(h?"-":"")+o.toLowerCase()}),V1=Wi(function(r,o,h){return r+(h?" ":"")+o.toLowerCase()}),A1=Fu("toLowerCase");function F1(r,o,h){r=Ze(r),o=pe(o);var g=o?_i(r):0;if(!o||g>=o)return r;var w=(o-g)/2;return ps(ts(w),h)+r+ps(es(w),h)}function X1(r,o,h){r=Ze(r),o=pe(o);var g=o?_i(r):0;return o&&g<o?r+ps(o-g,h):r}function z1(r,o,h){r=Ze(r),o=pe(o);var g=o?_i(r):0;return o&&g<o?ps(o-g,h)+r:r}function D1(r,o,h){return h||o==null?o=0:o&&(o=+o),Bg(Ze(r).replace(To,""),o||0)}function k1(r,o,h){return(h?dt(r,o,h):o===e)?o=1:o=pe(o),ra(Ze(r),o)}function O1(){var r=arguments,o=Ze(r[0]);return r.length<3?o:o.replace(r[1],r[2])}var R1=Wi(function(r,o,h){return r+(h?"_":"")+o.toLowerCase()});function K1(r,o,h){return h&&typeof h!="number"&&dt(r,o,h)&&(o=h=e),h=h===e?be:h>>>0,h?(r=Ze(r),r&&(typeof o=="string"||o!=null&&!Za(o))&&(o=Mt(o),!o&&bi(r))?On(Jt(r),0,h):r.split(o,h)):[]}var Y1=Wi(function(r,o,h){return r+(h?" ":"")+Pa(o)});function U1(r,o,h){return r=Ze(r),h=h==null?0:ri(pe(h),0,r.length),o=Mt(o),r.slice(h,h+o.length)==o}function B1(r,o,h){var g=b.templateSettings;h&&dt(r,o,h)&&(o=e),r=Ze(r),o=Ts({},o,g,Ku);var w=Ts({},o.imports,g.imports,Ku),L=He(w),W=Ro(w,L),P,F,U=0,B=o.interpolate||kr,Q="__p += '",$=Yo((o.escape||kr).source+"|"+B.source+"|"+(B===Cn?L0:kr).source+"|"+(o.evaluate||kr).source+"|$","g"),ie="//# sourceURL="+(Ge.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++eg+"]")+`
|
|
549
|
+
`;r.replace($,function(ce,_e,Le,St,ft,Tt){return Le||(Le=St),Q+=r.slice(U,Tt).replace(I0,xg),_e&&(P=!0,Q+=`' +
|
|
550
550
|
__e(`+_e+`) +
|
|
551
|
-
'`),
|
|
552
|
-
`+
|
|
551
|
+
'`),ft&&(F=!0,Q+=`';
|
|
552
|
+
`+ft+`;
|
|
553
553
|
__p += '`),Le&&(Q+=`' +
|
|
554
554
|
((__t = (`+Le+`)) == null ? '' : __t) +
|
|
555
|
-
'`),U=
|
|
555
|
+
'`),U=Tt+ce.length,ce}),Q+=`';
|
|
556
556
|
`;var le=Ge.call(o,"variable")&&o.variable;if(!le)Q=`with (obj) {
|
|
557
557
|
`+Q+`
|
|
558
558
|
}
|
|
559
|
-
`;else if(
|
|
559
|
+
`;else if(_0.test(le))throw new de(u);Q=(F?Q.replace(ue,""):Q).replace(Se,"$1").replace(Ke,"$1;"),Q="function("+(le||"obj")+`) {
|
|
560
560
|
`+(le?"":`obj || (obj = {});
|
|
561
|
-
`)+"var __t, __p = ''"+(
|
|
561
|
+
`)+"var __t, __p = ''"+(P?", __e = _.escape":"")+(F?`, __j = Array.prototype.join;
|
|
562
562
|
function print() { __p += __j.call(arguments, '') }
|
|
563
563
|
`:`;
|
|
564
564
|
`)+Q+`return __p
|
|
565
|
-
}`;var ge=Ph(function(){return Ze(M,re+"return "+Q).apply(e,P)});if(ge.source=Q,xa(ge))throw ge;return ge}function Kx(i){return Te(i).toLowerCase()}function Rx(i){return Te(i).toUpperCase()}function Yx(i,o,h){if(i=Te(i),i&&(h||o===e))return Dc(i);if(!i||!(o=Mt(o)))return i;var g=Jt(i),w=Jt(o),M=zc(g,w),P=Oc(g,w)+1;return On(g,M,P).join("")}function Ux(i,o,h){if(i=Te(i),i&&(h||o===e))return i.slice(0,Rc(i)+1);if(!i||!(o=Mt(o)))return i;var g=Jt(i),w=Oc(g,Jt(o))+1;return On(g,0,w).join("")}function Bx(i,o,h){if(i=Te(i),i&&(h||o===e))return i.replace(xo,"");if(!i||!(o=Mt(o)))return i;var g=Jt(i),w=zc(g,Jt(o));return On(g,w).join("")}function Nx(i,o){var h=W,g=k;if(Fe(o)){var w="separator"in o?o.separator:w;h="length"in o?pe(o.length):h,g="omission"in o?Mt(o.omission):g}i=Te(i);var M=i.length;if(xr(i)){var P=Jt(i);M=P.length}if(h>=M)return i;var I=h-br(g);if(I<1)return g;var F=P?On(P,0,I).join(""):i.slice(0,I);if(w===e)return F+g;if(P&&(I+=F.length-I),ba(w)){if(i.slice(I).search(w)){var U,B=F;for(w.global||(w=ko(w.source,Te(oc.exec(w))+"g")),w.lastIndex=0;U=w.exec(B);)var Q=U.index;F=F.slice(0,Q===e?I:Q)}}else if(i.indexOf(Mt(w),I)!=I){var $=F.lastIndexOf(w);$>-1&&(F=F.slice(0,$))}return F+g}function jx(i){return i=Te(i),i&&sc.test(i)?i.replace(Ct,_g):i}var Jx=Gr(function(i,o,h){return i+(h?" ":"")+o.toUpperCase()}),La=Iu("toUpperCase");function Gh(i,o,h){return i=Te(i),o=h?e:o,o===e?yg(i)?Sg(i):lg(i):i.match(o)||[]}var Ph=ye(function(i,o){try{return bt(i,e,o)}catch(h){return xa(h)?h:new de(h)}}),Qx=gn(function(i,o){return At(o,function(h){h=ln(h),pn(i,h,va(i[h],i))}),i});function Hx(i){var o=i==null?0:i.length,h=ae();return i=o?Ve(i,function(g){if(typeof g[1]!="function")throw new Ft(a);return[h(g[0]),g[1]]}):[],ye(function(g){for(var w=-1;++w<o;){var M=i[w];if(bt(M[0],this,g))return bt(M[1],this,g)}})}function Ex(i){return _y(kt(i,f))}function Sa(i){return function(){return i}}function qx(i,o){return i==null||i!==i?o:i}var $x=Cu(),eb=Cu(!0);function vt(i){return i}function Za(i){return lu(typeof i=="function"?i:kt(i,f))}function tb(i){return uu(kt(i,f))}function nb(i,o){return hu(i,kt(o,f))}var rb=ye(function(i,o){return function(h){return oi(h,i,o)}}),ib=ye(function(i,o){return function(h){return oi(i,h,o)}});function Ta(i,o,h){var g=He(o),w=os(o,g);h==null&&!(Fe(o)&&(w.length||!g.length))&&(h=o,o=i,i=this,w=os(o,He(o)));var M=!(Fe(h)&&"chain"in h)||!!h.chain,P=vn(i);return At(w,function(I){var F=o[I];i[I]=F,P&&(i.prototype[I]=function(){var U=this.__chain__;if(M||U){var B=i(this.__wrapped__),Q=B.__actions__=mt(this.__actions__);return Q.push({func:F,args:arguments,thisArg:i}),B.__chain__=U,B}return F.apply(i,An([this.value()],arguments))})}),i}function sb(){return nt._===this&&(nt._=Wg),this}function Ga(){}function ob(i){return i=pe(i),ye(function(o){return du(o,i)})}var ab=sa(Ve),lb=sa(Vc),cb=sa(Io);function Ih(i){return da(i)?Wo(ln(i)):zy(i)}function ub(i){return function(o){return i==null?e:sr(i,o)}}var hb=Au(),db=Au(!0);function Pa(){return[]}function Ia(){return!1}function fb(){return{}}function pb(){return""}function mb(){return!0}function gb(i,o){if(i=pe(i),i<1||i>ie)return[];var h=be,g=st(i,be);o=ae(o),i-=be;for(var w=Ao(g,o);++h<i;)o(h);return w}function yb(i){return fe(i)?Ve(i,ln):Lt(i)?[i]:mt(Hu(Te(i)))}function vb(i){var o=++Pg;return Te(i)+o}var wb=ds(function(i,o){return i+o},0),xb=oa("ceil"),bb=ds(function(i,o){return i/o},1),_b=oa("floor");function Mb(i){return i&&i.length?ss(i,vt,Bo):e}function Lb(i,o){return i&&i.length?ss(i,ae(o,2),Bo):e}function Sb(i){return Xc(i,vt)}function Zb(i,o){return Xc(i,ae(o,2))}function Tb(i){return i&&i.length?ss(i,vt,Qo):e}function Gb(i,o){return i&&i.length?ss(i,ae(o,2),Qo):e}var Pb=ds(function(i,o){return i*o},1),Ib=oa("round"),Wb=ds(function(i,o){return i-o},0);function Cb(i){return i&&i.length?Vo(i,vt):0}function Vb(i,o){return i&&i.length?Vo(i,ae(o,2)):0}return b.after=t1,b.ary=ah,b.assign=R1,b.assignIn=bh,b.assignInWith=Ss,b.assignWith=Y1,b.at=U1,b.before=lh,b.bind=va,b.bindAll=Qx,b.bindKey=ch,b.castArray=f1,b.chain=ih,b.chunk=_v,b.compact=Mv,b.concat=Lv,b.cond=Hx,b.conforms=Ex,b.constant=Sa,b.countBy=Cw,b.create=B1,b.curry=uh,b.curryRight=hh,b.debounce=dh,b.defaults=N1,b.defaultsDeep=j1,b.defer=n1,b.delay=r1,b.difference=Sv,b.differenceBy=Zv,b.differenceWith=Tv,b.drop=Gv,b.dropRight=Pv,b.dropRightWhile=Iv,b.dropWhile=Wv,b.fill=Cv,b.filter=Aw,b.flatMap=kw,b.flatMapDeep=Dw,b.flatMapDepth=zw,b.flatten=eh,b.flattenDeep=Vv,b.flattenDepth=Av,b.flip=i1,b.flow=$x,b.flowRight=eb,b.fromPairs=Fv,b.functions=ex,b.functionsIn=tx,b.groupBy=Ow,b.initial=kv,b.intersection=Dv,b.intersectionBy=zv,b.intersectionWith=Ov,b.invert=rx,b.invertBy=ix,b.invokeMap=Rw,b.iteratee=Za,b.keyBy=Yw,b.keys=He,b.keysIn=yt,b.map=ws,b.mapKeys=ox,b.mapValues=ax,b.matches=tb,b.matchesProperty=nb,b.memoize=bs,b.merge=lx,b.mergeWith=_h,b.method=rb,b.methodOf=ib,b.mixin=Ta,b.negate=_s,b.nthArg=ob,b.omit=cx,b.omitBy=ux,b.once=s1,b.orderBy=Uw,b.over=ab,b.overArgs=o1,b.overEvery=lb,b.overSome=cb,b.partial=wa,b.partialRight=fh,b.partition=Bw,b.pick=hx,b.pickBy=Mh,b.property=Ih,b.propertyOf=ub,b.pull=Uv,b.pullAll=nh,b.pullAllBy=Bv,b.pullAllWith=Nv,b.pullAt=jv,b.range=hb,b.rangeRight=db,b.rearg=a1,b.reject=Jw,b.remove=Jv,b.rest=l1,b.reverse=ga,b.sampleSize=Hw,b.set=fx,b.setWith=px,b.shuffle=Ew,b.slice=Qv,b.sortBy=e1,b.sortedUniq=nw,b.sortedUniqBy=rw,b.split=kx,b.spread=c1,b.tail=iw,b.take=sw,b.takeRight=ow,b.takeRightWhile=aw,b.takeWhile=lw,b.tap=Mw,b.throttle=u1,b.thru=vs,b.toArray=vh,b.toPairs=Lh,b.toPairsIn=Sh,b.toPath=yb,b.toPlainObject=xh,b.transform=mx,b.unary=h1,b.union=cw,b.unionBy=uw,b.unionWith=hw,b.uniq=dw,b.uniqBy=fw,b.uniqWith=pw,b.unset=gx,b.unzip=ya,b.unzipWith=rh,b.update=yx,b.updateWith=vx,b.values=Wr,b.valuesIn=wx,b.without=mw,b.words=Gh,b.wrap=d1,b.xor=gw,b.xorBy=yw,b.xorWith=vw,b.zip=ww,b.zipObject=xw,b.zipObjectDeep=bw,b.zipWith=_w,b.entries=Lh,b.entriesIn=Sh,b.extend=bh,b.extendWith=Ss,Ta(b,b),b.add=wb,b.attempt=Ph,b.camelCase=Mx,b.capitalize=Zh,b.ceil=xb,b.clamp=xx,b.clone=p1,b.cloneDeep=g1,b.cloneDeepWith=y1,b.cloneWith=m1,b.conformsTo=v1,b.deburr=Th,b.defaultTo=qx,b.divide=bb,b.endsWith=Lx,b.eq=Ht,b.escape=Sx,b.escapeRegExp=Zx,b.every=Vw,b.find=Fw,b.findIndex=qu,b.findKey=J1,b.findLast=Xw,b.findLastIndex=$u,b.findLastKey=Q1,b.floor=_b,b.forEach=sh,b.forEachRight=oh,b.forIn=H1,b.forInRight=E1,b.forOwn=q1,b.forOwnRight=$1,b.get=_a,b.gt=w1,b.gte=x1,b.has=nx,b.hasIn=Ma,b.head=th,b.identity=vt,b.includes=Kw,b.indexOf=Xv,b.inRange=bx,b.invoke=sx,b.isArguments=lr,b.isArray=fe,b.isArrayBuffer=b1,b.isArrayLike=gt,b.isArrayLikeObject=Oe,b.isBoolean=_1,b.isBuffer=Kn,b.isDate=M1,b.isElement=L1,b.isEmpty=S1,b.isEqual=Z1,b.isEqualWith=T1,b.isError=xa,b.isFinite=G1,b.isFunction=vn,b.isInteger=ph,b.isLength=Ms,b.isMap=mh,b.isMatch=P1,b.isMatchWith=I1,b.isNaN=W1,b.isNative=C1,b.isNil=A1,b.isNull=V1,b.isNumber=gh,b.isObject=Fe,b.isObjectLike=De,b.isPlainObject=di,b.isRegExp=ba,b.isSafeInteger=F1,b.isSet=yh,b.isString=Ls,b.isSymbol=Lt,b.isTypedArray=Ir,b.isUndefined=X1,b.isWeakMap=k1,b.isWeakSet=D1,b.join=Kv,b.kebabCase=Tx,b.last=zt,b.lastIndexOf=Rv,b.lowerCase=Gx,b.lowerFirst=Px,b.lt=z1,b.lte=O1,b.max=Mb,b.maxBy=Lb,b.mean=Sb,b.meanBy=Zb,b.min=Tb,b.minBy=Gb,b.stubArray=Pa,b.stubFalse=Ia,b.stubObject=fb,b.stubString=pb,b.stubTrue=mb,b.multiply=Pb,b.nth=Yv,b.noConflict=sb,b.noop=Ga,b.now=xs,b.pad=Ix,b.padEnd=Wx,b.padStart=Cx,b.parseInt=Vx,b.random=_x,b.reduce=Nw,b.reduceRight=jw,b.repeat=Ax,b.replace=Fx,b.result=dx,b.round=Ib,b.runInContext=C,b.sample=Qw,b.size=qw,b.snakeCase=Xx,b.some=$w,b.sortedIndex=Hv,b.sortedIndexBy=Ev,b.sortedIndexOf=qv,b.sortedLastIndex=$v,b.sortedLastIndexBy=ew,b.sortedLastIndexOf=tw,b.startCase=Dx,b.startsWith=zx,b.subtract=Wb,b.sum=Cb,b.sumBy=Vb,b.template=Ox,b.times=gb,b.toFinite=wn,b.toInteger=pe,b.toLength=wh,b.toLower=Kx,b.toNumber=Ot,b.toSafeInteger=K1,b.toString=Te,b.toUpper=Rx,b.trim=Yx,b.trimEnd=Ux,b.trimStart=Bx,b.truncate=Nx,b.unescape=jx,b.uniqueId=vb,b.upperCase=Jx,b.upperFirst=La,b.each=sh,b.eachRight=oh,b.first=th,Ta(b,function(){var i={};return on(b,function(o,h){Ge.call(b.prototype,h)||(i[h]=o)}),i}(),{chain:!1}),b.VERSION=n,At(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){b[i].placeholder=b}),At(["drop","take"],function(i,o){Me.prototype[i]=function(h){h=h===e?1:Ne(pe(h),0);var g=this.__filtered__&&!o?new Me(this):this.clone();return g.__filtered__?g.__takeCount__=st(h,g.__takeCount__):g.__views__.push({size:st(h,be),type:i+(g.__dir__<0?"Right":"")}),g},Me.prototype[i+"Right"]=function(h){return this.reverse()[i](h).reverse()}}),At(["filter","map","takeWhile"],function(i,o){var h=o+1,g=h==j||h==J;Me.prototype[i]=function(w){var M=this.clone();return M.__iteratees__.push({iteratee:ae(w,3),type:h}),M.__filtered__=M.__filtered__||g,M}}),At(["head","last"],function(i,o){var h="take"+(o?"Right":"");Me.prototype[i]=function(){return this[h](1).value()[0]}}),At(["initial","tail"],function(i,o){var h="drop"+(o?"":"Right");Me.prototype[i]=function(){return this.__filtered__?new Me(this):this[h](1)}}),Me.prototype.compact=function(){return this.filter(vt)},Me.prototype.find=function(i){return this.filter(i).head()},Me.prototype.findLast=function(i){return this.reverse().find(i)},Me.prototype.invokeMap=ye(function(i,o){return typeof i=="function"?new Me(this):this.map(function(h){return oi(h,i,o)})}),Me.prototype.reject=function(i){return this.filter(_s(ae(i)))},Me.prototype.slice=function(i,o){i=pe(i);var h=this;return h.__filtered__&&(i>0||o<0)?new Me(h):(i<0?h=h.takeRight(-i):i&&(h=h.drop(i)),o!==e&&(o=pe(o),h=o<0?h.dropRight(-o):h.take(o-i)),h)},Me.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},Me.prototype.toArray=function(){return this.take(be)},on(Me.prototype,function(i,o){var h=/^(?:filter|find|map|reject)|While$/.test(o),g=/^(?:head|last)$/.test(o),w=b[g?"take"+(o=="last"?"Right":""):o],M=g||/^find/.test(o);w&&(b.prototype[o]=function(){var P=this.__wrapped__,I=g?[1]:arguments,F=P instanceof Me,U=I[0],B=F||fe(P),Q=function(_e){var Le=w.apply(b,An([_e],I));return g&&$?Le[0]:Le};B&&h&&typeof U=="function"&&U.length!=1&&(F=B=!1);var $=this.__chain__,re=!!this.__actions__.length,le=M&&!$,ge=F&&!re;if(!M&&B){P=ge?P:new Me(this);var ce=i.apply(P,I);return ce.__actions__.push({func:vs,args:[Q],thisArg:e}),new Xt(ce,$)}return le&&ge?i.apply(this,I):(ce=this.thru(Q),le?g?ce.value()[0]:ce.value():ce)})}),At(["pop","push","shift","sort","splice","unshift"],function(i){var o=Ui[i],h=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",g=/^(?:pop|shift)$/.test(i);b.prototype[i]=function(){var w=arguments;if(g&&!this.__chain__){var M=this.value();return o.apply(fe(M)?M:[],w)}return this[h](function(P){return o.apply(fe(P)?P:[],w)})}}),on(Me.prototype,function(i,o){var h=b[o];if(h){var g=h.name+"";Ge.call(Sr,g)||(Sr[g]=[]),Sr[g].push({name:o,func:h})}}),Sr[hs(e,S).name]=[{name:"wrapper",func:e}],Me.prototype.clone=jg,Me.prototype.reverse=Jg,Me.prototype.value=Qg,b.prototype.at=Lw,b.prototype.chain=Sw,b.prototype.commit=Zw,b.prototype.next=Tw,b.prototype.plant=Pw,b.prototype.reverse=Iw,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Ww,b.prototype.first=b.prototype.head,$r&&(b.prototype[$r]=Gw),b},_r=Zg();er?((er.exports=_r)._=_r,Zo._=_r):nt._=_r}).call(Yr)}(Pi,Pi.exports);var _p=Pi.exports;let Ur=class extends Sn{constructor(e){super(e);T(this,"_baseType","Point");this._threeGeometry=this._createThreeGeometry(),this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=new m.Vector3(this._geometry.coordinates[0],this._geometry.coordinates[1],this._geometry.coordinates[2]||0);return e?e.geo2world(n):n}_toThreeJSGeometry(){}_createThreeGeometry(){return new m.Points(new m.BufferGeometry,new m.PointsMaterial({size:1,color:8947848}))}};const Mp={};class ro extends Ur{constructor(e){super(e);T(this,"_type","Maker")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-point":return bl(e.config,new m.Vector3(0,0,0));case"icon-point":return _l(e.config,this._position);case"icon-label-point":return Nf(e.config,this.getMap(),this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{switch(this._style?.config.type){case"icon-point":return this._calculateSpriteBoundingBox(this._threeGeometry);default:return this._getFallbackBoundingBox()}}catch(r){return console.warn(`Maker ${this._id} 包围盒计算失败:`,r),this._getFallbackBoundingBox()}}_calculateSpriteBoundingBox(e){try{const r=Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))/.002;return console.log("Sprite尺寸估算:",{spriteScale:{x:e.scale.x,y:e.scale.y},计算尺寸:r,使用尺寸:r}),{width:r,height:r,offsetX:-r/2,offsetY:-r/2}}catch{return{width:20,height:20,offsetX:-10,offsetY:-10}}}_getFallbackBoundingBox(){switch(this.getStyle()?.config.type){case"icon-point":case"icon-label-point":return{width:20,height:20,offsetX:-10,offsetY:-10};case"basic-point":return{width:10,height:10,offsetX:-5,offsetY:-5};default:return{width:15,height:15,offsetX:-7.5,offsetY:-7.5}}}}ro.mergeOptions(Mp);class Cl extends Sn{constructor(e){super(e);T(this,"_baseType","Line");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=this._geometry,r=e?.prjcenter;if(this._geometry.type==="LineString"){let a=n.coordinates.map(u=>{const d=new m.Vector3(u[0],u[1],u[2]||0);return(e?e.geo2world(d):d).sub(r)}),c=a.flatMap(u=>[u.x,u.y,u.z]);return{_position:a,_vertexPoints:c}}}_toThreeJSGeometry(){}_createThreeGeometry(){const e=new yi,n=new Xr({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Ys(e,n)}}const Lp={};class io extends Cl{constructor(e){super(e);T(this,"_type","LineString")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-line":return Gi(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_updateGeometry(){const e=this.getMap();if(this._disposeGeometry(),this._threeGeometry){const r=this._threeGeometry.geometry;r.setPositions(this._vertexPoints),r.computeBoundingSphere(),r.computeBoundingBox(),this._threeGeometry.position.add(e?.prjcenter),this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue()}}}io.mergeOptions(Lp);class Sp extends Sn{constructor(e){super(e);T(this,"_baseType","Surface");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=e?.prjcenter,r=this._geometry;if(!r)throw new Error("几何数据未定义");if(r.type==="Polygon"){const s=r.coordinates;let a=[],c=[];return s.forEach(u=>{const d=u.map(p=>{const f=new m.Vector3(p[0],p[1],p[2]||0);return(e?e.geo2world(f):f).sub(n)});a.push(d),c.push(...d.flatMap(p=>[p.x,p.y,p.z]))}),{_positions:a,_vertexPoints:c}}else if(r.type==="MultiPolygon"){const s=r.coordinates;let a=[],c=[];return s.forEach(u=>{const d=[];u.forEach(p=>{const f=p.map(y=>{const v=new m.Vector3(y[0],y[1],y[2]||0);return(e?e.geo2world(v):v).sub(n)});d.push(f),c.push(...f.flatMap(y=>[y.x,y.y,y.z]))}),a.push(d)}),{_positions:a,_vertexPoints:c}}else throw new Error(`不支持的几何类型: ${r.type}`)}_updateGeometry(){const e=this._style?.config.type;if(this.clear(),!this._threeGeometry||!this._vertexPoints?.length){console.warn("无法更新几何体:缺少几何体或顶点数据");return}const n=this._threeGeometry,r=n.geometry,s=this.getMap();try{if(e==="basic-polygon"){const a=r.getAttribute("position");if(a.count*3!==this._vertexPoints.length)throw new Error(`顶点数量不匹配: ${a.count} 预期, 实际 ${this._vertexPoints.length/3}`);a.array.set(this._vertexPoints),a.needsUpdate=!0,this._threeGeometry.renderOrder=999,r.computeBoundingSphere(),r.computeBoundingBox(),this._threeGeometry.position.add(s?.prjcenter),this.add(this._threeGeometry),n.updateMatrix(),this.updateMatrixWorld(!0)}else(e==="extrude-polygon"||e?.includes("water"))&&(this._threeGeometry.renderOrder=999,this._threeGeometry.position.add(s?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry))}catch(a){throw console.error("更新多边形位置失败:",a),a}}_createThreeGeometry(){const e=new yi,n=new Xr({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Ys(e,n)}}const Zp={};class Vl extends Sp{constructor(e){super(e);T(this,"_type","Polygon")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this.remove(this._threeGeometry),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-polygon":return zf(e.config,this._vertexPoints);case"extrude-polygon":return Of(e.config,this._vertexPoints);case"water":return Kf(e.config,this.getMap(),this._vertexPoints);case"base-water":return Rf(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(){return null}}Vl.mergeOptions(Zp);const Tp={};class Al extends Cl{constructor(e){super(e);T(this,"_type","MultiLineString");T(this,"_lineObjects",[]);T(this,"_linesContainer");this._linesContainer=new m.Group}async _toThreeJSGeometry(){const{_position:e}=this._coordsTransform(),n=this.getMap();if(this.clearLines(),this._disposeGeometry(),this._style){for(const r of e){const s=r.flatMap(c=>[c.x,c.y,c.z]),a=await this._createLineObject(this._style,s);a.position.add(n?.prjcenter),a.updateMatrixWorld(!0),this._lineObjects.push(a),this._linesContainer.add(a),this._threeGeometry=this._linesContainer}this.add(this._threeGeometry),this._updateContainer(),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0),this._tryProcessQueue()}}async _createLineObject(e,n){switch(e.config.type){case"basic-line":return Gi(e.config,n);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(this._geometry.type==="MultiLineString"){const r=e?.prjcenter;return{_position:n.coordinates.map(a=>a.map(c=>{const u=new m.Vector3(c[0],c[1],c[2]||0);return(e?e.geo2world(u):u).sub(r)}))}}}_updateContainer(){this._linesContainer.updateMatrixWorld(!0)}clearLines(){this._lineObjects.forEach(e=>{this._linesContainer.remove(e),e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this._lineObjects=[]}_updateGeometry(){this._toThreeJSGeometry()}_disposeObject(){}}Al.mergeOptions(Tp);class Gp extends wt.MeshStandardMaterial{constructor(e={}){const{shaderOption:n,...r}=e;super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,...r});T(this,"shaderOption");T(this,"clock");T(this,"time");T(this,"startTime");this.shaderOption={minY:0,maxY:100,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!1,color:new wt.Color("#9ECDEC"),width:20,speed:1,maxDistance:100,center:void 0},flow:{enabled:!1,color:new wt.Color("#00E4FF"),range:10,speed:20},sweep:{enabled:!1,color:new wt.Color("#FFFFFF"),width:1.5,speed:10}},...n},this.clock=new wt.Clock,this.time={value:0},this.startTime={value:0},this.animate()}onBeforeCompile(e){const{minY:n,maxY:r,minRate:s,maxRate:a,effects:c}=this.shaderOption,u=r-n;e.uniforms={...e.uniforms,time:this.time,uStartTime:this.startTime,uMinY:{value:n},uMaxY:{value:r},uHeightRange:{value:u},uMinRate:{value:s},uMaxRate:{value:a},uDiffusionEnabled:{value:c?.diffusion?.enabled?1:0},uDiffusionColor:{value:c?.diffusion?.color||new wt.Color("#9ECDEC")},uDiffusionWidth:{value:c?.diffusion?.width||20},uDiffusionSpeed:{value:c?.diffusion?.speed||1},uDiffusionMaxDistance:{value:c?.diffusion?.maxDistance||100},uDiffusionCenter:{value:c?.diffusion?.center||new wt.Vector3(0,0,0)},uFlowEnabled:{value:c?.flow?.enabled?1:0},uFlowColor:{value:c?.flow?.color||new wt.Color("#00E4FF")},uFlowRange:{value:c?.flow?.range||10},uFlowSpeed:{value:c?.flow?.speed||20},uSweepEnabled:{value:c?.sweep?.enabled?1:0},uSweepColor:{value:c?.sweep?.color||new wt.Color("#FFFFFF")},uSweepWidth:{value:c?.sweep?.width||1.5},uSweepSpeed:{value:c?.sweep?.speed||10}},e.vertexShader=`
|
|
565
|
+
}`;var ge=Ah(function(){return Te(L,ie+"return "+Q).apply(e,W)});if(ge.source=Q,Ta(ge))throw ge;return ge}function N1(r){return Ze(r).toLowerCase()}function j1(r){return Ze(r).toUpperCase()}function J1(r,o,h){if(r=Ze(r),r&&(h||o===e))return Yc(r);if(!r||!(o=Mt(o)))return r;var g=Jt(r),w=Jt(o),L=Uc(g,w),W=Bc(g,w)+1;return On(g,L,W).join("")}function Q1(r,o,h){if(r=Ze(r),r&&(h||o===e))return r.slice(0,jc(r)+1);if(!r||!(o=Mt(o)))return r;var g=Jt(r),w=Bc(g,Jt(o))+1;return On(g,0,w).join("")}function H1(r,o,h){if(r=Ze(r),r&&(h||o===e))return r.replace(To,"");if(!r||!(o=Mt(o)))return r;var g=Jt(r),w=Uc(g,Jt(o));return On(g,w).join("")}function E1(r,o){var h=I,g=z;if(Fe(o)){var w="separator"in o?o.separator:w;h="length"in o?pe(o.length):h,g="omission"in o?Mt(o.omission):g}r=Ze(r);var L=r.length;if(bi(r)){var W=Jt(r);L=W.length}if(h>=L)return r;var P=h-_i(g);if(P<1)return g;var F=W?On(W,0,P).join(""):r.slice(0,P);if(w===e)return F+g;if(W&&(P+=F.length-P),Za(w)){if(r.slice(P).search(w)){var U,B=F;for(w.global||(w=Yo(w.source,Ze(hc.exec(w))+"g")),w.lastIndex=0;U=w.exec(B);)var Q=U.index;F=F.slice(0,Q===e?P:Q)}}else if(r.indexOf(Mt(w),P)!=P){var $=F.lastIndexOf(w);$>-1&&(F=F.slice(0,$))}return F+g}function q1(r){return r=Ze(r),r&&uc.test(r)?r.replace(Ct,Zg):r}var $1=Wi(function(r,o,h){return r+(h?" ":"")+o.toUpperCase()}),Pa=Fu("toUpperCase");function Vh(r,o,h){return r=Ze(r),o=h?e:o,o===e?_g(r)?Pg(r):fg(r):r.match(o)||[]}var Ah=ye(function(r,o){try{return bt(r,e,o)}catch(h){return Ta(h)?h:new de(h)}}),eb=yn(function(r,o){return At(o,function(h){h=ln(h),mn(r,h,La(r[h],r))}),r});function tb(r){var o=r==null?0:r.length,h=ae();return r=o?Ve(r,function(g){if(typeof g[1]!="function")throw new Ft(l);return[h(g[0]),g[1]]}):[],ye(function(g){for(var w=-1;++w<o;){var L=r[w];if(bt(L[0],this,g))return bt(L[1],this,g)}})}function nb(r){return Zy(zt(r,f))}function Ia(r){return function(){return r}}function ib(r,o){return r==null||r!==r?o:r}var rb=zu(),sb=zu(!0);function wt(r){return r}function Ca(r){return fu(typeof r=="function"?r:zt(r,f))}function ob(r){return mu(zt(r,f))}function ab(r,o){return gu(r,zt(o,f))}var lb=ye(function(r,o){return function(h){return cr(h,r,o)}}),cb=ye(function(r,o){return function(h){return cr(r,h,o)}});function Va(r,o,h){var g=He(o),w=as(o,g);h==null&&!(Fe(o)&&(w.length||!g.length))&&(h=o,o=r,r=this,w=as(o,He(o)));var L=!(Fe(h)&&"chain"in h)||!!h.chain,W=wn(r);return At(w,function(P){var F=o[P];r[P]=F,W&&(r.prototype[P]=function(){var U=this.__chain__;if(L||U){var B=r(this.__wrapped__),Q=B.__actions__=gt(this.__actions__);return Q.push({func:F,args:arguments,thisArg:r}),B.__chain__=U,B}return F.apply(r,An([this.value()],arguments))})}),r}function ub(){return nt._===this&&(nt._=Xg),this}function Aa(){}function hb(r){return r=pe(r),ye(function(o){return yu(o,r)})}var db=ha(Ve),fb=ha(Dc),pb=ha(Xo);function Fh(r){return va(r)?zo(ln(r)):Uy(r)}function mb(r){return function(o){return r==null?e:si(r,o)}}var gb=ku(),yb=ku(!0);function Fa(){return[]}function Xa(){return!1}function vb(){return{}}function wb(){return""}function xb(){return!0}function bb(r,o){if(r=pe(r),r<1||r>re)return[];var h=be,g=ot(r,be);o=ae(o),r-=be;for(var w=Oo(g,o);++h<r;)o(h);return w}function _b(r){return fe(r)?Ve(r,ln):Lt(r)?[r]:gt(th(Ze(r)))}function Mb(r){var o=++Ag;return Ze(r)+o}var Lb=fs(function(r,o){return r+o},0),Sb=da("ceil"),Tb=fs(function(r,o){return r/o},1),Zb=da("floor");function Gb(r){return r&&r.length?os(r,wt,Eo):e}function Wb(r,o){return r&&r.length?os(r,ae(o,2),Eo):e}function Pb(r){return Rc(r,wt)}function Ib(r,o){return Rc(r,ae(o,2))}function Cb(r){return r&&r.length?os(r,wt,ta):e}function Vb(r,o){return r&&r.length?os(r,ae(o,2),ta):e}var Ab=fs(function(r,o){return r*o},1),Fb=da("round"),Xb=fs(function(r,o){return r-o},0);function zb(r){return r&&r.length?ko(r,wt):0}function Db(r,o){return r&&r.length?ko(r,ae(o,2)):0}return b.after=ox,b.ary=dh,b.assign=jx,b.assignIn=Th,b.assignInWith=Ts,b.assignWith=Jx,b.at=Qx,b.before=fh,b.bind=La,b.bindAll=eb,b.bindKey=ph,b.castArray=vx,b.chain=ch,b.chunk=Zv,b.compact=Gv,b.concat=Wv,b.cond=tb,b.conforms=nb,b.constant=Ia,b.countBy=zw,b.create=Hx,b.curry=mh,b.curryRight=gh,b.debounce=yh,b.defaults=Ex,b.defaultsDeep=qx,b.defer=ax,b.delay=lx,b.difference=Pv,b.differenceBy=Iv,b.differenceWith=Cv,b.drop=Vv,b.dropRight=Av,b.dropRightWhile=Fv,b.dropWhile=Xv,b.fill=zv,b.filter=kw,b.flatMap=Kw,b.flatMapDeep=Yw,b.flatMapDepth=Uw,b.flatten=sh,b.flattenDeep=Dv,b.flattenDepth=kv,b.flip=cx,b.flow=rb,b.flowRight=sb,b.fromPairs=Ov,b.functions=s1,b.functionsIn=o1,b.groupBy=Bw,b.initial=Kv,b.intersection=Yv,b.intersectionBy=Uv,b.intersectionWith=Bv,b.invert=l1,b.invertBy=c1,b.invokeMap=jw,b.iteratee=Ca,b.keyBy=Jw,b.keys=He,b.keysIn=vt,b.map=xs,b.mapKeys=h1,b.mapValues=d1,b.matches=ob,b.matchesProperty=ab,b.memoize=_s,b.merge=f1,b.mergeWith=Zh,b.method=lb,b.methodOf=cb,b.mixin=Va,b.negate=Ms,b.nthArg=hb,b.omit=p1,b.omitBy=m1,b.once=ux,b.orderBy=Qw,b.over=db,b.overArgs=hx,b.overEvery=fb,b.overSome=pb,b.partial=Sa,b.partialRight=vh,b.partition=Hw,b.pick=g1,b.pickBy=Gh,b.property=Fh,b.propertyOf=mb,b.pull=Qv,b.pullAll=ah,b.pullAllBy=Hv,b.pullAllWith=Ev,b.pullAt=qv,b.range=gb,b.rangeRight=yb,b.rearg=dx,b.reject=$w,b.remove=$v,b.rest=fx,b.reverse=_a,b.sampleSize=tx,b.set=v1,b.setWith=w1,b.shuffle=nx,b.slice=ew,b.sortBy=sx,b.sortedUniq=aw,b.sortedUniqBy=lw,b.split=K1,b.spread=px,b.tail=cw,b.take=uw,b.takeRight=hw,b.takeRightWhile=dw,b.takeWhile=fw,b.tap=Gw,b.throttle=mx,b.thru=ws,b.toArray=Mh,b.toPairs=Wh,b.toPairsIn=Ph,b.toPath=_b,b.toPlainObject=Sh,b.transform=x1,b.unary=gx,b.union=pw,b.unionBy=mw,b.unionWith=gw,b.uniq=yw,b.uniqBy=vw,b.uniqWith=ww,b.unset=b1,b.unzip=Ma,b.unzipWith=lh,b.update=_1,b.updateWith=M1,b.values=Ci,b.valuesIn=L1,b.without=xw,b.words=Vh,b.wrap=yx,b.xor=bw,b.xorBy=_w,b.xorWith=Mw,b.zip=Lw,b.zipObject=Sw,b.zipObjectDeep=Tw,b.zipWith=Zw,b.entries=Wh,b.entriesIn=Ph,b.extend=Th,b.extendWith=Ts,Va(b,b),b.add=Lb,b.attempt=Ah,b.camelCase=G1,b.capitalize=Ih,b.ceil=Sb,b.clamp=S1,b.clone=wx,b.cloneDeep=bx,b.cloneDeepWith=_x,b.cloneWith=xx,b.conformsTo=Mx,b.deburr=Ch,b.defaultTo=ib,b.divide=Tb,b.endsWith=W1,b.eq=Ht,b.escape=P1,b.escapeRegExp=I1,b.every=Dw,b.find=Ow,b.findIndex=ih,b.findKey=$x,b.findLast=Rw,b.findLastIndex=rh,b.findLastKey=e1,b.floor=Zb,b.forEach=uh,b.forEachRight=hh,b.forIn=t1,b.forInRight=n1,b.forOwn=i1,b.forOwnRight=r1,b.get=Ga,b.gt=Lx,b.gte=Sx,b.has=a1,b.hasIn=Wa,b.head=oh,b.identity=wt,b.includes=Nw,b.indexOf=Rv,b.inRange=T1,b.invoke=u1,b.isArguments=li,b.isArray=fe,b.isArrayBuffer=Tx,b.isArrayLike=yt,b.isArrayLikeObject=Oe,b.isBoolean=Zx,b.isBuffer=Rn,b.isDate=Gx,b.isElement=Wx,b.isEmpty=Px,b.isEqual=Ix,b.isEqualWith=Cx,b.isError=Ta,b.isFinite=Vx,b.isFunction=wn,b.isInteger=wh,b.isLength=Ls,b.isMap=xh,b.isMatch=Ax,b.isMatchWith=Fx,b.isNaN=Xx,b.isNative=zx,b.isNil=kx,b.isNull=Dx,b.isNumber=bh,b.isObject=Fe,b.isObjectLike=De,b.isPlainObject=mr,b.isRegExp=Za,b.isSafeInteger=Ox,b.isSet=_h,b.isString=Ss,b.isSymbol=Lt,b.isTypedArray=Ii,b.isUndefined=Rx,b.isWeakMap=Kx,b.isWeakSet=Yx,b.join=Nv,b.kebabCase=C1,b.last=kt,b.lastIndexOf=jv,b.lowerCase=V1,b.lowerFirst=A1,b.lt=Ux,b.lte=Bx,b.max=Gb,b.maxBy=Wb,b.mean=Pb,b.meanBy=Ib,b.min=Cb,b.minBy=Vb,b.stubArray=Fa,b.stubFalse=Xa,b.stubObject=vb,b.stubString=wb,b.stubTrue=xb,b.multiply=Ab,b.nth=Jv,b.noConflict=ub,b.noop=Aa,b.now=bs,b.pad=F1,b.padEnd=X1,b.padStart=z1,b.parseInt=D1,b.random=Z1,b.reduce=Ew,b.reduceRight=qw,b.repeat=k1,b.replace=O1,b.result=y1,b.round=Fb,b.runInContext=V,b.sample=ex,b.size=ix,b.snakeCase=R1,b.some=rx,b.sortedIndex=tw,b.sortedIndexBy=nw,b.sortedIndexOf=iw,b.sortedLastIndex=rw,b.sortedLastIndexBy=sw,b.sortedLastIndexOf=ow,b.startCase=Y1,b.startsWith=U1,b.subtract=Xb,b.sum=zb,b.sumBy=Db,b.template=B1,b.times=bb,b.toFinite=xn,b.toInteger=pe,b.toLength=Lh,b.toLower=N1,b.toNumber=Ot,b.toSafeInteger=Nx,b.toString=Ze,b.toUpper=j1,b.trim=J1,b.trimEnd=Q1,b.trimStart=H1,b.truncate=E1,b.unescape=q1,b.uniqueId=Mb,b.upperCase=$1,b.upperFirst=Pa,b.each=uh,b.eachRight=hh,b.first=oh,Va(b,function(){var r={};return on(b,function(o,h){Ge.call(b.prototype,h)||(r[h]=o)}),r}(),{chain:!1}),b.VERSION=n,At(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){b[r].placeholder=b}),At(["drop","take"],function(r,o){Me.prototype[r]=function(h){h=h===e?1:Ne(pe(h),0);var g=this.__filtered__&&!o?new Me(this):this.clone();return g.__filtered__?g.__takeCount__=ot(h,g.__takeCount__):g.__views__.push({size:ot(h,be),type:r+(g.__dir__<0?"Right":"")}),g},Me.prototype[r+"Right"]=function(h){return this.reverse()[r](h).reverse()}}),At(["filter","map","takeWhile"],function(r,o){var h=o+1,g=h==j||h==J;Me.prototype[r]=function(w){var L=this.clone();return L.__iteratees__.push({iteratee:ae(w,3),type:h}),L.__filtered__=L.__filtered__||g,L}}),At(["head","last"],function(r,o){var h="take"+(o?"Right":"");Me.prototype[r]=function(){return this[h](1).value()[0]}}),At(["initial","tail"],function(r,o){var h="drop"+(o?"":"Right");Me.prototype[r]=function(){return this.__filtered__?new Me(this):this[h](1)}}),Me.prototype.compact=function(){return this.filter(wt)},Me.prototype.find=function(r){return this.filter(r).head()},Me.prototype.findLast=function(r){return this.reverse().find(r)},Me.prototype.invokeMap=ye(function(r,o){return typeof r=="function"?new Me(this):this.map(function(h){return cr(h,r,o)})}),Me.prototype.reject=function(r){return this.filter(Ms(ae(r)))},Me.prototype.slice=function(r,o){r=pe(r);var h=this;return h.__filtered__&&(r>0||o<0)?new Me(h):(r<0?h=h.takeRight(-r):r&&(h=h.drop(r)),o!==e&&(o=pe(o),h=o<0?h.dropRight(-o):h.take(o-r)),h)},Me.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},Me.prototype.toArray=function(){return this.take(be)},on(Me.prototype,function(r,o){var h=/^(?:filter|find|map|reject)|While$/.test(o),g=/^(?:head|last)$/.test(o),w=b[g?"take"+(o=="last"?"Right":""):o],L=g||/^find/.test(o);w&&(b.prototype[o]=function(){var W=this.__wrapped__,P=g?[1]:arguments,F=W instanceof Me,U=P[0],B=F||fe(W),Q=function(_e){var Le=w.apply(b,An([_e],P));return g&&$?Le[0]:Le};B&&h&&typeof U=="function"&&U.length!=1&&(F=B=!1);var $=this.__chain__,ie=!!this.__actions__.length,le=L&&!$,ge=F&&!ie;if(!L&&B){W=ge?W:new Me(this);var ce=r.apply(W,P);return ce.__actions__.push({func:ws,args:[Q],thisArg:e}),new Xt(ce,$)}return le&&ge?r.apply(this,P):(ce=this.thru(Q),le?g?ce.value()[0]:ce.value():ce)})}),At(["pop","push","shift","sort","splice","unshift"],function(r){var o=Br[r],h=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",g=/^(?:pop|shift)$/.test(r);b.prototype[r]=function(){var w=arguments;if(g&&!this.__chain__){var L=this.value();return o.apply(fe(L)?L:[],w)}return this[h](function(W){return o.apply(fe(W)?W:[],w)})}}),on(Me.prototype,function(r,o){var h=b[o];if(h){var g=h.name+"";Ge.call(Ti,g)||(Ti[g]=[]),Ti[g].push({name:o,func:h})}}),Ti[ds(e,Z).name]=[{name:"wrapper",func:e}],Me.prototype.clone=qg,Me.prototype.reverse=$g,Me.prototype.value=ey,b.prototype.at=Ww,b.prototype.chain=Pw,b.prototype.commit=Iw,b.prototype.next=Cw,b.prototype.plant=Aw,b.prototype.reverse=Fw,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Xw,b.prototype.first=b.prototype.head,nr&&(b.prototype[nr]=Vw),b},Mi=Ig();ei?((ei.exports=Mi)._=Mi,Co._=Mi):nt._=Mi}).call(Ni)}(Pr,Pr.exports);var Zp=Pr.exports;let ji=class extends hn{constructor(e){super(e);T(this,"_baseType","Point");this._threeGeometry=this._createThreeGeometry(),this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=new m.Vector3(this._geometry.coordinates[0],this._geometry.coordinates[1],this._geometry.coordinates[2]||0);return e?e.geo2world(n):n}_toThreeJSGeometry(){}_createThreeGeometry(){return new m.Points(new m.BufferGeometry,new m.PointsMaterial({size:1,color:8947848}))}};const Gp={};class so extends ji{constructor(e){super(e);T(this,"_type","Maker")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-point":return Zl(e.config,new m.Vector3(0,0,0));case"icon-point":return Gl(e.config,this._position);case"icon-label-point":return Ef(e.config,this.getMap(),this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{switch(this._style?.config.type){case"icon-point":return this._calculateSpriteBoundingBox(this._threeGeometry);default:return this._getFallbackBoundingBox()}}catch(i){return console.warn(`Maker ${this._id} 包围盒计算失败:`,i),this._getFallbackBoundingBox()}}_calculateSpriteBoundingBox(e){try{const i=Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))/.002;return{width:i,height:i,offsetX:-i/2,offsetY:-i/2}}catch{return{width:20,height:20,offsetX:-10,offsetY:-10}}}_getFallbackBoundingBox(){switch(this.getStyle()?.config.type){case"icon-point":case"icon-label-point":return{width:20,height:20,offsetX:-10,offsetY:-10};case"basic-point":return{width:10,height:10,offsetX:-5,offsetY:-5};default:return{width:15,height:15,offsetX:-7.5,offsetY:-7.5}}}}so.mergeOptions(Gp);class zl extends hn{constructor(e){super(e);T(this,"_baseType","Line");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=this._geometry,i=e?.prjcenter;if(this._geometry.type==="LineString"){let l=n.coordinates.map(c=>{const d=new m.Vector3(c[0],c[1],c[2]||0);return(e?e.geo2world(d):d).sub(i)}),u=l.flatMap(c=>[c.x,c.y,c.z]);return{_position:l,_vertexPoints:u}}}_toThreeJSGeometry(){}_createThreeGeometry(){const e=new xr,n=new zi({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Us(e,n)}}const Wp={};class oo extends zl{constructor(e){super(e);T(this,"_type","LineString")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-line":return Wr(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_updateGeometry(){const e=this.getMap();if(this._disposeGeometry(),this._threeGeometry){const i=this._threeGeometry.geometry;i.setPositions(this._vertexPoints),i.computeBoundingSphere(),i.computeBoundingBox(),this._threeGeometry.position.add(e?.prjcenter),this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue()}}}oo.mergeOptions(Wp);class Pp extends hn{constructor(e){super(e);T(this,"_baseType","Surface");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=e?.prjcenter,i=this._geometry;if(!i)throw new Error("几何数据未定义");if(i.type==="Polygon"){const s=i.coordinates;let l=[],u=[];return s.forEach(c=>{const d=c.map(p=>{const f=new m.Vector3(p[0],p[1],p[2]||0);return(e?e.geo2world(f):f).sub(n)});l.push(d),u.push(...d.flatMap(p=>[p.x,p.y,p.z]))}),{_positions:l,_vertexPoints:u}}else if(i.type==="MultiPolygon"){const s=i.coordinates;let l=[],u=[];return s.forEach(c=>{const d=[];c.forEach(p=>{const f=p.map(y=>{const v=new m.Vector3(y[0],y[1],y[2]||0);return(e?e.geo2world(v):v).sub(n)});d.push(f),u.push(...f.flatMap(y=>[y.x,y.y,y.z]))}),l.push(d)}),{_positions:l,_vertexPoints:u}}else throw new Error(`不支持的几何类型: ${i.type}`)}_updateGeometry(){const e=this._style?.config.type;if(this.clear(),!this._threeGeometry||!this._vertexPoints?.length){console.warn("无法更新几何体:缺少几何体或顶点数据");return}const n=this.getMap();try{e==="basic-polygon"?(this._threeGeometry.position.add(n?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry)):(e==="extrude-polygon"||e?.includes("water"))&&(this._threeGeometry.position.add(n?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry))}catch(i){throw console.error("更新多边形位置失败:",i),i}}_createThreeGeometry(){const e=new xr,n=new zi({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Us(e,n)}}const Ip={};class Dl extends Pp{constructor(e){super(e);T(this,"_type","Polygon")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this.remove(this._threeGeometry),this._threeGeometry=await this._createObject(this._style),this._updateGeometry(),await this._style.applyTo(this._threeGeometry))}async _createObject(e){switch(e.config.type){case"basic-polygon":return Uf(e.config,this._vertexPoints);case"extrude-polygon":return Bf(e.config,this._vertexPoints);case"water":return Nf(e.config,this.getMap(),this._vertexPoints);case"base-water":return jf(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(){return null}}Dl.mergeOptions(Ip);const Cp={};class kl extends zl{constructor(e){super(e);T(this,"_type","MultiLineString");T(this,"_lineObjects",[]);T(this,"_linesContainer");this._linesContainer=new m.Group}async _toThreeJSGeometry(){const{_position:e}=this._coordsTransform(),n=this.getMap();if(this.clearLines(),this._disposeGeometry(),this._style){for(const i of e){const s=i.flatMap(u=>[u.x,u.y,u.z]),l=await this._createLineObject(this._style,s);l.position.add(n?.prjcenter),l.updateMatrixWorld(!0),this._lineObjects.push(l),this._linesContainer.add(l),this._threeGeometry=this._linesContainer}this.add(this._threeGeometry),this._updateContainer(),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0),this._tryProcessQueue()}}async _createLineObject(e,n){switch(e.config.type){case"basic-line":return Wr(e.config,n);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(this._geometry.type==="MultiLineString"){const i=e?.prjcenter;return{_position:n.coordinates.map(l=>l.map(u=>{const c=new m.Vector3(u[0],u[1],u[2]||0);return(e?e.geo2world(c):c).sub(i)}))}}}_updateContainer(){this._linesContainer.updateMatrixWorld(!0)}clearLines(){this._lineObjects.forEach(e=>{this._linesContainer.remove(e),e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this._lineObjects=[]}_updateGeometry(){this._toThreeJSGeometry()}_disposeObject(){}}kl.mergeOptions(Cp);const ao=64;class Vp extends rt.MeshStandardMaterial{constructor(e={}){const{shaderOption:n,regionOverlay:i,...s}=e;super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,depthWrite:!0,depthTest:!0,...s});T(this,"shaderOption");T(this,"clock");T(this,"time");T(this,"startTime");T(this,"regionOverlay");if(i&&i.vertices&&i.vertices.length>0){const l=i.vertices.slice(0,ao).map(c=>c.clone()),u=l.length;for(;l.length<ao;)l.push(new rt.Vector2(0,0));this.regionOverlay={color:i.color,opacity:i.opacity,vertices:l,vertexCount:u}}this.shaderOption={minY:0,maxY:100,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!1,color:new rt.Color("#9ECDEC"),width:20,speed:1,maxDistance:100,center:void 0},flow:{enabled:!1,color:new rt.Color("#00E4FF"),range:10,speed:20},sweep:{enabled:!1,color:new rt.Color("#FFFFFF"),width:1.5,speed:10}},...n},this.clock=new rt.Clock,this.time={value:0},this.startTime={value:0},this.animate()}onBeforeCompile(e){const{minY:n,maxY:i,minRate:s,maxRate:l,effects:u}=this.shaderOption,c=i-n,d=!!this.regionOverlay;e.uniforms={...e.uniforms,time:this.time,uStartTime:this.startTime,uMinY:{value:n},uMaxY:{value:i},uHeightRange:{value:c},uMinRate:{value:s},uMaxRate:{value:l},uDiffusionEnabled:{value:u?.diffusion?.enabled?1:0},uDiffusionColor:{value:u?.diffusion?.color||new rt.Color("#9ECDEC")},uDiffusionWidth:{value:u?.diffusion?.width||20},uDiffusionSpeed:{value:u?.diffusion?.speed||1},uDiffusionMaxDistance:{value:u?.diffusion?.maxDistance||100},uDiffusionCenter:{value:u?.diffusion?.center||new rt.Vector3(0,0,0)},uFlowEnabled:{value:u?.flow?.enabled?1:0},uFlowColor:{value:u?.flow?.color||new rt.Color("#00E4FF")},uFlowRange:{value:u?.flow?.range||10},uFlowSpeed:{value:u?.flow?.speed||20},uSweepEnabled:{value:u?.sweep?.enabled?1:0},uSweepColor:{value:u?.sweep?.color||new rt.Color("#FFFFFF")},uSweepWidth:{value:u?.sweep?.width||1.5},uSweepSpeed:{value:u?.sweep?.speed||10},uRegionOverlayEnabled:{value:d?1:0},uRegionOverlayColor:{value:this.regionOverlay?.color||new rt.Color("#00FF88")},uRegionOverlayOpacity:{value:this.regionOverlay?.opacity??0},uRegionOverlayVertexCount:{value:this.regionOverlay?.vertexCount??0},uRegionOverlayVertices:{value:this.regionOverlay?.vertices||new Array(ao).fill(0).map(()=>new rt.Vector2(0,0))}},e.vertexShader=`
|
|
566
566
|
varying vec3 vWorldPosition;
|
|
567
567
|
varying vec3 vPosition;
|
|
568
568
|
varying float vHeight;
|
|
@@ -574,6 +574,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
574
574
|
vHeight = position.y;
|
|
575
575
|
`),e.fragmentShader=`
|
|
576
576
|
#define PI 3.141592653589793
|
|
577
|
+
#define REGION_OVERLAY_MAX_VERTS 64
|
|
577
578
|
varying vec3 vWorldPosition;
|
|
578
579
|
varying vec3 vPosition;
|
|
579
580
|
varying float vHeight;
|
|
@@ -598,6 +599,14 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
598
599
|
uniform vec3 uSweepColor;
|
|
599
600
|
uniform float uSweepWidth;
|
|
600
601
|
uniform float uSweepSpeed;
|
|
602
|
+
|
|
603
|
+
// 区域多边形外衣相关 uniform 声明(之前缺少)
|
|
604
|
+
uniform int uRegionOverlayEnabled;
|
|
605
|
+
uniform vec3 uRegionOverlayColor;
|
|
606
|
+
uniform float uRegionOverlayOpacity;
|
|
607
|
+
uniform int uRegionOverlayVertexCount;
|
|
608
|
+
uniform vec2 uRegionOverlayVertices[REGION_OVERLAY_MAX_VERTS];
|
|
609
|
+
|
|
601
610
|
|
|
602
611
|
float distanceTo(vec2 src, vec2 dst) {
|
|
603
612
|
return distance(src, dst);
|
|
@@ -652,9 +661,38 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
652
661
|
diffuseColor.rgb = mix(uSweepColor, diffuseColor.rgb, 1.0 - sweepFactor);
|
|
653
662
|
}
|
|
654
663
|
}
|
|
655
|
-
`)}setDiffusionFromObject(e){if(!this.shaderOption.effects?.diffusion)return;const n=new wt.Box3().setFromObject(e);if(n.isEmpty())return;const r=new wt.Vector3;n.getCenter(r);const s=[new wt.Vector3(n.min.x,n.min.y,n.min.z),new wt.Vector3(n.max.x,n.max.y,n.max.z)];let a=0;s.forEach(c=>{const u=r.distanceTo(c);u>a&&(a=u)}),this.shaderOption.effects.diffusion={...this.shaderOption.effects.diffusion,center:r,maxDistance:a},this.needsUpdate=!0}updateBoundingBox(e,n){this.shaderOption.minY=e,this.shaderOption.maxY=n,this.needsUpdate=!0}updateEffects(e){this.shaderOption.effects={...this.shaderOption.effects,...e},this.needsUpdate=!0}animate(){requestAnimationFrame(()=>this.animate()),this.time.value=this.clock.getElapsedTime(),this.startTime.value<1&&(this.startTime.value+=.01)}}const Pp={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class Fl extends Ur{constructor(e){super(e);T(this,"_type","Model");T(this,"_emissive",!1);T(this,"_emissiveIntensity",1);T(this,"_emissiveColor","#ffffff");T(this,"_mixer",null);T(this,"_currentAction",null);T(this,"_animations",[]);T(this,"_clock",new m.Clock);T(this,"_autoUpdate",!0);T(this,"_animationRequestId",null);T(this,"_iscity",!1);this._emissive=e.emissive||!1,this._emissiveIntensity=e.emissiveIntensity||1,this._emissiveColor=e.emissiveColor||"#ffffff",this.castShadow=e.castShadow||!1,this.receiveShadow=e.receiveShadow||!1,this._iscity=e.iscity||!1}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this.modelunino=await this._createObject(this._style),this._threeGeometry=this.modelunino.model,this._threeGeometry.userData._type="Model",this.modelunino.animations&&this.modelunino.animations.length>0&&(this._animations=this.modelunino.animations,this._mixer=new m.AnimationMixer(this._threeGeometry),this._startAnimationLoop(),this.playAnimation({name:this._animations[0].name,loop:!0,speed:1.5,fadeInDuration:.5,fadeOutDuration:.3})),this._updateGeometry(),this.setShadows({cast:this.castShadow,receive:this.receiveShadow}),this._applyEmissionProperties(),this._iscity&&this._rendercity())}async _createObject(e){switch(e.config.type){case"fbx":case"gltf":return Df(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_applyEmissionProperties(){this._threeGeometry&&this._threeGeometry.traverse(e=>{if("material"in e){const n=e.material;n&&(n.emissiveIntensity=this._emissive?this._emissiveIntensity:0,n.emissive&&n.emissive.setStyle(this._emissiveColor))}})}get emissive(){return this._emissive}set emissive(e){this._emissive=e,this._applyEmissionProperties()}get emissiveIntensity(){return this._emissiveIntensity}set emissiveIntensity(e){this._emissiveIntensity=e,this._applyEmissionProperties()}get emissiveColor(){return this._emissiveColor}set emissiveColor(e){this._emissiveColor=e,this._applyEmissionProperties()}setEmission(e,n,r){this._emissive=e,n!==void 0&&(this._emissiveIntensity=n),r!==void 0&&(this._emissiveColor=r),this._applyEmissionProperties()}async setShadows(e){this.castShadow=e.cast,this.receiveShadow=e.receive,this._threeGeometry&&this._threeGeometry.traverse(n=>{n.isMesh&&n.material&&(n.castShadow=e.cast,n.receiveShadow=e.receive)})}playAnimation(e){if(!this._mixer||this._animations.length===0){console.warn("模型没有可用的动画");return}this._currentAction&&(e.fadeOutDuration&&e.fadeOutDuration>0?this._currentAction.fadeOut(e.fadeOutDuration):this._currentAction.stop());const n=typeof e.name=="number"?this._animations[e.name]:this._animations.find(r=>r.name===e.name);if(!n){console.warn(`找不到动画: ${e.name}`);return}this._currentAction=this._mixer.clipAction(n),this._currentAction.setLoop(e.loop?m.LoopRepeat:m.LoopOnce,e.loop?1/0:1),this._currentAction.timeScale=e.speed||1,this._currentAction.time=e.startAt||0,this._currentAction.setEffectiveWeight(e.weight||1),e.fadeInDuration&&e.fadeInDuration>0&&this._currentAction.fadeIn(e.fadeInDuration),this._currentAction.play(),this._autoUpdate&&this._animationRequestId===null&&this._startAnimationLoop()}stopAnimation(e={}){this._currentAction&&(e.fadeDuration&&e.fadeDuration>0?(this._currentAction.fadeOut(e.fadeDuration),setTimeout(()=>{this._currentAction&&(this._currentAction.stop(),this._currentAction=null)},e.fadeDuration*1e3)):(this._currentAction.stop(),this._currentAction=null))}setAnimationPaused(e){this._currentAction&&(this._currentAction.paused=e.paused)}setAnimationSpeed(e){this._currentAction&&(this._currentAction.timeScale=e.speed)}updateAnimation(e){this._mixer&&this._mixer.update(e.deltaTime)}getAnimationNames(){return this._animations.map(e=>e.name)}getCurrentAnimationName(){return this._currentAction?this._currentAction.getClip().name:null}getAnimationDuration(e){let n;return typeof e.name=="number"?n=this._animations[e.name]:n=this._animations.find(r=>r.name===e.name),n?n.duration:null}dispose(){this._stopAnimationLoop(),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._threeGeometry)),super.dispose()}_startAnimationLoop(){if(!this._autoUpdate||this._animationRequestId!==null)return;const e=()=>{if(this._mixer){const n=this._clock.getDelta();this._mixer.update(n)}this._animationRequestId=requestAnimationFrame(e)};this._clock.start(),this._animationRequestId=requestAnimationFrame(e)}_stopAnimationLoop(){this._animationRequestId!==null&&(cancelAnimationFrame(this._animationRequestId),this._animationRequestId=null),this._clock.stop()}setAutoUpdate(e){this._autoUpdate=e,e?this._startAnimationLoop():this._stopAnimationLoop()}_rendercity(){this.traverse(async e=>{if(e instanceof m.Mesh&&e.material){if(e.castShadow=!0,e.name==="building"){const n=new Gp({color:new m.Color("#6BA7EC").multiplyScalar(1.8),opacity:.95,shaderOption:{minY:0,maxY:50,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!0,color:new m.Color("#FFFFF"),width:300,speed:.05},flow:{enabled:!1,color:new m.Color("#FFFFF"),range:1e3,speed:3e3},sweep:{enabled:!0,color:new m.Color("#ffffff"),width:3,speed:5}}}}),r=new m.Box3().setFromObject(e);n.updateBoundingBox(r.min.y,r.max.y),n.setDiffusionFromObject(e),e.material=n,e.material.needsUpdate=!0}e.name==="grass"&&(e.castShadow=!1,e.receiveShadow=!0,e.material.color=new m.Color("#81e4d8ff)").multiplyScalar(.7),e.material.metalness=.2,e.material.roughness=.8,["metalnessMap","normalMap","roughnessMap","specularColorMap"].forEach(n=>{const r=e.material[n];r&&(r.wrapS=r.wrapT=m.RepeatWrapping,r.repeat.set(.3,.3),r.needsUpdate=!0)}),e.material.normalScale=new m.Vector2(3,3))}})}}Fl.mergeOptions(Pp);const Ip={};class Xl extends Ur{constructor(e){super(e);T(this,"_type","Cloud")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._disposeGeometry();const e=this.getLayer();this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry.renderOrder=1e3,e&&(e._clouds.add(this._threeGeometry),e._clouds.updateMatrixWorld()))}async _createObject(e){switch(e.config.type){case"cloud":return Yf(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Xl.mergeOptions(Ip);const Wp={};class kl extends Ur{constructor(e){super(e);T(this,"_type","Label")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"canvas-label-fixed":return Bf(e.config,new m.Vector3(0,0,0),this.getMap());case"canvas-label":return Uf(e.config,new m.Vector3(0,0,0));default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}kl.mergeOptions(Wp);const Cp={};class Dl extends Ur{constructor(e){super(e);T(this,"_type","TPoints");T(this,"_geometries");this._geometries=e.geometries}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._threeGeometry&&(this._threeGeometry.points&&this.add(this._threeGeometry.points),this._threeGeometry.InstancedCol&&this.add(this._threeGeometry.InstancedCol),this.updateMatrixWorld(!0))}async _createObject(e){switch(e.config.type){case"light":return Qf(e.config,this._geometries,this.getMap());default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Dl.mergeOptions(Cp);function Ii(l,t){if(!l||l===!0)return!0;if(!Array.isArray(l))return!!l;switch(l[0]){case"all":return l.slice(1).every(n=>Ii(n,t));case"any":return l.slice(1).some(n=>Ii(n,t));case"!":return!Ii(l[1],t);case"==":{const n=it(l[1],t),r=it(l[2],t);return Wi(n)==Wi(r)}case"!=":{const n=it(l[1],t),r=it(l[2],t);return Wi(n)!=Wi(r)}case">":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)>Zn(r)}case"<":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)<Zn(r)}case">=":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)>=Zn(r)}case"<=":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)<=Zn(r)}case"in":{const n=it(l[1],t);return l.slice(2).map(s=>it(s,t)).includes(n)}case"!in":{const n=it(l[1],t);return!l.slice(2).map(s=>it(s,t)).includes(n)}case"has":{const n=l[1];return t!=null&&Object.prototype.hasOwnProperty.call(t,n)}case"!has":{const n=l[1];return!(t!=null&&Object.prototype.hasOwnProperty.call(t,n))}default:return!0}}function it(l,t){if(Array.isArray(l))switch(l[0]){case"get":return t?t[l[1]]:void 0;default:return l}return l}function Wi(l){if(l==null)return null;if(typeof l=="string"){const t=Number(l);if(!isNaN(t)&&l.trim()!=="")return t}return typeof l=="boolean"?l?1:0:l}function Zn(l){if(l==null)return 0;if(typeof l=="number")return l;if(typeof l=="boolean")return l?1:0;if(typeof l=="string"){const t=Number(l);return isNaN(t)?0:t}return Number(l)}class Vp extends Bn{constructor(e,n){super(e,n);T(this,"TILE_SIZE");T(this,"EXTENT");T(this,"style");T(this,"_tileFeatureMap",new Map);T(this,"_activeFeatureFilter");this.TILE_SIZE=n.tileSize??256,this.EXTENT=n.extent??4096,this.style=n.style||[],this._onMapUpdate=this._onMapUpdate.bind(this)}processTileData(e,n){const r=this.getMap(),s=`${e.z}-${e.x}-${e.y}`,a=this._tileFeatureMap.get(s);if(a&&a.length>0){a.forEach(p=>{p.visible=!0,this.children.some(f=>f&&p&&f.uuid===p.uuid)||p.addTo(this)});return}const c=n.vectorData;if(!c||!c.layers||!r||this.style.length===0)return;const u=[],d=this.style;Object.keys(c.layers).forEach(p=>{const f=c.layers[p];for(let y=0;y<f.length;y++){const v=f[y],x=v.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(v.properties))continue;let L=null;for(const _ of d)if(this._evaluateFilter(_.filter,v.properties,p,v.geometry.type)){L=_.style;break}if(L){const _={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:x,extent:this.EXTENT,tileSize:this.TILE_SIZE},S=this._createFeatureInstance(v.geometry,v.geometry.type,L,v.properties);S&&(S.userData.tileData=_,S.style=Pt.create(L),S.addTo(this),S.initializeGeometry(),u.push(S))}}}),this._tileFeatureMap.set(s,u)}_evaluateFilter(e,n,r,s){if(!e||e===!0)return!0;const a={...n,$layer:r,$type:s};return Ii(e,a)}hideFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&n.forEach(r=>{r.visible=!1})}removeFeaturesByTileKey(e){this._removeFeaturesByTileKey(e)}_removeFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&(n.forEach(r=>{r._remove()}),this._tileFeatureMap.delete(e))}_createFeatureInstance(e,n,r,s){const c={geometry:{ismvt:!0,...e},style:r,userData:s};switch(n){case"Point":return new ro(c);case"LineString":return new io(c);default:return null}}setFeatureFilter(e){this._activeFeatureFilter=e}clearFeatureFilter(){this._activeFeatureFilter=void 0}setOpacity(e){this.opacity=e,this._tileFeatureMap.forEach(n=>{n.forEach(r=>{r.material&&(r.material.opacity=e,r.material.transparent=e<1)})})}_onMapUpdate(){}validateFeature(e){return e instanceof Sn}dispose(){this._tileFeatureMap.forEach((e,n)=>{this._removeFeaturesByTileKey(n)}),super.dispose()}}class zl extends Si{constructor(e,n){super(e,n);T(this,"isTileLayer",!0);T(this,"layerType","base");T(this,"isBaseLayer",!1);T(this,"_enabled",!0);T(this,"_visible",!0);T(this,"_rootTile");T(this,"_loader");T(this,"_LODThreshold",1);T(this,"isSceneLayer",!1);T(this,"opacity",1);T(this,"source");T(this,"projection");T(this,"minLevel",2);T(this,"maxLevel",19);this.layerId=e,this.source=n.source,this.projection=n.projection,this.minLevel=n.minLevel??2,this.maxLevel=n.maxLevel??19,this._LODThreshold=n.LODThreshold??1,this.opacity=n.opacity??1,this.name=`Layer-${e}`,this._loader=this.createLoader(),this._rootTile=new nn,this._rootTile.matrixAutoUpdate=!0,this._rootTile.scale.set(this.projection.mapWidth,this.projection.mapHeight,1),this.add(this._rootTile),this._rootTile.updateMatrix(),this.layerId=e,this.name==="Layer-label-layer"&&this.position.set(0,0,1)}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}get loader(){return this._loader}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._rootTile&&(this._rootTile.visible=e&&this._visible)}get ivisible(){return this._visible&&super._visible}set ivisible(e){this._visible=e,this._rootTile&&(this._rootTile.visible=e&&this._enabled)}update(e){if(!(!this._enabled||!this._visible)){try{this._rootTile.update({camera:e,loader:this._loader,minLevel:this.minLevel,maxLevel:this.maxLevel,LODThreshold:this.LODThreshold})}catch{}console.groupEnd()}}_debugTileTree(){this._rootTile.traverse(e=>{e.isTile&&(e.loaded,e.visible,e.inFrustum,e.loaded)})}_getLODThreshold(){return 1}_getCurrentTileLevel(){let e=0;return this._rootTile.traverse(n=>{n.isTile&&n.loaded&&(e=Math.max(e,n.z))}),`最大层级: ${e}`}dispose(){this.remove(this._rootTile),this._rootTile.reload(this._loader)}reload(){this._rootTile.reload(this._loader)}setElevation(e){this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0)}raiseElevation(e){this.position.z+=e,this.updateMatrix(),this.updateMatrixWorld(!0)}getElevation(){return this.position.y}}class Ol extends m.LoadingManager{constructor(){super(...arguments);T(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const Xe={manager:new Ol,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(l){Xe.imgLoaderMap.set(l.dataType,l),l.info.author=l.info.author??Zs.name},registerGeometryLoader(l){Xe.demLoaderMap.set(l.dataType,l),l.info.author=l.info.author??Zs.name},registerMeshLoader(l){Xe.meshLoaderMap.set(l.dataType,l),l.info.author=l.info.author??Zs.name},getMaterialLoader(l){const t=Xe.imgLoaderMap.get(l.dataType);if(t)return t;throw`Source dataType "${l.dataType}" is not support!`},getGeometryLoader(l){const t=Xe.demLoaderMap.get(l.dataType);if(t)return t;throw`Source dataType "${l.dataType}" is not support!`},getMeshLoader(l){const t=Xe.meshLoaderMap.get(l.dataType);if(t)return t;throw`Source dataType "${l.dataType}" is not support!`}};class Ap{constructor(t){T(this,"worker");this.worker=t()}async run(t,e){return new Promise(n=>{this.worker.onmessage=r=>{n(r.data)},this.worker.postMessage(t,e)})}terminate(){this.worker.terminate()}}const Fp=4096,Kl=Math.PI;function so(l,t){const e=Math.floor(l[0]*t),n=Math.floor(l[1]*t),r=Math.floor((l[2]-l[0])*t),s=Math.floor((l[3]-l[1])*t);return{sx:e,sy:n,sw:r,sh:s}}function oo(l,t,e,n){if(n<l.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=l.maxLevel)return{url:l._getUrl(t,e,n),clipBounds:[0,0,1,1]};const r=Xp(t,e,n,l.maxLevel),s=r.parentNO;return{url:l._getUrl(s.x,s.y,s.z),clipBounds:r.bounds}}function Xp(l,t,e,n){const r=e-n,s={x:l>>r,y:t>>r,z:e-r},a=Math.pow(2,r),c=Math.pow(.5,r),u=l%a/a-.5+c/2,d=t%a/a-.5+c/2,p=new m.Vector2(u,d),f=new m.Box2().setFromCenterAndSize(p,new m.Vector2(c,c)),y=[f.min.x+.5,f.min.y+.5,f.max.x+.5,f.max.y+.5];return{parentNO:s,bounds:y}}function ao(l,t,e,n,r=Fp){const{x:s,y:a}=l,c=(t+s/r)/Math.pow(2,n),u=(e+a/r)/Math.pow(2,n),d=c*360-180,f=Math.atan(Math.sinh(Kl*(1-2*u)))*180/Kl;return[parseFloat(d.toFixed(8)),parseFloat(f.toFixed(8))]}function kp(l,t,e,n){if(!l||!l.coordinates)throw new Error("无效的geometry数据格式");const r={type:l.type,coordinates:null};function s(a){if(typeof a=="object"&&a.x!==void 0&&a.y!==void 0)return ao(a,t,e,n);if(Array.isArray(a)&&a.length>0){const c=a[0];return typeof c=="object"&&c.x!==void 0&&c.y!==void 0?a.map(u=>ao(u,t,e,n)):a.map(u=>s(u))}return a}return r.coordinates=s(l.coordinates),r}class Ci{constructor(){T(this,"_imgSource",[]);T(this,"_demSource");T(this,"_vtSource");T(this,"manager",Xe.manager)}get imgSource(){return this._imgSource}set imgSource(t){this._imgSource=t}get demSource(){return this._demSource}set demSource(t){this._demSource=t}get vtSource(){return this._vtSource}set vtSource(t){this._vtSource=t}async load(t){const e=await this.loadGeometry(t),n=await this.loadMaterial(t);console.assert(!!n&&!!e);for(let r=0;r<n.length;r++)e.addGroup(0,1/0,r);return{materials:n,geometry:e}}unload(t){const e=t.material,n=t.geometry;for(let r=0;r<e.length;r++)e[r].dispose();n.dispose()}async loadGeometry(t){let e;if(this.demSource&&t.z>=this.demSource.minLevel&&this._isBoundsInSourceBounds(this.demSource,t.bounds)){const n=Xe.getGeometryLoader(this.demSource),r=this.demSource;e=await n.load({source:r,...t}).catch(s=>(console.error("Load material error",r.dataType,t.x,t.y,t.z),new m.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else if(this.vtSource&&t.z>=this.vtSource.minLevel&&this._isBoundsInSourceBounds(this.vtSource,t.bounds)){const n=Xe.getMeshLoader(this.vtSource),r=this.vtSource;e=await n.load({source:r,...t}).catch(s=>(console.error("Load geometry error",r.dataType,t.x,t.y,t.z),new m.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else e=new m.PlaneGeometry;return e}async loadMaterial(t){const n=this.imgSource.filter(r=>t.z>=r.minLevel&&this._isBoundsInSourceBounds(r,t.bounds)).map(async r=>{const s=Xe.getMaterialLoader(r),a=await s.load({source:r,...t}).catch(u=>(console.error("Load material error",r.dataType,t.x,t.y,t.z),new m.MeshBasicMaterial)),c=u=>{s.unload&&s.unload(u.target),u.target.removeEventListener("dispose",c)};return a instanceof m.MeshBasicMaterial||a.addEventListener("dispose",c),a});return Promise.all(n)}_isBoundsInSourceBounds(t,e){const n=t._projectionBounds;return!(e[2]<n[0]||e[3]<n[1]||e[0]>n[2]||e[1]>n[3])}}function Br(...l){const t=l,e=t&&t.length>1&&t[0].constructor||null;if(!e)throw new Error("concatenateTypedArrays - incorrect quantity of arguments or arguments have incompatible data types");const n=t.reduce((a,c)=>a+c.length,0),r=new e(n);let s=0;for(const a of t)r.set(a,s),s+=a.length;return r}function Rl(l,t,e,n){const r=n?zp(n,l.position.value):Dp(t),s=r.length,a=new Float32Array(s*6),c=new Float32Array(s*4),u=new t.constructor(s*6),d=new Float32Array(s*6);for(let f=0;f<s;f++)Op({edge:r[f],edgeIndex:f,attributes:l,skirtHeight:e,newPosition:a,newTexcoord0:c,newTriangles:u,newNormals:d});l.position.value=Br(l.position.value,a),l.texcoord.value=Br(l.texcoord.value,c),l.normal.value=Br(l.normal.value,d);const p=Br(t,u);return{attributes:l,indices:p}}function Dp(l){const t=[],e=Array.isArray(l)?l:Array.from(l);for(let r=0;r<e.length;r+=3){const s=e[r],a=e[r+1],c=e[r+2];t.push([s,a],[a,c],[c,s])}t.sort(([r,s],[a,c])=>{const u=Math.min(r,s),d=Math.min(a,c);return u!==d?u-d:Math.max(r,s)-Math.max(a,c)});const n=[];for(let r=0;r<t.length;r++)r+1<t.length&&t[r][0]===t[r+1][1]&&t[r][1]===t[r+1][0]?r++:n.push(t[r]);return n}function zp(l,t){const e=(r,s)=>{r.sort(s)};e(l.westIndices,(r,s)=>t[3*r+1]-t[3*s+1]),e(l.eastIndices,(r,s)=>t[3*s+1]-t[3*r+1]),e(l.southIndices,(r,s)=>t[3*s]-t[3*r]),e(l.northIndices,(r,s)=>t[3*r]-t[3*s]);const n=[];return Object.values(l).forEach(r=>{if(r.length>1)for(let s=0;s<r.length-1;s++)n.push([r[s],r[s+1]])}),n}function Op({edge:l,edgeIndex:t,attributes:e,skirtHeight:n,newPosition:r,newTexcoord0:s,newTriangles:a,newNormals:c}){const u=e.position.value.length,d=t*2,p=d+1;r.set(e.position.value.subarray(l[0]*3,l[0]*3+3),d*3),r[d*3+2]=r[d*3+2]-n,r.set(e.position.value.subarray(l[1]*3,l[1]*3+3),p*3),r[p*3+2]=r[p*3+2]-n,s.set(e.texcoord.value.subarray(l[0]*2,l[0]*2+2),d*2),s.set(e.texcoord.value.subarray(l[1]*2,l[1]*2+2),p*2);const f=t*2*3;a[f]=l[0],a[f+1]=u/3+p,a[f+2]=l[1],a[f+3]=u/3+p,a[f+4]=l[0],a[f+5]=u/3+d,c[f]=0,c[f+1]=0,c[f+2]=1,c[f+3]=0,c[f+4]=0,c[f+5]=1}function Yl(l){if(l.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${l.length}!`);const t=Math.floor(Math.sqrt(l.length)),e=t,n=t,r=lo(n,e);return{attributes:Kp(l,n,e),indices:r}}function Kp(l,t,e){const n=e*t,r=new Float32Array(n*3),s=new Float32Array(n*2);let a=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const d=u/(e-1),p=c/(t-1);s[a*2]=d,s[a*2+1]=p,r[a*3]=d-.5,r[a*3+1]=p-.5,r[a*3+2]=l[(t-c-1)*e+u],a++}return{position:{value:r,size:3},texcoord:{value:s,size:2},normal:{value:co(r,lo(t,e)),size:3}}}function lo(l,t){const e=6*(t-1)*(l-1),n=new Uint16Array(e);let r=0;for(let s=0;s<l-1;s++)for(let a=0;a<t-1;a++){const c=s*t+a,u=c+1,d=c+t,p=d+1,f=r*6;n[f]=c,n[f+1]=u,n[f+2]=d,n[f+3]=d,n[f+4]=u,n[f+5]=p,r++}return n}function co(l,t){const e=new Float32Array(l.length);for(let n=0;n<t.length;n+=3){const r=t[n]*3,s=t[n+1]*3,a=t[n+2]*3,c=l[r],u=l[r+1],d=l[r+2],p=l[s],f=l[s+1],y=l[s+2],v=l[a],x=l[a+1],L=l[a+2],_=p-c,S=f-u,Z=y-d,G=v-c,A=x-u,K=L-d,D=S*K-Z*A,O=Z*G-_*K,V=_*A-S*G,R=Math.sqrt(D*D+O*O+V*V),W=[0,0,1];if(R>0){const k=1/R;W[0]=D*k,W[1]=O*k,W[2]=V*k}for(let k=0;k<3;k++)e[r+k]=e[s+k]=e[a+k]=W[k]}return e}class fr extends m.PlaneGeometry{constructor(){super(...arguments);T(this,"type","TileGeometry")}setData(e,n=1e3){let r=e instanceof Float32Array?Yl(e):e;r=Rl(r.attributes,r.indices,n);const{attributes:s,indices:a}=r;return this.setIndex(new m.BufferAttribute(a,1)),this.setAttribute("position",new m.BufferAttribute(s.position.value,s.position.size)),this.setAttribute("uv",new m.BufferAttribute(s.texcoord.value,s.texcoord.size)),this.setAttribute("normal",new m.BufferAttribute(s.normal.value,s.normal.size)),this.computeBoundingBox(),this.computeBoundingSphere(),this}}class Ul{constructor(t=257){T(this,"gridSize");T(this,"numTriangles");T(this,"numParentTriangles");T(this,"indices");T(this,"coords");this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let r=n+2,s=0,a=0,c=0,u=0,d=0,p=0;for(r&1?c=u=d=e:s=a=p=e;(r>>=1)>1;){const y=s+c>>1,v=a+u>>1;r&1?(c=s,u=a,s=d,a=p):(s=c,a=u,c=d,u=p),d=y,p=v}const f=n*4;this.coords[f+0]=s,this.coords[f+1]=a,this.coords[f+2]=c,this.coords[f+3]=u}}createTile(t){return new Rp(t,this)}}class Rp{constructor(t,e){T(this,"martini");T(this,"terrain");T(this,"errors");const n=e.gridSize;if(t.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:n,gridSize:r}=this.martini,{terrain:s,errors:a}=this;for(let c=t-1;c>=0;c--){const u=c*4,d=n[u+0],p=n[u+1],f=n[u+2],y=n[u+3],v=d+f>>1,x=p+y>>1,L=v+x-p,_=x+d-v,S=(s[p*r+d]+s[y*r+f])/2,Z=x*r+v,G=Math.abs(S-s[Z]);if(a[Z]=Math.max(a[Z],G),c<e){const A=(p+_>>1)*r+(d+L>>1),K=(y+_>>1)*r+(f+L>>1);a[Z]=Math.max(a[Z],a[A],a[K])}}}getGeometryData(t=0){const{gridSize:e,indices:n}=this.martini,{errors:r}=this;let s=0,a=0;const c=e-1;let u,d,p=0;n.fill(0);function f(Z,G,A,K,D,O){const V=Z+A>>1,R=G+K>>1;Math.abs(Z-D)+Math.abs(G-O)>1&&r[R*e+V]>t?(f(D,O,Z,G,V,R),f(A,K,D,O,V,R)):(u=G*e+Z,d=K*e+A,p=O*e+D,n[u]===0&&(n[u]=++s),n[d]===0&&(n[d]=++s),n[p]===0&&(n[p]=++s),a++)}f(0,0,c,c,c,0),f(c,c,0,0,0,c);const y=s*2,v=a*3,x=new Uint16Array(y),L=new Uint32Array(v);let _=0;function S(Z,G,A,K,D,O){const V=Z+A>>1,R=G+K>>1;if(Math.abs(Z-D)+Math.abs(G-O)>1&&r[R*e+V]>t)S(D,O,Z,G,V,R),S(A,K,D,O,V,R);else{const W=n[G*e+Z]-1,k=n[K*e+A]-1,N=n[O*e+D]-1;x[2*W]=Z,x[2*W+1]=G,x[2*k]=A,x[2*k+1]=K,x[2*N]=D,x[2*N+1]=O,L[_++]=W,L[_++]=k,L[_++]=N}}return S(0,0,c,c,c,0),S(c,c,0,0,0,c),{attributes:this._getMeshAttributes(this.terrain,x,L),indices:L}}_getMeshAttributes(t,e,n){const r=Math.floor(Math.sqrt(t.length)),s=r-1,a=e.length/2,c=new Float32Array(a*3),u=new Float32Array(a*2);for(let p=0;p<a;p++){const f=e[p*2],y=e[p*2+1],v=y*r+f;c[3*p+0]=f/s-.5,c[3*p+1]=.5-y/s,c[3*p+2]=t[v],u[2*p+0]=f/s,u[2*p+1]=1-y/s}const d=co(c,n);return{position:{value:c,size:3},texcoord:{value:u,size:2},normal:{value:d,size:3}}}}class uo{constructor(){T(this,"info",{version:"0.10.0",description:"Terrain loader base class"});T(this,"dataType","")}async load(t){const{source:e,x:n,y:r,z:s}=t,{url:a,clipBounds:c}=oo(e,n,r,s);if(!a)return new fr;const u=await this.doLoad(a,{source:e,x:n,y:r,z:s,bounds:c});return Xe.manager.parseEnd(a),u}}class ho extends m.MeshStandardMaterial{constructor(t={}){super({transparent:!0,side:m.FrontSide,...t})}setTexture(t){this.map=t,this.needsUpdate=!0}dispose(){const t=this.map;t&&(t.image instanceof ImageBitmap&&t.image.close(),t.dispose())}}var tt=(l=>(l[l.Unknown=0]="Unknown",l[l.Point=1]="Point",l[l.Linestring=2]="Linestring",l[l.Polygon=3]="Polygon",l))(tt||{});class Bl{render(t,e,n,r,s=1){switch(t.lineCap="round",t.lineJoin="round",(r.shadowBlur??0)>0&&(t.shadowBlur=r.shadowBlur??2,t.shadowColor=r.shadowColor??"black",t.shadowOffsetX=r.shadowOffset?r.shadowOffset[0]:0,t.shadowOffsetY=r.shadowOffset?r.shadowOffset[1]:0),e){case tt.Point:t.textAlign="center",t.textBaseline="middle",t.font=r.font??"14px Arial",t.fillStyle=r.fontColor??"white",this._renderPointText(t,n,s,r.textField??"name",r.fontOffset??[0,-8]);break;case tt.Linestring:this._renderLineString(t,n,s);break;case tt.Polygon:this._renderPolygon(t,n,s);break;default:console.warn(`Unknown feature type: ${e}`)}(r.fill||e===tt.Point)&&(t.globalAlpha=r.fillOpacity||.5,t.fillStyle=r.fillColor||r.color||"#3388ff",t.fill(r.fillRule||"evenodd")),(r.stroke??!0)&&(r.weight??1)>0&&(t.globalAlpha=r.opacity||1,t.lineWidth=r.weight||1,t.strokeStyle=r.color||"#3388ff",t.setLineDash(r.dashArray||[]),t.stroke())}_renderPointText(t,e,n=1,r="name",s=[0,0]){const a=e.geometry;t.beginPath();for(const u of a)for(let d=0;d<u.length;d++){const p=u[d];t.arc(p.x*n,p.y*n,2,0,2*Math.PI)}const c=e.properties;c&&c[r]&&t.fillText(c[r],a[0][0].x*n+s[0],a[0][0].y*n+s[1])}_renderLineString(t,e,n){const r=e.geometry;t.beginPath();for(const s of r)for(let a=0;a<s.length;a++){const{x:c,y:u}=s[a];a===0?t.moveTo(c*n,u*n):t.lineTo(c*n,u*n)}}_renderPolygon(t,e,n){const r=e.geometry;t.beginPath();for(let s=0;s<r.length;s++){const a=r[s];for(let c=0;c<a.length;c++){const{x:u,y:d}=a[c];c===0?t.moveTo(u*n,d*n):t.lineTo(u*n,d*n)}t.closePath()}}}class fo{constructor(){T(this,"info",{version:"0.10.0",description:"Image loader base class"});T(this,"dataType","")}async load(t){const{source:e,x:n,y:r,z:s}=t,a=new ho,{url:c,clipBounds:u}=oo(e,n,r,s);if(c){const d=await this.doLoad(c,{source:e,x:n,y:r,z:s,bounds:u});a.map=d,Xe.manager.parseEnd(c)}return a}}class Yp{constructor(){T(this,"info",{version:"0.10.0",description:"Canvas tile abstract loader"});T(this,"dataType","")}async load(t){const e=this._creatCanvasContext(256,256);this.drawTile(e,t);const n=new m.CanvasTexture(e.canvas.transferToImageBitmap());return new ho({transparent:!0,map:n,opacity:t.source.opacity})}_creatCanvasContext(t,e){const r=new OffscreenCanvas(t,e).getContext("2d");if(!r)throw new Error("create canvas context failed");return r.scale(1,-1),r.translate(0,-e),r}}class Up extends fo{constructor(){super(...arguments);T(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."});T(this,"dataType","image");T(this,"loader",new m.ImageLoader(Xe.manager))}async doLoad(e,n){const r=await this.loader.loadAsync(e).catch(c=>new Image(1,1)),s=new m.Texture;s.colorSpace=m.SRGBColorSpace;const{bounds:a}=n;return a[2]-a[0]<1?s.image=Bp(r,a):s.image=r,s.needsUpdate=!0,s}}function Bp(l,t){const e=l.width,n=new OffscreenCanvas(e,e),r=n.getContext("2d"),{sx:s,sy:a,sw:c,sh:u}=so(t,l.width);return r.drawImage(l,s,a,c,u,0,0,e,e),n}const Np=`{
|
|
664
|
+
// 区域多边形外衣叠色(Ray casting 判定点是否在多边形内)
|
|
665
|
+
if (uRegionOverlayEnabled == 1 && uRegionOverlayOpacity > 0.0 && uRegionOverlayVertexCount >= 3) {
|
|
666
|
+
vec2 p = vec2(vWorldPosition.x, vWorldPosition.z);
|
|
667
|
+
bool inside = false;
|
|
668
|
+
int j = 0;
|
|
669
|
+
for (int i = 0; i < REGION_OVERLAY_MAX_VERTS; i++) {
|
|
670
|
+
if (i >= uRegionOverlayVertexCount) break;
|
|
671
|
+
if (i == 0) {
|
|
672
|
+
j = uRegionOverlayVertexCount - 1;
|
|
673
|
+
}
|
|
674
|
+
vec2 pi = uRegionOverlayVertices[i];
|
|
675
|
+
vec2 pj = uRegionOverlayVertices[j];
|
|
676
|
+
|
|
677
|
+
bool intersect = ((pi.y > p.y) != (pj.y > p.y)) &&
|
|
678
|
+
(p.x < (pj.x - pi.x) * (p.y - pi.y) / (pj.y - pi.y + 1e-6) + pi.x);
|
|
679
|
+
if (intersect) {
|
|
680
|
+
inside = !inside;
|
|
681
|
+
}
|
|
682
|
+
j = i;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (inside) {
|
|
686
|
+
diffuseColor.rgb = mix(
|
|
687
|
+
diffuseColor.rgb,
|
|
688
|
+
uRegionOverlayColor,
|
|
689
|
+
clamp(uRegionOverlayOpacity, 0.0, 1.0)
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
`)}setDiffusionFromObject(e){if(!this.shaderOption.effects?.diffusion)return;const n=new rt.Box3().setFromObject(e);if(n.isEmpty())return;const i=new rt.Vector3;n.getCenter(i);const s=[new rt.Vector3(n.min.x,n.min.y,n.min.z),new rt.Vector3(n.max.x,n.max.y,n.max.z)];let l=0;s.forEach(u=>{const c=i.distanceTo(u);c>l&&(l=c)}),this.shaderOption.effects.diffusion={...this.shaderOption.effects.diffusion,center:i,maxDistance:l},this.needsUpdate=!0}updateBoundingBox(e,n){this.shaderOption.minY=e,this.shaderOption.maxY=n,this.needsUpdate=!0}updateEffects(e){this.shaderOption.effects={...this.shaderOption.effects,...e},this.needsUpdate=!0}animate(){requestAnimationFrame(()=>this.animate()),this.time.value=this.clock.getElapsedTime(),this.startTime.value<1&&(this.startTime.value+=.01)}}const Ap={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class Ol extends ji{constructor(e){super(e);T(this,"_type","Model");T(this,"_emissive",!1);T(this,"_emissiveIntensity",1);T(this,"_emissiveColor","#ffffff");T(this,"_mixer",null);T(this,"_currentAction",null);T(this,"_animations",[]);T(this,"_clock",new m.Clock);T(this,"_autoUpdate",!0);T(this,"_animationRequestId",null);T(this,"_iscity",!1);this._emissive=e.emissive||!1,this._emissiveIntensity=e.emissiveIntensity||1,this._emissiveColor=e.emissiveColor||"#ffffff",this.castShadow=e.castShadow||!1,this.receiveShadow=e.receiveShadow||!1,this._iscity=e.iscity||!1}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this.modelunino=await this._createObject(this._style),this._threeGeometry=this.modelunino.model,this._threeGeometry.userData._type="Model",this.modelunino.animations&&this.modelunino.animations.length>0&&(this._animations=this.modelunino.animations,this._mixer=new m.AnimationMixer(this._threeGeometry),this._startAnimationLoop(),this.playAnimation({name:this._animations[0].name,loop:!0,speed:1.5,fadeInDuration:.5,fadeOutDuration:.3})),this._updateGeometry(),this.setShadows({cast:this.castShadow,receive:this.receiveShadow}),this._applyEmissionProperties(),this._iscity&&this._rendercity())}async _createObject(e){switch(e.config.type){case"fbx":case"gltf":return Yf(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_applyEmissionProperties(){this._threeGeometry&&this._threeGeometry.traverse(e=>{if("material"in e){const n=e.material;n&&(n.emissiveIntensity=this._emissive?this._emissiveIntensity:0,n.emissive&&n.emissive.setStyle(this._emissiveColor))}})}get emissive(){return this._emissive}set emissive(e){this._emissive=e,this._applyEmissionProperties()}get emissiveIntensity(){return this._emissiveIntensity}set emissiveIntensity(e){this._emissiveIntensity=e,this._applyEmissionProperties()}get emissiveColor(){return this._emissiveColor}set emissiveColor(e){this._emissiveColor=e,this._applyEmissionProperties()}setEmission(e,n,i){this._emissive=e,n!==void 0&&(this._emissiveIntensity=n),i!==void 0&&(this._emissiveColor=i),this._applyEmissionProperties()}async setShadows(e){this.castShadow=e.cast,this.receiveShadow=e.receive,this._threeGeometry&&this._threeGeometry.traverse(n=>{n.isMesh&&n.material&&(n.castShadow=e.cast,n.receiveShadow=e.receive)})}playAnimation(e){if(!this._mixer||this._animations.length===0){console.warn("模型没有可用的动画");return}this._currentAction&&(e.fadeOutDuration&&e.fadeOutDuration>0?this._currentAction.fadeOut(e.fadeOutDuration):this._currentAction.stop());const n=typeof e.name=="number"?this._animations[e.name]:this._animations.find(i=>i.name===e.name);if(!n){console.warn(`找不到动画: ${e.name}`);return}this._currentAction=this._mixer.clipAction(n),this._currentAction.setLoop(e.loop?m.LoopRepeat:m.LoopOnce,e.loop?1/0:1),this._currentAction.timeScale=e.speed||1,this._currentAction.time=e.startAt||0,this._currentAction.setEffectiveWeight(e.weight||1),e.fadeInDuration&&e.fadeInDuration>0&&this._currentAction.fadeIn(e.fadeInDuration),this._currentAction.play(),this._autoUpdate&&this._animationRequestId===null&&this._startAnimationLoop()}stopAnimation(e={}){this._currentAction&&(e.fadeDuration&&e.fadeDuration>0?(this._currentAction.fadeOut(e.fadeDuration),setTimeout(()=>{this._currentAction&&(this._currentAction.stop(),this._currentAction=null)},e.fadeDuration*1e3)):(this._currentAction.stop(),this._currentAction=null))}setAnimationPaused(e){this._currentAction&&(this._currentAction.paused=e.paused)}setAnimationSpeed(e){this._currentAction&&(this._currentAction.timeScale=e.speed)}updateAnimation(e){this._mixer&&this._mixer.update(e.deltaTime)}getAnimationNames(){return this._animations.map(e=>e.name)}getCurrentAnimationName(){return this._currentAction?this._currentAction.getClip().name:null}getAnimationDuration(e){let n;return typeof e.name=="number"?n=this._animations[e.name]:n=this._animations.find(i=>i.name===e.name),n?n.duration:null}dispose(){this._stopAnimationLoop(),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._threeGeometry)),super.dispose()}_startAnimationLoop(){if(!this._autoUpdate||this._animationRequestId!==null)return;const e=()=>{if(this._mixer){const n=this._clock.getDelta();this._mixer.update(n)}this._animationRequestId=requestAnimationFrame(e)};this._clock.start(),this._animationRequestId=requestAnimationFrame(e)}_stopAnimationLoop(){this._animationRequestId!==null&&(cancelAnimationFrame(this._animationRequestId),this._animationRequestId=null),this._clock.stop()}setAutoUpdate(e){this._autoUpdate=e,e?this._startAnimationLoop():this._stopAnimationLoop()}_computeOverlayVertices(e){const n=e.feature;if(n&&Array.isArray(n._vertexPoints)&&n._vertexPoints.length>=6){const d=n.getMap?.()||this.getMap();if(d&&d.prjcenter){const p=d.prjcenter,f=n._vertexPoints,y=[];for(let v=0;v+2<f.length;v+=3){const x=f[v],S=f[v+2],_=p.x+x,Z=p.z+S;y.push(new m.Vector2(_,Z))}if(y.length>=3)return y}}const i=this.getMap();if(!i||!e.geometry)return null;const s=e.geometry;let l;if(s.type==="Polygon")l=s.coordinates;else if(s.type==="MultiPolygon"){if(!s.coordinates.length)return null;l=s.coordinates[0]}else return null;if(!l.length||!l[0].length)return null;const u=l[0],c=[];for(const d of u){const p=d[0],f=d[1],y=i.geo2world(new m.Vector3(p,f,0));c.push(new m.Vector2(y.x,y.z))}return c.length<3?null:c}_rendercity(){const e=this.getLayer();let n=null;if(e&&e.getRegionOverlays){const i=e.getRegionOverlays()||[];if(i.length){const s=i.filter(u=>(u.mode??"overlay")==="overlay").sort((u,c)=>(u.zIndex??0)-(c.zIndex??0)),l=s[s.length-1];if(l&&(l.geometry||l.feature)){const u=this._computeOverlayVertices(l);u&&u.length>=3&&(n={color:new m.Color(l.color??"#00FF88"),opacity:l.opacity??.3,vertices:u})}}}this.traverse(async i=>{if(i instanceof m.Mesh&&i.material){if(i.castShadow=!0,i.name==="building"){const s=new Vp({color:new m.Color("#6BA7EC").multiplyScalar(1.8),opacity:.9,shaderOption:{minY:0,maxY:50,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!0,color:new m.Color("#FFFFF"),width:300,speed:.05},flow:{enabled:!1,color:new m.Color("#FFFFF"),range:1e3,speed:3e3},sweep:{enabled:!0,color:new m.Color("#ffffff"),width:3,speed:5}}},regionOverlay:n||void 0}),l=new m.Box3().setFromObject(i);s.updateBoundingBox(l.min.y,l.max.y),s.setDiffusionFromObject(i),i.material=s,i.material.needsUpdate=!0}i.name==="grass"&&(i.castShadow=!1,i.receiveShadow=!0,i.material.color=new m.Color("#81e4d8ff)").multiplyScalar(.7),i.material.metalness=.2,i.material.roughness=.8,["metalnessMap","normalMap","roughnessMap","specularColorMap"].forEach(s=>{const l=i.material[s];l&&(l.wrapS=l.wrapT=m.RepeatWrapping,l.repeat.set(.3,.3),l.needsUpdate=!0)}),i.material.normalScale=new m.Vector2(3,3))}})}}Ol.mergeOptions(Ap);const Fp={};class Rl extends ji{constructor(e){super(e);T(this,"_type","Cloud")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._disposeGeometry();const e=this.getLayer();this._threeGeometry&&(this._threeGeometry.position.copy(this._position),e&&(e._clouds.add(this._threeGeometry),e._clouds.updateMatrixWorld()))}async _createObject(e){switch(e.config.type){case"cloud":return Jf(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Rl.mergeOptions(Fp);const Xp={};class Kl extends ji{constructor(e){super(e);T(this,"_type","Label")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"canvas-label-fixed":return Hf(e.config,new m.Vector3(0,0,0),this.getMap());case"canvas-label":return Qf(e.config,new m.Vector3(0,0,0));default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Kl.mergeOptions(Xp);const zp={};class Yl extends ji{constructor(e){super(e);T(this,"_type","TPoints");T(this,"_geometries");this._geometries=e.geometries}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._threeGeometry&&(this._threeGeometry.points&&this.add(this._threeGeometry.points),this._threeGeometry.InstancedCol&&this.add(this._threeGeometry.InstancedCol),this.updateMatrixWorld(!0))}async _createObject(e){switch(e.config.type){case"light":return ep(e.config,this._geometries,this.getMap());default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Yl.mergeOptions(zp);function Ir(a,t){if(!a||a===!0)return!0;if(!Array.isArray(a))return!!a;switch(a[0]){case"all":return a.slice(1).every(n=>Ir(n,t));case"any":return a.slice(1).some(n=>Ir(n,t));case"!":return!Ir(a[1],t);case"==":{const n=st(a[1],t),i=st(a[2],t);return Cr(n)==Cr(i)}case"!=":{const n=st(a[1],t),i=st(a[2],t);return Cr(n)!=Cr(i)}case">":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)>Tn(i)}case"<":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)<Tn(i)}case">=":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)>=Tn(i)}case"<=":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)<=Tn(i)}case"in":{const n=st(a[1],t);return a.slice(2).map(s=>st(s,t)).includes(n)}case"!in":{const n=st(a[1],t);return!a.slice(2).map(s=>st(s,t)).includes(n)}case"has":{const n=a[1];return t!=null&&Object.prototype.hasOwnProperty.call(t,n)}case"!has":{const n=a[1];return!(t!=null&&Object.prototype.hasOwnProperty.call(t,n))}default:return!0}}function st(a,t){if(Array.isArray(a))switch(a[0]){case"get":return t?t[a[1]]:void 0;default:return a}return a}function Cr(a){if(a==null)return null;if(typeof a=="string"){const t=Number(a);if(!isNaN(t)&&a.trim()!=="")return t}return typeof a=="boolean"?a?1:0:a}function Tn(a){if(a==null)return 0;if(typeof a=="number")return a;if(typeof a=="boolean")return a?1:0;if(typeof a=="string"){const t=Number(a);return isNaN(t)?0:t}return Number(a)}class lo extends Bn{constructor(e,n){super(e,n);T(this,"TILE_SIZE");T(this,"EXTENT");T(this,"style");T(this,"_tileFeatureMap",new Map);T(this,"_activeFeatureFilter");this.TILE_SIZE=n.tileSize??256,this.EXTENT=n.extent??4096,this.style=n.style||[],this._onMapUpdate=this._onMapUpdate.bind(this)}processTileData(e,n){const i=this.getMap(),s=`${e.z}-${e.x}-${e.y}`,l=this._tileFeatureMap.get(s);if(l&&l.length>0){l.forEach(p=>{p.visible=!0,this.children.some(f=>f&&p&&f.uuid===p.uuid)||p.addTo(this)});return}const u=n.vectorData;if(!u||!u.layers||!i||this.style.length===0)return;const c=[],d=this.style;Object.keys(u.layers).forEach(p=>{const f=u.layers[p];for(let y=0;y<f.length;y++){const v=f[y],x=v.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(v.properties))continue;let S=null;for(const _ of d)if(this._evaluateFilter(_.filter,v.properties,p,v.geometry.type)){S=_.style;break}if(S){const _={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:x,extent:this.EXTENT,tileSize:this.TILE_SIZE},Z=this._createFeatureInstance(v.geometry,v.geometry.type,S,v.properties);Z&&(Z.userData.tileData=_,Z.style=Wt.create(S),Z.addTo(this),Z.initializeGeometry(),c.push(Z))}}}),this._tileFeatureMap.set(s,c)}_evaluateFilter(e,n,i,s){if(!e||e===!0)return!0;const l={...n,$layer:i,$type:s};return Ir(e,l)}hideFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&n.forEach(i=>{i.visible=!1})}removeFeaturesByTileKey(e){this._removeFeaturesByTileKey(e)}_removeFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&(n.forEach(i=>{i._remove()}),this._tileFeatureMap.delete(e))}_createFeatureInstance(e,n,i,s){const u={geometry:{ismvt:!0,...e},style:i,userData:s};switch(n){case"Point":return new so(u);case"LineString":return new oo(u);default:return null}}setFeatureFilter(e){this._activeFeatureFilter=e}clearFeatureFilter(){this._activeFeatureFilter=void 0}setOpacity(e){this.opacity=e,this._tileFeatureMap.forEach(n=>{n.forEach(i=>{i.material&&(i.material.opacity=e,i.material.transparent=e<1)})})}_onMapUpdate(){}validateFeature(e){return e instanceof hn}dispose(){this._tileFeatureMap.forEach((e,n)=>{this._removeFeaturesByTileKey(n)}),super.dispose()}}class Ul extends Tr{constructor(e,n){super(e,n);T(this,"isTileLayer",!0);T(this,"layerType","base");T(this,"isBaseLayer",!1);T(this,"_enabled",!0);T(this,"_visible",!0);T(this,"_rootTile");T(this,"_loader");T(this,"_LODThreshold",1);T(this,"isSceneLayer",!1);T(this,"opacity",1);T(this,"source");T(this,"projection");T(this,"minLevel",2);T(this,"maxLevel",19);this.layerId=e,this.source=n.source,this.projection=n.projection,this.minLevel=n.minLevel??2,this.maxLevel=n.maxLevel??19,this._LODThreshold=n.LODThreshold??1,this.opacity=n.opacity??1,this.name=`Layer-${e}`,this._loader=this.createLoader(),this._rootTile=new nn,this._rootTile.matrixAutoUpdate=!0,this._rootTile.scale.set(this.projection.mapWidth,this.projection.mapHeight,1),this.add(this._rootTile),this._rootTile.updateMatrix(),this.layerId=e,this.name==="Layer-label-layer"&&this.position.set(0,0,1)}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}get loader(){return this._loader}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._rootTile&&(this._rootTile.visible=e&&this._visible)}get ivisible(){return this._visible&&super._visible}set ivisible(e){this._visible=e,this._rootTile&&(this._rootTile.visible=e&&this._enabled)}update(e){if(!(!this._enabled||!this._visible)){try{this._rootTile.update({camera:e,loader:this._loader,minLevel:this.minLevel,maxLevel:this.maxLevel,LODThreshold:this.LODThreshold})}catch{}console.groupEnd()}}_debugTileTree(){this._rootTile.traverse(e=>{e.isTile&&(e.loaded,e.visible,e.inFrustum,e.loaded)})}_getLODThreshold(){return 1}_getCurrentTileLevel(){let e=0;return this._rootTile.traverse(n=>{n.isTile&&n.loaded&&(e=Math.max(e,n.z))}),`最大层级: ${e}`}dispose(){this.remove(this._rootTile),this._rootTile.reload(this._loader)}reload(){this._rootTile.reload(this._loader)}setElevation(e){this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0)}raiseElevation(e){this.position.z+=e,this.updateMatrix(),this.updateMatrixWorld(!0)}getElevation(){return this.position.y}}class Bl extends m.LoadingManager{constructor(){super(...arguments);T(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const Xe={manager:new Bl,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(a){Xe.imgLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Zs.name},registerGeometryLoader(a){Xe.demLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Zs.name},registerMeshLoader(a){Xe.meshLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Zs.name},getMaterialLoader(a){const t=Xe.imgLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`},getGeometryLoader(a){const t=Xe.demLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`},getMeshLoader(a){const t=Xe.meshLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`}};class Dp{constructor(t){T(this,"worker");this.worker=t()}async run(t,e){return new Promise(n=>{this.worker.onmessage=i=>{n(i.data)},this.worker.postMessage(t,e)})}terminate(){this.worker.terminate()}}const kp=4096,Nl=Math.PI;function co(a,t){const e=Math.floor(a[0]*t),n=Math.floor(a[1]*t),i=Math.floor((a[2]-a[0])*t),s=Math.floor((a[3]-a[1])*t);return{sx:e,sy:n,sw:i,sh:s}}function uo(a,t,e,n){if(n<a.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=a.maxLevel)return{url:a._getUrl(t,e,n),clipBounds:[0,0,1,1]};const i=Op(t,e,n,a.maxLevel),s=i.parentNO;return{url:a._getUrl(s.x,s.y,s.z),clipBounds:i.bounds}}function Op(a,t,e,n){const i=e-n,s={x:a>>i,y:t>>i,z:e-i},l=Math.pow(2,i),u=Math.pow(.5,i),c=a%l/l-.5+u/2,d=t%l/l-.5+u/2,p=new m.Vector2(c,d),f=new m.Box2().setFromCenterAndSize(p,new m.Vector2(u,u)),y=[f.min.x+.5,f.min.y+.5,f.max.x+.5,f.max.y+.5];return{parentNO:s,bounds:y}}function ho(a,t,e,n,i=kp){const{x:s,y:l}=a,u=(t+s/i)/Math.pow(2,n),c=(e+l/i)/Math.pow(2,n),d=u*360-180,f=Math.atan(Math.sinh(Nl*(1-2*c)))*180/Nl;return[parseFloat(d.toFixed(8)),parseFloat(f.toFixed(8))]}function Rp(a,t,e,n){if(!a||!a.coordinates)throw new Error("无效的geometry数据格式");const i={type:a.type,coordinates:null};function s(l){if(typeof l=="object"&&l.x!==void 0&&l.y!==void 0)return ho(l,t,e,n);if(Array.isArray(l)&&l.length>0){const u=l[0];return typeof u=="object"&&u.x!==void 0&&u.y!==void 0?l.map(c=>ho(c,t,e,n)):l.map(c=>s(c))}return l}return i.coordinates=s(a.coordinates),i}class Vr{constructor(){T(this,"_imgSource",[]);T(this,"_demSource");T(this,"_vtSource");T(this,"manager",Xe.manager)}get imgSource(){return this._imgSource}set imgSource(t){this._imgSource=t}get demSource(){return this._demSource}set demSource(t){this._demSource=t}get vtSource(){return this._vtSource}set vtSource(t){this._vtSource=t}async load(t){const e=await this.loadGeometry(t),n=await this.loadMaterial(t);console.assert(!!n&&!!e);for(let i=0;i<n.length;i++)e.addGroup(0,1/0,i);return{materials:n,geometry:e}}unload(t){const e=t.material,n=t.geometry;for(let i=0;i<e.length;i++)e[i].dispose();n.dispose()}async loadGeometry(t){let e;if(this.demSource&&t.z>=this.demSource.minLevel&&this._isBoundsInSourceBounds(this.demSource,t.bounds)){const n=Xe.getGeometryLoader(this.demSource),i=this.demSource;e=await n.load({source:i,...t}).catch(s=>(console.error("Load material error",i.dataType,t.x,t.y,t.z),new m.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else if(this.vtSource&&t.z>=this.vtSource.minLevel&&this._isBoundsInSourceBounds(this.vtSource,t.bounds)){const n=Xe.getMeshLoader(this.vtSource),i=this.vtSource;e=await n.load({source:i,...t}).catch(s=>(console.error("Load geometry error",i.dataType,t.x,t.y,t.z),new m.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else e=new m.PlaneGeometry;return e}async loadMaterial(t){const n=this.imgSource.filter(i=>t.z>=i.minLevel&&this._isBoundsInSourceBounds(i,t.bounds)).map(async i=>{const s=Xe.getMaterialLoader(i),l=await s.load({source:i,...t}).catch(c=>(console.error("Load material error",i.dataType,t.x,t.y,t.z),new m.MeshBasicMaterial)),u=c=>{s.unload&&s.unload(c.target),c.target.removeEventListener("dispose",u)};return l instanceof m.MeshBasicMaterial||l.addEventListener("dispose",u),l});return Promise.all(n)}_isBoundsInSourceBounds(t,e){const n=t._projectionBounds;return!(e[2]<n[0]||e[3]<n[1]||e[0]>n[2]||e[1]>n[3])}}function Ji(...a){const t=a,e=t&&t.length>1&&t[0].constructor||null;if(!e)throw new Error("concatenateTypedArrays - incorrect quantity of arguments or arguments have incompatible data types");const n=t.reduce((l,u)=>l+u.length,0),i=new e(n);let s=0;for(const l of t)i.set(l,s),s+=l.length;return i}function jl(a,t,e,n){const i=n?Yp(n,a.position.value):Kp(t),s=i.length,l=new Float32Array(s*6),u=new Float32Array(s*4),c=new t.constructor(s*6),d=new Float32Array(s*6);for(let f=0;f<s;f++)Up({edge:i[f],edgeIndex:f,attributes:a,skirtHeight:e,newPosition:l,newTexcoord0:u,newTriangles:c,newNormals:d});a.position.value=Ji(a.position.value,l),a.texcoord.value=Ji(a.texcoord.value,u),a.normal.value=Ji(a.normal.value,d);const p=Ji(t,c);return{attributes:a,indices:p}}function Kp(a){const t=[],e=Array.isArray(a)?a:Array.from(a);for(let i=0;i<e.length;i+=3){const s=e[i],l=e[i+1],u=e[i+2];t.push([s,l],[l,u],[u,s])}t.sort(([i,s],[l,u])=>{const c=Math.min(i,s),d=Math.min(l,u);return c!==d?c-d:Math.max(i,s)-Math.max(l,u)});const n=[];for(let i=0;i<t.length;i++)i+1<t.length&&t[i][0]===t[i+1][1]&&t[i][1]===t[i+1][0]?i++:n.push(t[i]);return n}function Yp(a,t){const e=(i,s)=>{i.sort(s)};e(a.westIndices,(i,s)=>t[3*i+1]-t[3*s+1]),e(a.eastIndices,(i,s)=>t[3*s+1]-t[3*i+1]),e(a.southIndices,(i,s)=>t[3*s]-t[3*i]),e(a.northIndices,(i,s)=>t[3*i]-t[3*s]);const n=[];return Object.values(a).forEach(i=>{if(i.length>1)for(let s=0;s<i.length-1;s++)n.push([i[s],i[s+1]])}),n}function Up({edge:a,edgeIndex:t,attributes:e,skirtHeight:n,newPosition:i,newTexcoord0:s,newTriangles:l,newNormals:u}){const c=e.position.value.length,d=t*2,p=d+1;i.set(e.position.value.subarray(a[0]*3,a[0]*3+3),d*3),i[d*3+2]=i[d*3+2]-n,i.set(e.position.value.subarray(a[1]*3,a[1]*3+3),p*3),i[p*3+2]=i[p*3+2]-n,s.set(e.texcoord.value.subarray(a[0]*2,a[0]*2+2),d*2),s.set(e.texcoord.value.subarray(a[1]*2,a[1]*2+2),p*2);const f=t*2*3;l[f]=a[0],l[f+1]=c/3+p,l[f+2]=a[1],l[f+3]=c/3+p,l[f+4]=a[0],l[f+5]=c/3+d,u[f]=0,u[f+1]=0,u[f+2]=1,u[f+3]=0,u[f+4]=0,u[f+5]=1}function Jl(a){if(a.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${a.length}!`);const t=Math.floor(Math.sqrt(a.length)),e=t,n=t,i=fo(n,e);return{attributes:Bp(a,n,e),indices:i}}function Bp(a,t,e){const n=e*t,i=new Float32Array(n*3),s=new Float32Array(n*2);let l=0;for(let u=0;u<t;u++)for(let c=0;c<e;c++){const d=c/(e-1),p=u/(t-1);s[l*2]=d,s[l*2+1]=p,i[l*3]=d-.5,i[l*3+1]=p-.5,i[l*3+2]=a[(t-u-1)*e+c],l++}return{position:{value:i,size:3},texcoord:{value:s,size:2},normal:{value:po(i,fo(t,e)),size:3}}}function fo(a,t){const e=6*(t-1)*(a-1),n=new Uint16Array(e);let i=0;for(let s=0;s<a-1;s++)for(let l=0;l<t-1;l++){const u=s*t+l,c=u+1,d=u+t,p=d+1,f=i*6;n[f]=u,n[f+1]=c,n[f+2]=d,n[f+3]=d,n[f+4]=c,n[f+5]=p,i++}return n}function po(a,t){const e=new Float32Array(a.length);for(let n=0;n<t.length;n+=3){const i=t[n]*3,s=t[n+1]*3,l=t[n+2]*3,u=a[i],c=a[i+1],d=a[i+2],p=a[s],f=a[s+1],y=a[s+2],v=a[l],x=a[l+1],S=a[l+2],_=p-u,Z=f-c,M=y-d,G=v-u,A=x-c,R=S-d,D=Z*R-M*A,k=M*G-_*R,C=_*A-Z*G,K=Math.sqrt(D*D+k*k+C*C),I=[0,0,1];if(K>0){const z=1/K;I[0]=D*z,I[1]=k*z,I[2]=C*z}for(let z=0;z<3;z++)e[i+z]=e[s+z]=e[l+z]=I[z]}return e}class fi extends m.PlaneGeometry{constructor(){super(...arguments);T(this,"type","TileGeometry")}setData(e,n=1e3){let i=e instanceof Float32Array?Jl(e):e;i=jl(i.attributes,i.indices,n);const{attributes:s,indices:l}=i;return this.setIndex(new m.BufferAttribute(l,1)),this.setAttribute("position",new m.BufferAttribute(s.position.value,s.position.size)),this.setAttribute("uv",new m.BufferAttribute(s.texcoord.value,s.texcoord.size)),this.setAttribute("normal",new m.BufferAttribute(s.normal.value,s.normal.size)),this.computeBoundingBox(),this.computeBoundingSphere(),this}}class Ql{constructor(t=257){T(this,"gridSize");T(this,"numTriangles");T(this,"numParentTriangles");T(this,"indices");T(this,"coords");this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let i=n+2,s=0,l=0,u=0,c=0,d=0,p=0;for(i&1?u=c=d=e:s=l=p=e;(i>>=1)>1;){const y=s+u>>1,v=l+c>>1;i&1?(u=s,c=l,s=d,l=p):(s=u,l=c,u=d,c=p),d=y,p=v}const f=n*4;this.coords[f+0]=s,this.coords[f+1]=l,this.coords[f+2]=u,this.coords[f+3]=c}}createTile(t){return new Np(t,this)}}class Np{constructor(t,e){T(this,"martini");T(this,"terrain");T(this,"errors");const n=e.gridSize;if(t.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:n,gridSize:i}=this.martini,{terrain:s,errors:l}=this;for(let u=t-1;u>=0;u--){const c=u*4,d=n[c+0],p=n[c+1],f=n[c+2],y=n[c+3],v=d+f>>1,x=p+y>>1,S=v+x-p,_=x+d-v,Z=(s[p*i+d]+s[y*i+f])/2,M=x*i+v,G=Math.abs(Z-s[M]);if(l[M]=Math.max(l[M],G),u<e){const A=(p+_>>1)*i+(d+S>>1),R=(y+_>>1)*i+(f+S>>1);l[M]=Math.max(l[M],l[A],l[R])}}}getGeometryData(t=0){const{gridSize:e,indices:n}=this.martini,{errors:i}=this;let s=0,l=0;const u=e-1;let c,d,p=0;n.fill(0);function f(M,G,A,R,D,k){const C=M+A>>1,K=G+R>>1;Math.abs(M-D)+Math.abs(G-k)>1&&i[K*e+C]>t?(f(D,k,M,G,C,K),f(A,R,D,k,C,K)):(c=G*e+M,d=R*e+A,p=k*e+D,n[c]===0&&(n[c]=++s),n[d]===0&&(n[d]=++s),n[p]===0&&(n[p]=++s),l++)}f(0,0,u,u,u,0),f(u,u,0,0,0,u);const y=s*2,v=l*3,x=new Uint16Array(y),S=new Uint32Array(v);let _=0;function Z(M,G,A,R,D,k){const C=M+A>>1,K=G+R>>1;if(Math.abs(M-D)+Math.abs(G-k)>1&&i[K*e+C]>t)Z(D,k,M,G,C,K),Z(A,R,D,k,C,K);else{const I=n[G*e+M]-1,z=n[R*e+A]-1,N=n[k*e+D]-1;x[2*I]=M,x[2*I+1]=G,x[2*z]=A,x[2*z+1]=R,x[2*N]=D,x[2*N+1]=k,S[_++]=I,S[_++]=z,S[_++]=N}}return Z(0,0,u,u,u,0),Z(u,u,0,0,0,u),{attributes:this._getMeshAttributes(this.terrain,x,S),indices:S}}_getMeshAttributes(t,e,n){const i=Math.floor(Math.sqrt(t.length)),s=i-1,l=e.length/2,u=new Float32Array(l*3),c=new Float32Array(l*2);for(let p=0;p<l;p++){const f=e[p*2],y=e[p*2+1],v=y*i+f;u[3*p+0]=f/s-.5,u[3*p+1]=.5-y/s,u[3*p+2]=t[v],c[2*p+0]=f/s,c[2*p+1]=1-y/s}const d=po(u,n);return{position:{value:u,size:3},texcoord:{value:c,size:2},normal:{value:d,size:3}}}}class mo{constructor(){T(this,"info",{version:"0.10.0",description:"Terrain loader base class"});T(this,"dataType","")}async load(t){const{source:e,x:n,y:i,z:s}=t,{url:l,clipBounds:u}=uo(e,n,i,s);if(!l)return new fi;const c=await this.doLoad(l,{source:e,x:n,y:i,z:s,bounds:u});return Xe.manager.parseEnd(l),c}}class go extends m.MeshStandardMaterial{constructor(t={}){super({transparent:!0,side:m.FrontSide,...t})}setTexture(t){this.map=t,this.needsUpdate=!0}dispose(){const t=this.map;t&&(t.image instanceof ImageBitmap&&t.image.close(),t.dispose())}}var tt=(a=>(a[a.Unknown=0]="Unknown",a[a.Point=1]="Point",a[a.Linestring=2]="Linestring",a[a.Polygon=3]="Polygon",a))(tt||{});class Hl{render(t,e,n,i,s=1){switch(t.lineCap="round",t.lineJoin="round",(i.shadowBlur??0)>0&&(t.shadowBlur=i.shadowBlur??2,t.shadowColor=i.shadowColor??"black",t.shadowOffsetX=i.shadowOffset?i.shadowOffset[0]:0,t.shadowOffsetY=i.shadowOffset?i.shadowOffset[1]:0),e){case tt.Point:t.textAlign="center",t.textBaseline="middle",t.font=i.font??"14px Arial",t.fillStyle=i.fontColor??"white",this._renderPointText(t,n,s,i.textField??"name",i.fontOffset??[0,-8]);break;case tt.Linestring:this._renderLineString(t,n,s);break;case tt.Polygon:this._renderPolygon(t,n,s);break;default:console.warn(`Unknown feature type: ${e}`)}(i.fill||e===tt.Point)&&(t.globalAlpha=i.fillOpacity||.5,t.fillStyle=i.fillColor||i.color||"#3388ff",t.fill(i.fillRule||"evenodd")),(i.stroke??!0)&&(i.weight??1)>0&&(t.globalAlpha=i.opacity||1,t.lineWidth=i.weight||1,t.strokeStyle=i.color||"#3388ff",t.setLineDash(i.dashArray||[]),t.stroke())}_renderPointText(t,e,n=1,i="name",s=[0,0]){const l=e.geometry;t.beginPath();for(const c of l)for(let d=0;d<c.length;d++){const p=c[d];t.arc(p.x*n,p.y*n,2,0,2*Math.PI)}const u=e.properties;u&&u[i]&&t.fillText(u[i],l[0][0].x*n+s[0],l[0][0].y*n+s[1])}_renderLineString(t,e,n){const i=e.geometry;t.beginPath();for(const s of i)for(let l=0;l<s.length;l++){const{x:u,y:c}=s[l];l===0?t.moveTo(u*n,c*n):t.lineTo(u*n,c*n)}}_renderPolygon(t,e,n){const i=e.geometry;t.beginPath();for(let s=0;s<i.length;s++){const l=i[s];for(let u=0;u<l.length;u++){const{x:c,y:d}=l[u];u===0?t.moveTo(c*n,d*n):t.lineTo(c*n,d*n)}t.closePath()}}}class yo{constructor(){T(this,"info",{version:"0.10.0",description:"Image loader base class"});T(this,"dataType","")}async load(t){const{source:e,x:n,y:i,z:s}=t,l=new go,{url:u,clipBounds:c}=uo(e,n,i,s);if(u){const d=await this.doLoad(u,{source:e,x:n,y:i,z:s,bounds:c});l.map=d,Xe.manager.parseEnd(u)}return l}}class jp{constructor(){T(this,"info",{version:"0.10.0",description:"Canvas tile abstract loader"});T(this,"dataType","")}async load(t){const e=this._creatCanvasContext(256,256);this.drawTile(e,t);const n=new m.CanvasTexture(e.canvas.transferToImageBitmap());return new go({transparent:!0,map:n,opacity:t.source.opacity})}_creatCanvasContext(t,e){const i=new OffscreenCanvas(t,e).getContext("2d");if(!i)throw new Error("create canvas context failed");return i.scale(1,-1),i.translate(0,-e),i}}class Jp extends yo{constructor(){super(...arguments);T(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."});T(this,"dataType","image");T(this,"loader",new m.ImageLoader(Xe.manager))}async doLoad(e,n){const i=await this.loader.loadAsync(e).catch(u=>new Image(1,1)),s=new m.Texture;s.colorSpace=m.SRGBColorSpace;const{bounds:l}=n;return l[2]-l[0]<1?s.image=Qp(i,l):s.image=i,s.needsUpdate=!0,s}}function Qp(a,t){const e=a.width,n=new OffscreenCanvas(e,e),i=n.getContext("2d"),{sx:s,sy:l,sw:u,sh:c}=co(t,a.width);return i.drawImage(a,s,l,u,c,0,0,e,e),n}const Hp=`{
|
|
656
694
|
"name": "@terra.gl/core",
|
|
657
|
-
"version": "0.0.1-alpha.
|
|
695
|
+
"version": "0.0.1-alpha.18",
|
|
658
696
|
"type": "module",
|
|
659
697
|
"files": [
|
|
660
698
|
"dist"
|
|
@@ -698,10 +736,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
698
736
|
"dependencies": {
|
|
699
737
|
"@mapbox/vector-tile": "^2.0.4",
|
|
700
738
|
"@pmndrs/vanilla": "^1.20.4",
|
|
701
|
-
"@takram/three-atmosphere": "^0.11.2",
|
|
702
|
-
"@takram/three-clouds": "^0.2.2",
|
|
703
|
-
"@takram/three-geospatial": "^0.2.1",
|
|
704
|
-
"@takram/three-geospatial-effects": "^0.3.1",
|
|
705
739
|
"@types/earcut": "^3.0.0",
|
|
706
740
|
"@types/geojson": "^7946.0.16",
|
|
707
741
|
"d3-quadtree": "^3.0.1",
|
|
@@ -720,4 +754,4 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
720
754
|
"vue": "^3.5.18"
|
|
721
755
|
}
|
|
722
756
|
}
|
|
723
|
-
`;class Rt{constructor(t){T(this,"dataType","image");T(this,"attribution","isource");T(this,"minLevel",0);T(this,"maxLevel",18);T(this,"projectionID","3857");T(this,"url","");T(this,"subdomains",[]);T(this,"s","");T(this,"opacity",1);T(this,"isTMS",!1);T(this,"bounds",[-180,-85,180,85]);T(this,"_projectionBounds",[-1/0,-1/0,1/0,1/0]);T(this,"tileMaterial");Object.assign(this,t)}getUrl(t,e,n){const r={...this,x:t,y:e,z:n};return jp(this.url,r)}_getUrl(t,e,n){const r=this.subdomains.length;if(r>0){const a=Math.floor(Math.random()*r);this.s=this.subdomains[a]}const s=this.isTMS?Math.pow(2,n)-1-e:e;return this.getUrl(t,s,n)}static create(t){return new Rt(t)}}function jp(l,t){const e=/\{ *([\w_-]+) *\}/g;return l.replace(e,(n,r)=>{const s=t[r]??(()=>{throw new Error(`source url template error, No value provided for variable: ${n}`)})();return typeof s=="function"?s(t):s})}const{version:Jp,author:Qp}=JSON.parse(Np);function Hp(l,t=100){return new Promise(e=>{const n=setInterval(()=>{l&&(clearInterval(n),e())},t)})}function po(l){return Xe.registerMaterialLoader(l),l}function mo(l){return Xe.registerGeometryLoader(l),l}function Nl(l){return Xe.registerMeshLoader(l),l}po(new Up);const jl="dmFyIGNlPU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgbWU9KGosWixxKT0+WiBpbiBqP2NlKGosWix7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6cX0pOmpbWl09cTt2YXIgTj0oaixaLHEpPT5tZShqLHR5cGVvZiBaIT0ic3ltYm9sIj9aKyIiOloscSk7KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGooQSxwKXtjb25zdCBrPW5ldyBGbG9hdDMyQXJyYXkoQS5sZW5ndGgpO2ZvcihsZXQgVT0wO1U8cC5sZW5ndGg7VSs9Myl7Y29uc3QgYT1wW1VdKjMsZT1wW1UrMV0qMyxyPXBbVSsyXSozLHM9QVthXSx0PUFbYSsxXSxuPUFbYSsyXSxoPUFbZV0saT1BW2UrMV0sbz1BW2UrMl0sYz1BW3JdLHU9QVtyKzFdLG09QVtyKzJdLHc9aC1zLGw9aS10LGY9by1uLGc9Yy1zLE09dS10LFY9bS1uLGQ9bCpWLWYqTSx5PWYqZy13KlYsST13Kk0tbCpnLHo9TWF0aC5zcXJ0KGQqZCt5KnkrSSpJKSx4PVswLDAsMV07aWYoej4wKXtjb25zdCB2PTEvejt4WzBdPWQqdix4WzFdPXkqdix4WzJdPUkqdn1mb3IobGV0IHY9MDt2PDM7disrKWtbYSt2XT1rW2Urdl09a1tyK3ZdPXhbdl19cmV0dXJuIGt9Y2xhc3MgWntjb25zdHJ1Y3RvcihwPTI1Nyl7Tih0aGlzLCJncmlkU2l6ZSIpO04odGhpcywibnVtVHJpYW5nbGVzIik7Tih0aGlzLCJudW1QYXJlbnRUcmlhbmdsZXMiKTtOKHRoaXMsImluZG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yXS1BWzBdKSpwKSxlPU1hdGguZmxvb3IoKEFbM10tQVsxXSkqcCk7cmV0dXJue3N4Omssc3k6VSxzdzphLHNoOmV9fXNlbGYub25tZXNzYWdlPUE9Pntjb25zdCBwPUEuZGF0YSxrPXNlKHAuZGVtRGF0YSxwLnoscC5jbGlwQm91bmRzKTtzZWxmLnBvc3RNZXNzYWdlKGspfX0pKCk7Cg==",Ep=l=>Uint8Array.from(atob(l),t=>t.charCodeAt(0)),Jl=typeof self<"u"&&self.Blob&&new Blob([Ep(jl)],{type:"text/javascript;charset=utf-8"});function qp(l){let t;try{if(t=Jl&&(self.URL||self.webkitURL).createObjectURL(Jl),!t)throw"";const e=new Worker(t,{name:l?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+jl,{name:l?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}/* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */const $p=function(){var l={};l.defaultNoDataValue=-34027999387901484e22,l.decode=function(a,c){c=c||{};var u=c.encodedMaskData||c.encodedMaskData===null,d=r(a,c.inputOffset||0,u),p=c.noDataValue!==null?c.noDataValue:l.defaultNoDataValue,f=t(d,c.pixelType||Float32Array,c.encodedMaskData,p,c.returnMask),y={width:d.width,height:d.height,pixelData:f.resultPixels,minValue:f.minValue,maxValue:d.pixels.maxValue,noDataValue:p};return f.resultMask&&(y.maskData=f.resultMask),c.returnEncodedMask&&d.mask&&(y.encodedMaskData=d.mask.bitset?d.mask.bitset:null),c.returnFileInfo&&(y.fileInfo=e(d),c.computeUsedBitDepths&&(y.fileInfo.bitDepths=n(d))),y};var t=function(a,c,u,d,p){var f=0,y=a.pixels.numBlocksX,v=a.pixels.numBlocksY,x=Math.floor(a.width/y),L=Math.floor(a.height/v),_=2*a.maxZError,S=Number.MAX_VALUE,Z;u=u||(a.mask?a.mask.bitset:null);var G,A;G=new c(a.width*a.height),p&&u&&(A=new Uint8Array(a.width*a.height));for(var K=new Float32Array(x*L),D,O,V=0;V<=v;V++){var R=V!==v?L:a.height%v;if(R!==0)for(var W=0;W<=y;W++){var k=W!==y?x:a.width%y;if(k!==0){var N=V*a.width*L+W*x,H=a.width-k,j=a.pixels.blocks[f],q,J,oe;j.encoding<2?(j.encoding===0?q=j.rawData:(s(j.stuffedData,j.bitsPerPixel,j.numValidPixels,j.offset,_,K,a.pixels.maxValue),q=K),J=0):j.encoding===2?oe=0:oe=j.offset;var ie;if(u)for(O=0;O<R;O++){for(N&7&&(ie=u[N>>3],ie<<=N&7),D=0;D<k;D++)N&7||(ie=u[N>>3]),ie&128?(A&&(A[N]=1),Z=j.encoding<2?q[J++]:oe,S=S>Z?Z:S,G[N++]=Z):(A&&(A[N]=0),G[N++]=d),ie<<=1;N+=H}else if(j.encoding<2)for(O=0;O<R;O++){for(D=0;D<k;D++)Z=q[J++],S=S>Z?Z:S,G[N++]=Z;N+=H}else for(S=S>oe?oe:S,O=0;O<R;O++){for(D=0;D<k;D++)G[N++]=oe;N+=H}if(j.encoding===1&&J!==j.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:G,resultMask:A,minValue:S}},e=function(a){return{fileIdentifierString:a.fileIdentifierString,fileVersion:a.fileVersion,imageType:a.imageType,height:a.height,width:a.width,maxZError:a.maxZError,eofOffset:a.eofOffset,mask:a.mask?{numBlocksX:a.mask.numBlocksX,numBlocksY:a.mask.numBlocksY,numBytes:a.mask.numBytes,maxValue:a.mask.maxValue}:null,pixels:{numBlocksX:a.pixels.numBlocksX,numBlocksY:a.pixels.numBlocksY,numBytes:a.pixels.numBytes,maxValue:a.pixels.maxValue,noDataValue:a.noDataValue}}},n=function(a){for(var c=a.pixels.numBlocksX*a.pixels.numBlocksY,u={},d=0;d<c;d++){var p=a.pixels.blocks[d];p.encoding===0?u.float32=!0:p.encoding===1?u[p.bitsPerPixel]=!0:u[0]=!0}return Object.keys(u)},r=function(a,c,u){var d={},p=new Uint8Array(a,c,10);if(d.fileIdentifierString=String.fromCharCode.apply(null,p),d.fileIdentifierString.trim()!=="CntZImage")throw"Unexpected file identifier string: "+d.fileIdentifierString;c+=10;var f=new DataView(a,c,24);if(d.fileVersion=f.getInt32(0,!0),d.imageType=f.getInt32(4,!0),d.height=f.getUint32(8,!0),d.width=f.getUint32(12,!0),d.maxZError=f.getFloat64(16,!0),c+=24,!u)if(f=new DataView(a,c,16),d.mask={},d.mask.numBlocksY=f.getUint32(0,!0),d.mask.numBlocksX=f.getUint32(4,!0),d.mask.numBytes=f.getUint32(8,!0),d.mask.maxValue=f.getFloat32(12,!0),c+=16,d.mask.numBytes>0){var y=new Uint8Array(Math.ceil(d.width*d.height/8));f=new DataView(a,c,d.mask.numBytes);var v=f.getInt16(0,!0),x=2,L=0;do{if(v>0)for(;v--;)y[L++]=f.getUint8(x++);else{var _=f.getUint8(x++);for(v=-v;v--;)y[L++]=_}v=f.getInt16(x,!0),x+=2}while(x<d.mask.numBytes);if(v!==-32768||L<y.length)throw"Unexpected end of mask RLE encoding";d.mask.bitset=y,c+=d.mask.numBytes}else d.mask.numBytes|d.mask.numBlocksY|d.mask.maxValue||(d.mask.bitset=new Uint8Array(Math.ceil(d.width*d.height/8)));f=new DataView(a,c,16),d.pixels={},d.pixels.numBlocksY=f.getUint32(0,!0),d.pixels.numBlocksX=f.getUint32(4,!0),d.pixels.numBytes=f.getUint32(8,!0),d.pixels.maxValue=f.getFloat32(12,!0),c+=16;var S=d.pixels.numBlocksX,Z=d.pixels.numBlocksY,G=S+(d.width%S>0?1:0),A=Z+(d.height%Z>0?1:0);d.pixels.blocks=new Array(G*A);for(var K=0,D=0;D<A;D++)for(var O=0;O<G;O++){var V=0,R=a.byteLength-c;f=new DataView(a,c,Math.min(10,R));var W={};d.pixels.blocks[K++]=W;var k=f.getUint8(0);if(V++,W.encoding=k&63,W.encoding>3)throw"Invalid block encoding ("+W.encoding+")";if(W.encoding===2){c++;continue}if(k!==0&&k!==2){if(k>>=6,W.offsetType=k,k===2)W.offset=f.getInt8(1),V++;else if(k===1)W.offset=f.getInt16(1,!0),V+=2;else if(k===0)W.offset=f.getFloat32(1,!0),V+=4;else throw"Invalid block offset type";if(W.encoding===1)if(k=f.getUint8(V),V++,W.bitsPerPixel=k&63,k>>=6,W.numValidPixelsType=k,k===2)W.numValidPixels=f.getUint8(V),V++;else if(k===1)W.numValidPixels=f.getUint16(V,!0),V+=2;else if(k===0)W.numValidPixels=f.getUint32(V,!0),V+=4;else throw"Invalid valid pixel count type"}if(c+=V,W.encoding!==3){var N,H;if(W.encoding===0){var j=(d.pixels.numBytes-1)/4;if(j!==Math.floor(j))throw"uncompressed block has invalid length";N=new ArrayBuffer(j*4),H=new Uint8Array(N),H.set(new Uint8Array(a,c,j*4));var q=new Float32Array(N);W.rawData=q,c+=j*4}else if(W.encoding===1){var J=Math.ceil(W.numValidPixels*W.bitsPerPixel/8),oe=Math.ceil(J/4);N=new ArrayBuffer(oe*4),H=new Uint8Array(N),H.set(new Uint8Array(a,c,J)),W.stuffedData=new Uint32Array(N),c+=J}}}return d.eofOffset=c,d},s=function(a,c,u,d,p,f,y){var v=(1<<c)-1,x=0,L,_=0,S,Z,G=Math.ceil((y-d)/p),A=a.length*4-Math.ceil(c*u/8);for(a[a.length-1]<<=8*A,L=0;L<u;L++){if(_===0&&(Z=a[x++],_=32),_>=c)S=Z>>>_-c&v,_-=c;else{var K=c-_;S=(Z&v)<<K&v,Z=a[x++],_=32-K,S+=Z>>>_}f[L]=S<G?d+S*p:y}return f};return l}(),em=function(){var l={unstuff:function(r,s,a,c,u,d,p,f){var y=(1<<a)-1,v=0,x,L=0,_,S,Z,G,A=r.length*4-Math.ceil(a*c/8);if(r[r.length-1]<<=8*A,u)for(x=0;x<c;x++)L===0&&(S=r[v++],L=32),L>=a?(_=S>>>L-a&y,L-=a):(Z=a-L,_=(S&y)<<Z&y,S=r[v++],L=32-Z,_+=S>>>L),s[x]=u[_];else for(G=Math.ceil((f-d)/p),x=0;x<c;x++)L===0&&(S=r[v++],L=32),L>=a?(_=S>>>L-a&y,L-=a):(Z=a-L,_=(S&y)<<Z&y,S=r[v++],L=32-Z,_+=S>>>L),s[x]=_<G?d+_*p:f},unstuffLUT:function(r,s,a,c,u,d){var p=(1<<s)-1,f=0,y=0,v=0,x=0,L=0,_,S=[],Z=r.length*4-Math.ceil(s*a/8);r[r.length-1]<<=8*Z;var G=Math.ceil((d-c)/u);for(y=0;y<a;y++)x===0&&(_=r[f++],x=32),x>=s?(L=_>>>x-s&p,x-=s):(v=s-x,L=(_&p)<<v&p,_=r[f++],x=32-v,L+=_>>>x),S[y]=L<G?c+L*u:d;return S.unshift(c),S},unstuff2:function(r,s,a,c,u,d,p,f){var y=(1<<a)-1,v=0,x,L=0,_=0,S,Z,G;if(u)for(x=0;x<c;x++)L===0&&(Z=r[v++],L=32,_=0),L>=a?(S=Z>>>_&y,L-=a,_+=a):(G=a-L,S=Z>>>_&y,Z=r[v++],L=32-G,S|=(Z&(1<<G)-1)<<a-G,_=G),s[x]=u[S];else{var A=Math.ceil((f-d)/p);for(x=0;x<c;x++)L===0&&(Z=r[v++],L=32,_=0),L>=a?(S=Z>>>_&y,L-=a,_+=a):(G=a-L,S=Z>>>_&y,Z=r[v++],L=32-G,S|=(Z&(1<<G)-1)<<a-G,_=G),s[x]=S<A?d+S*p:f}return s},unstuffLUT2:function(r,s,a,c,u,d){var p=(1<<s)-1,f=0,y=0,v=0,x=0,L=0,_=0,S,Z=[],G=Math.ceil((d-c)/u);for(y=0;y<a;y++)x===0&&(S=r[f++],x=32,_=0),x>=s?(L=S>>>_&p,x-=s,_+=s):(v=s-x,L=S>>>_&p,S=r[f++],x=32-v,L|=(S&(1<<v)-1)<<s-v,_=v),Z[y]=L<G?c+L*u:d;return Z.unshift(c),Z},originalUnstuff:function(r,s,a,c){var u=(1<<a)-1,d=0,p,f=0,y,v,x,L=r.length*4-Math.ceil(a*c/8);for(r[r.length-1]<<=8*L,p=0;p<c;p++)f===0&&(v=r[d++],f=32),f>=a?(y=v>>>f-a&u,f-=a):(x=a-f,y=(v&u)<<x&u,v=r[d++],f=32-x,y+=v>>>f),s[p]=y;return s},originalUnstuff2:function(r,s,a,c){var u=(1<<a)-1,d=0,p,f=0,y=0,v,x,L;for(p=0;p<c;p++)f===0&&(x=r[d++],f=32,y=0),f>=a?(v=x>>>y&u,f-=a,y+=a):(L=a-f,v=x>>>y&u,x=r[d++],f=32-L,v|=(x&(1<<L)-1)<<a-L,y=L),s[p]=v;return s}},t={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(r){for(var s=65535,a=65535,c=r.length,u=Math.floor(c/2),d=0;u;){var p=u>=359?359:u;u-=p;do s+=r[d++]<<8,a+=s+=r[d++];while(--p);s=(s&65535)+(s>>>16),a=(a&65535)+(a>>>16)}return c&1&&(a+=s+=r[d]<<8),s=(s&65535)+(s>>>16),a=(a&65535)+(a>>>16),(a<<16|s)>>>0},readHeaderInfo:function(r,s){var a=s.ptr,c=new Uint8Array(r,a,6),u={};if(u.fileIdentifierString=String.fromCharCode.apply(null,c),u.fileIdentifierString.lastIndexOf("Lerc2",0)!==0)throw"Unexpected file identifier string (expect Lerc2 ): "+u.fileIdentifierString;a+=6;var d=new DataView(r,a,8),p=d.getInt32(0,!0);u.fileVersion=p,a+=4,p>=3&&(u.checksum=d.getUint32(4,!0),a+=4),d=new DataView(r,a,12),u.height=d.getUint32(0,!0),u.width=d.getUint32(4,!0),a+=8,p>=4?(u.numDims=d.getUint32(8,!0),a+=4):u.numDims=1,d=new DataView(r,a,40),u.numValidPixel=d.getUint32(0,!0),u.microBlockSize=d.getInt32(4,!0),u.blobSize=d.getInt32(8,!0),u.imageType=d.getInt32(12,!0),u.maxZError=d.getFloat64(16,!0),u.zMin=d.getFloat64(24,!0),u.zMax=d.getFloat64(32,!0),a+=40,s.headerInfo=u,s.ptr=a;var f,y;if(p>=3&&(y=p>=4?52:48,f=this.computeChecksumFletcher32(new Uint8Array(r,a-y,u.blobSize-14)),f!==u.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(r,s){var a=s.headerInfo,c=this.getDataTypeArray(a.imageType),u=a.numDims*this.getDataTypeSize(a.imageType),d=this.readSubArray(r,s.ptr,c,u),p=this.readSubArray(r,s.ptr+u,c,u);s.ptr+=2*u;var f,y=!0;for(f=0;f<a.numDims;f++)if(d[f]!==p[f]){y=!1;break}return a.minValues=d,a.maxValues=p,y},readSubArray:function(r,s,a,c){var u;if(a===Uint8Array)u=new Uint8Array(r,s,c);else{var d=new ArrayBuffer(c),p=new Uint8Array(d);p.set(new Uint8Array(r,s,c)),u=new a(d)}return u},readMask:function(r,s){var a=s.ptr,c=s.headerInfo,u=c.width*c.height,d=c.numValidPixel,p=new DataView(r,a,4),f={};if(f.numBytes=p.getUint32(0,!0),a+=4,(d===0||u===d)&&f.numBytes!==0)throw"invalid mask";var y,v;if(d===0)y=new Uint8Array(Math.ceil(u/8)),f.bitset=y,v=new Uint8Array(u),s.pixels.resultMask=v,a+=f.numBytes;else if(f.numBytes>0){y=new Uint8Array(Math.ceil(u/8)),p=new DataView(r,a,f.numBytes);var x=p.getInt16(0,!0),L=2,_=0,S=0;do{if(x>0)for(;x--;)y[_++]=p.getUint8(L++);else for(S=p.getUint8(L++),x=-x;x--;)y[_++]=S;x=p.getInt16(L,!0),L+=2}while(L<f.numBytes);if(x!==-32768||_<y.length)throw"Unexpected end of mask RLE encoding";v=new Uint8Array(u);var Z=0,G=0;for(G=0;G<u;G++)G&7?(Z=y[G>>3],Z<<=G&7):Z=y[G>>3],Z&128&&(v[G]=1);s.pixels.resultMask=v,f.bitset=y,a+=f.numBytes}return s.ptr=a,s.mask=f,!0},readDataOneSweep:function(r,s,a,c){var u=s.ptr,d=s.headerInfo,p=d.numDims,f=d.width*d.height,y=d.imageType,v=d.numValidPixel*t.getDataTypeSize(y)*p,x,L=s.pixels.resultMask;if(a===Uint8Array)x=new Uint8Array(r,u,v);else{var _=new ArrayBuffer(v),S=new Uint8Array(_);S.set(new Uint8Array(r,u,v)),x=new a(_)}if(x.length===f*p)c?s.pixels.resultPixels=t.swapDimensionOrder(x,f,p,a,!0):s.pixels.resultPixels=x;else{s.pixels.resultPixels=new a(f*p);var Z=0,G=0,A=0,K=0;if(p>1){if(c){for(G=0;G<f;G++)if(L[G])for(K=G,A=0;A<p;A++,K+=f)s.pixels.resultPixels[K]=x[Z++]}else for(G=0;G<f;G++)if(L[G])for(K=G*p,A=0;A<p;A++)s.pixels.resultPixels[K+A]=x[Z++]}else for(G=0;G<f;G++)L[G]&&(s.pixels.resultPixels[G]=x[Z++])}return u+=v,s.ptr=u,!0},readHuffmanTree:function(r,s){var a=this.HUFFMAN_LUT_BITS_MAX,c=new DataView(r,s.ptr,16);s.ptr+=16;var u=c.getInt32(0,!0);if(u<2)throw"unsupported Huffman version";var d=c.getInt32(4,!0),p=c.getInt32(8,!0),f=c.getInt32(12,!0);if(p>=f)return!1;var y=new Uint32Array(f-p);t.decodeBits(r,s,y);var v=[],x,L,_,S;for(x=p;x<f;x++)L=x-(x<d?0:d),v[L]={first:y[x-p],second:null};var Z=r.byteLength-s.ptr,G=Math.ceil(Z/4),A=new ArrayBuffer(G*4),K=new Uint8Array(A);K.set(new Uint8Array(r,s.ptr,Z));var D=new Uint32Array(A),O=0,V,R=0;for(V=D[0],x=p;x<f;x++)L=x-(x<d?0:d),S=v[L].first,S>0&&(v[L].second=V<<O>>>32-S,32-O>=S?(O+=S,O===32&&(O=0,R++,V=D[R])):(O+=S-32,R++,V=D[R],v[L].second|=V>>>32-O));var W=0,k=0,N=new e;for(x=0;x<v.length;x++)v[x]!==void 0&&(W=Math.max(W,v[x].first));W>=a?k=a:k=W;var H=[],j,q,J,oe,ie,te;for(x=p;x<f;x++)if(L=x-(x<d?0:d),S=v[L].first,S>0)if(j=[S,L],S<=k)for(q=v[L].second<<k-S,J=1<<k-S,_=0;_<J;_++)H[q|_]=j;else for(q=v[L].second,te=N,oe=S-1;oe>=0;oe--)ie=q>>>oe&1,ie?(te.right||(te.right=new e),te=te.right):(te.left||(te.left=new e),te=te.left),oe===0&&!te.val&&(te.val=j[1]);return{decodeLut:H,numBitsLUTQick:k,numBitsLUT:W,tree:N,stuffedData:D,srcPtr:R,bitPos:O}},readHuffman:function(r,s,a,c){var u=s.headerInfo,d=u.numDims,p=s.headerInfo.height,f=s.headerInfo.width,y=f*p,v=this.readHuffmanTree(r,s),x=v.decodeLut,L=v.tree,_=v.stuffedData,S=v.srcPtr,Z=v.bitPos,G=v.numBitsLUTQick,A=v.numBitsLUT,K=s.headerInfo.imageType===0?128:0,D,O,V,R=s.pixels.resultMask,W,k,N,H,j,q,J,oe=0;Z>0&&(S++,Z=0);var ie=_[S],te=s.encodeMode===1,me=new a(y*d),be=me,he;if(d<2||te){for(he=0;he<d;he++)if(d>1&&(be=new a(me.buffer,y*he,y),oe=0),s.headerInfo.numValidPixel===f*p)for(q=0,H=0;H<p;H++)for(j=0;j<f;j++,q++){if(O=0,W=ie<<Z>>>32-G,k=W,32-Z<G&&(W|=_[S+1]>>>64-Z-G,k=W),x[k])O=x[k][1],Z+=x[k][0];else for(W=ie<<Z>>>32-A,k=W,32-Z<A&&(W|=_[S+1]>>>64-Z-A,k=W),D=L,J=0;J<A;J++)if(N=W>>>A-J-1&1,D=N?D.right:D.left,!(D.left||D.right)){O=D.val,Z=Z+J+1;break}Z>=32&&(Z-=32,S++,ie=_[S]),V=O-K,te?(j>0?V+=oe:H>0?V+=be[q-f]:V+=oe,V&=255,be[q]=V,oe=V):be[q]=V}else for(q=0,H=0;H<p;H++)for(j=0;j<f;j++,q++)if(R[q]){if(O=0,W=ie<<Z>>>32-G,k=W,32-Z<G&&(W|=_[S+1]>>>64-Z-G,k=W),x[k])O=x[k][1],Z+=x[k][0];else for(W=ie<<Z>>>32-A,k=W,32-Z<A&&(W|=_[S+1]>>>64-Z-A,k=W),D=L,J=0;J<A;J++)if(N=W>>>A-J-1&1,D=N?D.right:D.left,!(D.left||D.right)){O=D.val,Z=Z+J+1;break}Z>=32&&(Z-=32,S++,ie=_[S]),V=O-K,te?(j>0&&R[q-1]?V+=oe:H>0&&R[q-f]?V+=be[q-f]:V+=oe,V&=255,be[q]=V,oe=V):be[q]=V}}else for(q=0,H=0;H<p;H++)for(j=0;j<f;j++)if(q=H*f+j,!R||R[q])for(he=0;he<d;he++,q+=y){if(O=0,W=ie<<Z>>>32-G,k=W,32-Z<G&&(W|=_[S+1]>>>64-Z-G,k=W),x[k])O=x[k][1],Z+=x[k][0];else for(W=ie<<Z>>>32-A,k=W,32-Z<A&&(W|=_[S+1]>>>64-Z-A,k=W),D=L,J=0;J<A;J++)if(N=W>>>A-J-1&1,D=N?D.right:D.left,!(D.left||D.right)){O=D.val,Z=Z+J+1;break}Z>=32&&(Z-=32,S++,ie=_[S]),V=O-K,be[q]=V}s.ptr=s.ptr+(S+1)*4+(Z>0?4:0),s.pixels.resultPixels=me,d>1&&!c&&(s.pixels.resultPixels=t.swapDimensionOrder(me,y,d,a))},decodeBits:function(r,s,a,c,u){{var d=s.headerInfo,p=d.fileVersion,f=0,y=r.byteLength-s.ptr>=5?5:r.byteLength-s.ptr,v=new DataView(r,s.ptr,y),x=v.getUint8(0);f++;var L=x>>6,_=L===0?4:3-L,S=(x&32)>0,Z=x&31,G=0;if(_===1)G=v.getUint8(f),f++;else if(_===2)G=v.getUint16(f,!0),f+=2;else if(_===4)G=v.getUint32(f,!0),f+=4;else throw"Invalid valid pixel count type";var A=2*d.maxZError,K,D,O,V,R,W,k,N,H,j=d.numDims>1?d.maxValues[u]:d.zMax;if(S){for(s.counter.lut++,N=v.getUint8(f),f++,V=Math.ceil((N-1)*Z/8),R=Math.ceil(V/4),D=new ArrayBuffer(R*4),O=new Uint8Array(D),s.ptr+=f,O.set(new Uint8Array(r,s.ptr,V)),k=new Uint32Array(D),s.ptr+=V,H=0;N-1>>>H;)H++;V=Math.ceil(G*H/8),R=Math.ceil(V/4),D=new ArrayBuffer(R*4),O=new Uint8Array(D),O.set(new Uint8Array(r,s.ptr,V)),K=new Uint32Array(D),s.ptr+=V,p>=3?W=l.unstuffLUT2(k,Z,N-1,c,A,j):W=l.unstuffLUT(k,Z,N-1,c,A,j),p>=3?l.unstuff2(K,a,H,G,W):l.unstuff(K,a,H,G,W)}else s.counter.bitstuffer++,H=Z,s.ptr+=f,H>0&&(V=Math.ceil(G*H/8),R=Math.ceil(V/4),D=new ArrayBuffer(R*4),O=new Uint8Array(D),O.set(new Uint8Array(r,s.ptr,V)),K=new Uint32Array(D),s.ptr+=V,p>=3?c==null?l.originalUnstuff2(K,a,H,G):l.unstuff2(K,a,H,G,!1,c,A,j):c==null?l.originalUnstuff(K,a,H,G):l.unstuff(K,a,H,G,!1,c,A,j))}},readTiles:function(r,s,a,c){var u=s.headerInfo,d=u.width,p=u.height,f=d*p,y=u.microBlockSize,v=u.imageType,x=t.getDataTypeSize(v),L=Math.ceil(d/y),_=Math.ceil(p/y);s.pixels.numBlocksY=_,s.pixels.numBlocksX=L,s.pixels.ptr=0;var S=0,Z=0,G=0,A=0,K=0,D=0,O=0,V=0,R=0,W=0,k=0,N=0,H=0,j=0,q=0,J=0,oe,ie,te,me,be,he,ve=new a(y*y),ke=p%y||y,Ye=d%y||y,je,Je,Qe=u.numDims,ct,pt=s.pixels.resultMask,Ue=s.pixels.resultPixels,hn=u.fileVersion,Gn=hn>=5?14:15,Ae,Ut=u.zMax,It;for(G=0;G<_;G++)for(K=G!==_-1?y:ke,A=0;A<L;A++)for(D=A!==L-1?y:Ye,k=G*d*y+A*y,N=d-D,ct=0;ct<Qe;ct++){if(Qe>1?(It=Ue,k=G*d*y+A*y,Ue=new a(s.pixels.resultPixels.buffer,f*ct*x,f),Ut=u.maxValues[ct]):It=null,O=r.byteLength-s.ptr,oe=new DataView(r,s.ptr,Math.min(10,O)),ie={},J=0,V=oe.getUint8(0),J++,Ae=u.fileVersion>=5?V&4:0,R=V>>6&255,W=V>>2&Gn,W!==(A*y>>3&Gn)||Ae&&ct===0)throw"integrity issue";if(he=V&3,he>3)throw s.ptr+=J,"Invalid block encoding ("+he+")";if(he===2){if(Ae)if(pt)for(S=0;S<K;S++)for(Z=0;Z<D;Z++)pt[k]&&(Ue[k]=It[k]),k++;else for(S=0;S<K;S++)for(Z=0;Z<D;Z++)Ue[k]=It[k],k++;s.counter.constant++,s.ptr+=J;continue}else if(he===0){if(Ae)throw"integrity issue";if(s.counter.uncompressed++,s.ptr+=J,H=K*D*x,j=r.byteLength-s.ptr,H=H<j?H:j,te=new ArrayBuffer(H%x===0?H:H+x-H%x),me=new Uint8Array(te),me.set(new Uint8Array(r,s.ptr,H)),be=new a(te),q=0,pt)for(S=0;S<K;S++){for(Z=0;Z<D;Z++)pt[k]&&(Ue[k]=be[q++]),k++;k+=N}else for(S=0;S<K;S++){for(Z=0;Z<D;Z++)Ue[k++]=be[q++];k+=N}s.ptr+=q*x}else if(je=t.getDataTypeUsed(Ae&&v<6?4:v,R),Je=t.getOnePixel(ie,J,je,oe),J+=t.getDataTypeSize(je),he===3)if(s.ptr+=J,s.counter.constantoffset++,pt)for(S=0;S<K;S++){for(Z=0;Z<D;Z++)pt[k]&&(Ue[k]=Ae?Math.min(Ut,It[k]+Je):Je),k++;k+=N}else for(S=0;S<K;S++){for(Z=0;Z<D;Z++)Ue[k]=Ae?Math.min(Ut,It[k]+Je):Je,k++;k+=N}else if(s.ptr+=J,t.decodeBits(r,s,ve,Je,ct),J=0,Ae)if(pt)for(S=0;S<K;S++){for(Z=0;Z<D;Z++)pt[k]&&(Ue[k]=ve[J++]+It[k]),k++;k+=N}else for(S=0;S<K;S++){for(Z=0;Z<D;Z++)Ue[k]=ve[J++]+It[k],k++;k+=N}else if(pt)for(S=0;S<K;S++){for(Z=0;Z<D;Z++)pt[k]&&(Ue[k]=ve[J++]),k++;k+=N}else for(S=0;S<K;S++){for(Z=0;Z<D;Z++)Ue[k++]=ve[J++];k+=N}}Qe>1&&!c&&(s.pixels.resultPixels=t.swapDimensionOrder(s.pixels.resultPixels,f,Qe,a))},formatFileInfo:function(r){return{fileIdentifierString:r.headerInfo.fileIdentifierString,fileVersion:r.headerInfo.fileVersion,imageType:r.headerInfo.imageType,height:r.headerInfo.height,width:r.headerInfo.width,numValidPixel:r.headerInfo.numValidPixel,microBlockSize:r.headerInfo.microBlockSize,blobSize:r.headerInfo.blobSize,maxZError:r.headerInfo.maxZError,pixelType:t.getPixelType(r.headerInfo.imageType),eofOffset:r.eofOffset,mask:r.mask?{numBytes:r.mask.numBytes}:null,pixels:{numBlocksX:r.pixels.numBlocksX,numBlocksY:r.pixels.numBlocksY,maxValue:r.headerInfo.zMax,minValue:r.headerInfo.zMin,noDataValue:r.noDataValue}}},constructConstantSurface:function(r,s){var a=r.headerInfo.zMax,c=r.headerInfo.zMin,u=r.headerInfo.maxValues,d=r.headerInfo.numDims,p=r.headerInfo.height*r.headerInfo.width,f=0,y=0,v=0,x=r.pixels.resultMask,L=r.pixels.resultPixels;if(x)if(d>1){if(s)for(f=0;f<d;f++)for(v=f*p,a=u[f],y=0;y<p;y++)x[y]&&(L[v+y]=a);else for(y=0;y<p;y++)if(x[y])for(v=y*d,f=0;f<d;f++)L[v+d]=u[f]}else for(y=0;y<p;y++)x[y]&&(L[y]=a);else if(d>1&&c!==a)if(s)for(f=0;f<d;f++)for(v=f*p,a=u[f],y=0;y<p;y++)L[v+y]=a;else for(y=0;y<p;y++)for(v=y*d,f=0;f<d;f++)L[v+f]=u[f];else for(y=0;y<p*d;y++)L[y]=a},getDataTypeArray:function(r){var s;switch(r){case 0:s=Int8Array;break;case 1:s=Uint8Array;break;case 2:s=Int16Array;break;case 3:s=Uint16Array;break;case 4:s=Int32Array;break;case 5:s=Uint32Array;break;case 6:s=Float32Array;break;case 7:s=Float64Array;break;default:s=Float32Array}return s},getPixelType:function(r){var s;switch(r){case 0:s="S8";break;case 1:s="U8";break;case 2:s="S16";break;case 3:s="U16";break;case 4:s="S32";break;case 5:s="U32";break;case 6:s="F32";break;case 7:s="F64";break;default:s="F32"}return s},isValidPixelValue:function(r,s){if(s==null)return!1;var a;switch(r){case 0:a=s>=-128&&s<=127;break;case 1:a=s>=0&&s<=255;break;case 2:a=s>=-32768&&s<=32767;break;case 3:a=s>=0&&s<=65536;break;case 4:a=s>=-2147483648&&s<=2147483647;break;case 5:a=s>=0&&s<=4294967296;break;case 6:a=s>=-34027999387901484e22&&s<=34027999387901484e22;break;case 7:a=s>=-17976931348623157e292&&s<=17976931348623157e292;break;default:a=!1}return a},getDataTypeSize:function(r){var s=0;switch(r){case 0:case 1:s=1;break;case 2:case 3:s=2;break;case 4:case 5:case 6:s=4;break;case 7:s=8;break;default:s=r}return s},getDataTypeUsed:function(r,s){var a=r;switch(r){case 2:case 4:a=r-s;break;case 3:case 5:a=r-2*s;break;case 6:s===0?a=r:s===1?a=2:a=1;break;case 7:s===0?a=r:a=r-2*s+1;break;default:a=r;break}return a},getOnePixel:function(r,s,a,c){var u=0;switch(a){case 0:u=c.getInt8(s);break;case 1:u=c.getUint8(s);break;case 2:u=c.getInt16(s,!0);break;case 3:u=c.getUint16(s,!0);break;case 4:u=c.getInt32(s,!0);break;case 5:u=c.getUInt32(s,!0);break;case 6:u=c.getFloat32(s,!0);break;case 7:u=c.getFloat64(s,!0);break;default:throw"the decoder does not understand this pixel type"}return u},swapDimensionOrder:function(r,s,a,c,u){var d=0,p=0,f=0,y=0,v=r;if(a>1)if(v=new c(s*a),u)for(d=0;d<s;d++)for(y=d,f=0;f<a;f++,y+=s)v[y]=r[p++];else for(d=0;d<s;d++)for(y=d,f=0;f<a;f++,y+=s)v[p++]=r[y];return v}},e=function(r,s,a){this.val=r,this.left=s,this.right=a},n={decode:function(r,s){s=s||{};var a=s.noDataValue,c=0,u={};if(u.ptr=s.inputOffset||0,u.pixels={},!!t.readHeaderInfo(r,u)){var d=u.headerInfo,p=d.fileVersion,f=t.getDataTypeArray(d.imageType);if(p>5)throw"unsupported lerc version 2."+p;t.readMask(r,u),d.numValidPixel!==d.width*d.height&&!u.pixels.resultMask&&(u.pixels.resultMask=s.maskData);var y=d.width*d.height;u.pixels.resultPixels=new f(y*d.numDims),u.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var v=!s.returnPixelInterleavedDims;if(d.numValidPixel!==0)if(d.zMax===d.zMin)t.constructConstantSurface(u,v);else if(p>=4&&t.checkMinMaxRanges(r,u))t.constructConstantSurface(u,v);else{var x=new DataView(r,u.ptr,2),L=x.getUint8(0);if(u.ptr++,L)t.readDataOneSweep(r,u,f,v);else if(p>1&&d.imageType<=1&&Math.abs(d.maxZError-.5)<1e-5){var _=x.getUint8(1);if(u.ptr++,u.encodeMode=_,_>2||p<4&&_>1)throw"Invalid Huffman flag "+_;_?t.readHuffman(r,u,f,v):t.readTiles(r,u,f,v)}else t.readTiles(r,u,f,v)}u.eofOffset=u.ptr;var S;s.inputOffset?(S=u.headerInfo.blobSize+s.inputOffset-u.ptr,Math.abs(S)>=1&&(u.eofOffset=s.inputOffset+u.headerInfo.blobSize)):(S=u.headerInfo.blobSize-u.ptr,Math.abs(S)>=1&&(u.eofOffset=u.headerInfo.blobSize));var Z={width:d.width,height:d.height,pixelData:u.pixels.resultPixels,minValue:d.zMin,maxValue:d.zMax,validPixelCount:d.numValidPixel,dimCount:d.numDims,dimStats:{minValues:d.minValues,maxValues:d.maxValues},maskData:u.pixels.resultMask};if(u.pixels.resultMask&&t.isValidPixelValue(d.imageType,a)){var G=u.pixels.resultMask;for(c=0;c<y;c++)G[c]||(Z.pixelData[c]=a);Z.noDataValue=a}return u.noDataValue=a,s.returnFileInfo&&(Z.fileInfo=t.formatFileInfo(u)),Z}},getBandCount:function(r){var s=0,a=0,c={};for(c.ptr=0,c.pixels={};a<r.byteLength-58;)t.readHeaderInfo(r,c),a+=c.headerInfo.blobSize,s++,c.ptr=a;return s}};return n}();var tm=function(){var l=new ArrayBuffer(4),t=new Uint8Array(l),e=new Uint32Array(l);return e[0]=1,t[0]===1}(),nm={decode:function(l,t){if(!tm)throw"Big endian system is not supported.";t=t||{};var e=t.inputOffset||0,n=new Uint8Array(l,e,10),r=String.fromCharCode.apply(null,n),s,a;if(r.trim()==="CntZImage")s=$p,a=1;else if(r.substring(0,5)==="Lerc2")s=em,a=2;else throw"Unexpected file identifier string: "+r;for(var c=0,u=l.byteLength-10,d,p=[],f,y,v={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},x=0;e<u;){var L=s.decode(l,{inputOffset:e,encodedMaskData:d,maskData:y,returnMask:c===0,returnEncodedMask:c===0,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});e=L.fileInfo.eofOffset,y=L.maskData,c===0&&(d=L.encodedMaskData,v.width=L.width,v.height=L.height,v.dimCount=L.dimCount||1,v.pixelType=L.pixelType||L.fileInfo.pixelType,v.mask=y),a>1&&(y&&p.push(y),L.fileInfo.mask&&L.fileInfo.mask.numBytes>0&&x++),c++,v.pixels.push(L.pixelData),v.statistics.push({minValue:L.minValue,maxValue:L.maxValue,noDataValue:L.noDataValue,dimStats:L.dimStats})}var _,S,Z;if(a>1&&x>1){for(Z=v.width*v.height,v.bandMasks=p,y=new Uint8Array(Z),y.set(p[0]),_=1;_<p.length;_++)for(f=p[_],S=0;S<Z;S++)y[S]=y[S]&f[S];v.maskData=y}return v}};const rm={0:7e3,1:6e3,2:5e3,3:4e3,4:3e3,5:2500,6:2e3,7:1500,8:800,9:500,10:200,11:100,12:40,13:12,14:5,15:2,16:1,17:.5,18:.2,19:.1,20:.01};function im(l){const{height:t,width:e,pixels:n}=nm.decode(l),r=new Float32Array(t*e);for(let s=0;s<r.length;s++)r[s]=n[0][s];return{array:r,width:e,height:t}}function sm(l,t,e){let n=im(l);e[2]-e[0]<1&&(n=om(n,e));const{array:r,width:s}=n,c=new Ul(s).createTile(r),u=rm[t]||0;return c.getGeometryData(u)}function om(l,t){function e(c,u,d,p,f,y,v,x){const L=new Float32Array(f*y);for(let S=0;S<y;S++)for(let Z=0;Z<f;Z++){const G=(S+p)*u+(Z+d),A=S*f+Z;L[A]=c[G]}const _=new Float32Array(x*v);for(let S=0;S<x;S++)for(let Z=0;Z<v;Z++){const G=S*x+Z,A=Math.round(Z*y/x),D=Math.round(S*f/v)*f+A;_[G]=L[D]}return _}const n=am(t,l.width),r=n.sw+1,s=n.sh+1;return{array:e(l.array,l.width,n.sx,n.sy,n.sw,n.sh,r,s),width:r,height:s}}function am(l,t){const e=Math.floor(l[0]*t),n=Math.floor(l[1]*t),r=Math.floor((l[2]-l[0])*t),s=Math.floor((l[3]-l[1])*t);return{sx:e,sy:n,sw:r,sh:s}}const lm=10;class cm extends uo{constructor(){super();T(this,"info",{version:"0.10.0",description:"Tile LERC terrain loader. It can load ArcGis-lerc format terrain data."});T(this,"dataType","lerc");T(this,"fileLoader",new m.FileLoader(Xe.manager));T(this,"_workerPool",new eo(0));this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new qp)}async doLoad(e,n){this._workerPool.pool===0&&this._workerPool.setWorkerLimit(lm);const{z:r,bounds:s}=n,a=await this.fileLoader.loadAsync(e).catch(()=>new Float32Array(256*256)),c=sm(a,r,s);return new fr().setData(c)}}mo(new cm);const Ql="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGModCl7cmV0dXJuIGEodC5kYXRhKX1mdW5jdGlvbiBhKHQpe2Z1bmN0aW9uIG4oZSx1KXtjb25zdCByPXUqNCxbaSxmLGcsbF09ZS5zbGljZShyLHIrNCk7cmV0dXJuIGw9PT0wPzA6LTFlNCsoaTw8MTZ8Zjw8OHxnKSouMX1jb25zdCBvPXQubGVuZ3RoPj4+MixzPW5ldyBGbG9hdDMyQXJyYXkobyk7Zm9yKGxldCBlPTA7ZTxvO2UrKylzW2VdPW4odCxlKTtyZXR1cm4gc31zZWxmLm9ubWVzc2FnZT10PT57Y29uc3Qgbj1jKHQuZGF0YS5pbWdEYXRhKTtzZWxmLnBvc3RNZXNzYWdlKG4pfX0pKCk7Cg==",um=l=>Uint8Array.from(atob(l),t=>t.charCodeAt(0)),Hl=typeof self<"u"&&self.Blob&&new Blob([um(Ql)],{type:"text/javascript;charset=utf-8"});function hm(l){let t;try{if(t=Hl&&(self.URL||self.webkitURL).createObjectURL(Hl),!t)throw"";const e=new Worker(t,{name:l?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+Ql,{name:l?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const dm=10;class fm extends uo{constructor(){super();T(this,"info",{version:"0.10.0",description:"Mapbox-RGB terrain loader, It can load Mapbox-RGB terrain data."});T(this,"dataType","terrain-rgb");T(this,"imageLoader",new m.ImageLoader(Xe.manager));T(this,"_workerPool",new eo(0));this._workerPool.setWorkerCreator(()=>new hm)}async doLoad(e,n){const r=await this.imageLoader.loadAsync(e).catch(d=>new Image),s=m.MathUtils.clamp((n.z+2)*3,2,64),a=pm(r,n.bounds,s);let c;this._workerPool.pool===0&&this._workerPool.setWorkerLimit(dm),c=(await this._workerPool.postMessage({imgData:a},[a.data.buffer])).data;const u=new fr;return u.setData(c),u}}function pm(l,t,e){const n=so(t,l.width);e=Math.min(e,n.sw);const s=new OffscreenCanvas(e,e).getContext("2d");return s.imageSmoothingEnabled=!1,s.drawImage(l,n.sx,n.sy,n.sw,n.sh,0,0,e,e),s.getImageData(0,0,e,e)}mo(new fm);function Tn(l,t){this.x=l,this.y=t}Tn.prototype={clone(){return new Tn(this.x,this.y)},add(l){return this.clone()._add(l)},sub(l){return this.clone()._sub(l)},multByPoint(l){return this.clone()._multByPoint(l)},divByPoint(l){return this.clone()._divByPoint(l)},mult(l){return this.clone()._mult(l)},div(l){return this.clone()._div(l)},rotate(l){return this.clone()._rotate(l)},rotateAround(l,t){return this.clone()._rotateAround(l,t)},matMult(l){return this.clone()._matMult(l)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(l){return this.x===l.x&&this.y===l.y},dist(l){return Math.sqrt(this.distSqr(l))},distSqr(l){const t=l.x-this.x,e=l.y-this.y;return t*t+e*e},angle(){return Math.atan2(this.y,this.x)},angleTo(l){return Math.atan2(this.y-l.y,this.x-l.x)},angleWith(l){return this.angleWithSep(l.x,l.y)},angleWithSep(l,t){return Math.atan2(this.x*t-this.y*l,this.x*l+this.y*t)},_matMult(l){const t=l[0]*this.x+l[1]*this.y,e=l[2]*this.x+l[3]*this.y;return this.x=t,this.y=e,this},_add(l){return this.x+=l.x,this.y+=l.y,this},_sub(l){return this.x-=l.x,this.y-=l.y,this},_mult(l){return this.x*=l,this.y*=l,this},_div(l){return this.x/=l,this.y/=l,this},_multByPoint(l){return this.x*=l.x,this.y*=l.y,this},_divByPoint(l){return this.x/=l.x,this.y/=l.y,this},_unit(){return this._div(this.mag()),this},_perp(){const l=this.y;return this.y=this.x,this.x=-l,this},_rotate(l){const t=Math.cos(l),e=Math.sin(l),n=t*this.x-e*this.y,r=e*this.x+t*this.y;return this.x=n,this.y=r,this},_rotateAround(l,t){const e=Math.cos(l),n=Math.sin(l),r=t.x+e*(this.x-t.x)-n*(this.y-t.y),s=t.y+n*(this.x-t.x)+e*(this.y-t.y);return this.x=r,this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Tn},Tn.convert=function(l){if(l instanceof Tn)return l;if(Array.isArray(l))return new Tn(+l[0],+l[1]);if(l.x!==void 0&&l.y!==void 0)return new Tn(+l.x,+l.y);throw new Error("Expected [x, y] or {x, y} point format")};class El{constructor(t,e,n,r,s){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=s,t.readFields(mm,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos,n=[];let r,s=1,a=0,c=0,u=0;for(;t.pos<e;){if(a<=0){const d=t.readVarint();s=d&7,a=d>>3}if(a--,s===1||s===2)c+=t.readSVarint(),u+=t.readSVarint(),s===1&&(r&&n.push(r),r=[]),r&&r.push(new Tn(c,u));else if(s===7)r&&r.push(r[0].clone());else throw new Error(`unknown command ${s}`)}return r&&n.push(r),n}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let n=1,r=0,s=0,a=0,c=1/0,u=-1/0,d=1/0,p=-1/0;for(;t.pos<e;){if(r<=0){const f=t.readVarint();n=f&7,r=f>>3}if(r--,n===1||n===2)s+=t.readSVarint(),a+=t.readSVarint(),s<c&&(c=s),s>u&&(u=s),a<d&&(d=a),a>p&&(p=a);else if(n!==7)throw new Error(`unknown command ${n}`)}return[c,d,u,p]}toGeoJSON(t,e,n){const r=this.extent*Math.pow(2,n),s=this.extent*t,a=this.extent*e,c=this.loadGeometry();function u(y){return[(y.x+s)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(y.y+a)*2/r)*Math.PI))-90]}function d(y){return y.map(u)}let p;if(this.type===1){const y=[];for(const x of c)y.push(x[0]);const v=d(y);p=y.length===1?{type:"Point",coordinates:v[0]}:{type:"MultiPoint",coordinates:v}}else if(this.type===2){const y=c.map(d);p=y.length===1?{type:"LineString",coordinates:y[0]}:{type:"MultiLineString",coordinates:y}}else if(this.type===3){const y=ym(c),v=[];for(const x of y)v.push(x.map(d));p=v.length===1?{type:"Polygon",coordinates:v[0]}:{type:"MultiPolygon",coordinates:v}}else throw new Error("unknown feature type");const f={type:"Feature",geometry:p,properties:this.properties};return this.id!=null&&(f.id=this.id),f}}El.types=["Unknown","Point","LineString","Polygon"];function mm(l,t,e){l===1?t.id=e.readVarint():l===2?gm(e,t):l===3?t.type=e.readVarint():l===4&&(t._geometry=e.pos)}function gm(l,t){const e=l.readVarint()+l.pos;for(;l.pos<e;){const n=t._keys[l.readVarint()],r=t._values[l.readVarint()];t.properties[n]=r}}function ym(l){const t=l.length;if(t<=1)return[l];const e=[];let n,r;for(let s=0;s<t;s++){const a=vm(l[s]);a!==0&&(r===void 0&&(r=a<0),r===a<0?(n&&e.push(n),n=[l[s]]):n&&n.push(l[s]))}return n&&e.push(n),e}function vm(l){let t=0;for(let e=0,n=l.length,r=n-1,s,a;e<n;r=e++)s=l[e],a=l[r],t+=(a.x-s.x)*(s.y+a.y);return t}let wm=class{constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(xm,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new El(this._pbf,e,this.extent,this._keys,this._values)}};function xm(l,t,e){l===15?t.version=e.readVarint():l===1?t.name=e.readString():l===5?t.extent=e.readVarint():l===2?t._features.push(e.pos):l===3?t._keys.push(e.readString()):l===4&&t._values.push(bm(e))}function bm(l){let t=null;const e=l.readVarint()+l.pos;for(;l.pos<e;){const n=l.readVarint()>>3;t=n===1?l.readString():n===2?l.readFloat():n===3?l.readDouble():n===4?l.readVarint64():n===5?l.readVarint():n===6?l.readSVarint():n===7?l.readBoolean():null}if(t==null)throw new Error("unknown feature value");return t}class _m{constructor(t,e){this.layers=t.readFields(Mm,{},e)}}function Mm(l,t,e){if(l===3){const n=new wm(e,e.readVarint()+e.pos);n.length&&(t[n.name]=n)}}const go=65536*65536,ql=1/go,Lm=12,$l=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),yo=0,Vi=1,Nr=2,Ai=5;class Sm{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,n=this.length){for(;this.pos<n;){const r=this.readVarint(),s=r>>3,a=this.pos;this.type=r&7,t(s,e,this),this.pos===a&&this.skip(r)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*go;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*go;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let n,r;return r=e[this.pos++],n=r&127,r<128||(r=e[this.pos++],n|=(r&127)<<7,r<128)||(r=e[this.pos++],n|=(r&127)<<14,r<128)||(r=e[this.pos++],n|=(r&127)<<21,r<128)?n:(r=e[this.pos],n|=(r&15)<<28,Zm(n,t,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=Lm&&$l?$l.decode(this.buf.subarray(e,t)):zm(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===Nr?this.readVarint()+this.pos:this.pos+1}skip(t){const e=t&7;if(e===yo)for(;this.buf[this.pos++]>127;);else if(e===Nr)this.pos=this.readVarint()+this.pos;else if(e===Ai)this.pos+=4;else if(e===Vi)this.pos+=8;else throw new Error(`Unimplemented type: ${e}`)}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.dataView=new DataView(n.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ql),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ql),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){Tm(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;const e=this.pos;this.pos=Om(this.buf,t,this.pos);const n=this.pos-e;n>=128&&ec(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let n=0;n<e;n++)this.buf[this.pos++]=t[n]}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const r=this.pos-n;r>=128&&ec(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeMessage(t,e,n){this.writeTag(t,Nr),this.writeRawMessage(e,n)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Im,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Wm,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Am,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Cm,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,Vm,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,Fm,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Xm,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,km,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Dm,e)}writeBytesField(t,e){this.writeTag(t,Nr),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,Ai),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,Ai),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,Vi),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,Vi),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,yo),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,yo),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,Nr),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,Ai),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,Vi),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function Zm(l,t,e){const n=e.buf;let r,s;if(s=n[e.pos++],r=(s&112)>>4,s<128||(s=n[e.pos++],r|=(s&127)<<3,s<128)||(s=n[e.pos++],r|=(s&127)<<10,s<128)||(s=n[e.pos++],r|=(s&127)<<17,s<128)||(s=n[e.pos++],r|=(s&127)<<24,s<128)||(s=n[e.pos++],r|=(s&1)<<31,s<128))return pr(l,r,t);throw new Error("Expected varint not more than 10 bytes")}function pr(l,t,e){return e?t*4294967296+(l>>>0):(t>>>0)*4294967296+(l>>>0)}function Tm(l,t){let e,n;if(l>=0?(e=l%4294967296|0,n=l/4294967296|0):(e=~(-l%4294967296),n=~(-l/4294967296),e^4294967295?e=e+1|0:(e=0,n=n+1|0)),l>=18446744073709552e3||l<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),Gm(e,n,t),Pm(n,t)}function Gm(l,t,e){e.buf[e.pos++]=l&127|128,l>>>=7,e.buf[e.pos++]=l&127|128,l>>>=7,e.buf[e.pos++]=l&127|128,l>>>=7,e.buf[e.pos++]=l&127|128,l>>>=7,e.buf[e.pos]=l&127}function Pm(l,t){const e=(l&7)<<4;t.buf[t.pos++]|=e|((l>>>=3)?128:0),l&&(t.buf[t.pos++]=l&127|((l>>>=7)?128:0),l&&(t.buf[t.pos++]=l&127|((l>>>=7)?128:0),l&&(t.buf[t.pos++]=l&127|((l>>>=7)?128:0),l&&(t.buf[t.pos++]=l&127|((l>>>=7)?128:0),l&&(t.buf[t.pos++]=l&127)))))}function ec(l,t,e){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));e.realloc(n);for(let r=e.pos-1;r>=l;r--)e.buf[r+n]=e.buf[r]}function Im(l,t){for(let e=0;e<l.length;e++)t.writeVarint(l[e])}function Wm(l,t){for(let e=0;e<l.length;e++)t.writeSVarint(l[e])}function Cm(l,t){for(let e=0;e<l.length;e++)t.writeFloat(l[e])}function Vm(l,t){for(let e=0;e<l.length;e++)t.writeDouble(l[e])}function Am(l,t){for(let e=0;e<l.length;e++)t.writeBoolean(l[e])}function Fm(l,t){for(let e=0;e<l.length;e++)t.writeFixed32(l[e])}function Xm(l,t){for(let e=0;e<l.length;e++)t.writeSFixed32(l[e])}function km(l,t){for(let e=0;e<l.length;e++)t.writeFixed64(l[e])}function Dm(l,t){for(let e=0;e<l.length;e++)t.writeSFixed64(l[e])}function zm(l,t,e){let n="",r=t;for(;r<e;){const s=l[r];let a=null,c=s>239?4:s>223?3:s>191?2:1;if(r+c>e)break;let u,d,p;c===1?s<128&&(a=s):c===2?(u=l[r+1],(u&192)===128&&(a=(s&31)<<6|u&63,a<=127&&(a=null))):c===3?(u=l[r+1],d=l[r+2],(u&192)===128&&(d&192)===128&&(a=(s&15)<<12|(u&63)<<6|d&63,(a<=2047||a>=55296&&a<=57343)&&(a=null))):c===4&&(u=l[r+1],d=l[r+2],p=l[r+3],(u&192)===128&&(d&192)===128&&(p&192)===128&&(a=(s&15)<<18|(u&63)<<12|(d&63)<<6|p&63,(a<=65535||a>=1114112)&&(a=null))),a===null?(a=65533,c=1):a>65535&&(a-=65536,n+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),n+=String.fromCharCode(a),r+=c}return n}function Om(l,t,e){for(let n=0,r,s;n<t.length;n++){if(r=t.charCodeAt(n),r>55295&&r<57344)if(s)if(r<56320){l[e++]=239,l[e++]=191,l[e++]=189,s=r;continue}else r=s-55296<<10|r-56320|65536,s=null;else{r>56319||n+1===t.length?(l[e++]=239,l[e++]=191,l[e++]=189):s=r;continue}else s&&(l[e++]=239,l[e++]=191,l[e++]=189,s=null);r<128?l[e++]=r:(r<2048?l[e++]=r>>6|192:(r<65536?l[e++]=r>>12|224:(l[e++]=r>>18|240,l[e++]=r>>12&63|128),l[e++]=r>>6&63|128),l[e++]=r&63|128)}return e}class Km extends fo{constructor(){super();T(this,"dataType","mvt");T(this,"_loader",new m.FileLoader(Xe.manager));T(this,"_render",new Bl);console.log("MVTLoader constructor"),this._loader.setResponseType("arraybuffer")}async doLoad(e,n){const r=await this._loader.loadAsync(e),s=new _m(new Sm(r)),a=this.drawTile(s,n.source.style,n.z);return console.log("drawTile",a),new m.CanvasTexture(a)}drawTile(e,n,r){const u=new OffscreenCanvas(256,256).getContext("2d");if(u){if(n)for(const d in n.layer){const p=n.layer[d];if(n&&(r<(p.minLevel??1)||r>(p.maxLevel??20)))continue;const f=e.layers[d];if(f){const y=256/f.extent;this._renderLayer(u,f,p,y)}}else for(const d in e.layers){const p=e.layers[d],f=256/p.extent;this._renderLayer(u,p,void 0,f)}return u.canvas}else throw new Error("Canvas context is not available")}_renderLayer(e,n,r,s=1){e.save();for(let a=0;a<n.length;a++){const c=n.feature(a);this._renderFeature(e,c,r,s)}return e.restore(),this}_renderFeature(e,n,r={},s=1){const a=[tt.Unknown,tt.Point,tt.Linestring,tt.Polygon][n.type],c={geometry:n.loadGeometry(),properties:n.properties};this._render.render(e,a,c,r,s)}_convertToGeoJSONFeature(e,n){const r=this._convertGeometryToGeoJSON(e.geometry,n);return r?{type:"Feature",geometry:r,properties:e.properties||{},id:e.id}:null}_convertGeometryToGeoJSON(e,n){switch(n){case tt.Point:return this._convertPointGeometry(e);case tt.Linestring:return this._convertLineGeometry(e);case tt.Polygon:return this._convertPolygonGeometry(e);default:return console.warn("未知的几何类型:",n),null}}_convertPointGeometry(e){const n=[];for(const r of e)for(const s of r)n.push([s.x,s.y]);return n.length===0?null:n.length===1?{type:"Point",coordinates:n[0]}:{type:"MultiPoint",coordinates:n}}_convertLineGeometry(e){const n=[];for(const r of e){const s=[];for(const a of r)s.push([a.x,a.y]);s.length>=2&&n.push(s)}return n.length===0?null:n.length===1?{type:"LineString",coordinates:n[0]}:{type:"MultiLineString",coordinates:n}}_convertPolygonGeometry(e){const n=[];let r=[];for(const s of e){const a=[];for(const c of s)a.push([c.x,c.y]);a.length>=4&&(this._isRingClockwise(a)||r.length===0?(r.length>0&&n.push(r),r=[a]):r.push(a))}return r.length>0&&n.push(r),n.length===0?null:n.length===1?{type:"Polygon",coordinates:n[0]}:{type:"MultiPolygon",coordinates:n}}_isRingClockwise(e){let n=0;for(let r=0;r<e.length-1;r++){const[s,a]=e[r],[c,u]=e[r+1];n+=(c-s)*(u+a)}return n>0}convertVectorTileToGeoJSON(e){const n=[];for(const r in e.layers){const s=e.layers[r];for(let a=0;a<s.length;a++){const c=s.feature(a),u=[tt.Unknown,tt.Point,tt.Linestring,tt.Polygon][c.type],d={geometry:c.loadGeometry(),properties:c.properties},p=this._convertToGeoJSONFeature(d,u);p&&(p.properties._layer=r,n.push(p))}}return{type:"FeatureCollection",features:n}}}po(new Km);const tc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IF89MjMyODMwNjQzNjUzODY5NjNlLTI2LG09MTIsUD10eXBlb2YgVGV4dERlY29kZXI+InUiP251bGw6bmV3IFRleHREZWNvZGVyKCJ1dGYtOCIpLGc9MCx5PTEsRj0yLHA9NTtjbGFzcyBNe2NvbnN0cnVjdG9yKHQ9bmV3IFVpbnQ4QXJyYXkoMTYpKXt0aGlzLmJ1Zj1BcnJheUJ1ZmZlci5pc1ZpZXcodCk/dDpuZXcgVWludDhBcnJheSh0KSx0aGlzLmRhdGFWaWV3PW5ldyBEYXRhVmlldyh0aGlzLmJ1Zi5idWZmZXIpLHRoaXMucG9zPTAsdGhpcy50eXBlPTAsdGhpcy5sZW5ndGg9dGhpcy5idWYubGVuZ3RofXJlYWRGaWVsZHModCxlLHI9dGhpcy5sZW5ndGgpe2Zvcig7dGhpcy5wb3M8cjspe2NvbnN0IHM9dGhpcy5yZWFkVmFyaW50KCksbj1zPj4zLG89dGhpcy5wb3M7dGhpcy50eXBlPXMmNyx0KG4sZSx0aGlzKSx0aGlzLnBvcz09PW8mJnRoaXMuc2tpcChzKX1yZXR1cm4gZX1yZWFkTWVzc2FnZSh0LGUpe3JldHVybiB0aGlzLnJlYWRGaWVsZHModCxlLHRoaXMucmVhZFZhcm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),nc=typeof self<"u"&&self.Blob&&new Blob([Rm(tc)],{type:"text/javascript;charset=utf-8"});function Ym(l){let t;try{if(t=nc&&(self.URL||self.webkitURL).createObjectURL(nc),!t)throw"";const e=new Worker(t,{name:l?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+tc,{name:l?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const Um=10;class Bm{constructor(){T(this,"info",{version:"1.0.0",description:"Vector Tile loader for Mapbox Vector Tile format. It can load and parse MVT data."});T(this,"dataType","VectorTile");T(this,"fileLoader",new m.FileLoader(Xe.manager));T(this,"_workerPool",new eo(0));this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new Ym)}async load(t){const{source:e,x:n,y:r,z:s}=t,a=typeof e._getUrl=="function"?e._getUrl(n,r,s):this.buildTileUrl(e.url,n,r,s);if(!a)return this.createErrorGeometry(n,r,s,new Error("VectorTileLoader: source._getUrl 返回空 URL"));this._workerPool.pool===0&&this._workerPool.setWorkerLimit(Um);try{const c=await this.fetchVectorData(a),u={arrayBuffer:c,x:n,y:r,z:s},p=(await this._workerPool.postMessage(u,[c])).data;if(p.error)throw new Error(p.error);const f=this.createGeometryWithVectorData(p,t);return Xe.manager.parseEnd(a),f}catch(c){return this.createErrorGeometry(n,r,s,c)}}async fetchVectorData(t){try{const e=await this.fileLoader.loadAsync(t);if(!e||e.byteLength===0)throw new Error("Empty response");return e}catch(e){throw new Error(`Failed to fetch vector tile: ${e.message}`)}}calculateTileBounds(t,e,n){const r=4007501668557849e-8/Math.pow(2,n),s=-20037508342789244e-9+t*r,a=s+r,c=20037508342789244e-9-(e+1)*r,u=c+r;return{min:new m.Vector2(s,c),max:new m.Vector2(a,u),world:new m.Vector2(r,r)}}buildTileUrl(t,e,n,r){return t.replace("{x}",e.toString()).replace("{y}",n.toString()).replace("{z}",r.toString()).replace("{-y}",(Math.pow(2,r)-1-n).toString())}createGeometryWithVectorData(t,e){const n=new fr;return n.userData={vectorData:t,tileInfo:{x:e.x,y:e.y,z:e.z,bounds:e.bounds},metadata:{dataType:"vector-tile",version:"1.0.0",loadedAt:Date.now()}},n}createErrorGeometry(t,e,n,r){const s=new fr;return s.userData={vectorData:{x:t,y:e,z:n,layers:{},totalFeatures:0,bounds:this.calculateTileBounds(t,e,n),error:r.message,timestamp:Date.now(),dataFormat:"error"},tileInfo:{x:t,y:e,z:n,bounds:[0,0,0,0]},metadata:{dataType:"vector-tile-error",error:!0,errorMessage:r.message}},s}unload(t){t.userData?.vectorData&&(t.userData.vectorData=null),t.dispose&&t.dispose()}static getVectorData(t){return t.userData?.vectorData||null}static hasValidVectorData(t){const e=this.getVectorData(t);return e&&!e.error&&e.totalFeatures>0}static getLayerNames(t){const e=this.getVectorData(t);return e?Object.keys(e.layers||{}):[]}static getFeaturesByLayer(t,e){return this.getVectorData(t)?.layers?.[e]?.convertedFeatures||[]}}Nl(new Bm);class rc extends zl{constructor(e,n){super(e,n);T(this,"layerType","vector");T(this,"_tileDataMap",new Map);T(this,"_renderer");T(this,"_style");T(this,"_feaList",[]);T(this,"_collision",!1);T(this,"_renderAltitude",0);if(!n.style)throw new Error("VectorTileLayer 必须提供样式配置");this._style=n.style,this._collision=n.collision||!1,this._featureFilter=n.featureFilter,this._renderAltitude=n.altitude||0,this._rootTile.setDataOnlyMode(!0),this._setupDataModeAndListenersForChildren(),this._setupLifeCycleListeners()}_setupDataModeAndListenersForChildren(){const e=n=>{n!==this._rootTile&&n.setDataOnlyMode(!0),this._addShownListenerToTile(n),this._addUnloadListenerToTile(n)};this._rootTile.addEventListener("tile-created",n=>{const r=n.tile;e(r)}),this._rootTile.traverse(n=>{n.isTile&&e(n)})}_addShownListenerToTile(e){const n=r=>{const s=r.tile,a=`${s.z}-${s.x}-${s.y}`,c=!!this._renderer,u=this._tileDataMap.get(a);c&&u&&this._renderer.processTileData(s,u.data)};e.addEventListener("tile-shown",n)}_addUnloadListenerToTile(e){const n=r=>{const s=r.tile||r.target,a=`${s.z}-${s.x}-${s.y}`;if(this._renderer)try{this._renderer.removeFeaturesByTileKey(a)}catch{}this._tileDataMap.delete(a)};e.addEventListener("unload",n)}setAltitude(e){return super.setAltitude(0),this._renderAltitude=e,this._renderer&&this._renderer.setAltitude(e),this}getAltitude(){return this._renderAltitude}_addHiddenListenerToTile(e){const n=r=>{const s=r.tile,a=`${s.z}-${s.x}-${s.y}`;if(this._renderer)try{this._renderer.hideFeaturesByTileKey(a)}catch{}};e.addEventListener("tile-hidden",n)}_setupLifeCycleListeners(){this._rootTile.addEventListener("tile-loaded",e=>{const n=e.tile,r=`${n.z}-${n.x}-${n.y}`,s=this.getVectorDataFromTile(n);if(!s){console.warn(`[VectorTileLayer] Tile ${r} loaded but has no vector data.`);return}if(s.vectorData?.dataFormat==="mvt"&&this._tileDataMap.set(r,{data:s,tile:n,timestamp:Date.now(),pending:!1}),n.showing&&this._renderer&&s.vectorData?.dataFormat==="mvt")try{this._renderer.processTileData(n,s)}catch{}})}getVectorDataFromTile(e){return!e.geometry||!e.getVectorData()?null:e.getVectorData()}createLoader(){const e=new Ci;return e.vtSource=this.source,e}getVisibleVectorTiles(){const e=[];return this._rootTile.traverse(n=>{if(n.isTile&&n.loaded&&n.inFrustum){const r=`${n.z}-${n.x}-${n.y}`,s=this._tileDataMap.get(r);s&&e.push({tileKey:r,data:s.data,tile:s.tile})}}),e}getAllVectorData(){return new Map(this._tileDataMap)}getVectorData(e,n,r){const s=`${r}-${e}-${n}`,a=this._tileDataMap.get(s);return a?a.data:null}setFeatureFilter(e){this._featureFilter=e,this._renderer&&this._renderer.setFeatureFilter(e)}clearFeatureFilter(){this._featureFilter=void 0,this._renderer&&this._renderer.clearFeatureFilter()}setOpacity(e){this.opacity=e,this._renderer&&this._renderer.setOpacity(e)}update(e){!this.enabled||!this.visible||super.update(e)}dispose(){this._renderer&&this._renderer.dispose(),super.dispose()}_setRenderer(e){this._renderer=e}_getRenderer(){return this._renderer||null}getStyle(){return this._style}}class Nm{constructor(...t){}}const jm={};let Nn=class Ch extends Es(Mi(Li(Nm))){constructor(e,n){Ns(e,"container","Map container element must be specified");const r=["center","basemap"];for(const K of r)cl(n,K);const a={...n,viewer:{...{viewer:{antialias:!0,stencil:!0,logarithmicDepthBuffer:!0}}.viewer,...n.viewer}};super(a);T(this,"viewer");T(this,"tilemap");T(this,"center");T(this,"prjcenter");T(this,"_layerContainer");T(this,"_EventMap",{loaded:{listened:!1}});T(this,"_canvasManager",new tp);T(this,"collisionEngine");T(this,"_onLoadHooks");T(this,"_minZoom",0);T(this,"_maxZoom",22);T(this,"_ZOOM_MIN_CONST",0);T(this,"_ZOOM_MAX_CONST",22);T(this,"_minZoomDistance",500);T(this,"_maxZoomDistance",8e4);T(this,"_isZooming",!1);T(this,"_zoomStartValue",0);T(this,"_lastZoomForControls",0);T(this,"_overZoom",0);T(this,"_lastCameraDistance",0);this.tilemap=this.initTileMap(a.basemap),this.center=this.options.center,this.viewer=new ul(e,{...a.viewer,map:this}),this.tilemap.receiveShadow=!0,this.viewer.scene.add(this.tilemap);const c=this.tilemap.geo2world(new m.Vector3(this.center[0],this.center[1],0));this.prjcenter=c;const u=this.options.viewer??{};this.viewer.flyToPoint({center:this.center,distance:typeof this.center[2]=="number"?this.center[2]:void 0,polarDeg:typeof u.polarDeg=="number"?u.polarDeg:void 0,azimuthDeg:typeof u.azimuthDeg=="number"?u.azimuthDeg:void 0,polarAngle:u.polarAngle,azimuthAngle:u.azimuthAngle,duration:0,curvePath:!1}),this._minZoomDistance=this.viewer.controls.minDistance,this._maxZoomDistance=this.viewer.controls.maxDistance;const d=this._getCameraDistance();this._lastCameraDistance=d,this._layerContainer=new ep,this.viewer.scene.add(this._layerContainer);const p=this.viewer.controls;this._minZoomDistance=typeof p?.minDistance=="number"?p.minDistance:500,this._maxZoomDistance=typeof p?.maxDistance=="number"?p.maxDistance:8e4;const y=this.tilemap.getLayers().find(K=>K.isBaseLayer===!0)?.minLevel??this.tilemap.minLevel;this._minZoom=Math.max(this._ZOOM_MIN_CONST,Math.min(this._ZOOM_MAX_CONST,y)),this._maxZoom=this._ZOOM_MAX_CONST;const v=this.prjcenter,L=this.viewer.camera.position.clone().clone().sub(v).normalize(),S=_i(n.zoom)?13:n.zoom,Z=Math.max(this._minZoom,Math.min(this._maxZoom,S)),G=this._computeDistanceFromZoom(Z);c.clone().addScaledVector(L,G);const A=this.getZoom();this._lastZoomForControls=A,this._zoomStartValue=A,this.collisionEngine=new bp(this.viewer.renderer,{padding:8,updateInterval:16,animationDuration:200,maxFeaturesPerFrame:2e4,strategies:{priority:!0,grouping:!0,proximity:!0}}),this.on("control-change",_p.debounce(K=>{const D=this.tilemap,O=D.getDataZoom(),R=D.getLayers().find(J=>J.isBaseLayer===!0)?.maxLevel??D.maxLevel,W=this._getCameraDistance(),k=W-this._lastCameraDistance;this._lastCameraDistance=W;const{max:N}=this._getViewZoomRange(),H=Math.max(0,N-R);O<R?this._overZoom=0:k<-.001?this._overZoom=Math.min(this._overZoom+1,H):k>.001&&(this._overZoom=Math.max(this._overZoom-1,0));const j=this.getZoom();Math.abs(j-this._lastZoomForControls)>.001&&(this._isZooming?this.trigger("zooming",{from:this._zoomStartValue,to:j}):(this._isZooming=!0,this._zoomStartValue=this._lastZoomForControls,this.trigger("zoomstart",{from:this._zoomStartValue,to:j})),this._lastZoomForControls=j),this.collisionEngine.update(K.camera)},10,{leading:!1,trailing:!0})),this.on("control-end",()=>{this._isZooming&&(this._isZooming=!1,this.trigger("zoomend",{from:this._zoomStartValue,to:this.getZoom()}))}),this._callOnLoadHooks(),this._registerDomEvents()}static addOnLoadHook(e,...n){const r=typeof e=="function"?e:function(){this[e].apply(this,n)},s=this.prototype;return s._onLoadHooks=s._onLoadHooks||[],s._onLoadHooks.push(r),this}_callOnLoadHooks(){const e=Ch.prototype;if(e._onLoadHooks)for(let n=0,r=e._onLoadHooks.length;n<r;n++)e._onLoadHooks[n].call(this)}getZoom(){const e=this.tilemap,n=e.getDataZoom(),s=e.getLayers().find(a=>a.isBaseLayer===!0)?.maxLevel??e.maxLevel;return n<s?n:s+this._overZoom}getDataZoom(){return this.tilemap.getDataZoom()}getMinZoom(){return this._minZoom}getMaxZoom(){return this._maxZoom}setZoomRange(e,n){if(e>n){const s=e;e=n,n=s}this._minZoom=e,this._maxZoom=n;const r=this.viewer.controls;if(r){const s=this._computeDistanceFromZoom(this._maxZoom),a=this._computeDistanceFromZoom(this._minZoom);r.minDistance=s,r.maxDistance=a}return this}setMinZoom(e){return this.setZoomRange(e,this._maxZoom)}setMaxZoom(e){return this.setZoomRange(this._minZoom,e)}setZoom(e){const n=this.getMinZoom(),r=this.getMaxZoom(),s=Math.max(n,Math.min(r,e)),a=this.getZoom(),c=this._computeDistanceFromZoom(s),u=this.viewer.controls,d=u?.target??this.prjcenter,p=this.viewer.camera,f=p.position.clone().sub(d).normalize();return p.position.copy(d).addScaledVector(f,c),p.updateProjectionMatrix(),typeof u?.update=="function"&&u.update(),this._lastZoomForControls=s,this.trigger("zoomend",{from:a,to:this.getZoom()}),this}zoomIn(e=1){return this.setZoom(this.getZoom()+e)}zoomOut(e=1){return this.setZoom(this.getZoom()-e)}_computeDistanceFromZoom(e){const n=this._ZOOM_MIN_CONST,r=this._ZOOM_MAX_CONST,s=this._minZoomDistance,a=this._maxZoomDistance;if(s<=0||s>=a){const f=Math.max(n,Math.min(r,e)),y=(r-f)/(r-n);return s+y*(a-s)}const u=(Math.max(n,Math.min(r,e))-n)/(r-n),d=s/a;return a*Math.pow(d,u)}initTileMap(e){const n=new bi({...e});try{if(e.Baselayers?.length)for(const r of e.Baselayers)r.isBaseLayer=!0,n.addLayer(r)}catch(r){console.error("💥 诊断失败:",r)}return n.rotateX(-Math.PI/2),n.receiveShadow=!0,setTimeout(()=>{const r={timestamp:If(),targrt:this};this._EventMap.loaded={listened:!0},this.trigger("loaded",r)},0),n}addLayer(e,...n){if(!e)return this;Array.isArray(e)||(e=[e]),n?.length&&(e=e.concat(n)),n?.length&&(e=e.concat(n));for(let r=0,s=e.length;r<s;r++){const a=e[r],c=a.getId();if(_i(c))throw new Error("Invalid id for the layer: "+c);a.isTileLayer?this.addTileLayer(a):this.addRegularLayer(a)}return this}removeLayer(e){const n=this._layerContainer.getLayerById(e);return n?(this._layerContainer.remove(n),console.log(`✅ 图层从场景移除: ${e}`),n.isTileLayer&&(this.tilemap.removeLayer(e),console.log(`✅ 瓦片图层从管理器移除: ${e}`)),n instanceof Bn&&n?._collision,!0):(console.warn(`⚠️ 图层不存在: ${e}`),!1)}addRegularLayer(e){const n=e.getId();this._layerContainer.add(e),e._bindMap(this),e instanceof Bn&&e?._collision&&(this.collisionEngine.registerLayer(e),e.setCollisionEngine(this.collisionEngine)),console.log(`📁 普通图层已添加到场景: ${n}`)}addTileLayer(e){if(this.tilemap.addLayer(e),e._bindMap(this),e instanceof rc){const n=new Vp(e.getId()+"-vtrender",{altitude:e.getAltitude(),style:e.getStyle(),collision:e._collision});e._setRenderer(n),this.addRegularLayer(n)}return this}clearLayers(){return this._layerContainer.clear(),this.tilemap.clearLayers(),this}getLayers(){return[...this._layerContainer.getLayers(),...this.tilemap.getLayers()]}getLayerById(e){const n=this._layerContainer.getLayerById(e);return n||this.tilemap.getLayer(e)}geo2world(e){return this.tilemap.geo2world(e)}world2geo(e){return this.tilemap.world2geo(e)}geo2map(e){return this.tilemap.geo2map(e)}_getCanvas(e=40,n=30,r){return this._canvasManager.getCanvas(e,n,1,r)}getContainer(){return this.viewer.container}getRenderer(){return this.viewer.renderer}getCamera(){return this.viewer.camera}_findFeaturesAt(e){const n=this,r=n.getRenderer(),s=n.getCamera(),a=r.domElement.getBoundingClientRect(),c=e.x/a.width*2-1,u=-(e.y/a.height)*2+1,d=new m.Raycaster;d.setFromCamera(new m.Vector2(c,u),s);const p=n.getLayers().filter(v=>!v?.isSceneLayer),y=d.intersectObjects(p,!0).map(v=>{let x=v.object,L=null;for(;x;){if(x instanceof Sn){L=x;break}x=x.parent}return L?{feature:L,distance:v.distance,object:v.object}:null}).filter(v=>!!v);return y.length?y.sort((v,x)=>v.distance-x.distance):[]}getCenter(){const e=this.viewer.controls.target.clone(),n=this.world2geo(e);return[n.x,n.y,n.z]}_getEventPosition(e){let n,r;if("touches"in e){if(e.touches.length===0)return null;n=e.touches[0].clientX,r=e.touches[0].clientY}else n=e.clientX,r=e.clientY;const s=this.getContainer();if(!s)return null;const a=s.getBoundingClientRect();return{x:n-a.left,y:r-a.top}}get isInteracting(){return this.viewer.isInteracting}_getCameraDistance(){const e=this.viewer.controls,n=this.viewer.camera,r=e?.target??this.prjcenter;return e&&typeof e.getDistance=="function"?e.getDistance():n.position.distanceTo(r)}_getViewZoomRange(){const e=this.viewer.controls,n=typeof e?.minDistance=="number"?e.minDistance:this._minZoomDistance,r=typeof e?.maxDistance=="number"?e.maxDistance:this._maxZoomDistance;if(n<=0||n>=r){const y=this.tilemap.getDataZoom();return{min:y,max:y}}const s=r/n,a=Math.log2(s),c=this.tilemap.getLayers().find(y=>y.isBaseLayer===!0),u=c?.minLevel??this.tilemap.minLevel,d=c?.maxLevel??this.tilemap.maxLevel,p=u,f=d+a;return{min:p,max:f}}flyTo(e){this.viewer.flyToAdvanced(e)}flyToPoint(e){this.viewer.flyToPoint(e)}};Nn.mergeOptions(jm);function ic(l,t,e){const{currentTarget:n,clientX:r,clientY:s}=l;if(n instanceof HTMLElement){const a=n.clientWidth,c=n.clientHeight,u=new m.Vector2(r/a*2-1,-(s/c)*2+1);return t.getLocalInfoFromScreen(e,u)?.location}else return}const Jm=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout"];Nn.prototype._removeDomEvents=function(){console.log("removeDomEvents",this)},Nn.prototype._registerDomEvents=function(){const l=this.viewer.container;l&&Jm.forEach(t=>{l.addEventListener(t,e=>{let n=ic(e,this.tilemap,this.viewer.camera),r={target:this,originEvent:e,eventName:t,screenXY:{X:e.screenX,Y:e.screenY}};if(n){let s=[n.x,n.y,n.z];r={target:this,originEvent:e,coordinate:s,eventName:t,screenXY:{X:e.screenX,Y:e.screenY}}}this.trigger(t,r)})})},Nn.addOnLoadHook("_registerDomEvents");const Qm=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchmove","touchend"];class Hm extends ml{constructor(){super(...arguments);T(this,"_registeredEvents",[]);T(this,"_eventCommon",e=>{(e.type==="mousedown"||e.type==="touchstart")&&(this._mouseDownTime=Date.now()),!(e.type==="click"&&Date.now()-this._mouseDownTime>300)&&this._handleEvent(e,e.type)})}addHooks(){const n=this.target.getContainer();n&&Qm.forEach(r=>{n.addEventListener(r,this._eventCommon),this._registeredEvents.push(r)})}removeHooks(){const n=this.target.getContainer();n&&this._registeredEvents.length>0&&(this._registeredEvents.forEach(r=>{const s=r;n.removeEventListener(s,this._eventCommon)}),this._registeredEvents=[])}_handleEvent(e,n){const r=this.target;if(this._shouldIgnoreEvent()||(n==="mousemove"||n==="mouseenter"||n==="mouseleave"||n==="mouseover"||n==="mouseout"||n==="touchmove")&&!r.getLayers().some(d=>!d.isSceneLayer&&d._feaList?.length>0))return;const s=r._getEventPosition(e);if(!s)return;const a=r._findFeaturesAt(s);if(a.length===0)return;const c=a[0].feature;switch(n){case"click":this._handleClickEvent(c,e);break;case"mousemove":case"mouseenter":case"mouseleave":case"mouseover":case"mouseout":case"touchmove":this.handleMoveEvent(c,e);break;default:if(c){this._fireFeatureEvent(c,n,e);const u=c.getLayer();u&&u.trigger("feature"+n,{feature:c,domEvent:e,type:"feature"+n})}}}_handleClickEvent(e,n){if(!e)return;this._fireFeatureEvent(e,"click",n);const r=e.getLayer();r&&r.trigger("featureclick",{feature:e,domEvent:n,type:"featureclick"})}handleMoveEvent(e,n){if(!e)return;this._fireFeatureEvent(e,n.type,n);const r=e.getLayer();r&&r.trigger("feature"+n.type,{feature:e,domEvent:n,type:"feature"+n.type})}_fireFeatureEvent(e,n,r){const s=this.target;let a=r,c,u;if("touches"in r){const y=r.touches[0]||r.changedTouches[0];if(!y)return;a={currentTarget:r.currentTarget,clientX:y.clientX,clientY:y.clientY},c=y.screenX,u=y.screenY}else{const y=r;a=y,c=y.screenX,u=y.screenY}const d=ic(a,s.tilemap,s.viewer.camera);if(!d)return;const p=[d.x,d.y,d.z],f={target:e,originEvent:r,coordinate:p,eventName:n,screenXY:{X:c,Y:u}};e.trigger(n,f)}_shouldIgnoreEvent(){return!!this.target.isInteracting}}Nn.mergeOptions({FeatureEvents:!0,onlyVisibleFeatureEvents:!0}),Nn.addOnLoadHook("addHandler","FeatureEvents",Hm);class Em extends Rt{constructor(e){super(e);T(this,"dataType","image");T(this,"attribution","天地图");T(this,"token","");T(this,"style","img_w");T(this,"subdomains","01234");T(this,"url","https://t{s}.tianditu.gov.cn/DataServer?T={style}&x={x}&y={y}&l={z}&tk={token}");if(Object.assign(this,e),!this.token)throw new Error("天地图访问令牌(token)是必填参数")}}class qm extends Rt{constructor(e){super(e);T(this,"dataType","quantized-mesh");T(this,"attribution","天地图");T(this,"token","");T(this,"subdomains","01234");T(this,"url","https://t{s}.tianditu.gov.cn/mapservice/swdx?T=elv_c&tk={token}&x={x}&y={y}&l={z}");if(Object.assign(this,e),!this.token)throw new Error("天地图访问令牌(token)是必填参数")}}class $m extends Rt{constructor(e){super({...e,url:e.urlTemplate,isTMS:e.isTMS||!1});T(this,"minLevel",2);T(this,"maxLevel",24)}getUrl(e,n,r){const s=this.isTMS?Math.pow(2,r)-1-n:n;return Pf(this.url,{...this,x:e,y:s,z:r,tileMatrix:r,tileRow:s,tileCol:e})}}class e0 extends Rt{constructor(e){super(e);T(this,"dataType","image");T(this,"attribution","ArcGIS");T(this,"style","World_Imagery");T(this,"url","https://services.arcgisonline.com/arcgis/rest/services/{style}/MapServer/tile/{z}/{y}/{x}");Object.assign(this,e)}}class t0 extends Rt{constructor(e){super(e);T(this,"dataType","lerc");T(this,"attribution","ArcGIS");T(this,"minLevel",6);T(this,"maxLevel",13);T(this,"url","https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer/tile/{z}/{y}/{x}");Object.assign(this,e)}}class n0 extends Rt{constructor(e){super(e);T(this,"token","");T(this,"format","webp");T(this,"style","cm2myr6qx001t01pi0sf7estf");T(this,"attribution","MapBox");T(this,"maxLevel",25);T(this,"url","https://api.mapbox.com/styles/v1/criska/cm2myr6qx001t01pi0sf7estf/tiles/256/{z}/{x}/{y}?access_token={token}&format={format}");if(Object.assign(this,e),!this.token)throw new Error("MapBox访问令牌(token)是必填参数")}}class r0 extends Rt{constructor(e){super(e);T(this,"dataType","mvt");T(this,"style",{layer:[]});Object.assign(this,e)}}class i0 extends Rt{constructor(e){super(e);T(this,"dataType","VectorTile");T(this,"attribution","ArcGIS");T(this,"minLevel",1);T(this,"maxLevel",21);T(this,"url","https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key=uKYsZQZpm72WlbSgH9B7");Object.assign(this,e)}}class s0 extends Bn{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Line"}}class o0 extends Bn{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Point"}}class a0 extends Bn{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Surface"}}class l0 extends Bn{constructor(e,n){super(e,n);T(this,"_clouds",null);const r=["texture"];for(const s of r)cl(n,s);this._createClouds(n.texture)}async _createClouds(e){const n=await Pt._loadTexture(e),r=new Ff({texture:n,material:m.MeshBasicMaterial});r.castShadow=!0,r.renderOrder=99999,this._clouds=r}validateFeature(e){return e._type==="Cloud"}animate(e,n){this._clouds&&this._clouds.update(this.map.viewer.camera,n,e)}}class c0 extends zl{constructor(e,n){super(e,n);T(this,"layerType","raster")}createLoader(){const e=new Ci;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}}class u0 extends c0{constructor(e,n){super(e,n);T(this,"layerType","wmts");T(this,"_layerName");T(this,"_style");T(this,"_matrixSet");this._layerName=n.layerName,this._style=n.style||"default",this._matrixSet=n.matrixSet||"GoogleMapsCompatible"}get layerName(){return this._layerName}get style(){return this._style}get matrixSet(){return this._matrixSet}createLoader(){const e=new Ci;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}update(e){this.loader&&super.update(e)}}console.log("%c✨ terra.gl V"+Vh+" ","color:rgb(255, 255, 255); font-weight: bold; background: linear-gradient(90deg, #ffb6c1, #ff69b4); padding: 5px; border-radius: 5px;"),ee.ArcGisDemSource=t0,ee.ArcGisSource=e0,ee.CloudsLayer=l0,ee.EventClass=Qs,ee.ICloud=Xl,ee.Label=kl,ee.LineLayer=s0,ee.LineString=io,ee.LoaderFactory=Xe,ee.MVTGeoSource=i0,ee.MVTSource=r0,ee.Maker=ro,ee.Map=Nn,ee.MapBoxSource=n0,ee.Martini=Ul,ee.Model=Fl,ee.MultiLineString=Al,ee.PointLayer=o0,ee.Polygon=Vl,ee.PolygonLayer=a0,ee.ProjectFactory=Zf,ee.PromiseWorker=Ap,ee.Style=Pt,ee.TDTQMSource=qm,ee.TDTSource=Em,ee.TPoints=Dl,ee.Tile=nn,ee.TileCanvasLoader=Yp,ee.TileGeometry=fr,ee.TileGeometryLoader=uo,ee.TileLoader=Ci,ee.TileLoadingManager=Ol,ee.TileMap=bi,ee.TileMaterial=ho,ee.TileMaterialLoader=fo,ee.TileSource=Rt,ee.VectorFeatureTypes=tt,ee.VectorTileLayer=rc,ee.VectorTileRender=Bl,ee.Viewer=ul,ee.WMTSSource=$m,ee.WMTSTileLayer=u0,ee.addSkirt=Rl,ee.author=Qp,ee.concatenateTypedArrays=Br,ee.convertGeometryToWGS84=kp,ee.createBillboards=Gf,ee.getBoundsCoord=so,ee.getGeometryDataFromDem=Yl,ee.getGridIndices=lo,ee.getLocalInfoFromRay=js,ee.getLocalInfoFromScreen=pl,ee.getLocalInfoFromWorld=Js,ee.getNormals=co,ee.getSafeTileUrlAndBounds=oo,ee.registerDEMLoader=mo,ee.registerImgLoader=po,ee.registerMeshLoader=Nl,ee.vector2ToWGS84=ao,ee.version=Jp,ee.waitFor=Hp,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})});
|
|
757
|
+
`;class Kt{constructor(t){T(this,"dataType","image");T(this,"attribution","isource");T(this,"minLevel",0);T(this,"maxLevel",18);T(this,"projectionID","3857");T(this,"url","");T(this,"subdomains",[]);T(this,"s","");T(this,"opacity",1);T(this,"isTMS",!1);T(this,"bounds",[-180,-85,180,85]);T(this,"_projectionBounds",[-1/0,-1/0,1/0,1/0]);T(this,"tileMaterial");Object.assign(this,t)}getUrl(t,e,n){const i={...this,x:t,y:e,z:n};return Ep(this.url,i)}_getUrl(t,e,n){const i=this.subdomains.length;if(i>0){const l=Math.floor(Math.random()*i);this.s=this.subdomains[l]}const s=this.isTMS?Math.pow(2,n)-1-e:e;return this.getUrl(t,s,n)}static create(t){return new Kt(t)}}function Ep(a,t){const e=/\{ *([\w_-]+) *\}/g;return a.replace(e,(n,i)=>{const s=t[i]??(()=>{throw new Error(`source url template error, No value provided for variable: ${n}`)})();return typeof s=="function"?s(t):s})}const{version:qp,author:$p}=JSON.parse(Hp);function em(a,t=100){return new Promise(e=>{const n=setInterval(()=>{a&&(clearInterval(n),e())},t)})}function vo(a){return Xe.registerMaterialLoader(a),a}function wo(a){return Xe.registerGeometryLoader(a),a}function El(a){return Xe.registerMeshLoader(a),a}vo(new Jp);const ql="dmFyIGNlPU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgbWU9KGosWixxKT0+WiBpbiBqP2NlKGosWix7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6cX0pOmpbWl09cTt2YXIgTj0oaixaLHEpPT5tZShqLHR5cGVvZiBaIT0ic3ltYm9sIj9aKyIiOloscSk7KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGooQSxwKXtjb25zdCBrPW5ldyBGbG9hdDMyQXJyYXkoQS5sZW5ndGgpO2Z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jLHUpe2NvbnN0IG09bmV3IEZsb2F0MzJBcnJheShpKm8pO2ZvcihsZXQgbD0wO2w8bztsKyspZm9yKGxldCBmPTA7ZjxpO2YrKyl7Y29uc3QgZz0obCtoKSp0KyhmK24pLE09bCppK2Y7bVtNXT1zW2ddfWNvbnN0IHc9bmV3IEZsb2F0MzJBcnJheSh1KmMpO2ZvcihsZXQgbD0wO2w8dTtsKyspZm9yKGxldCBmPTA7ZjxjO2YrKyl7Y29uc3QgZz1sKnUrZixNPU1hdGgucm91bmQoZipvL3UpLGQ9TWF0aC5yb3VuZChsKmkvYykqaStNO3dbZ109bVtkXX1yZXR1cm4gd31jb25zdCBVPW9lKHAsQS53aWR0aCksYT1VLnN3KzEsZT1VLnNoKzE7cmV0dXJue2FycmF5OmsoQS5hcnJheSxBLndpZHRoLFUuc3gsVS5zeSxVLnN3LFUuc2gsYSxlKSx3aWR0aDphLGhlaWdodDplfX1mdW5jdGlvbiBvZShBLHApe2NvbnN0IGs9TWF0aC5mbG9vcihBWzBdKnApLFU9TWF0aC5mbG9vcihBWzFdKnApLGE9TWF0aC5mbG9vcigoQVsyXS1BWzBdKSpwKSxlPU1hdGguZmxvb3IoKEFbM10tQVsxXSkqcCk7cmV0dXJue3N4Omssc3k6VSxzdzphLHNoOmV9fXNlbGYub25tZXNzYWdlPUE9Pntjb25zdCBwPUEuZGF0YSxrPXNlKHAuZGVtRGF0YSxwLnoscC5jbGlwQm91bmRzKTtzZWxmLnBvc3RNZXNzYWdlKGspfX0pKCk7Cg==",tm=a=>Uint8Array.from(atob(a),t=>t.charCodeAt(0)),$l=typeof self<"u"&&self.Blob&&new Blob([tm(ql)],{type:"text/javascript;charset=utf-8"});function nm(a){let t;try{if(t=$l&&(self.URL||self.webkitURL).createObjectURL($l),!t)throw"";const e=new Worker(t,{name:a?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+ql,{name:a?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}/* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */const im=function(){var a={};a.defaultNoDataValue=-34027999387901484e22,a.decode=function(l,u){u=u||{};var c=u.encodedMaskData||u.encodedMaskData===null,d=i(l,u.inputOffset||0,c),p=u.noDataValue!==null?u.noDataValue:a.defaultNoDataValue,f=t(d,u.pixelType||Float32Array,u.encodedMaskData,p,u.returnMask),y={width:d.width,height:d.height,pixelData:f.resultPixels,minValue:f.minValue,maxValue:d.pixels.maxValue,noDataValue:p};return f.resultMask&&(y.maskData=f.resultMask),u.returnEncodedMask&&d.mask&&(y.encodedMaskData=d.mask.bitset?d.mask.bitset:null),u.returnFileInfo&&(y.fileInfo=e(d),u.computeUsedBitDepths&&(y.fileInfo.bitDepths=n(d))),y};var t=function(l,u,c,d,p){var f=0,y=l.pixels.numBlocksX,v=l.pixels.numBlocksY,x=Math.floor(l.width/y),S=Math.floor(l.height/v),_=2*l.maxZError,Z=Number.MAX_VALUE,M;c=c||(l.mask?l.mask.bitset:null);var G,A;G=new u(l.width*l.height),p&&c&&(A=new Uint8Array(l.width*l.height));for(var R=new Float32Array(x*S),D,k,C=0;C<=v;C++){var K=C!==v?S:l.height%v;if(K!==0)for(var I=0;I<=y;I++){var z=I!==y?x:l.width%y;if(z!==0){var N=C*l.width*S+I*x,H=l.width-z,j=l.pixels.blocks[f],q,J,oe;j.encoding<2?(j.encoding===0?q=j.rawData:(s(j.stuffedData,j.bitsPerPixel,j.numValidPixels,j.offset,_,R,l.pixels.maxValue),q=R),J=0):j.encoding===2?oe=0:oe=j.offset;var re;if(c)for(k=0;k<K;k++){for(N&7&&(re=c[N>>3],re<<=N&7),D=0;D<z;D++)N&7||(re=c[N>>3]),re&128?(A&&(A[N]=1),M=j.encoding<2?q[J++]:oe,Z=Z>M?M:Z,G[N++]=M):(A&&(A[N]=0),G[N++]=d),re<<=1;N+=H}else if(j.encoding<2)for(k=0;k<K;k++){for(D=0;D<z;D++)M=q[J++],Z=Z>M?M:Z,G[N++]=M;N+=H}else for(Z=Z>oe?oe:Z,k=0;k<K;k++){for(D=0;D<z;D++)G[N++]=oe;N+=H}if(j.encoding===1&&J!==j.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:G,resultMask:A,minValue:Z}},e=function(l){return{fileIdentifierString:l.fileIdentifierString,fileVersion:l.fileVersion,imageType:l.imageType,height:l.height,width:l.width,maxZError:l.maxZError,eofOffset:l.eofOffset,mask:l.mask?{numBlocksX:l.mask.numBlocksX,numBlocksY:l.mask.numBlocksY,numBytes:l.mask.numBytes,maxValue:l.mask.maxValue}:null,pixels:{numBlocksX:l.pixels.numBlocksX,numBlocksY:l.pixels.numBlocksY,numBytes:l.pixels.numBytes,maxValue:l.pixels.maxValue,noDataValue:l.noDataValue}}},n=function(l){for(var u=l.pixels.numBlocksX*l.pixels.numBlocksY,c={},d=0;d<u;d++){var p=l.pixels.blocks[d];p.encoding===0?c.float32=!0:p.encoding===1?c[p.bitsPerPixel]=!0:c[0]=!0}return Object.keys(c)},i=function(l,u,c){var d={},p=new Uint8Array(l,u,10);if(d.fileIdentifierString=String.fromCharCode.apply(null,p),d.fileIdentifierString.trim()!=="CntZImage")throw"Unexpected file identifier string: "+d.fileIdentifierString;u+=10;var f=new DataView(l,u,24);if(d.fileVersion=f.getInt32(0,!0),d.imageType=f.getInt32(4,!0),d.height=f.getUint32(8,!0),d.width=f.getUint32(12,!0),d.maxZError=f.getFloat64(16,!0),u+=24,!c)if(f=new DataView(l,u,16),d.mask={},d.mask.numBlocksY=f.getUint32(0,!0),d.mask.numBlocksX=f.getUint32(4,!0),d.mask.numBytes=f.getUint32(8,!0),d.mask.maxValue=f.getFloat32(12,!0),u+=16,d.mask.numBytes>0){var y=new Uint8Array(Math.ceil(d.width*d.height/8));f=new DataView(l,u,d.mask.numBytes);var v=f.getInt16(0,!0),x=2,S=0;do{if(v>0)for(;v--;)y[S++]=f.getUint8(x++);else{var _=f.getUint8(x++);for(v=-v;v--;)y[S++]=_}v=f.getInt16(x,!0),x+=2}while(x<d.mask.numBytes);if(v!==-32768||S<y.length)throw"Unexpected end of mask RLE encoding";d.mask.bitset=y,u+=d.mask.numBytes}else d.mask.numBytes|d.mask.numBlocksY|d.mask.maxValue||(d.mask.bitset=new Uint8Array(Math.ceil(d.width*d.height/8)));f=new DataView(l,u,16),d.pixels={},d.pixels.numBlocksY=f.getUint32(0,!0),d.pixels.numBlocksX=f.getUint32(4,!0),d.pixels.numBytes=f.getUint32(8,!0),d.pixels.maxValue=f.getFloat32(12,!0),u+=16;var Z=d.pixels.numBlocksX,M=d.pixels.numBlocksY,G=Z+(d.width%Z>0?1:0),A=M+(d.height%M>0?1:0);d.pixels.blocks=new Array(G*A);for(var R=0,D=0;D<A;D++)for(var k=0;k<G;k++){var C=0,K=l.byteLength-u;f=new DataView(l,u,Math.min(10,K));var I={};d.pixels.blocks[R++]=I;var z=f.getUint8(0);if(C++,I.encoding=z&63,I.encoding>3)throw"Invalid block encoding ("+I.encoding+")";if(I.encoding===2){u++;continue}if(z!==0&&z!==2){if(z>>=6,I.offsetType=z,z===2)I.offset=f.getInt8(1),C++;else if(z===1)I.offset=f.getInt16(1,!0),C+=2;else if(z===0)I.offset=f.getFloat32(1,!0),C+=4;else throw"Invalid block offset type";if(I.encoding===1)if(z=f.getUint8(C),C++,I.bitsPerPixel=z&63,z>>=6,I.numValidPixelsType=z,z===2)I.numValidPixels=f.getUint8(C),C++;else if(z===1)I.numValidPixels=f.getUint16(C,!0),C+=2;else if(z===0)I.numValidPixels=f.getUint32(C,!0),C+=4;else throw"Invalid valid pixel count type"}if(u+=C,I.encoding!==3){var N,H;if(I.encoding===0){var j=(d.pixels.numBytes-1)/4;if(j!==Math.floor(j))throw"uncompressed block has invalid length";N=new ArrayBuffer(j*4),H=new Uint8Array(N),H.set(new Uint8Array(l,u,j*4));var q=new Float32Array(N);I.rawData=q,u+=j*4}else if(I.encoding===1){var J=Math.ceil(I.numValidPixels*I.bitsPerPixel/8),oe=Math.ceil(J/4);N=new ArrayBuffer(oe*4),H=new Uint8Array(N),H.set(new Uint8Array(l,u,J)),I.stuffedData=new Uint32Array(N),u+=J}}}return d.eofOffset=u,d},s=function(l,u,c,d,p,f,y){var v=(1<<u)-1,x=0,S,_=0,Z,M,G=Math.ceil((y-d)/p),A=l.length*4-Math.ceil(u*c/8);for(l[l.length-1]<<=8*A,S=0;S<c;S++){if(_===0&&(M=l[x++],_=32),_>=u)Z=M>>>_-u&v,_-=u;else{var R=u-_;Z=(M&v)<<R&v,M=l[x++],_=32-R,Z+=M>>>_}f[S]=Z<G?d+Z*p:y}return f};return a}(),rm=function(){var a={unstuff:function(i,s,l,u,c,d,p,f){var y=(1<<l)-1,v=0,x,S=0,_,Z,M,G,A=i.length*4-Math.ceil(l*u/8);if(i[i.length-1]<<=8*A,c)for(x=0;x<u;x++)S===0&&(Z=i[v++],S=32),S>=l?(_=Z>>>S-l&y,S-=l):(M=l-S,_=(Z&y)<<M&y,Z=i[v++],S=32-M,_+=Z>>>S),s[x]=c[_];else for(G=Math.ceil((f-d)/p),x=0;x<u;x++)S===0&&(Z=i[v++],S=32),S>=l?(_=Z>>>S-l&y,S-=l):(M=l-S,_=(Z&y)<<M&y,Z=i[v++],S=32-M,_+=Z>>>S),s[x]=_<G?d+_*p:f},unstuffLUT:function(i,s,l,u,c,d){var p=(1<<s)-1,f=0,y=0,v=0,x=0,S=0,_,Z=[],M=i.length*4-Math.ceil(s*l/8);i[i.length-1]<<=8*M;var G=Math.ceil((d-u)/c);for(y=0;y<l;y++)x===0&&(_=i[f++],x=32),x>=s?(S=_>>>x-s&p,x-=s):(v=s-x,S=(_&p)<<v&p,_=i[f++],x=32-v,S+=_>>>x),Z[y]=S<G?u+S*c:d;return Z.unshift(u),Z},unstuff2:function(i,s,l,u,c,d,p,f){var y=(1<<l)-1,v=0,x,S=0,_=0,Z,M,G;if(c)for(x=0;x<u;x++)S===0&&(M=i[v++],S=32,_=0),S>=l?(Z=M>>>_&y,S-=l,_+=l):(G=l-S,Z=M>>>_&y,M=i[v++],S=32-G,Z|=(M&(1<<G)-1)<<l-G,_=G),s[x]=c[Z];else{var A=Math.ceil((f-d)/p);for(x=0;x<u;x++)S===0&&(M=i[v++],S=32,_=0),S>=l?(Z=M>>>_&y,S-=l,_+=l):(G=l-S,Z=M>>>_&y,M=i[v++],S=32-G,Z|=(M&(1<<G)-1)<<l-G,_=G),s[x]=Z<A?d+Z*p:f}return s},unstuffLUT2:function(i,s,l,u,c,d){var p=(1<<s)-1,f=0,y=0,v=0,x=0,S=0,_=0,Z,M=[],G=Math.ceil((d-u)/c);for(y=0;y<l;y++)x===0&&(Z=i[f++],x=32,_=0),x>=s?(S=Z>>>_&p,x-=s,_+=s):(v=s-x,S=Z>>>_&p,Z=i[f++],x=32-v,S|=(Z&(1<<v)-1)<<s-v,_=v),M[y]=S<G?u+S*c:d;return M.unshift(u),M},originalUnstuff:function(i,s,l,u){var c=(1<<l)-1,d=0,p,f=0,y,v,x,S=i.length*4-Math.ceil(l*u/8);for(i[i.length-1]<<=8*S,p=0;p<u;p++)f===0&&(v=i[d++],f=32),f>=l?(y=v>>>f-l&c,f-=l):(x=l-f,y=(v&c)<<x&c,v=i[d++],f=32-x,y+=v>>>f),s[p]=y;return s},originalUnstuff2:function(i,s,l,u){var c=(1<<l)-1,d=0,p,f=0,y=0,v,x,S;for(p=0;p<u;p++)f===0&&(x=i[d++],f=32,y=0),f>=l?(v=x>>>y&c,f-=l,y+=l):(S=l-f,v=x>>>y&c,x=i[d++],f=32-S,v|=(x&(1<<S)-1)<<l-S,y=S),s[p]=v;return s}},t={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(i){for(var s=65535,l=65535,u=i.length,c=Math.floor(u/2),d=0;c;){var p=c>=359?359:c;c-=p;do s+=i[d++]<<8,l+=s+=i[d++];while(--p);s=(s&65535)+(s>>>16),l=(l&65535)+(l>>>16)}return u&1&&(l+=s+=i[d]<<8),s=(s&65535)+(s>>>16),l=(l&65535)+(l>>>16),(l<<16|s)>>>0},readHeaderInfo:function(i,s){var l=s.ptr,u=new Uint8Array(i,l,6),c={};if(c.fileIdentifierString=String.fromCharCode.apply(null,u),c.fileIdentifierString.lastIndexOf("Lerc2",0)!==0)throw"Unexpected file identifier string (expect Lerc2 ): "+c.fileIdentifierString;l+=6;var d=new DataView(i,l,8),p=d.getInt32(0,!0);c.fileVersion=p,l+=4,p>=3&&(c.checksum=d.getUint32(4,!0),l+=4),d=new DataView(i,l,12),c.height=d.getUint32(0,!0),c.width=d.getUint32(4,!0),l+=8,p>=4?(c.numDims=d.getUint32(8,!0),l+=4):c.numDims=1,d=new DataView(i,l,40),c.numValidPixel=d.getUint32(0,!0),c.microBlockSize=d.getInt32(4,!0),c.blobSize=d.getInt32(8,!0),c.imageType=d.getInt32(12,!0),c.maxZError=d.getFloat64(16,!0),c.zMin=d.getFloat64(24,!0),c.zMax=d.getFloat64(32,!0),l+=40,s.headerInfo=c,s.ptr=l;var f,y;if(p>=3&&(y=p>=4?52:48,f=this.computeChecksumFletcher32(new Uint8Array(i,l-y,c.blobSize-14)),f!==c.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(i,s){var l=s.headerInfo,u=this.getDataTypeArray(l.imageType),c=l.numDims*this.getDataTypeSize(l.imageType),d=this.readSubArray(i,s.ptr,u,c),p=this.readSubArray(i,s.ptr+c,u,c);s.ptr+=2*c;var f,y=!0;for(f=0;f<l.numDims;f++)if(d[f]!==p[f]){y=!1;break}return l.minValues=d,l.maxValues=p,y},readSubArray:function(i,s,l,u){var c;if(l===Uint8Array)c=new Uint8Array(i,s,u);else{var d=new ArrayBuffer(u),p=new Uint8Array(d);p.set(new Uint8Array(i,s,u)),c=new l(d)}return c},readMask:function(i,s){var l=s.ptr,u=s.headerInfo,c=u.width*u.height,d=u.numValidPixel,p=new DataView(i,l,4),f={};if(f.numBytes=p.getUint32(0,!0),l+=4,(d===0||c===d)&&f.numBytes!==0)throw"invalid mask";var y,v;if(d===0)y=new Uint8Array(Math.ceil(c/8)),f.bitset=y,v=new Uint8Array(c),s.pixels.resultMask=v,l+=f.numBytes;else if(f.numBytes>0){y=new Uint8Array(Math.ceil(c/8)),p=new DataView(i,l,f.numBytes);var x=p.getInt16(0,!0),S=2,_=0,Z=0;do{if(x>0)for(;x--;)y[_++]=p.getUint8(S++);else for(Z=p.getUint8(S++),x=-x;x--;)y[_++]=Z;x=p.getInt16(S,!0),S+=2}while(S<f.numBytes);if(x!==-32768||_<y.length)throw"Unexpected end of mask RLE encoding";v=new Uint8Array(c);var M=0,G=0;for(G=0;G<c;G++)G&7?(M=y[G>>3],M<<=G&7):M=y[G>>3],M&128&&(v[G]=1);s.pixels.resultMask=v,f.bitset=y,l+=f.numBytes}return s.ptr=l,s.mask=f,!0},readDataOneSweep:function(i,s,l,u){var c=s.ptr,d=s.headerInfo,p=d.numDims,f=d.width*d.height,y=d.imageType,v=d.numValidPixel*t.getDataTypeSize(y)*p,x,S=s.pixels.resultMask;if(l===Uint8Array)x=new Uint8Array(i,c,v);else{var _=new ArrayBuffer(v),Z=new Uint8Array(_);Z.set(new Uint8Array(i,c,v)),x=new l(_)}if(x.length===f*p)u?s.pixels.resultPixels=t.swapDimensionOrder(x,f,p,l,!0):s.pixels.resultPixels=x;else{s.pixels.resultPixels=new l(f*p);var M=0,G=0,A=0,R=0;if(p>1){if(u){for(G=0;G<f;G++)if(S[G])for(R=G,A=0;A<p;A++,R+=f)s.pixels.resultPixels[R]=x[M++]}else for(G=0;G<f;G++)if(S[G])for(R=G*p,A=0;A<p;A++)s.pixels.resultPixels[R+A]=x[M++]}else for(G=0;G<f;G++)S[G]&&(s.pixels.resultPixels[G]=x[M++])}return c+=v,s.ptr=c,!0},readHuffmanTree:function(i,s){var l=this.HUFFMAN_LUT_BITS_MAX,u=new DataView(i,s.ptr,16);s.ptr+=16;var c=u.getInt32(0,!0);if(c<2)throw"unsupported Huffman version";var d=u.getInt32(4,!0),p=u.getInt32(8,!0),f=u.getInt32(12,!0);if(p>=f)return!1;var y=new Uint32Array(f-p);t.decodeBits(i,s,y);var v=[],x,S,_,Z;for(x=p;x<f;x++)S=x-(x<d?0:d),v[S]={first:y[x-p],second:null};var M=i.byteLength-s.ptr,G=Math.ceil(M/4),A=new ArrayBuffer(G*4),R=new Uint8Array(A);R.set(new Uint8Array(i,s.ptr,M));var D=new Uint32Array(A),k=0,C,K=0;for(C=D[0],x=p;x<f;x++)S=x-(x<d?0:d),Z=v[S].first,Z>0&&(v[S].second=C<<k>>>32-Z,32-k>=Z?(k+=Z,k===32&&(k=0,K++,C=D[K])):(k+=Z-32,K++,C=D[K],v[S].second|=C>>>32-k));var I=0,z=0,N=new e;for(x=0;x<v.length;x++)v[x]!==void 0&&(I=Math.max(I,v[x].first));I>=l?z=l:z=I;var H=[],j,q,J,oe,re,te;for(x=p;x<f;x++)if(S=x-(x<d?0:d),Z=v[S].first,Z>0)if(j=[Z,S],Z<=z)for(q=v[S].second<<z-Z,J=1<<z-Z,_=0;_<J;_++)H[q|_]=j;else for(q=v[S].second,te=N,oe=Z-1;oe>=0;oe--)re=q>>>oe&1,re?(te.right||(te.right=new e),te=te.right):(te.left||(te.left=new e),te=te.left),oe===0&&!te.val&&(te.val=j[1]);return{decodeLut:H,numBitsLUTQick:z,numBitsLUT:I,tree:N,stuffedData:D,srcPtr:K,bitPos:k}},readHuffman:function(i,s,l,u){var c=s.headerInfo,d=c.numDims,p=s.headerInfo.height,f=s.headerInfo.width,y=f*p,v=this.readHuffmanTree(i,s),x=v.decodeLut,S=v.tree,_=v.stuffedData,Z=v.srcPtr,M=v.bitPos,G=v.numBitsLUTQick,A=v.numBitsLUT,R=s.headerInfo.imageType===0?128:0,D,k,C,K=s.pixels.resultMask,I,z,N,H,j,q,J,oe=0;M>0&&(Z++,M=0);var re=_[Z],te=s.encodeMode===1,me=new l(y*d),be=me,he;if(d<2||te){for(he=0;he<d;he++)if(d>1&&(be=new l(me.buffer,y*he,y),oe=0),s.headerInfo.numValidPixel===f*p)for(q=0,H=0;H<p;H++)for(j=0;j<f;j++,q++){if(k=0,I=re<<M>>>32-G,z=I,32-M<G&&(I|=_[Z+1]>>>64-M-G,z=I),x[z])k=x[z][1],M+=x[z][0];else for(I=re<<M>>>32-A,z=I,32-M<A&&(I|=_[Z+1]>>>64-M-A,z=I),D=S,J=0;J<A;J++)if(N=I>>>A-J-1&1,D=N?D.right:D.left,!(D.left||D.right)){k=D.val,M=M+J+1;break}M>=32&&(M-=32,Z++,re=_[Z]),C=k-R,te?(j>0?C+=oe:H>0?C+=be[q-f]:C+=oe,C&=255,be[q]=C,oe=C):be[q]=C}else for(q=0,H=0;H<p;H++)for(j=0;j<f;j++,q++)if(K[q]){if(k=0,I=re<<M>>>32-G,z=I,32-M<G&&(I|=_[Z+1]>>>64-M-G,z=I),x[z])k=x[z][1],M+=x[z][0];else for(I=re<<M>>>32-A,z=I,32-M<A&&(I|=_[Z+1]>>>64-M-A,z=I),D=S,J=0;J<A;J++)if(N=I>>>A-J-1&1,D=N?D.right:D.left,!(D.left||D.right)){k=D.val,M=M+J+1;break}M>=32&&(M-=32,Z++,re=_[Z]),C=k-R,te?(j>0&&K[q-1]?C+=oe:H>0&&K[q-f]?C+=be[q-f]:C+=oe,C&=255,be[q]=C,oe=C):be[q]=C}}else for(q=0,H=0;H<p;H++)for(j=0;j<f;j++)if(q=H*f+j,!K||K[q])for(he=0;he<d;he++,q+=y){if(k=0,I=re<<M>>>32-G,z=I,32-M<G&&(I|=_[Z+1]>>>64-M-G,z=I),x[z])k=x[z][1],M+=x[z][0];else for(I=re<<M>>>32-A,z=I,32-M<A&&(I|=_[Z+1]>>>64-M-A,z=I),D=S,J=0;J<A;J++)if(N=I>>>A-J-1&1,D=N?D.right:D.left,!(D.left||D.right)){k=D.val,M=M+J+1;break}M>=32&&(M-=32,Z++,re=_[Z]),C=k-R,be[q]=C}s.ptr=s.ptr+(Z+1)*4+(M>0?4:0),s.pixels.resultPixels=me,d>1&&!u&&(s.pixels.resultPixels=t.swapDimensionOrder(me,y,d,l))},decodeBits:function(i,s,l,u,c){{var d=s.headerInfo,p=d.fileVersion,f=0,y=i.byteLength-s.ptr>=5?5:i.byteLength-s.ptr,v=new DataView(i,s.ptr,y),x=v.getUint8(0);f++;var S=x>>6,_=S===0?4:3-S,Z=(x&32)>0,M=x&31,G=0;if(_===1)G=v.getUint8(f),f++;else if(_===2)G=v.getUint16(f,!0),f+=2;else if(_===4)G=v.getUint32(f,!0),f+=4;else throw"Invalid valid pixel count type";var A=2*d.maxZError,R,D,k,C,K,I,z,N,H,j=d.numDims>1?d.maxValues[c]:d.zMax;if(Z){for(s.counter.lut++,N=v.getUint8(f),f++,C=Math.ceil((N-1)*M/8),K=Math.ceil(C/4),D=new ArrayBuffer(K*4),k=new Uint8Array(D),s.ptr+=f,k.set(new Uint8Array(i,s.ptr,C)),z=new Uint32Array(D),s.ptr+=C,H=0;N-1>>>H;)H++;C=Math.ceil(G*H/8),K=Math.ceil(C/4),D=new ArrayBuffer(K*4),k=new Uint8Array(D),k.set(new Uint8Array(i,s.ptr,C)),R=new Uint32Array(D),s.ptr+=C,p>=3?I=a.unstuffLUT2(z,M,N-1,u,A,j):I=a.unstuffLUT(z,M,N-1,u,A,j),p>=3?a.unstuff2(R,l,H,G,I):a.unstuff(R,l,H,G,I)}else s.counter.bitstuffer++,H=M,s.ptr+=f,H>0&&(C=Math.ceil(G*H/8),K=Math.ceil(C/4),D=new ArrayBuffer(K*4),k=new Uint8Array(D),k.set(new Uint8Array(i,s.ptr,C)),R=new Uint32Array(D),s.ptr+=C,p>=3?u==null?a.originalUnstuff2(R,l,H,G):a.unstuff2(R,l,H,G,!1,u,A,j):u==null?a.originalUnstuff(R,l,H,G):a.unstuff(R,l,H,G,!1,u,A,j))}},readTiles:function(i,s,l,u){var c=s.headerInfo,d=c.width,p=c.height,f=d*p,y=c.microBlockSize,v=c.imageType,x=t.getDataTypeSize(v),S=Math.ceil(d/y),_=Math.ceil(p/y);s.pixels.numBlocksY=_,s.pixels.numBlocksX=S,s.pixels.ptr=0;var Z=0,M=0,G=0,A=0,R=0,D=0,k=0,C=0,K=0,I=0,z=0,N=0,H=0,j=0,q=0,J=0,oe,re,te,me,be,he,ve=new l(y*y),ze=p%y||y,Ye=d%y||y,je,Je,Qe=c.numDims,ut,mt=s.pixels.resultMask,Ue=s.pixels.resultPixels,dn=c.fileVersion,Gn=dn>=5?14:15,Ae,Ut=c.zMax,Pt;for(G=0;G<_;G++)for(R=G!==_-1?y:ze,A=0;A<S;A++)for(D=A!==S-1?y:Ye,z=G*d*y+A*y,N=d-D,ut=0;ut<Qe;ut++){if(Qe>1?(Pt=Ue,z=G*d*y+A*y,Ue=new l(s.pixels.resultPixels.buffer,f*ut*x,f),Ut=c.maxValues[ut]):Pt=null,k=i.byteLength-s.ptr,oe=new DataView(i,s.ptr,Math.min(10,k)),re={},J=0,C=oe.getUint8(0),J++,Ae=c.fileVersion>=5?C&4:0,K=C>>6&255,I=C>>2&Gn,I!==(A*y>>3&Gn)||Ae&&ut===0)throw"integrity issue";if(he=C&3,he>3)throw s.ptr+=J,"Invalid block encoding ("+he+")";if(he===2){if(Ae)if(mt)for(Z=0;Z<R;Z++)for(M=0;M<D;M++)mt[z]&&(Ue[z]=Pt[z]),z++;else for(Z=0;Z<R;Z++)for(M=0;M<D;M++)Ue[z]=Pt[z],z++;s.counter.constant++,s.ptr+=J;continue}else if(he===0){if(Ae)throw"integrity issue";if(s.counter.uncompressed++,s.ptr+=J,H=R*D*x,j=i.byteLength-s.ptr,H=H<j?H:j,te=new ArrayBuffer(H%x===0?H:H+x-H%x),me=new Uint8Array(te),me.set(new Uint8Array(i,s.ptr,H)),be=new l(te),q=0,mt)for(Z=0;Z<R;Z++){for(M=0;M<D;M++)mt[z]&&(Ue[z]=be[q++]),z++;z+=N}else for(Z=0;Z<R;Z++){for(M=0;M<D;M++)Ue[z++]=be[q++];z+=N}s.ptr+=q*x}else if(je=t.getDataTypeUsed(Ae&&v<6?4:v,K),Je=t.getOnePixel(re,J,je,oe),J+=t.getDataTypeSize(je),he===3)if(s.ptr+=J,s.counter.constantoffset++,mt)for(Z=0;Z<R;Z++){for(M=0;M<D;M++)mt[z]&&(Ue[z]=Ae?Math.min(Ut,Pt[z]+Je):Je),z++;z+=N}else for(Z=0;Z<R;Z++){for(M=0;M<D;M++)Ue[z]=Ae?Math.min(Ut,Pt[z]+Je):Je,z++;z+=N}else if(s.ptr+=J,t.decodeBits(i,s,ve,Je,ut),J=0,Ae)if(mt)for(Z=0;Z<R;Z++){for(M=0;M<D;M++)mt[z]&&(Ue[z]=ve[J++]+Pt[z]),z++;z+=N}else for(Z=0;Z<R;Z++){for(M=0;M<D;M++)Ue[z]=ve[J++]+Pt[z],z++;z+=N}else if(mt)for(Z=0;Z<R;Z++){for(M=0;M<D;M++)mt[z]&&(Ue[z]=ve[J++]),z++;z+=N}else for(Z=0;Z<R;Z++){for(M=0;M<D;M++)Ue[z++]=ve[J++];z+=N}}Qe>1&&!u&&(s.pixels.resultPixels=t.swapDimensionOrder(s.pixels.resultPixels,f,Qe,l))},formatFileInfo:function(i){return{fileIdentifierString:i.headerInfo.fileIdentifierString,fileVersion:i.headerInfo.fileVersion,imageType:i.headerInfo.imageType,height:i.headerInfo.height,width:i.headerInfo.width,numValidPixel:i.headerInfo.numValidPixel,microBlockSize:i.headerInfo.microBlockSize,blobSize:i.headerInfo.blobSize,maxZError:i.headerInfo.maxZError,pixelType:t.getPixelType(i.headerInfo.imageType),eofOffset:i.eofOffset,mask:i.mask?{numBytes:i.mask.numBytes}:null,pixels:{numBlocksX:i.pixels.numBlocksX,numBlocksY:i.pixels.numBlocksY,maxValue:i.headerInfo.zMax,minValue:i.headerInfo.zMin,noDataValue:i.noDataValue}}},constructConstantSurface:function(i,s){var l=i.headerInfo.zMax,u=i.headerInfo.zMin,c=i.headerInfo.maxValues,d=i.headerInfo.numDims,p=i.headerInfo.height*i.headerInfo.width,f=0,y=0,v=0,x=i.pixels.resultMask,S=i.pixels.resultPixels;if(x)if(d>1){if(s)for(f=0;f<d;f++)for(v=f*p,l=c[f],y=0;y<p;y++)x[y]&&(S[v+y]=l);else for(y=0;y<p;y++)if(x[y])for(v=y*d,f=0;f<d;f++)S[v+d]=c[f]}else for(y=0;y<p;y++)x[y]&&(S[y]=l);else if(d>1&&u!==l)if(s)for(f=0;f<d;f++)for(v=f*p,l=c[f],y=0;y<p;y++)S[v+y]=l;else for(y=0;y<p;y++)for(v=y*d,f=0;f<d;f++)S[v+f]=c[f];else for(y=0;y<p*d;y++)S[y]=l},getDataTypeArray:function(i){var s;switch(i){case 0:s=Int8Array;break;case 1:s=Uint8Array;break;case 2:s=Int16Array;break;case 3:s=Uint16Array;break;case 4:s=Int32Array;break;case 5:s=Uint32Array;break;case 6:s=Float32Array;break;case 7:s=Float64Array;break;default:s=Float32Array}return s},getPixelType:function(i){var s;switch(i){case 0:s="S8";break;case 1:s="U8";break;case 2:s="S16";break;case 3:s="U16";break;case 4:s="S32";break;case 5:s="U32";break;case 6:s="F32";break;case 7:s="F64";break;default:s="F32"}return s},isValidPixelValue:function(i,s){if(s==null)return!1;var l;switch(i){case 0:l=s>=-128&&s<=127;break;case 1:l=s>=0&&s<=255;break;case 2:l=s>=-32768&&s<=32767;break;case 3:l=s>=0&&s<=65536;break;case 4:l=s>=-2147483648&&s<=2147483647;break;case 5:l=s>=0&&s<=4294967296;break;case 6:l=s>=-34027999387901484e22&&s<=34027999387901484e22;break;case 7:l=s>=-17976931348623157e292&&s<=17976931348623157e292;break;default:l=!1}return l},getDataTypeSize:function(i){var s=0;switch(i){case 0:case 1:s=1;break;case 2:case 3:s=2;break;case 4:case 5:case 6:s=4;break;case 7:s=8;break;default:s=i}return s},getDataTypeUsed:function(i,s){var l=i;switch(i){case 2:case 4:l=i-s;break;case 3:case 5:l=i-2*s;break;case 6:s===0?l=i:s===1?l=2:l=1;break;case 7:s===0?l=i:l=i-2*s+1;break;default:l=i;break}return l},getOnePixel:function(i,s,l,u){var c=0;switch(l){case 0:c=u.getInt8(s);break;case 1:c=u.getUint8(s);break;case 2:c=u.getInt16(s,!0);break;case 3:c=u.getUint16(s,!0);break;case 4:c=u.getInt32(s,!0);break;case 5:c=u.getUInt32(s,!0);break;case 6:c=u.getFloat32(s,!0);break;case 7:c=u.getFloat64(s,!0);break;default:throw"the decoder does not understand this pixel type"}return c},swapDimensionOrder:function(i,s,l,u,c){var d=0,p=0,f=0,y=0,v=i;if(l>1)if(v=new u(s*l),c)for(d=0;d<s;d++)for(y=d,f=0;f<l;f++,y+=s)v[y]=i[p++];else for(d=0;d<s;d++)for(y=d,f=0;f<l;f++,y+=s)v[p++]=i[y];return v}},e=function(i,s,l){this.val=i,this.left=s,this.right=l},n={decode:function(i,s){s=s||{};var l=s.noDataValue,u=0,c={};if(c.ptr=s.inputOffset||0,c.pixels={},!!t.readHeaderInfo(i,c)){var d=c.headerInfo,p=d.fileVersion,f=t.getDataTypeArray(d.imageType);if(p>5)throw"unsupported lerc version 2."+p;t.readMask(i,c),d.numValidPixel!==d.width*d.height&&!c.pixels.resultMask&&(c.pixels.resultMask=s.maskData);var y=d.width*d.height;c.pixels.resultPixels=new f(y*d.numDims),c.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var v=!s.returnPixelInterleavedDims;if(d.numValidPixel!==0)if(d.zMax===d.zMin)t.constructConstantSurface(c,v);else if(p>=4&&t.checkMinMaxRanges(i,c))t.constructConstantSurface(c,v);else{var x=new DataView(i,c.ptr,2),S=x.getUint8(0);if(c.ptr++,S)t.readDataOneSweep(i,c,f,v);else if(p>1&&d.imageType<=1&&Math.abs(d.maxZError-.5)<1e-5){var _=x.getUint8(1);if(c.ptr++,c.encodeMode=_,_>2||p<4&&_>1)throw"Invalid Huffman flag "+_;_?t.readHuffman(i,c,f,v):t.readTiles(i,c,f,v)}else t.readTiles(i,c,f,v)}c.eofOffset=c.ptr;var Z;s.inputOffset?(Z=c.headerInfo.blobSize+s.inputOffset-c.ptr,Math.abs(Z)>=1&&(c.eofOffset=s.inputOffset+c.headerInfo.blobSize)):(Z=c.headerInfo.blobSize-c.ptr,Math.abs(Z)>=1&&(c.eofOffset=c.headerInfo.blobSize));var M={width:d.width,height:d.height,pixelData:c.pixels.resultPixels,minValue:d.zMin,maxValue:d.zMax,validPixelCount:d.numValidPixel,dimCount:d.numDims,dimStats:{minValues:d.minValues,maxValues:d.maxValues},maskData:c.pixels.resultMask};if(c.pixels.resultMask&&t.isValidPixelValue(d.imageType,l)){var G=c.pixels.resultMask;for(u=0;u<y;u++)G[u]||(M.pixelData[u]=l);M.noDataValue=l}return c.noDataValue=l,s.returnFileInfo&&(M.fileInfo=t.formatFileInfo(c)),M}},getBandCount:function(i){var s=0,l=0,u={};for(u.ptr=0,u.pixels={};l<i.byteLength-58;)t.readHeaderInfo(i,u),l+=u.headerInfo.blobSize,s++,u.ptr=l;return s}};return n}();var sm=function(){var a=new ArrayBuffer(4),t=new Uint8Array(a),e=new Uint32Array(a);return e[0]=1,t[0]===1}(),om={decode:function(a,t){if(!sm)throw"Big endian system is not supported.";t=t||{};var e=t.inputOffset||0,n=new Uint8Array(a,e,10),i=String.fromCharCode.apply(null,n),s,l;if(i.trim()==="CntZImage")s=im,l=1;else if(i.substring(0,5)==="Lerc2")s=rm,l=2;else throw"Unexpected file identifier string: "+i;for(var u=0,c=a.byteLength-10,d,p=[],f,y,v={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},x=0;e<c;){var S=s.decode(a,{inputOffset:e,encodedMaskData:d,maskData:y,returnMask:u===0,returnEncodedMask:u===0,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});e=S.fileInfo.eofOffset,y=S.maskData,u===0&&(d=S.encodedMaskData,v.width=S.width,v.height=S.height,v.dimCount=S.dimCount||1,v.pixelType=S.pixelType||S.fileInfo.pixelType,v.mask=y),l>1&&(y&&p.push(y),S.fileInfo.mask&&S.fileInfo.mask.numBytes>0&&x++),u++,v.pixels.push(S.pixelData),v.statistics.push({minValue:S.minValue,maxValue:S.maxValue,noDataValue:S.noDataValue,dimStats:S.dimStats})}var _,Z,M;if(l>1&&x>1){for(M=v.width*v.height,v.bandMasks=p,y=new Uint8Array(M),y.set(p[0]),_=1;_<p.length;_++)for(f=p[_],Z=0;Z<M;Z++)y[Z]=y[Z]&f[Z];v.maskData=y}return v}};const am={0:7e3,1:6e3,2:5e3,3:4e3,4:3e3,5:2500,6:2e3,7:1500,8:800,9:500,10:200,11:100,12:40,13:12,14:5,15:2,16:1,17:.5,18:.2,19:.1,20:.01};function lm(a){const{height:t,width:e,pixels:n}=om.decode(a),i=new Float32Array(t*e);for(let s=0;s<i.length;s++)i[s]=n[0][s];return{array:i,width:e,height:t}}function cm(a,t,e){let n=lm(a);e[2]-e[0]<1&&(n=um(n,e));const{array:i,width:s}=n,u=new Ql(s).createTile(i),c=am[t]||0;return u.getGeometryData(c)}function um(a,t){function e(u,c,d,p,f,y,v,x){const S=new Float32Array(f*y);for(let Z=0;Z<y;Z++)for(let M=0;M<f;M++){const G=(Z+p)*c+(M+d),A=Z*f+M;S[A]=u[G]}const _=new Float32Array(x*v);for(let Z=0;Z<x;Z++)for(let M=0;M<v;M++){const G=Z*x+M,A=Math.round(M*y/x),D=Math.round(Z*f/v)*f+A;_[G]=S[D]}return _}const n=hm(t,a.width),i=n.sw+1,s=n.sh+1;return{array:e(a.array,a.width,n.sx,n.sy,n.sw,n.sh,i,s),width:i,height:s}}function hm(a,t){const e=Math.floor(a[0]*t),n=Math.floor(a[1]*t),i=Math.floor((a[2]-a[0])*t),s=Math.floor((a[3]-a[1])*t);return{sx:e,sy:n,sw:i,sh:s}}const dm=10;class fm extends mo{constructor(){super();T(this,"info",{version:"0.10.0",description:"Tile LERC terrain loader. It can load ArcGis-lerc format terrain data."});T(this,"dataType","lerc");T(this,"fileLoader",new m.FileLoader(Xe.manager));T(this,"_workerPool",new to(0));this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new nm)}async doLoad(e,n){this._workerPool.pool===0&&this._workerPool.setWorkerLimit(dm);const{z:i,bounds:s}=n,l=await this.fileLoader.loadAsync(e).catch(()=>new Float32Array(256*256)),u=cm(l,i,s);return new fi().setData(u)}}wo(new fm);const ec="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGModCl7cmV0dXJuIGEodC5kYXRhKX1mdW5jdGlvbiBhKHQpe2Z1bmN0aW9uIG4oZSx1KXtjb25zdCByPXUqNCxbaSxmLGcsbF09ZS5zbGljZShyLHIrNCk7cmV0dXJuIGw9PT0wPzA6LTFlNCsoaTw8MTZ8Zjw8OHxnKSouMX1jb25zdCBvPXQubGVuZ3RoPj4+MixzPW5ldyBGbG9hdDMyQXJyYXkobyk7Zm9yKGxldCBlPTA7ZTxvO2UrKylzW2VdPW4odCxlKTtyZXR1cm4gc31zZWxmLm9ubWVzc2FnZT10PT57Y29uc3Qgbj1jKHQuZGF0YS5pbWdEYXRhKTtzZWxmLnBvc3RNZXNzYWdlKG4pfX0pKCk7Cg==",pm=a=>Uint8Array.from(atob(a),t=>t.charCodeAt(0)),tc=typeof self<"u"&&self.Blob&&new Blob([pm(ec)],{type:"text/javascript;charset=utf-8"});function mm(a){let t;try{if(t=tc&&(self.URL||self.webkitURL).createObjectURL(tc),!t)throw"";const e=new Worker(t,{name:a?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+ec,{name:a?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const gm=10;class ym extends mo{constructor(){super();T(this,"info",{version:"0.10.0",description:"Mapbox-RGB terrain loader, It can load Mapbox-RGB terrain data."});T(this,"dataType","terrain-rgb");T(this,"imageLoader",new m.ImageLoader(Xe.manager));T(this,"_workerPool",new to(0));this._workerPool.setWorkerCreator(()=>new mm)}async doLoad(e,n){const i=await this.imageLoader.loadAsync(e).catch(d=>new Image),s=m.MathUtils.clamp((n.z+2)*3,2,64),l=vm(i,n.bounds,s);let u;this._workerPool.pool===0&&this._workerPool.setWorkerLimit(gm),u=(await this._workerPool.postMessage({imgData:l},[l.data.buffer])).data;const c=new fi;return c.setData(u),c}}function vm(a,t,e){const n=co(t,a.width);e=Math.min(e,n.sw);const s=new OffscreenCanvas(e,e).getContext("2d");return s.imageSmoothingEnabled=!1,s.drawImage(a,n.sx,n.sy,n.sw,n.sh,0,0,e,e),s.getImageData(0,0,e,e)}wo(new ym);function Zn(a,t){this.x=a,this.y=t}Zn.prototype={clone(){return new Zn(this.x,this.y)},add(a){return this.clone()._add(a)},sub(a){return this.clone()._sub(a)},multByPoint(a){return this.clone()._multByPoint(a)},divByPoint(a){return this.clone()._divByPoint(a)},mult(a){return this.clone()._mult(a)},div(a){return this.clone()._div(a)},rotate(a){return this.clone()._rotate(a)},rotateAround(a,t){return this.clone()._rotateAround(a,t)},matMult(a){return this.clone()._matMult(a)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(a){return this.x===a.x&&this.y===a.y},dist(a){return Math.sqrt(this.distSqr(a))},distSqr(a){const t=a.x-this.x,e=a.y-this.y;return t*t+e*e},angle(){return Math.atan2(this.y,this.x)},angleTo(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith(a){return this.angleWithSep(a.x,a.y)},angleWithSep(a,t){return Math.atan2(this.x*t-this.y*a,this.x*a+this.y*t)},_matMult(a){const t=a[0]*this.x+a[1]*this.y,e=a[2]*this.x+a[3]*this.y;return this.x=t,this.y=e,this},_add(a){return this.x+=a.x,this.y+=a.y,this},_sub(a){return this.x-=a.x,this.y-=a.y,this},_mult(a){return this.x*=a,this.y*=a,this},_div(a){return this.x/=a,this.y/=a,this},_multByPoint(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint(a){return this.x/=a.x,this.y/=a.y,this},_unit(){return this._div(this.mag()),this},_perp(){const a=this.y;return this.y=this.x,this.x=-a,this},_rotate(a){const t=Math.cos(a),e=Math.sin(a),n=t*this.x-e*this.y,i=e*this.x+t*this.y;return this.x=n,this.y=i,this},_rotateAround(a,t){const e=Math.cos(a),n=Math.sin(a),i=t.x+e*(this.x-t.x)-n*(this.y-t.y),s=t.y+n*(this.x-t.x)+e*(this.y-t.y);return this.x=i,this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Zn},Zn.convert=function(a){if(a instanceof Zn)return a;if(Array.isArray(a))return new Zn(+a[0],+a[1]);if(a.x!==void 0&&a.y!==void 0)return new Zn(+a.x,+a.y);throw new Error("Expected [x, y] or {x, y} point format")};class nc{constructor(t,e,n,i,s){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=s,t.readFields(wm,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos,n=[];let i,s=1,l=0,u=0,c=0;for(;t.pos<e;){if(l<=0){const d=t.readVarint();s=d&7,l=d>>3}if(l--,s===1||s===2)u+=t.readSVarint(),c+=t.readSVarint(),s===1&&(i&&n.push(i),i=[]),i&&i.push(new Zn(u,c));else if(s===7)i&&i.push(i[0].clone());else throw new Error(`unknown command ${s}`)}return i&&n.push(i),n}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let n=1,i=0,s=0,l=0,u=1/0,c=-1/0,d=1/0,p=-1/0;for(;t.pos<e;){if(i<=0){const f=t.readVarint();n=f&7,i=f>>3}if(i--,n===1||n===2)s+=t.readSVarint(),l+=t.readSVarint(),s<u&&(u=s),s>c&&(c=s),l<d&&(d=l),l>p&&(p=l);else if(n!==7)throw new Error(`unknown command ${n}`)}return[u,d,c,p]}toGeoJSON(t,e,n){const i=this.extent*Math.pow(2,n),s=this.extent*t,l=this.extent*e,u=this.loadGeometry();function c(y){return[(y.x+s)*360/i-180,360/Math.PI*Math.atan(Math.exp((1-(y.y+l)*2/i)*Math.PI))-90]}function d(y){return y.map(c)}let p;if(this.type===1){const y=[];for(const x of u)y.push(x[0]);const v=d(y);p=y.length===1?{type:"Point",coordinates:v[0]}:{type:"MultiPoint",coordinates:v}}else if(this.type===2){const y=u.map(d);p=y.length===1?{type:"LineString",coordinates:y[0]}:{type:"MultiLineString",coordinates:y}}else if(this.type===3){const y=bm(u),v=[];for(const x of y)v.push(x.map(d));p=v.length===1?{type:"Polygon",coordinates:v[0]}:{type:"MultiPolygon",coordinates:v}}else throw new Error("unknown feature type");const f={type:"Feature",geometry:p,properties:this.properties};return this.id!=null&&(f.id=this.id),f}}nc.types=["Unknown","Point","LineString","Polygon"];function wm(a,t,e){a===1?t.id=e.readVarint():a===2?xm(e,t):a===3?t.type=e.readVarint():a===4&&(t._geometry=e.pos)}function xm(a,t){const e=a.readVarint()+a.pos;for(;a.pos<e;){const n=t._keys[a.readVarint()],i=t._values[a.readVarint()];t.properties[n]=i}}function bm(a){const t=a.length;if(t<=1)return[a];const e=[];let n,i;for(let s=0;s<t;s++){const l=_m(a[s]);l!==0&&(i===void 0&&(i=l<0),i===l<0?(n&&e.push(n),n=[a[s]]):n&&n.push(a[s]))}return n&&e.push(n),e}function _m(a){let t=0;for(let e=0,n=a.length,i=n-1,s,l;e<n;i=e++)s=a[e],l=a[i],t+=(l.x-s.x)*(s.y+l.y);return t}let Mm=class{constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Lm,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new nc(this._pbf,e,this.extent,this._keys,this._values)}};function Lm(a,t,e){a===15?t.version=e.readVarint():a===1?t.name=e.readString():a===5?t.extent=e.readVarint():a===2?t._features.push(e.pos):a===3?t._keys.push(e.readString()):a===4&&t._values.push(Sm(e))}function Sm(a){let t=null;const e=a.readVarint()+a.pos;for(;a.pos<e;){const n=a.readVarint()>>3;t=n===1?a.readString():n===2?a.readFloat():n===3?a.readDouble():n===4?a.readVarint64():n===5?a.readVarint():n===6?a.readSVarint():n===7?a.readBoolean():null}if(t==null)throw new Error("unknown feature value");return t}class Tm{constructor(t,e){this.layers=t.readFields(Zm,{},e)}}function Zm(a,t,e){if(a===3){const n=new Mm(e,e.readVarint()+e.pos);n.length&&(t[n.name]=n)}}const xo=65536*65536,ic=1/xo,Gm=12,rc=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),bo=0,Ar=1,Qi=2,Fr=5;class Wm{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,n=this.length){for(;this.pos<n;){const i=this.readVarint(),s=i>>3,l=this.pos;this.type=i&7,t(s,e,this),this.pos===l&&this.skip(i)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*xo;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*xo;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let n,i;return i=e[this.pos++],n=i&127,i<128||(i=e[this.pos++],n|=(i&127)<<7,i<128)||(i=e[this.pos++],n|=(i&127)<<14,i<128)||(i=e[this.pos++],n|=(i&127)<<21,i<128)?n:(i=e[this.pos],n|=(i&15)<<28,Pm(n,t,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=Gm&&rc?rc.decode(this.buf.subarray(e,t)):Ym(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===Qi?this.readVarint()+this.pos:this.pos+1}skip(t){const e=t&7;if(e===bo)for(;this.buf[this.pos++]>127;);else if(e===Qi)this.pos=this.readVarint()+this.pos;else if(e===Fr)this.pos+=4;else if(e===Ar)this.pos+=8;else throw new Error(`Unimplemented type: ${e}`)}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.dataView=new DataView(n.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ic),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ic),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){Im(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;const e=this.pos;this.pos=Um(this.buf,t,this.pos);const n=this.pos-e;n>=128&&sc(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let n=0;n<e;n++)this.buf[this.pos++]=t[n]}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const i=this.pos-n;i>=128&&sc(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeMessage(t,e,n){this.writeTag(t,Qi),this.writeRawMessage(e,n)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Am,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Fm,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Dm,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Xm,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,zm,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,km,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Om,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Rm,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Km,e)}writeBytesField(t,e){this.writeTag(t,Qi),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,Fr),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,Fr),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,Ar),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,Ar),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,bo),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,bo),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,Qi),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,Fr),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,Ar),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function Pm(a,t,e){const n=e.buf;let i,s;if(s=n[e.pos++],i=(s&112)>>4,s<128||(s=n[e.pos++],i|=(s&127)<<3,s<128)||(s=n[e.pos++],i|=(s&127)<<10,s<128)||(s=n[e.pos++],i|=(s&127)<<17,s<128)||(s=n[e.pos++],i|=(s&127)<<24,s<128)||(s=n[e.pos++],i|=(s&1)<<31,s<128))return pi(a,i,t);throw new Error("Expected varint not more than 10 bytes")}function pi(a,t,e){return e?t*4294967296+(a>>>0):(t>>>0)*4294967296+(a>>>0)}function Im(a,t){let e,n;if(a>=0?(e=a%4294967296|0,n=a/4294967296|0):(e=~(-a%4294967296),n=~(-a/4294967296),e^4294967295?e=e+1|0:(e=0,n=n+1|0)),a>=18446744073709552e3||a<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),Cm(e,n,t),Vm(n,t)}function Cm(a,t,e){e.buf[e.pos++]=a&127|128,a>>>=7,e.buf[e.pos++]=a&127|128,a>>>=7,e.buf[e.pos++]=a&127|128,a>>>=7,e.buf[e.pos++]=a&127|128,a>>>=7,e.buf[e.pos]=a&127}function Vm(a,t){const e=(a&7)<<4;t.buf[t.pos++]|=e|((a>>>=3)?128:0),a&&(t.buf[t.pos++]=a&127|((a>>>=7)?128:0),a&&(t.buf[t.pos++]=a&127|((a>>>=7)?128:0),a&&(t.buf[t.pos++]=a&127|((a>>>=7)?128:0),a&&(t.buf[t.pos++]=a&127|((a>>>=7)?128:0),a&&(t.buf[t.pos++]=a&127)))))}function sc(a,t,e){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));e.realloc(n);for(let i=e.pos-1;i>=a;i--)e.buf[i+n]=e.buf[i]}function Am(a,t){for(let e=0;e<a.length;e++)t.writeVarint(a[e])}function Fm(a,t){for(let e=0;e<a.length;e++)t.writeSVarint(a[e])}function Xm(a,t){for(let e=0;e<a.length;e++)t.writeFloat(a[e])}function zm(a,t){for(let e=0;e<a.length;e++)t.writeDouble(a[e])}function Dm(a,t){for(let e=0;e<a.length;e++)t.writeBoolean(a[e])}function km(a,t){for(let e=0;e<a.length;e++)t.writeFixed32(a[e])}function Om(a,t){for(let e=0;e<a.length;e++)t.writeSFixed32(a[e])}function Rm(a,t){for(let e=0;e<a.length;e++)t.writeFixed64(a[e])}function Km(a,t){for(let e=0;e<a.length;e++)t.writeSFixed64(a[e])}function Ym(a,t,e){let n="",i=t;for(;i<e;){const s=a[i];let l=null,u=s>239?4:s>223?3:s>191?2:1;if(i+u>e)break;let c,d,p;u===1?s<128&&(l=s):u===2?(c=a[i+1],(c&192)===128&&(l=(s&31)<<6|c&63,l<=127&&(l=null))):u===3?(c=a[i+1],d=a[i+2],(c&192)===128&&(d&192)===128&&(l=(s&15)<<12|(c&63)<<6|d&63,(l<=2047||l>=55296&&l<=57343)&&(l=null))):u===4&&(c=a[i+1],d=a[i+2],p=a[i+3],(c&192)===128&&(d&192)===128&&(p&192)===128&&(l=(s&15)<<18|(c&63)<<12|(d&63)<<6|p&63,(l<=65535||l>=1114112)&&(l=null))),l===null?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|l&1023),n+=String.fromCharCode(l),i+=u}return n}function Um(a,t,e){for(let n=0,i,s;n<t.length;n++){if(i=t.charCodeAt(n),i>55295&&i<57344)if(s)if(i<56320){a[e++]=239,a[e++]=191,a[e++]=189,s=i;continue}else i=s-55296<<10|i-56320|65536,s=null;else{i>56319||n+1===t.length?(a[e++]=239,a[e++]=191,a[e++]=189):s=i;continue}else s&&(a[e++]=239,a[e++]=191,a[e++]=189,s=null);i<128?a[e++]=i:(i<2048?a[e++]=i>>6|192:(i<65536?a[e++]=i>>12|224:(a[e++]=i>>18|240,a[e++]=i>>12&63|128),a[e++]=i>>6&63|128),a[e++]=i&63|128)}return e}class Bm extends yo{constructor(){super();T(this,"dataType","mvt");T(this,"_loader",new m.FileLoader(Xe.manager));T(this,"_render",new Hl);console.log("MVTLoader constructor"),this._loader.setResponseType("arraybuffer")}async doLoad(e,n){const i=await this._loader.loadAsync(e),s=new Tm(new Wm(i)),l=this.drawTile(s,n.source.style,n.z);return console.log("drawTile",l),new m.CanvasTexture(l)}drawTile(e,n,i){const c=new OffscreenCanvas(256,256).getContext("2d");if(c){if(n)for(const d in n.layer){const p=n.layer[d];if(n&&(i<(p.minLevel??1)||i>(p.maxLevel??20)))continue;const f=e.layers[d];if(f){const y=256/f.extent;this._renderLayer(c,f,p,y)}}else for(const d in e.layers){const p=e.layers[d],f=256/p.extent;this._renderLayer(c,p,void 0,f)}return c.canvas}else throw new Error("Canvas context is not available")}_renderLayer(e,n,i,s=1){e.save();for(let l=0;l<n.length;l++){const u=n.feature(l);this._renderFeature(e,u,i,s)}return e.restore(),this}_renderFeature(e,n,i={},s=1){const l=[tt.Unknown,tt.Point,tt.Linestring,tt.Polygon][n.type],u={geometry:n.loadGeometry(),properties:n.properties};this._render.render(e,l,u,i,s)}_convertToGeoJSONFeature(e,n){const i=this._convertGeometryToGeoJSON(e.geometry,n);return i?{type:"Feature",geometry:i,properties:e.properties||{},id:e.id}:null}_convertGeometryToGeoJSON(e,n){switch(n){case tt.Point:return this._convertPointGeometry(e);case tt.Linestring:return this._convertLineGeometry(e);case tt.Polygon:return this._convertPolygonGeometry(e);default:return console.warn("未知的几何类型:",n),null}}_convertPointGeometry(e){const n=[];for(const i of e)for(const s of i)n.push([s.x,s.y]);return n.length===0?null:n.length===1?{type:"Point",coordinates:n[0]}:{type:"MultiPoint",coordinates:n}}_convertLineGeometry(e){const n=[];for(const i of e){const s=[];for(const l of i)s.push([l.x,l.y]);s.length>=2&&n.push(s)}return n.length===0?null:n.length===1?{type:"LineString",coordinates:n[0]}:{type:"MultiLineString",coordinates:n}}_convertPolygonGeometry(e){const n=[];let i=[];for(const s of e){const l=[];for(const u of s)l.push([u.x,u.y]);l.length>=4&&(this._isRingClockwise(l)||i.length===0?(i.length>0&&n.push(i),i=[l]):i.push(l))}return i.length>0&&n.push(i),n.length===0?null:n.length===1?{type:"Polygon",coordinates:n[0]}:{type:"MultiPolygon",coordinates:n}}_isRingClockwise(e){let n=0;for(let i=0;i<e.length-1;i++){const[s,l]=e[i],[u,c]=e[i+1];n+=(u-s)*(c+l)}return n>0}convertVectorTileToGeoJSON(e){const n=[];for(const i in e.layers){const s=e.layers[i];for(let l=0;l<s.length;l++){const u=s.feature(l),c=[tt.Unknown,tt.Point,tt.Linestring,tt.Polygon][u.type],d={geometry:u.loadGeometry(),properties:u.properties},p=this._convertToGeoJSONFeature(d,c);p&&(p.properties._layer=i,n.push(p))}}return{type:"FeatureCollection",features:n}}}vo(new Bm);const oc="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IF89MjMyODMwNjQzNjUzODY5NjNlLTI2LG09MTIsUD10eXBlb2YgVGV4dERlY29kZXI+InUiP251bG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55Om54mH5pWw5o2u5pe25Ye66ZSZOiIscyksc319ZnVuY3Rpb24gUShpLHQsZSxyKXtjb25zdCBzPW5ldyBNKGkpLG49bmV3IHoocyksbz17fTtmb3IoY29uc3QgaCBpbiBuLmxheWVycyl7Y29uc3QgYT1uLmxheWVyc1toXSxkPVtdO2ZvcihsZXQgdT0wO3U8YS5sZW5ndGg7dSsrKXtjb25zdCBsPWEuZmVhdHVyZSh1KS50b0dlb0pTT04odCxlLHIpO2QucHVzaChsKX1vW2hdPWR9cmV0dXJuIG99c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e2NvbnN0IHQ9aS5kYXRhO3RyeXtjb25zdCBlPWF3YWl0IEsodC5hcnJheUJ1ZmZlcix0LngsdC55LHQueik7c2VsZi5wb3N0TWVzc2FnZShlKX1jYXRjaChlKXtjb25zb2xlLmVycm9yKCJXb3JrZXIgTVZUIOino+aekOWksei0pToiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfX19KSgpOwo=",Nm=a=>Uint8Array.from(atob(a),t=>t.charCodeAt(0)),ac=typeof self<"u"&&self.Blob&&new Blob([Nm(oc)],{type:"text/javascript;charset=utf-8"});function jm(a){let t;try{if(t=ac&&(self.URL||self.webkitURL).createObjectURL(ac),!t)throw"";const e=new Worker(t,{name:a?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+oc,{name:a?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const Jm=10;class Qm{constructor(){T(this,"info",{version:"1.0.0",description:"Vector Tile loader for Mapbox Vector Tile format. It can load and parse MVT data."});T(this,"dataType","VectorTile");T(this,"fileLoader",new m.FileLoader(Xe.manager));T(this,"_workerPool",new to(0));this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new jm)}async load(t){const{source:e,x:n,y:i,z:s}=t,l=typeof e._getUrl=="function"?e._getUrl(n,i,s):this.buildTileUrl(e.url,n,i,s);if(!l)return this.createErrorGeometry(n,i,s,new Error("VectorTileLoader: source._getUrl 返回空 URL"));this._workerPool.pool===0&&this._workerPool.setWorkerLimit(Jm);try{const u=await this.fetchVectorData(l),c={arrayBuffer:u,x:n,y:i,z:s},p=(await this._workerPool.postMessage(c,[u])).data;if(p.error)throw new Error(p.error);const f=this.createGeometryWithVectorData(p,t);return Xe.manager.parseEnd(l),f}catch(u){return this.createErrorGeometry(n,i,s,u)}}async fetchVectorData(t){try{const e=await this.fileLoader.loadAsync(t);if(!e||e.byteLength===0)throw new Error("Empty response");return e}catch(e){throw new Error(`Failed to fetch vector tile: ${e.message}`)}}calculateTileBounds(t,e,n){const i=4007501668557849e-8/Math.pow(2,n),s=-20037508342789244e-9+t*i,l=s+i,u=20037508342789244e-9-(e+1)*i,c=u+i;return{min:new m.Vector2(s,u),max:new m.Vector2(l,c),world:new m.Vector2(i,i)}}buildTileUrl(t,e,n,i){return t.replace("{x}",e.toString()).replace("{y}",n.toString()).replace("{z}",i.toString()).replace("{-y}",(Math.pow(2,i)-1-n).toString())}createGeometryWithVectorData(t,e){const n=new fi;return n.userData={vectorData:t,tileInfo:{x:e.x,y:e.y,z:e.z,bounds:e.bounds},metadata:{dataType:"vector-tile",version:"1.0.0",loadedAt:Date.now()}},n}createErrorGeometry(t,e,n,i){const s=new fi;return s.userData={vectorData:{x:t,y:e,z:n,layers:{},totalFeatures:0,bounds:this.calculateTileBounds(t,e,n),error:i.message,timestamp:Date.now(),dataFormat:"error"},tileInfo:{x:t,y:e,z:n,bounds:[0,0,0,0]},metadata:{dataType:"vector-tile-error",error:!0,errorMessage:i.message}},s}unload(t){t.userData?.vectorData&&(t.userData.vectorData=null),t.dispose&&t.dispose()}static getVectorData(t){return t.userData?.vectorData||null}static hasValidVectorData(t){const e=this.getVectorData(t);return e&&!e.error&&e.totalFeatures>0}static getLayerNames(t){const e=this.getVectorData(t);return e?Object.keys(e.layers||{}):[]}static getFeaturesByLayer(t,e){return this.getVectorData(t)?.layers?.[e]?.convertedFeatures||[]}}El(new Qm);class _o extends Ul{constructor(e,n){super(e,n);T(this,"layerType","vector");T(this,"_tileDataMap",new Map);T(this,"_renderer");T(this,"_style");T(this,"_feaList",[]);T(this,"_collision",!1);T(this,"_renderAltitude",0);if(!n.style)throw new Error("VectorTileLayer 必须提供样式配置");this._style=n.style,this._collision=n.collision||!1,this._featureFilter=n.featureFilter,this._renderAltitude=n.altitude||0,this._rootTile.setDataOnlyMode(!0),this._setupDataModeAndListenersForChildren(),this._setupLifeCycleListeners()}_setupDataModeAndListenersForChildren(){const e=n=>{n!==this._rootTile&&n.setDataOnlyMode(!0),this._addShownListenerToTile(n),this._addUnloadListenerToTile(n)};this._rootTile.addEventListener("tile-created",n=>{const i=n.tile;e(i)}),this._rootTile.traverse(n=>{n.isTile&&e(n)})}_addShownListenerToTile(e){const n=i=>{const s=i.tile,l=`${s.z}-${s.x}-${s.y}`,u=!!this._renderer,c=this._tileDataMap.get(l);u&&c&&this._renderer.processTileData(s,c.data)};e.addEventListener("tile-shown",n)}_addUnloadListenerToTile(e){const n=i=>{const s=i.tile||i.target,l=`${s.z}-${s.x}-${s.y}`;if(this._renderer)try{this._renderer.removeFeaturesByTileKey(l)}catch{}this._tileDataMap.delete(l)};e.addEventListener("unload",n)}setAltitude(e){return super.setAltitude(0),this._renderAltitude=e,this._renderer&&this._renderer.setAltitude(e),this}getAltitude(){return this._renderAltitude}_addHiddenListenerToTile(e){const n=i=>{const s=i.tile,l=`${s.z}-${s.x}-${s.y}`;if(this._renderer)try{this._renderer.hideFeaturesByTileKey(l)}catch{}};e.addEventListener("tile-hidden",n)}_setupLifeCycleListeners(){this._rootTile.addEventListener("tile-loaded",e=>{const n=e.tile,i=`${n.z}-${n.x}-${n.y}`,s=this.getVectorDataFromTile(n);if(!s){console.warn(`[VectorTileLayer] Tile ${i} loaded but has no vector data.`);return}if(s.vectorData?.dataFormat==="mvt"&&this._tileDataMap.set(i,{data:s,tile:n,timestamp:Date.now(),pending:!1}),n.showing&&this._renderer&&s.vectorData?.dataFormat==="mvt")try{this._renderer.processTileData(n,s)}catch{}})}getVectorDataFromTile(e){return!e.geometry||!e.getVectorData()?null:e.getVectorData()}createLoader(){const e=new Vr;return e.vtSource=this.source,e}getVisibleVectorTiles(){const e=[];return this._rootTile.traverse(n=>{if(n.isTile&&n.loaded&&n.inFrustum){const i=`${n.z}-${n.x}-${n.y}`,s=this._tileDataMap.get(i);s&&e.push({tileKey:i,data:s.data,tile:s.tile})}}),e}getAllVectorData(){return new Map(this._tileDataMap)}getVectorData(e,n,i){const s=`${i}-${e}-${n}`,l=this._tileDataMap.get(s);return l?l.data:null}setFeatureFilter(e){this._featureFilter=e,this._renderer&&this._renderer.setFeatureFilter(e)}clearFeatureFilter(){this._featureFilter=void 0,this._renderer&&this._renderer.clearFeatureFilter()}setOpacity(e){this.opacity=e,this._renderer&&this._renderer.setOpacity(e)}update(e){!this.enabled||!this.visible||super.update(e)}dispose(){this._renderer&&this._renderer.dispose(),super.dispose()}_setRenderer(e){this._renderer=e}_getRenderer(){return this._renderer||null}getStyle(){return this._style}}class Hm{constructor(...t){}}const Em={};let Nn=class zh extends qs(Yi(Ui(Hm))){constructor(e,n){js(e,"container","Map container element must be specified");const i=["center","basemap"];for(const R of i)ml(n,R);const l={...n,viewer:{...{viewer:{antialias:!0,stencil:!0,logarithmicDepthBuffer:!0}}.viewer,...n.viewer}};super(l);T(this,"viewer");T(this,"tilemap");T(this,"center");T(this,"prjcenter");T(this,"_layerContainer");T(this,"_EventMap",{loaded:{listened:!1}});T(this,"_canvasManager",new op);T(this,"collisionEngine");T(this,"_onLoadHooks");T(this,"_minZoom",0);T(this,"_maxZoom",22);T(this,"_ZOOM_MIN_CONST",0);T(this,"_ZOOM_MAX_CONST",22);T(this,"_minZoomDistance",500);T(this,"_maxZoomDistance",8e4);T(this,"_isZooming",!1);T(this,"_zoomStartValue",0);T(this,"_lastZoomForControls",0);T(this,"_overZoom",0);T(this,"_lastCameraDistance",0);this.tilemap=this.initTileMap(l.basemap),this.center=this.options.center,this.viewer=new gl(e,{...l.viewer,map:this}),this.tilemap.receiveShadow=!0,this.viewer.scene.add(this.tilemap);const u=this.tilemap.geo2world(new m.Vector3(this.center[0],this.center[1],0));this.prjcenter=u;const c=this.options.viewer??{};this.viewer.flyToPoint({center:this.center,distance:typeof this.center[2]=="number"?this.center[2]:void 0,polarDeg:typeof c.polarDeg=="number"?c.polarDeg:void 0,azimuthDeg:typeof c.azimuthDeg=="number"?c.azimuthDeg:void 0,polarAngle:c.polarAngle,azimuthAngle:c.azimuthAngle,duration:0,curvePath:!1}),this._minZoomDistance=this.viewer.controls.minDistance,this._maxZoomDistance=this.viewer.controls.maxDistance;const d=this._getCameraDistance();this._lastCameraDistance=d,this._layerContainer=new sp,this.viewer.scene.add(this._layerContainer);const p=this.viewer.controls;this._minZoomDistance=typeof p?.minDistance=="number"?p.minDistance:500,this._maxZoomDistance=typeof p?.maxDistance=="number"?p.maxDistance:8e4;const y=this.tilemap.getLayers().find(R=>R.isBaseLayer===!0)?.minLevel??this.tilemap.minLevel;this._minZoom=Math.max(this._ZOOM_MIN_CONST,Math.min(this._ZOOM_MAX_CONST,y)),this._maxZoom=this._ZOOM_MAX_CONST;const v=this.prjcenter,S=this.viewer.camera.position.clone().clone().sub(v).normalize(),Z=Sr(n.zoom)?13:n.zoom,M=Math.max(this._minZoom,Math.min(this._maxZoom,Z)),G=this._computeDistanceFromZoom(M);u.clone().addScaledVector(S,G);const A=this.getZoom();this._lastZoomForControls=A,this._zoomStartValue=A,this.collisionEngine=new Tp(this.viewer.renderer,{padding:8,updateInterval:16,animationDuration:200,maxFeaturesPerFrame:2e4,strategies:{priority:!0,grouping:!0,proximity:!0}}),this.on("control-change",Zp.debounce(R=>{const D=this.tilemap,k=D.getDataZoom(),K=D.getLayers().find(J=>J.isBaseLayer===!0)?.maxLevel??D.maxLevel,I=this._getCameraDistance(),z=I-this._lastCameraDistance;this._lastCameraDistance=I;const{max:N}=this._getViewZoomRange(),H=Math.max(0,N-K);k<K?this._overZoom=0:z<-.001?this._overZoom=Math.min(this._overZoom+1,H):z>.001&&(this._overZoom=Math.max(this._overZoom-1,0));const j=this.getZoom();Math.abs(j-this._lastZoomForControls)>.001&&(this._isZooming?this.trigger("zooming",{from:this._zoomStartValue,to:j}):(this._isZooming=!0,this._zoomStartValue=this._lastZoomForControls,this.trigger("zoomstart",{from:this._zoomStartValue,to:j})),this._lastZoomForControls=j),this.collisionEngine.update(R.camera)},10,{leading:!1,trailing:!0})),this.on("control-end",()=>{this._isZooming&&(this._isZooming=!1,this.trigger("zoomend",{from:this._zoomStartValue,to:this.getZoom()}))}),this._callOnLoadHooks()}static addOnLoadHook(e,...n){const i=typeof e=="function"?e:function(){this[e].apply(this,n)},s=this.prototype;return s._onLoadHooks=s._onLoadHooks||[],s._onLoadHooks.push(i),this}_callOnLoadHooks(){const e=zh.prototype;if(e._onLoadHooks)for(let n=0,i=e._onLoadHooks.length;n<i;n++)e._onLoadHooks[n].call(this)}getZoom(){const e=this.tilemap,n=e.getDataZoom(),s=e.getLayers().find(l=>l.isBaseLayer===!0)?.maxLevel??e.maxLevel;return n<s?n:s+this._overZoom}getDataZoom(){return this.tilemap.getDataZoom()}getMinZoom(){return this._minZoom}getMaxZoom(){return this._maxZoom}setZoomRange(e,n){if(e>n){const s=e;e=n,n=s}this._minZoom=e,this._maxZoom=n;const i=this.viewer.controls;if(i){const s=this._computeDistanceFromZoom(this._maxZoom),l=this._computeDistanceFromZoom(this._minZoom);i.minDistance=s,i.maxDistance=l}return this}setMinZoom(e){return this.setZoomRange(e,this._maxZoom)}setMaxZoom(e){return this.setZoomRange(this._minZoom,e)}setZoom(e){const n=this.getMinZoom(),i=this.getMaxZoom(),s=Math.max(n,Math.min(i,e)),l=this.getZoom(),u=this._computeDistanceFromZoom(s),c=this.viewer.controls,d=c?.target??this.prjcenter,p=this.viewer.camera,f=p.position.clone().sub(d).normalize();return p.position.copy(d).addScaledVector(f,u),p.updateProjectionMatrix(),typeof c?.update=="function"&&c.update(),this._lastZoomForControls=s,this.trigger("zoomend",{from:l,to:this.getZoom()}),this}zoomIn(e=1){return this.setZoom(this.getZoom()+e)}zoomOut(e=1){return this.setZoom(this.getZoom()-e)}_computeDistanceFromZoom(e){const n=this._ZOOM_MIN_CONST,i=this._ZOOM_MAX_CONST,s=this._minZoomDistance,l=this._maxZoomDistance;if(s<=0||s>=l){const f=Math.max(n,Math.min(i,e)),y=(i-f)/(i-n);return s+y*(l-s)}const c=(Math.max(n,Math.min(i,e))-n)/(i-n),d=s/l;return l*Math.pow(d,c)}initTileMap(e){const n=new Lr({...e});try{if(e.Baselayers?.length)for(const i of e.Baselayers)i.isBaseLayer=!0,n.addLayer(i)}catch(i){console.error("💥 诊断失败:",i)}return n.rotateX(-Math.PI/2),n.receiveShadow=!0,setTimeout(()=>{const i={timestamp:Ff(),targrt:this};this._EventMap.loaded={listened:!0},this.trigger("loaded",i)},0),n}addLayer(e,...n){if(!e)return this;Array.isArray(e)||(e=[e]),n?.length&&(e=e.concat(n)),n?.length&&(e=e.concat(n));for(let i=0,s=e.length;i<s;i++){const l=e[i],u=l.getId();if(Sr(u))throw new Error("Invalid id for the layer: "+u);l.isTileLayer?this.addTileLayer(l):this.addRegularLayer(l)}return this}removeLayer(e){const n=this.tilemap.getLayer(e);if(n){if(n instanceof _o){const s=n._getRenderer();s&&this._layerContainer.remove(s)}return this.tilemap.removeLayer(e),!0}const i=this._layerContainer.getLayerById(e);return i?(this._layerContainer.remove(i),i instanceof Bn&&i?._collision,!0):(console.warn(`⚠️ 图层不存在: ${e}`),!1)}addRegularLayer(e){const n=e.getId();this._layerContainer.add(e),e._bindMap(this),e instanceof Bn&&e?._collision&&(this.collisionEngine.registerLayer(e),e.setCollisionEngine(this.collisionEngine)),console.log(`📁 普通图层已添加到场景: ${n}`)}addTileLayer(e){if(this.tilemap.addLayer(e),e._bindMap(this),e instanceof _o){const n=e.options||{},i=new lo(e.getId()+"-vtrender",{altitude:e.getAltitude(),style:e.getStyle(),collision:e._collision,zIndex:typeof n.zIndex=="number"?n.zIndex:void 0,depthOffset:typeof n.depthOffset=="number"?n.depthOffset:void 0});e._setRenderer(i),this.addRegularLayer(i)}return this}clearLayers(){return this._layerContainer.clear(),this.tilemap.clearLayers(),this}getLayers(){const e=this._layerContainer.getLayers().filter(i=>!(i instanceof lo)),n=this.tilemap.getLayers();return[...e,...n]}getLayerById(e){const n=this._layerContainer.getLayerById(e);return n?n instanceof lo?void 0:n:this.tilemap.getLayer(e)}geo2world(e){return this.tilemap.geo2world(e)}world2geo(e){return this.tilemap.world2geo(e)}geo2map(e){return this.tilemap.geo2map(e)}_getCanvas(e=40,n=30,i){return this._canvasManager.getCanvas(e,n,1,i)}getContainer(){return this.viewer.container}getRenderer(){return this.viewer.renderer}getCamera(){return this.viewer.camera}_findFeaturesAt(e){const n=this,i=n.getRenderer(),s=n.getCamera(),l=i.domElement.getBoundingClientRect(),u=e.x/l.width*2-1,c=-(e.y/l.height)*2+1,d=new m.Raycaster;d.setFromCamera(new m.Vector2(u,c),s);const p=n.getLayers().filter(v=>!v?.isSceneLayer),y=d.intersectObjects(p,!0).map(v=>{let x=v.object,S=null;for(;x;){if(x instanceof hn){S=x;break}x=x.parent}return S?{feature:S,distance:v.distance,object:v.object}:null}).filter(v=>!!v);return y.length?y.sort((v,x)=>v.distance-x.distance):[]}getCenter(){const e=this.viewer.controls.target.clone(),n=this.world2geo(e);return[n.x,n.y,n.z]}_getEventPosition(e){let n,i;if("touches"in e){if(e.touches.length===0)return null;n=e.touches[0].clientX,i=e.touches[0].clientY}else n=e.clientX,i=e.clientY;const s=this.getContainer();if(!s)return null;const l=s.getBoundingClientRect();return{x:n-l.left,y:i-l.top}}get isInteracting(){return this.viewer.isInteracting}_getCameraDistance(){const e=this.viewer.controls,n=this.viewer.camera,i=e?.target??this.prjcenter;return e&&typeof e.getDistance=="function"?e.getDistance():n.position.distanceTo(i)}_getViewZoomRange(){const e=this.viewer.controls,n=typeof e?.minDistance=="number"?e.minDistance:this._minZoomDistance,i=typeof e?.maxDistance=="number"?e.maxDistance:this._maxZoomDistance;if(n<=0||n>=i){const y=this.tilemap.getDataZoom();return{min:y,max:y}}const s=i/n,l=Math.log2(s),u=this.tilemap.getLayers().find(y=>y.isBaseLayer===!0),c=u?.minLevel??this.tilemap.minLevel,d=u?.maxLevel??this.tilemap.maxLevel,p=c,f=d+l;return{min:p,max:f}}flyTo(e){this.viewer.flyToAdvanced(e)}flyToPoint(e){this.viewer.flyToPoint(e)}};Nn.mergeOptions(Em);function lc(a,t,e){const{currentTarget:n,clientX:i,clientY:s}=a;if(n instanceof HTMLElement){const l=n.clientWidth,u=n.clientHeight,c=new m.Vector2(i/l*2-1,-(s/u)*2+1);return t.getLocalInfoFromScreen(e,c)?.location}else return}const qm=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout"];Nn.prototype._removeDomEvents=function(){console.log("removeDomEvents",this)},Nn.prototype._registerDomEvents=function(){const a=this.viewer.container;if(a){let e=null;qm.forEach(n=>{a.addEventListener(n,i=>{if(n==="mousedown"&&(e={x:i.clientX,y:i.clientY}),n==="click"&&e){const u=i.clientX-e.x,c=i.clientY-e.y;if(Math.sqrt(u*u+c*c)>5)return}let s=lc(i,this.tilemap,this.viewer.camera),l={target:this,originEvent:i,eventName:n,screenXY:{X:i.screenX,Y:i.screenY}};if(s){let u=[s.x,s.y,s.z];l={target:this,originEvent:i,coordinate:u,eventName:n,screenXY:{X:i.screenX,Y:i.screenY}}}this.trigger(n,l)})})}},Nn.addOnLoadHook("_registerDomEvents");const $m=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchmove","touchend"];class e0 extends bl{constructor(){super(...arguments);T(this,"_registeredEvents",[]);T(this,"_eventCommon",e=>{(e.type==="mousedown"||e.type==="touchstart")&&(this._mouseDownTime=Date.now()),!(e.type==="click"&&Date.now()-this._mouseDownTime>300)&&this._handleEvent(e,e.type)})}addHooks(){const n=this.target.getContainer();n&&$m.forEach(i=>{n.addEventListener(i,this._eventCommon),this._registeredEvents.push(i)})}removeHooks(){const n=this.target.getContainer();n&&this._registeredEvents.length>0&&(this._registeredEvents.forEach(i=>{const s=i;n.removeEventListener(s,this._eventCommon)}),this._registeredEvents=[])}_handleEvent(e,n){const i=this.target;if(this._shouldIgnoreEvent()||(n==="mousemove"||n==="mouseenter"||n==="mouseleave"||n==="mouseover"||n==="mouseout"||n==="touchmove")&&!i.getLayers().some(d=>!d.isSceneLayer&&d._feaList?.length>0))return;const s=i._getEventPosition(e);if(!s)return;const l=i._findFeaturesAt(s);if(l.length===0)return;const u=l[0].feature;switch(n){case"click":this._handleClickEvent(u,e);break;case"mousemove":case"mouseenter":case"mouseleave":case"mouseover":case"mouseout":case"touchmove":this.handleMoveEvent(u,e);break;default:if(u){this._fireFeatureEvent(u,n,e);const c=u.getLayer();c&&c.trigger("feature"+n,{feature:u,domEvent:e,type:"feature"+n})}}}_handleClickEvent(e,n){if(!e)return;this._fireFeatureEvent(e,"click",n);const i=e.getLayer();i&&i.trigger("featureclick",{feature:e,domEvent:n,type:"featureclick"})}handleMoveEvent(e,n){if(!e)return;this._fireFeatureEvent(e,n.type,n);const i=e.getLayer();i&&i.trigger("feature"+n.type,{feature:e,domEvent:n,type:"feature"+n.type})}_fireFeatureEvent(e,n,i){const s=this.target;let l=i,u,c;if("touches"in i){const y=i.touches[0]||i.changedTouches[0];if(!y)return;l={currentTarget:i.currentTarget,clientX:y.clientX,clientY:y.clientY},u=y.screenX,c=y.screenY}else{const y=i;l=y,u=y.screenX,c=y.screenY}const d=lc(l,s.tilemap,s.viewer.camera);if(!d)return;const p=[d.x,d.y,d.z],f={target:e,originEvent:i,coordinate:p,eventName:n,screenXY:{X:u,Y:c}};e.trigger(n,f)}_shouldIgnoreEvent(){return!!this.target.isInteracting}}Nn.mergeOptions({FeatureEvents:!0,onlyVisibleFeatureEvents:!0}),Nn.addOnLoadHook("addHandler","FeatureEvents",e0);class t0{constructor(...t){}}const mi=class mi extends Yi(Ui(t0)){constructor(e={}){super(e);T(this,"_owner");T(this,"_map");T(this,"_worldPosition");T(this,"_coordinate");T(this,"_dom");T(this,"_visible",!1);T(this,"_boundMapHandlers",new Map);T(this,"_viewerUpdateHandler");T(this,"_positionedOnce",!1)}_getClassName(){return"UIComponent"}getOffset(){return{x:this.options.dx??0,y:this.options.dy??0}}addTo(e){if(!e)return this;this._owner=e;const n=typeof e.getMap=="function"?e.getMap():e;return n?(this._map=n,this._bindMapEvents(!0),this.options.single&&(mi._singletons.forEach(i=>{i!==this&&i.options.single&&i._map===n&&i.hide()}),mi._singletons.add(this)),this.onAdd&&this.onAdd(),this.trigger("add",{owner:e,map:n}),this):this}remove(){const e=this._map;return this.hideDom(),this._bindMapEvents(!1),this.options.single&&mi._singletons.delete(this),this.onRemove&&this.onRemove(),this.trigger("remove",{owner:this._owner,map:e}),this._owner=void 0,this._map=void 0,this}show(e){const n=this._map??(this._owner&&typeof this._owner.getMap=="function"?this._owner.getMap():void 0);if(!n)return this;if(this._map=n,!this._dom){const i=this.buildOn();this._dom=i,i.style.position="absolute",typeof this.options.zIndex=="number"&&(i.style.zIndex=String(this.options.zIndex));const s=n.getContainer();if(!s)return this;s.appendChild(i)}return this._coordinate=e?[...e]:void 0,this._visible=!0,this._positionedOnce=!1,this._dom&&(this._dom.style.display="none"),this.trigger("show",{owner:this._owner,map:n}),this}hide(){return this._visible=!1,this._dom&&(this._dom.style.display="none"),this._coordinate=void 0,this.trigger("hide",{owner:this._owner,map:this._map}),this}hideDom(){return this._dom&&this._dom.parentElement&&(this._dom.parentElement.removeChild(this._dom),this.onDomRemove&&this.onDomRemove()),this._dom=void 0,this._visible=!1,this._coordinate=void 0,this}getMap(){return this._map}isVisible(){return this._visible}_bindMapEvents(e){const n=this._map;if(!n)return;const i=n,s=e?"on":"off",l=(u,c)=>{e?this._boundMapHandlers.set(u,c):this._boundMapHandlers.delete(u)};if(e){const u=()=>{this._visible&&this._updatePosition()};i[s]("control-change",u),l("control-change",u);const c=n.viewer;if(c&&!this._viewerUpdateHandler){const d=()=>{this._visible&&this._updatePosition()};this._viewerUpdateHandler=d,c.addEventListener("update",d)}}else{this._boundMapHandlers.forEach((c,d)=>{i[s](d,c)}),this._boundMapHandlers.clear();const u=n.viewer;u&&this._viewerUpdateHandler&&(u.removeEventListener("update",this._viewerUpdateHandler),this._viewerUpdateHandler=void 0)}}_resolveWorldPosition(){const e=this._map;if(!e)return;if(this._coordinate){const[i,s,l=0]=this._coordinate,u=new m.Vector3(i,s,l);return e.geo2world(u)}const n=this._owner;if(n&&n._geometry){const i=n._geometry;if(i&&(i.type==="Point"||i.type==="MultiPoint")){let s;if(i.type==="Point"?s=i.coordinates:i.type==="MultiPoint"&&Array.isArray(i.coordinates)&&i.coordinates.length>0&&(s=i.coordinates[0]),s&&s.length>=2){const l=new m.Vector3(s[0],s[1],s[2]??0);return e.geo2world(l)}}if(n._threeGeometry&&typeof n._threeGeometry.getWorldPosition=="function"){const s=new m.Vector3;if(n._threeGeometry.getWorldPosition(s),!(s.x===0&&s.y===0&&s.z===0))return s}if(n._position instanceof m.Vector3){const s=n._position;if(!(s.x===0&&s.y===0&&s.z===0))return s.clone()}}if(n&&typeof n.getWorldPosition=="function"){const i=new m.Vector3;return n.getWorldPosition(i),i}return e.prjcenter?.clone?.()??void 0}_updatePosition(){if(!this._dom||!this._map)return;if(this._visible){const p=this._resolveWorldPosition();if(!p){this._dom.style.display="none";return}this._worldPosition=p}if(!this._worldPosition)return;const e=this._map.viewer,n=e.camera,i=e.renderer,s=this._worldPosition.clone().project(n);if(s.x<-1.1||s.x>1.1||s.y<-1.1||s.y>1.1||s.z<-1||s.z>1){this._dom.style.display="none";return}const l=new m.Vector2;i.getSize(l);const u=(s.x*.5+.5)*l.width,c=(-s.y*.5+.5)*l.height,d=this.getOffset();if(this._dom.style.left=`${u+d.x}px`,this._dom.style.top=`${c+d.y}px`,!this._positionedOnce){this._positionedOnce=!0;return}this._dom.style.display=""}};T(mi,"_singletons",new Set);let Mo=mi;class cc extends Mo{constructor(e){super({single:!0,...e});T(this,"_titleEl");T(this,"_contentEl")}_getClassName(){return"InfoWindow"}buildOn(){if(this.options.custom){let c;this.options.content instanceof HTMLElement?c=this.options.content:(c=document.createElement("div"),typeof this.options.content=="string"&&(c.innerHTML=this.options.content));const d=this.options.containerClass;return d&&(Array.isArray(d)?d:[d]).forEach(f=>{c.classList.add(f)}),this.options.minWidth&&(c.style.minWidth=`${this.options.minWidth}px`),this.options.minHeight&&(c.style.minHeight=`${this.options.minHeight}px`),this._titleEl=void 0,this._contentEl=c,c}const e=document.createElement("div");e.className="terra-infowindow";const n=this.options.containerClass;n&&(Array.isArray(n)?n:[n]).forEach(d=>{e.classList.add(d)}),typeof this.options.zIndex=="number"&&(e.style.zIndex=String(this.options.zIndex)),this.options.minWidth&&(e.style.minWidth=`${this.options.minWidth}px`),this.options.minHeight&&(e.style.minHeight=`${this.options.minHeight}px`);const i=document.createElement("div");i.className="terra-infowindow-header";const s=document.createElement("div");s.className="terra-infowindow-title",this.options.title&&(s.innerText=this.options.title);const l=document.createElement("span");l.className="terra-infowindow-close",l.innerHTML="×",l.title="关闭",l.addEventListener("click",c=>{c.stopPropagation(),c.preventDefault(),this.close()}),l.addEventListener("mousedown",c=>{c.preventDefault()}),l.style.cursor="pointer",l.style.userSelect="none",i.appendChild(s),i.appendChild(l);const u=document.createElement("div");return u.className="terra-infowindow-content",this.options.content instanceof HTMLElement?u.appendChild(this.options.content):typeof this.options.content=="string"&&(u.innerHTML=this.options.content),e.appendChild(i),e.appendChild(u),this._titleEl=s,this._contentEl=u,e}getOffset(){const e=super.getOffset(),n=this._dom;if(!n)return e;const i=n.offsetWidth,s=n.offsetHeight;return{x:e.x-i/2,y:e.y-s-10}}setTitle(e){return this.options.title=e,this._titleEl&&(this._titleEl.innerText=e??""),this}setContent(e){return this.options.content=e,this._contentEl?(this._contentEl.innerHTML="",e instanceof HTMLElement?this._contentEl.appendChild(e):this._contentEl.innerHTML=e,this):this}open(e){super.show(e);const n=this,i=()=>{!n._dom||!n._map||!n._visible||(n._positionedOnce=!0,n._updatePosition())},l=this.getMap()?.viewer;if(l&&typeof l.addEventListener=="function"){const u=()=>{l.removeEventListener("update",u),i()};l.addEventListener("update",u)}else requestAnimationFrame(i);return this}close(){return this.hide()}}hn.include({setInfoWindow(a){this.removeInfoWindow();let t;return a instanceof cc?t=a:t=new cc(a),this._infoWindow=t,this.getMap()&&t.addTo(this),this},getInfoWindow(){return this._infoWindow},openInfoWindow(a){const t=this._infoWindow;return t?(t.getMap()||this.getMap()&&t.addTo(this),requestAnimationFrame(()=>{t.open(a)}),this):this},closeInfoWindow(){return this._infoWindow&&this._infoWindow.close(),this},removeInfoWindow(){return this._infoWindow&&(this._infoWindow.remove(),this._infoWindow=void 0),this}});class n0 extends Kt{constructor(e){super(e);T(this,"dataType","image");T(this,"attribution","天地图");T(this,"token","");T(this,"style","img_w");T(this,"subdomains","01234");T(this,"url","https://t{s}.tianditu.gov.cn/DataServer?T={style}&x={x}&y={y}&l={z}&tk={token}");if(Object.assign(this,e),!this.token)throw new Error("天地图访问令牌(token)是必填参数")}}class i0 extends Kt{constructor(e){super(e);T(this,"dataType","quantized-mesh");T(this,"attribution","天地图");T(this,"token","");T(this,"subdomains","01234");T(this,"url","https://t{s}.tianditu.gov.cn/mapservice/swdx?T=elv_c&tk={token}&x={x}&y={y}&l={z}");if(Object.assign(this,e),!this.token)throw new Error("天地图访问令牌(token)是必填参数")}}class r0 extends Kt{constructor(e){super({...e,url:e.urlTemplate,isTMS:e.isTMS||!1});T(this,"minLevel",2);T(this,"maxLevel",24)}getUrl(e,n,i){const s=this.isTMS?Math.pow(2,i)-1-n:n;return Af(this.url,{...this,x:e,y:s,z:i,tileMatrix:i,tileRow:s,tileCol:e})}}class s0 extends Kt{constructor(e){super(e);T(this,"dataType","image");T(this,"attribution","ArcGIS");T(this,"style","World_Imagery");T(this,"url","https://services.arcgisonline.com/arcgis/rest/services/{style}/MapServer/tile/{z}/{y}/{x}");Object.assign(this,e)}}class o0 extends Kt{constructor(e){super(e);T(this,"dataType","lerc");T(this,"attribution","ArcGIS");T(this,"minLevel",6);T(this,"maxLevel",13);T(this,"url","https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer/tile/{z}/{y}/{x}");Object.assign(this,e)}}class a0 extends Kt{constructor(e){super(e);T(this,"token","");T(this,"format","webp");T(this,"style","cm2myr6qx001t01pi0sf7estf");T(this,"attribution","MapBox");T(this,"maxLevel",25);T(this,"url","https://api.mapbox.com/styles/v1/criska/cm2myr6qx001t01pi0sf7estf/tiles/256/{z}/{x}/{y}?access_token={token}&format={format}");if(Object.assign(this,e),!this.token)throw new Error("MapBox访问令牌(token)是必填参数")}}class l0 extends Kt{constructor(e){super(e);T(this,"dataType","mvt");T(this,"style",{layer:[]});Object.assign(this,e)}}class c0 extends Kt{constructor(e){super(e);T(this,"dataType","VectorTile");T(this,"attribution","ArcGIS");T(this,"minLevel",1);T(this,"maxLevel",21);T(this,"url","https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key=uKYsZQZpm72WlbSgH9B7");Object.assign(this,e)}}class u0 extends Bn{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Line"}}class h0 extends Bn{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Point"}}class d0 extends Bn{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Surface"}}class f0 extends Bn{constructor(e,n){super(e,n);T(this,"_clouds",null);const i=["texture"];for(const s of i)ml(n,s);this._createClouds(n.texture)}async _createClouds(e){const n=await Wt._loadTexture(e),i=new Of({texture:n,material:m.MeshBasicMaterial});i.castShadow=!0,this._clouds=i}validateFeature(e){return e._type==="Cloud"}animate(e,n){this._clouds&&this._clouds.update(this.map.viewer.camera,n,e)}}class p0 extends Ul{constructor(e,n){super(e,n);T(this,"layerType","raster")}createLoader(){const e=new Vr;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}}class m0 extends p0{constructor(e,n){super(e,n);T(this,"layerType","wmts");T(this,"_layerName");T(this,"_style");T(this,"_matrixSet");this._layerName=n.layerName,this._style=n.style||"default",this._matrixSet=n.matrixSet||"GoogleMapsCompatible"}get layerName(){return this._layerName}get style(){return this._style}get matrixSet(){return this._matrixSet}createLoader(){const e=new Vr;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}update(e){this.loader&&super.update(e)}}console.log("%c✨ terra.gl V"+Dh+" ","color:rgb(255, 255, 255); font-weight: bold; background: linear-gradient(90deg, #ffb6c1, #ff69b4); padding: 5px; border-radius: 5px;"),ee.ArcGisDemSource=o0,ee.ArcGisSource=s0,ee.CloudsLayer=f0,ee.EventClass=Hs,ee.ICloud=Rl,ee.Label=Kl,ee.LineLayer=u0,ee.LineString=oo,ee.LoaderFactory=Xe,ee.MVTGeoSource=c0,ee.MVTSource=l0,ee.Maker=so,ee.Map=Nn,ee.MapBoxSource=a0,ee.Martini=Ql,ee.Model=Ol,ee.MultiLineString=kl,ee.PointLayer=h0,ee.Polygon=Dl,ee.PolygonLayer=d0,ee.ProjectFactory=If,ee.PromiseWorker=Dp,ee.Style=Wt,ee.TDTQMSource=i0,ee.TDTSource=n0,ee.TPoints=Yl,ee.Tile=nn,ee.TileCanvasLoader=jp,ee.TileGeometry=fi,ee.TileGeometryLoader=mo,ee.TileLoader=Vr,ee.TileLoadingManager=Bl,ee.TileMap=Lr,ee.TileMaterial=go,ee.TileMaterialLoader=yo,ee.TileSource=Kt,ee.VectorFeatureTypes=tt,ee.VectorTileLayer=_o,ee.VectorTileRender=Hl,ee.Viewer=gl,ee.WMTSSource=r0,ee.WMTSTileLayer=m0,ee.addSkirt=jl,ee.author=$p,ee.concatenateTypedArrays=Ji,ee.convertGeometryToWGS84=Rp,ee.createBillboards=Vf,ee.getBoundsCoord=co,ee.getGeometryDataFromDem=Jl,ee.getGridIndices=fo,ee.getLocalInfoFromRay=Js,ee.getLocalInfoFromScreen=xl,ee.getLocalInfoFromWorld=Qs,ee.getNormals=po,ee.getSafeTileUrlAndBounds=uo,ee.registerDEMLoader=wo,ee.registerImgLoader=vo,ee.registerMeshLoader=El,ee.vector2ToWGS84=ho,ee.version=qp,ee.waitFor=em,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})});
|