(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['deck'] = factory(); else root['deck'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var WL=Object.create;var Tc=Object.defineProperty;var jL=Object.getOwnPropertyDescriptor;var XL=Object.getOwnPropertyNames;var YL=Object.getPrototypeOf,qL=Object.prototype.hasOwnProperty;var KL=(t,e,r)=>e in t?Tc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var UE=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var ct=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ke=(t,e)=>{for(var r in e)Tc(t,r,{get:e[r],enumerable:!0})},kE=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of XL(e))!qL.call(t,i)&&i!==r&&Tc(t,i,{get:()=>e[i],enumerable:!(s=jL(e,i))||s.enumerable});return t};var ss=(t,e,r)=>(r=t!=null?WL(YL(t)):{},kE(e||!t||!t.__esModule?Tc(r,"default",{value:t,enumerable:!0}):r,t)),$L=t=>kE(Tc({},"__esModule",{value:!0}),t);var Y=(t,e,r)=>(KL(t,typeof e!="symbol"?e+"":e,r),r);var ww=ct((z_e,_p)=>{(function(t,e,r,s){"use strict";var i=["","webkit","Moz","MS","ms","o"],n=e.createElement("div"),o="function",a=Math.round,c=Math.abs,l=Date.now;function u(A,b,C){return setTimeout(y(A,C),b)}function f(A,b,C){return Array.isArray(A)?(h(A,C[b],C),!0):!1}function h(A,b,C){var N;if(A)if(A.forEach)A.forEach(b,C);else if(A.length!==s)for(N=0;N\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",ae=t.console&&(t.console.warn||t.console.log);return ae&&ae.call(t.console,N,$),A.apply(this,arguments)}}var p;typeof Object.assign!="function"?p=function(b){if(b===s||b===null)throw new TypeError("Cannot convert undefined or null to object");for(var C=Object(b),N=1;N-1}function v(A){return A.trim().split(/\s+/g)}function T(A,b,C){if(A.indexOf&&!C)return A.indexOf(b);for(var N=0;NRt[b]}):N=N.sort()),N}function z(A,b){for(var C,N,H=b[0].toUpperCase()+b.slice(1),$=0;$1&&!C.firstMultiple?C.firstMultiple=TE(b):H===1&&(C.firstMultiple=!1);var $=C.firstInput,ae=C.firstMultiple,at=ae?ae.center:$.center,pt=b.center=bE(N);b.timeStamp=l(),b.deltaTime=b.timeStamp-$.timeStamp,b.angle=l_(at,pt),b.distance=xh(at,pt),xL(C,b),b.offsetDirection=SE(b.deltaX,b.deltaY);var Rt=EE(b.deltaTime,b.deltaX,b.deltaY);b.overallVelocityX=Rt.x,b.overallVelocityY=Rt.y,b.overallVelocity=c(Rt.x)>c(Rt.y)?Rt.x:Rt.y,b.scale=ae?bL(ae.pointers,N):1,b.rotation=ae?TL(ae.pointers,N):0,b.maxPointers=C.prevInput?b.pointers.length>C.prevInput.maxPointers?b.pointers.length:C.prevInput.maxPointers:b.pointers.length,AL(C,b);var rs=A.element;L(b.srcEvent.target,rs)&&(rs=b.srcEvent.target),b.target=rs}function xL(A,b){var C=b.center,N=A.offsetDelta||{},H=A.prevDelta||{},$=A.prevInput||{};(b.eventType===Mt||$.eventType===qe)&&(H=A.prevDelta={x:$.deltaX||0,y:$.deltaY||0},N=A.offsetDelta={x:C.x,y:C.y}),b.deltaX=H.x+(C.x-N.x),b.deltaY=H.y+(C.y-N.y)}function AL(A,b){var C=A.lastInterval||b,N=b.timeStamp-C.timeStamp,H,$,ae,at;if(b.eventType!=Ut&&(N>c_||C.velocity===s)){var pt=b.deltaX-C.deltaX,Rt=b.deltaY-C.deltaY,rs=EE(N,pt,Rt);$=rs.x,ae=rs.y,H=c(rs.x)>c(rs.y)?rs.x:rs.y,at=SE(pt,Rt),A.lastInterval=b}else H=C.velocity,$=C.velocityX,ae=C.velocityY,at=C.direction;b.velocity=H,b.velocityX=$,b.velocityY=ae,b.direction=at}function TE(A){for(var b=[],C=0;C=c(b)?A<0?pc:gc:b<0?mc:_c}function xh(A,b,C){C||(C=AE);var N=b[C[0]]-A[C[0]],H=b[C[1]]-A[C[1]];return Math.sqrt(N*N+H*H)}function l_(A,b,C){C||(C=AE);var N=b[C[0]]-A[C[0]],H=b[C[1]]-A[C[1]];return Math.atan2(H,N)*180/Math.PI}function TL(A,b){return l_(b[1],b[0],yh)+l_(A[1],A[0],yh)}function bL(A,b){return xh(b[0],b[1],yh)/xh(A[0],A[1],yh)}var EL={mousedown:Mt,mousemove:rn,mouseup:qe},SL="mousedown",vL="mousemove mouseup";function Ah(){this.evEl=SL,this.evWin=vL,this.pressed=!1,ir.apply(this,arguments)}_(Ah,ir,{handler:function(b){var C=EL[b.type];C&Mt&&b.button===0&&(this.pressed=!0),C&rn&&b.which!==1&&(C=qe),this.pressed&&(C&qe&&(this.pressed=!1),this.callback(this.manager,C,{pointers:[b],changedPointers:[b],pointerType:dc,srcEvent:b}))}});var CL={pointerdown:Mt,pointermove:rn,pointerup:qe,pointercancel:Ut,pointerout:Ut},wL={2:Ee,3:xt,4:dc,5:yE},vE="pointerdown",CE="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(vE="MSPointerDown",CE="MSPointerMove MSPointerUp MSPointerCancel");function u_(){this.evEl=vE,this.evWin=CE,ir.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}_(u_,ir,{handler:function(b){var C=this.store,N=!1,H=b.type.toLowerCase().replace("ms",""),$=CL[H],ae=wL[b.pointerType]||b.pointerType,at=ae==Ee,pt=T(C,b.pointerId,"pointerId");$&Mt&&(b.button===0||at)?pt<0&&(C.push(b),pt=C.length-1):$&(qe|Ut)&&(N=!0),!(pt<0)&&(C[pt]=b,this.callback(this.manager,$,{pointers:C,changedPointers:[b],pointerType:ae,srcEvent:b}),N&&C.splice(pt,1))}});var PL={touchstart:Mt,touchmove:rn,touchend:qe,touchcancel:Ut},ML="touchstart",RL="touchstart touchmove touchend touchcancel";function wE(){this.evTarget=ML,this.evWin=RL,this.started=!1,ir.apply(this,arguments)}_(wE,ir,{handler:function(b){var C=PL[b.type];if(C===Mt&&(this.started=!0),!!this.started){var N=IL.call(this,b,C);C&(qe|Ut)&&N[0].length-N[1].length===0&&(this.started=!1),this.callback(this.manager,C,{pointers:N[0],changedPointers:N[1],pointerType:Ee,srcEvent:b})}}});function IL(A,b){var C=D(A.touches),N=D(A.changedTouches);return b&(qe|Ut)&&(C=V(C.concat(N),"identifier",!0)),[C,N]}var BL={touchstart:Mt,touchmove:rn,touchend:qe,touchcancel:Ut},OL="touchstart touchmove touchend touchcancel";function Th(){this.evTarget=OL,this.targetIds={},ir.apply(this,arguments)}_(Th,ir,{handler:function(b){var C=BL[b.type],N=FL.call(this,b,C);N&&this.callback(this.manager,C,{pointers:N[0],changedPointers:N[1],pointerType:Ee,srcEvent:b})}});function FL(A,b){var C=D(A.touches),N=this.targetIds;if(b&(Mt|rn)&&C.length===1)return N[C[0].identifier]=!0,[C,C];var H,$,ae=D(A.changedTouches),at=[],pt=this.target;if($=C.filter(function(Rt){return L(Rt.target,pt)}),b===Mt)for(H=0;H<$.length;)N[$[H].identifier]=!0,H++;for(H=0;H-1&&N.splice($,1)};setTimeout(H,LL)}}function DL(A){for(var b=A.srcEvent.clientX,C=A.srcEvent.clientY,N=0;N-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(A){return!!this.simultaneous[A.id]},emit:function(A){var b=this,C=this.state;function N(H){b.manager.emit(H,A)}C=oi&&N(b.options.event+FE(C))},tryEmit:function(A){if(this.canEmit())return this.emit(A);this.state=ts},canEmit:function(){for(var A=0;Ab.threshold&&H&b.direction},attrTest:function(A){return Mr.prototype.attrTest.call(this,A)&&(this.state&nr||!(this.state&nr)&&this.directionTest(A))},emit:function(A){this.pX=A.deltaX,this.pY=A.deltaY;var b=LE(A.direction);b&&(A.additionalEvent=this.options.event+b),this._super.emit.call(this,A)}});function p_(){Mr.apply(this,arguments)}_(p_,Mr,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[nn]},attrTest:function(A){return this._super.attrTest.call(this,A)&&(Math.abs(A.scale-1)>this.options.threshold||this.state&nr)},emit:function(A){if(A.scale!==1){var b=A.scale<1?"in":"out";A.additionalEvent=this.options.event+b}this._super.emit.call(this,A)}});function g_(){Ps.apply(this,arguments),this._timer=null,this._input=null}_(g_,Ps,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[OE]},process:function(A){var b=this.options,C=A.pointers.length===b.pointers,N=A.distanceb.time;if(this._input=A,!N||!C||A.eventType&(qe|Ut)&&!H)this.reset();else if(A.eventType&Mt)this.reset(),this._timer=u(function(){this.state=ws,this.tryEmit()},b.time,this);else if(A.eventType&qe)return ws;return ts},reset:function(){clearTimeout(this._timer)},emit:function(A){this.state===ws&&(A&&A.eventType&qe?this.manager.emit(this.options.event+"up",A):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function m_(){Mr.apply(this,arguments)}_(m_,Mr,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[nn]},attrTest:function(A){return this._super.attrTest.call(this,A)&&(Math.abs(A.rotation)>this.options.threshold||this.state&nr)}});function __(){Mr.apply(this,arguments)}_(__,Mr,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:es|sn,pointers:1},getTouchAction:function(){return vh.prototype.getTouchAction.call(this)},attrTest:function(A){var b=this.options.direction,C;return b&(es|sn)?C=A.overallVelocity:b&es?C=A.overallVelocityX:b&sn&&(C=A.overallVelocityY),this._super.attrTest.call(this,A)&&b&A.offsetDirection&&A.distance>this.options.threshold&&A.maxPointers==this.options.pointers&&c(C)>this.options.velocity&&A.eventType&qe},emit:function(A){var b=LE(A.offsetDirection);b&&this.manager.emit(this.options.event+b,A),this.manager.emit(this.options.event,A)}});function Ch(){Ps.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}_(Ch,Ps,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[h_]},process:function(A){var b=this.options,C=A.pointers.length===b.pointers,N=A.distance{"use strict";TA.exports=Zp;TA.exports.default=Zp;function Zp(t,e,r){r=r||2;var s=e&&e.length,i=s?e[0]*r:t.length,n=lM(t,0,i,r,!0),o=[];if(!n||n.next===n.prev)return o;var a,c,l,u,f,h,d;if(s&&(n=T9(t,e,n,r)),t.length>80*r){a=l=t[0],c=u=t[1];for(var p=r;pl&&(l=f),h>u&&(u=h);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return Fu(n,o,r,a,c,d,0),o}function lM(t,e,r,s,i){var n,o;if(i===AA(t,e,r,s)>0)for(n=e;n=e;n-=s)o=cM(n,t[n],t[n+1],o);return o&&Qp(o,o.next)&&(Nu(o),o=o.next),o}function qn(t,e){if(!t)return t;e||(e=t);var r=t,s;do if(s=!1,!r.steiner&&(Qp(r,r.next)||De(r.prev,r,r.next)===0)){if(Nu(r),r=e=r.prev,r===r.next)break;s=!0}else r=r.next;while(s||r!==e);return e}function Fu(t,e,r,s,i,n,o){if(t){!o&&n&&C9(t,s,i,n);for(var a=t,c,l;t.prev!==t.next;){if(c=t.prev,l=t.next,n?y9(t,s,i,n):_9(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Nu(t),t=l.next,a=l.next;continue}if(t=l,t===a){o?o===1?(t=x9(qn(t),e,r),Fu(t,e,r,s,i,n,2)):o===2&&A9(t,e,r,s,i,n):Fu(qn(t),e,r,s,i,n,1);break}}}}function _9(t){var e=t.prev,r=t,s=t.next;if(De(e,r,s)>=0)return!1;for(var i=e.x,n=r.x,o=s.x,a=e.y,c=r.y,l=s.y,u=in?i>o?i:o:n>o?n:o,d=a>c?a>l?a:l:c>l?c:l,p=s.next;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&_a(i,a,n,c,o,l,p.x,p.y)&&De(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function y9(t,e,r,s){var i=t.prev,n=t,o=t.next;if(De(i,n,o)>=0)return!1;for(var a=i.x,c=n.x,l=o.x,u=i.y,f=n.y,h=o.y,d=ac?a>l?a:l:c>l?c:l,m=u>f?u>h?u:h:f>h?f:h,_=yA(d,p,e,r,s),y=yA(g,m,e,r,s),x=t.prevZ,S=t.nextZ;x&&x.z>=_&&S&&S.z<=y;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&_a(a,u,c,f,l,h,x.x,x.y)&&De(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=d&&S.x<=g&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&_a(a,u,c,f,l,h,S.x,S.y)&&De(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=_;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&_a(a,u,c,f,l,h,x.x,x.y)&&De(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=y;){if(S.x>=d&&S.x<=g&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&_a(a,u,c,f,l,h,S.x,S.y)&&De(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function x9(t,e,r){var s=t;do{var i=s.prev,n=s.next.next;!Qp(i,n)&&uM(i,s,s.next,n)&&Lu(i,n)&&Lu(n,i)&&(e.push(i.i/r|0),e.push(s.i/r|0),e.push(n.i/r|0),Nu(s),Nu(s.next),s=t=n),s=s.next}while(s!==t);return qn(s)}function A9(t,e,r,s,i,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&M9(o,a)){var c=fM(o,a);o=qn(o,o.next),c=qn(c,c.next),Fu(o,e,r,s,i,n,0),Fu(c,e,r,s,i,n,0);return}a=a.next}o=o.next}while(o!==t)}function T9(t,e,r,s){var i=[],n,o,a,c,l;for(n=0,o=e.length;n=r.next.y&&r.next.y!==r.y){var a=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=s&&a>n&&(n=a,o=r.x=r.x&&r.x>=l&&s!==r.x&&_a(io.x||r.x===o.x&&v9(o,r)))&&(o=r,f=h)),r=r.next;while(r!==c);return o}function v9(t,e){return De(t.prev,t,e.prev)<0&&De(e.next,t,t.next)<0}function C9(t,e,r,s){var i=t;do i.z===0&&(i.z=yA(i.x,i.y,e,r,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,w9(i)}function w9(t){var e,r,s,i,n,o,a,c,l=1;do{for(r=t,t=null,n=null,o=0;r;){for(o++,s=r,a=0,e=0;e0||c>0&&s;)a!==0&&(c===0||!s||r.z<=s.z)?(i=r,r=r.nextZ,a--):(i=s,s=s.nextZ,c--),n?n.nextZ=i:t=i,i.prevZ=n,n=i;r=s}n.nextZ=null,l*=2}while(o>1);return t}function yA(t,e,r,s,i){return t=(t-r)*i|0,e=(e-s)*i|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function P9(t){var e=t,r=t;do(e.x=(t-o)*(n-a)&&(t-o)*(s-a)>=(r-o)*(e-a)&&(r-o)*(n-a)>=(i-o)*(s-a)}function M9(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!R9(t,e)&&(Lu(t,e)&&Lu(e,t)&&I9(t,e)&&(De(t.prev,t,e.prev)||De(t,e.prev,e))||Qp(t,e)&&De(t.prev,t,t.next)>0&&De(e.prev,e,e.next)>0)}function De(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Qp(t,e){return t.x===e.x&&t.y===e.y}function uM(t,e,r,s){var i=Jp(De(t,e,r)),n=Jp(De(t,e,s)),o=Jp(De(r,s,t)),a=Jp(De(r,s,e));return!!(i!==n&&o!==a||i===0&&$p(t,r,e)||n===0&&$p(t,s,e)||o===0&&$p(r,t,s)||a===0&&$p(r,e,s))}function $p(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Jp(t){return t>0?1:t<0?-1:0}function R9(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&uM(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Lu(t,e){return De(t.prev,t,t.next)<0?De(t,e,t.next)>=0&&De(t,t.prev,e)>=0:De(t,e,t.prev)<0||De(t,t.next,e)<0}function I9(t,e){var r=t,s=!1,i=(t.x+e.x)/2,n=(t.y+e.y)/2;do r.y>n!=r.next.y>n&&r.next.y!==r.y&&i<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next;while(r!==t);return s}function fM(t,e){var r=new xA(t.i,t.x,t.y),s=new xA(e.i,e.x,e.y),i=t.next,n=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,s.next=r,r.prev=s,n.next=s,s.prev=n,s}function cM(t,e,r,s){var i=new xA(t,e,r);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Nu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function xA(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Zp.deviation=function(t,e,r,s){var i=e&&e.length,n=i?e[0]*r:t.length,o=Math.abs(AA(t,0,n,r));if(i)for(var a=0,c=e.length;a0&&(s+=t[i-1].length,r.holes.push(s))}return r}});var pg=ct(qs=>{"use strict";var JM=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",nG=JM+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",ZM="["+JM+"]["+nG+"]*",oG=new RegExp("^"+ZM+"$"),aG=function(t,e){let r=[],s=e.exec(t);for(;s;){let i=[];i.startIndex=e.lastIndex-s[0].length;let n=s.length;for(let o=0;o"u")};qs.isExist=function(t){return typeof t<"u"};qs.isEmptyObject=function(t){return Object.keys(t).length===0};qs.merge=function(t,e,r){if(e){let s=Object.keys(e),i=s.length;for(let n=0;n{"use strict";var CA=pg(),lG={allowBooleanAttributes:!1,unpairedTags:[]};sR.validate=function(t,e){e=Object.assign({},lG,e);let r=[],s=!1,i=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let n=0;n"&&t[n]!==" "&&t[n]!==" "&&t[n]!==` `&&t[n]!=="\r";n++)c+=t[n];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),n--),!_G(c)){let f;return c.trim().length===0?f="Invalid space after '<'.":f="Tag '"+c+"' is an invalid name.",rt("InvalidTag",f,jt(t,n))}let l=hG(t,n);if(l===!1)return rt("InvalidAttr","Attributes for '"+c+"' have open quote.",jt(t,n));let u=l.value;if(n=l.index,u[u.length-1]==="/"){let f=n-u.length;u=u.substring(0,u.length-1);let h=rR(u,e);if(h===!0)s=!0;else return rt(h.err.code,h.err.msg,jt(t,f+h.err.line))}else if(a)if(l.tagClosed){if(u.trim().length>0)return rt("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",jt(t,o));{let f=r.pop();if(c!==f.tagName){let h=jt(t,f.tagStartPos);return rt("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+c+"'.",jt(t,o))}r.length==0&&(i=!0)}}else return rt("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",jt(t,n));else{let f=rR(u,e);if(f!==!0)return rt(f.err.code,f.err.msg,jt(t,n-u.length+f.err.line));if(i===!0)return rt("InvalidXml","Multiple possible root nodes found.",jt(t,n));e.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:o}),s=!0}for(n++;n0)return rt("InvalidXml","Invalid '"+JSON.stringify(r.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return rt("InvalidXml","Start tag expected.",1);return!0};function QM(t){return t===" "||t===" "||t===` `||t==="\r"}function eR(t,e){let r=e;for(;e5&&s==="xml")return rt("InvalidXml","XML declaration allowed only at the start of the document.",jt(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function tR(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let r=1;for(e+=8;e"&&(r--,r===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e"){e+=2;break}}return e}var uG='"',fG="'";function hG(t,e){let r="",s="",i=!1;for(;e"&&s===""){i=!0;break}r+=t[e]}return s!==""?!1:{value:r,index:e,tagClosed:i}}var dG=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function rR(t,e){let r=CA.getAllMatches(t,dG),s={};for(let i=0;i{var iR={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}},yG=function(t){return Object.assign({},iR,t)};PA.buildOptions=yG;PA.defaultOptions=iR});var aR=ct((LSe,oR)=>{"use strict";var MA=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,r){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:r})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child})}};oR.exports=MA});var lR=ct((NSe,cR)=>{var xG=pg();function AG(t,e){let r={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let s=1,i=!1,n=!1,o="";for(;e"){if(n?t[e-1]==="-"&&t[e-2]==="-"&&(n=!1,s--):s--,s===0)break}else t[e]==="["?i=!0:o+=t[e];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:r,i:e}}function TG(t,e){let r="";for(;e{var PG=/^[-+]?0x[a-fA-F0-9]+$/,MG=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var RG={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function IG(t,e={}){if(e=Object.assign({},RG,e),!t||typeof t!="string")return t;let r=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(r))return t;if(e.hex&&PG.test(r))return Number.parseInt(r,16);{let s=MG.exec(r);if(s){let i=s[1],n=s[2],o=BG(s[3]),a=s[4]||s[6];if(!e.leadingZeros&&n.length>0&&i&&r[2]!==".")return t;if(!e.leadingZeros&&n.length>0&&!i&&r[1]!==".")return t;{let c=Number(r),l=""+c;return l.search(/[eE]/)!==-1||a?e.eNotation?c:t:r.indexOf(".")!==-1?l==="0"&&o===""||l===o||i&&l==="-"+o?c:t:n?o===l||i+o===l?c:t:r===l||r===i+l?c:t}}else return t}}function BG(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}uR.exports=IG});var pR=ct((USe,dR)=>{"use strict";var hR=pg(),$u=aR(),OG=lR(),FG=fR(),RA=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(r,s)=>String.fromCharCode(Number.parseInt(s,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(r,s)=>String.fromCharCode(Number.parseInt(s,16))}},this.addExternalEntities=LG,this.parseXml=VG,this.parseTextData=NG,this.resolveNameSpace=DG,this.buildAttributesMap=kG,this.isItStopNode=WG,this.replaceEntitiesValue=HG,this.readStopNodeData=XG,this.saveTextToParentTag=GG,this.addChild=zG}};function LG(t){let e=Object.keys(t);for(let r=0;r0)){o||(t=this.replaceEntitiesValue(t));let a=this.options.tagValueProcessor(e,t,r,i,n);return a==null?t:typeof a!=typeof t||a!==t?a:this.options.trimValues?BA(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?BA(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function DG(t){if(this.options.removeNSPrefix){let e=t.split(":"),r=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=r+e[1])}return t}var UG=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function kG(t,e,r){if(!this.options.ignoreAttributes&&typeof t=="string"){let s=hR.getAllMatches(t,UG),i=s.length,n={};for(let o=0;o",n,"Closing Tag is not closed."),c=t.substring(n+2,a).trim();if(this.options.removeNSPrefix){let f=c.indexOf(":");f!==-1&&(c=c.substr(f+1))}this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&(s=this.saveTextToParentTag(s,r,i));let l=i.substring(i.lastIndexOf(".")+1);if(c&&this.options.unpairedTags.indexOf(c)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: `);let u=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(u=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=i.lastIndexOf("."),i=i.substring(0,u),r=this.tagsNodeStack.pop(),s="",n=a}else if(t[n+1]==="?"){let a=IA(t,n,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,r,i),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){let c=new $u(a.tagName);c.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(c[":@"]=this.buildAttributesMap(a.tagExp,i,a.tagName)),this.addChild(r,c,i)}n=a.closeIndex+1}else if(t.substr(n+1,3)==="!--"){let a=Jn(t,"-->",n+4,"Comment is not closed.");if(this.options.commentPropName){let c=t.substring(n+4,a-2);s=this.saveTextToParentTag(s,r,i),r.add(this.options.commentPropName,[{[this.options.textNodeName]:c}])}n=a}else if(t.substr(n+1,2)==="!D"){let a=OG(t,n);this.docTypeEntities=a.entities,n=a.i}else if(t.substr(n+1,2)==="!["){let a=Jn(t,"]]>",n,"CDATA is not closed.")-2,c=t.substring(n+9,a);s=this.saveTextToParentTag(s,r,i);let l=this.parseTextData(c,r.tagname,i,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:c}]):r.add(this.options.textNodeName,l),n=a+2}else{let a=IA(t,n,this.options.removeNSPrefix),c=a.tagName,l=a.rawTagName,u=a.tagExp,f=a.attrExpPresent,h=a.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&s&&r.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,r,i,!1));let d=r;if(d&&this.options.unpairedTags.indexOf(d.tagname)!==-1&&(r=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),c!==e.tagname&&(i+=i?"."+c:c),this.isItStopNode(this.options.stopNodes,i,c)){let p="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)n=a.closeIndex;else if(this.options.unpairedTags.indexOf(c)!==-1)n=a.closeIndex;else{let m=this.readStopNodeData(t,l,h+1);if(!m)throw new Error(`Unexpected end of ${l}`);n=m.i,p=m.tagContent}let g=new $u(c);c!==u&&f&&(g[":@"]=this.buildAttributesMap(u,i,c)),p&&(p=this.parseTextData(p,c,i,!0,f,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),g.add(this.options.textNodeName,p),this.addChild(r,g,i)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){c[c.length-1]==="/"?(c=c.substr(0,c.length-1),i=i.substr(0,i.length-1),u=c):u=u.substr(0,u.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));let p=new $u(c);c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,i,c)),this.addChild(r,p,i),i=i.substr(0,i.lastIndexOf("."))}else{let p=new $u(c);this.tagsNodeStack.push(r),c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,i,c)),this.addChild(r,p,i),r=p}s="",n=h}}else s+=t[n];return e.child};function zG(t,e,r){let s=this.options.updateTag(e.tagname,r,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),t.addChild(e))}var HG=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){let r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(let e in this.lastEntities){let r=this.lastEntities[e];t=t.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){let r=this.htmlEntities[e];t=t.replace(r.regex,r.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function GG(t,e,r,s){return t&&(s===void 0&&(s=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,r,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function WG(t,e,r){let s="*."+r;for(let i in t){let n=t[i];if(s===n||e===n)return!0}return!1}function jG(t,e,r=">"){let s,i="";for(let n=e;n",r,`${e} is not closed`);if(t.substring(r+2,n).trim()===e&&(i--,i===0))return{tagContent:t.substring(s,r),i:n};r=n}else if(t[r+1]==="?")r=Jn(t,"?>",r+1,"StopNode is not closed.");else if(t.substr(r+1,3)==="!--")r=Jn(t,"-->",r+3,"StopNode is not closed.");else if(t.substr(r+1,2)==="![")r=Jn(t,"]]>",r,"StopNode is not closed.")-2;else{let n=IA(t,r,">");n&&((n&&n.tagName)===e&&n.tagExp[n.tagExp.length-1]!=="/"&&i++,r=n.closeIndex)}}function BA(t,e,r){if(e&&typeof t=="string"){let s=t.trim();return s==="true"?!0:s==="false"?!1:FG(t,r)}else return hR.isExist(t)?t:""}dR.exports=RA});var _R=ct(mR=>{"use strict";function YG(t,e){return gR(t,e)}function gR(t,e,r){let s,i={};for(let n=0;n0&&(i[e.textNodeName]=s):s!==void 0&&(i[e.textNodeName]=s),i}function qG(t){let e=Object.keys(t);for(let r=0;r{var{buildOptions:JG}=nR(),ZG=pR(),{prettify:QG}=_R(),eW=wA(),OA=class{constructor(e){this.externalEntities={},this.options=JG(e)}parse(e,r){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let n=eW.validate(e,r);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let s=new ZG(this.options);s.addExternalEntities(this.externalEntities);let i=s.parseXml(e);return this.options.preserveOrder||i===void 0?i:QG(i,this.options)}addEntity(e,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for ' '");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=r}};yR.exports=OA});var SR=ct((zSe,ER)=>{var tW=` `;function rW(t,e){let r="";return e.format&&e.indentBy.length>0&&(r=tW),TR(t,e,"",r)}function TR(t,e,r,s){let i="",n=!1;for(let o=0;o`,n=!1;continue}else if(c===e.commentPropName){i+=s+``,n=!0;continue}else if(c[0]==="?"){let p=AR(a[":@"],e),g=c==="?xml"?"":s,m=a[c][0][e.textNodeName];m=m.length!==0?" "+m:"",i+=g+`<${c}${m}${p}?>`,n=!0;continue}let u=s;u!==""&&(u+=e.indentBy);let f=AR(a[":@"],e),h=s+`<${c}${f}`,d=TR(a[c],e,l,u);e.unpairedTags.indexOf(c)!==-1?e.suppressUnpairedNode?i+=h+">":i+=h+"/>":(!d||d.length===0)&&e.suppressEmptyNode?i+=h+"/>":d&&d.endsWith(">")?i+=h+`>${d}${s}`:(i+=h+">",d&&s!==""&&(d.includes("/>")||d.includes("`),n=!0}return i}function sW(t){let e=Object.keys(t);for(let r=0;r0&&e.processEntities)for(let r=0;r{"use strict";var nW=SR(),oW={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function Wi(t){this.options=Object.assign({},oW,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=lW),this.processTextOrObjNode=aW,this.options.format?(this.indentate=cW,this.tagEndChar=`> `,this.newLine=` `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}Wi.prototype.build=function(t){return this.options.preserveOrder?nW(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)};Wi.prototype.j2x=function(t,e){let r="",s="";for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i))if(typeof t[i]>"u")this.isAttribute(i)&&(s+="");else if(t[i]===null)this.isAttribute(i)?s+="":i[0]==="?"?s+=this.indentate(e)+"<"+i+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+i+"/"+this.tagEndChar;else if(t[i]instanceof Date)s+=this.buildTextValNode(t[i],i,"",e);else if(typeof t[i]!="object"){let n=this.isAttribute(i);if(n)r+=this.buildAttrPairStr(n,""+t[i]);else if(i===this.options.textNodeName){let o=this.options.tagValueProcessor(i,""+t[i]);s+=this.replaceEntitiesValue(o)}else s+=this.buildTextValNode(t[i],i,"",e)}else if(Array.isArray(t[i])){let n=t[i].length,o="";for(let a=0;a"u"||(c===null?i[0]==="?"?s+=this.indentate(e)+"<"+i+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+i+"/"+this.tagEndChar:typeof c=="object"?this.options.oneListGroup?o+=this.j2x(c,e+1).val:o+=this.processTextOrObjNode(c,i,e):o+=this.buildTextValNode(c,i,"",e))}this.options.oneListGroup&&(o=this.buildObjectNode(o,i,"",e)),s+=o}else if(this.options.attributesGroupName&&i===this.options.attributesGroupName){let n=Object.keys(t[i]),o=n.length;for(let a=0;a"+t+i:this.options.commentPropName!==!1&&e===this.options.commentPropName&&n.length===0?this.indentate(s)+``+this.newLine:this.indentate(s)+"<"+e+r+n+this.tagEndChar+t+this.indentate(s)+i}};Wi.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(s)+``+this.newLine;if(e[0]==="?")return this.indentate(s)+"<"+e+r+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),i===""?this.indentate(s)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+r+">"+i+"0&&this.options.processEntities)for(let e=0;e{"use strict";var uW=wA(),fW=xR(),hW=CR();wR.exports={XMLParser:fW,XMLValidator:uW,XMLBuilder:hW}});var GA=ct((VR,rf)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof UE=="function"&&typeof rf=="object"&&rf&&rf.exports?rf.exports=e():(t.dcodeIO=t.dcodeIO||{}).Long=e()})(VR,function(){"use strict";function t(v,T,D){this.low=v|0,this.high=T|0,this.unsigned=!!D}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function e(v){return(v&&v.__isLong__)===!0}t.isLong=e;var r={},s={};function i(v,T){var D,V,z;return T?(v>>>=0,(z=0<=v&&v<256)&&(V=s[v],V)?V:(D=o(v,(v|0)<0?-1:0,!0),z&&(s[v]=D),D)):(v|=0,(z=-128<=v&&v<128)&&(V=r[v],V)?V:(D=o(v,v<0?-1:0,!1),z&&(r[v]=D),D))}t.fromInt=i;function n(v,T){if(isNaN(v)||!isFinite(v))return T?_:m;if(T){if(v<0)return _;if(v>=d)return B}else{if(v<=-p)return L;if(v+1>=p)return P}return v<0?n(-v,T).neg():o(v%h|0,v/h|0,T)}t.fromNumber=n;function o(v,T,D){return new t(v,T,D)}t.fromBits=o;var a=Math.pow;function c(v,T,D){if(v.length===0)throw Error("empty string");if(v==="NaN"||v==="Infinity"||v==="+Infinity"||v==="-Infinity")return m;if(typeof T=="number"?(D=T,T=!1):T=!!T,D=D||10,D<2||360)throw Error("interior hyphen");if(V===0)return c(v.substring(1),T,D).neg();for(var z=n(a(D,8)),W=m,Z=0;Z>>0:this.low},M.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},M.toString=function(T){if(T=T||10,T<2||36>>0,ge=Re.toString(T);if(Z=ie,Z.isZero())return ge+le;for(;ge.length<6;)ge="0"+ge;le=""+ge+le}},M.getHighBits=function(){return this.high},M.getHighBitsUnsigned=function(){return this.high>>>0},M.getLowBits=function(){return this.low},M.getLowBitsUnsigned=function(){return this.low>>>0},M.getNumBitsAbs=function(){if(this.isNegative())return this.eq(L)?64:this.neg().getNumBitsAbs();for(var T=this.high!=0?this.high:this.low,D=31;D>0&&!(T&1<=0},M.isOdd=function(){return(this.low&1)===1},M.isEven=function(){return(this.low&1)===0},M.equals=function(T){return e(T)||(T=l(T)),this.unsigned!==T.unsigned&&this.high>>>31===1&&T.high>>>31===1?!1:this.high===T.high&&this.low===T.low},M.eq=M.equals,M.notEquals=function(T){return!this.eq(T)},M.neq=M.notEquals,M.lessThan=function(T){return this.comp(T)<0},M.lt=M.lessThan,M.lessThanOrEqual=function(T){return this.comp(T)<=0},M.lte=M.lessThanOrEqual,M.greaterThan=function(T){return this.comp(T)>0},M.gt=M.greaterThan,M.greaterThanOrEqual=function(T){return this.comp(T)>=0},M.gte=M.greaterThanOrEqual,M.compare=function(T){if(e(T)||(T=l(T)),this.eq(T))return 0;var D=this.isNegative(),V=T.isNegative();return D&&!V?-1:!D&&V?1:this.unsigned?T.high>>>0>this.high>>>0||T.high===this.high&&T.low>>>0>this.low>>>0?-1:1:this.sub(T).isNegative()?-1:1},M.comp=M.compare,M.negate=function(){return!this.unsigned&&this.eq(L)?L:this.not().add(y)},M.neg=M.negate,M.add=function(T){e(T)||(T=l(T));var D=this.high>>>16,V=this.high&65535,z=this.low>>>16,W=this.low&65535,Z=T.high>>>16,le=T.high&65535,ie=T.low>>>16,Re=T.low&65535,ge=0,be=0,Ee=0,xt=0;return xt+=W+Re,Ee+=xt>>>16,xt&=65535,Ee+=z+ie,be+=Ee>>>16,Ee&=65535,be+=V+le,ge+=be>>>16,be&=65535,ge+=D+Z,ge&=65535,o(Ee<<16|xt,ge<<16|be,this.unsigned)},M.subtract=function(T){return e(T)||(T=l(T)),this.add(T.neg())},M.sub=M.subtract,M.multiply=function(T){if(this.isZero()||(e(T)||(T=l(T)),T.isZero()))return m;if(this.eq(L))return T.isOdd()?L:m;if(T.eq(L))return this.isOdd()?L:m;if(this.isNegative())return T.isNegative()?this.neg().mul(T.neg()):this.neg().mul(T).neg();if(T.isNegative())return this.mul(T.neg()).neg();if(this.lt(g)&&T.lt(g))return n(this.toNumber()*T.toNumber(),this.unsigned);var D=this.high>>>16,V=this.high&65535,z=this.low>>>16,W=this.low&65535,Z=T.high>>>16,le=T.high&65535,ie=T.low>>>16,Re=T.low&65535,ge=0,be=0,Ee=0,xt=0;return xt+=W*Re,Ee+=xt>>>16,xt&=65535,Ee+=z*Re,be+=Ee>>>16,Ee&=65535,Ee+=W*ie,be+=Ee>>>16,Ee&=65535,be+=V*Re,ge+=be>>>16,be&=65535,be+=z*ie,ge+=be>>>16,be&=65535,be+=W*le,ge+=be>>>16,be&=65535,ge+=D*Re+V*ie+z*le+W*Z,ge&=65535,o(Ee<<16|xt,ge<<16|be,this.unsigned)},M.mul=M.multiply,M.divide=function(T){if(e(T)||(T=l(T)),T.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?_:m;var D,V,z;if(this.unsigned){if(T.unsigned||(T=T.toUnsigned()),T.gt(this))return _;if(T.gt(this.shru(1)))return x;z=_}else{if(this.eq(L)){if(T.eq(y)||T.eq(S))return L;if(T.eq(L))return y;var W=this.shr(1);return D=W.div(T).shl(1),D.eq(m)?T.isNegative()?y:S:(V=this.sub(T.mul(D)),z=D.add(V.div(T)),z)}else if(T.eq(L))return this.unsigned?_:m;if(this.isNegative())return T.isNegative()?this.neg().div(T.neg()):this.neg().div(T).neg();if(T.isNegative())return this.div(T.neg()).neg();z=m}for(V=this;V.gte(T);){D=Math.max(1,Math.floor(V.toNumber()/T.toNumber()));for(var Z=Math.ceil(Math.log(D)/Math.LN2),le=Z<=48?1:a(2,Z-48),ie=n(D),Re=ie.mul(T);Re.isNegative()||Re.gt(V);)D-=le,ie=n(D,this.unsigned),Re=ie.mul(T);ie.isZero()&&(ie=y),z=z.add(ie),V=V.sub(Re)}return z},M.div=M.divide,M.modulo=function(T){return e(T)||(T=l(T)),this.sub(this.div(T).mul(T))},M.mod=M.modulo,M.not=function(){return o(~this.low,~this.high,this.unsigned)},M.and=function(T){return e(T)||(T=l(T)),o(this.low&T.low,this.high&T.high,this.unsigned)},M.or=function(T){return e(T)||(T=l(T)),o(this.low|T.low,this.high|T.high,this.unsigned)},M.xor=function(T){return e(T)||(T=l(T)),o(this.low^T.low,this.high^T.high,this.unsigned)},M.shiftLeft=function(T){return e(T)&&(T=T.toInt()),(T&=63)===0?this:T<32?o(this.low<>>32-T,this.unsigned):o(0,this.low<>>T|this.high<<32-T,this.high>>T,this.unsigned):o(this.high>>T-32,this.high>=0?0:-1,this.unsigned)},M.shr=M.shiftRight,M.shiftRightUnsigned=function(T){if(e(T)&&(T=T.toInt()),T&=63,T===0)return this;var D=this.high;if(T<32){var V=this.low;return o(V>>>T|D<<32-T,D>>>T,this.unsigned)}else return T===32?o(D,0,this.unsigned):o(D>>>T-32,0,this.unsigned)},M.shru=M.shiftRightUnsigned,M.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},M.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},M.toBytes=function(v){return v?this.toBytesLE():this.toBytesBE()},M.toBytesLE=function(){var v=this.high,T=this.low;return[T&255,T>>>8&255,T>>>16&255,T>>>24&255,v&255,v>>>8&255,v>>>16&255,v>>>24&255]},M.toBytesBE=function(){var v=this.high,T=this.low;return[v>>>24&255,v>>>16&255,v>>>8&255,v&255,T>>>24&255,T>>>16&255,T>>>8&255,T&255]},t})});var ff=ct((jwe,yI)=>{yI.exports=globalThis.h3||{}});var VB=ct(Rb=>{Rb.read=function(t,e,r,s,i){var n,o,a=i*8-s-1,c=(1<>1,u=-7,f=r?i-1:0,h=r?-1:1,d=t[e+f];for(f+=h,n=d&(1<<-u)-1,d>>=-u,u+=a;u>0;n=n*256+t[e+f],f+=h,u-=8);for(o=n&(1<<-u)-1,n>>=-u,u+=s;u>0;o=o*256+t[e+f],f+=h,u-=8);if(n===0)n=1-l;else{if(n===c)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,s),n=n-l}return(d?-1:1)*o*Math.pow(2,n-s)};Rb.write=function(t,e,r,s,i,n){var o,a,c,l=n*8-i-1,u=(1<>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=s?0:n-1,p=s?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?e+=h/c:e+=h*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=a&255,d+=p,a/=256,i-=8);for(o=o<0;t[r+d]=o&255,d+=p,o/=256,l-=8);t[r+d-p]|=g*128}});var XB=ct((bNe,jB)=>{"use strict";jB.exports=ye;var Im=VB();function ye(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}ye.Varint=0;ye.Fixed64=1;ye.Bytes=2;ye.Fixed32=5;var Ib=(1<<16)*(1<<16),zB=1/Ib,b$=12,WB=typeof TextDecoder>"u"?null:new TextDecoder("utf8");ye.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,n=this.pos;this.type=s&7,t(i,e,this),this.pos===n&&this.skip(s)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Bm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=GB(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Bm(this.buf,this.pos)+Bm(this.buf,this.pos+4)*Ib;return this.pos+=8,t},readSFixed64:function(){var t=Bm(this.buf,this.pos)+GB(this.buf,this.pos+4)*Ib;return this.pos+=8,t},readFloat:function(){var t=Im.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Im.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,s;return s=e[this.pos++],r=s&127,s<128||(s=e[this.pos++],r|=(s&127)<<7,s<128)||(s=e[this.pos++],r|=(s&127)<<14,s<128)||(s=e[this.pos++],r|=(s&127)<<21,s<128)?r:(s=e[this.pos],r|=(s&15)<<28,E$(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=b$&&WB?D$(this.buf,e,t):N$(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==ye.Bytes)return t.push(this.readVarint(e));var r=si(this);for(t=t||[];this.pos127;);else if(e===ye.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ye.Fixed32)this.pos+=4;else if(e===ye.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0){S$(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=U$(this.buf,t,this.pos);var r=this.pos-e;r>=128&&HB(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Im.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Im.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&HB(r,s,this),this.pos=r-1,this.writeVarint(s),this.pos+=s},writeMessage:function(t,e,r){this.writeTag(t,ye.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,w$,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,P$,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,I$,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,M$,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,R$,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,B$,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,O$,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,F$,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,L$,e)},writeBytesField:function(t,e){this.writeTag(t,ye.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,ye.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,ye.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,ye.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,ye.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,ye.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,ye.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,ye.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,ye.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,ye.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};function E$(t,e,r){var s=r.buf,i,n;if(n=s[r.pos++],i=(n&112)>>4,n<128||(n=s[r.pos++],i|=(n&127)<<3,n<128)||(n=s[r.pos++],i|=(n&127)<<10,n<128)||(n=s[r.pos++],i|=(n&127)<<17,n<128)||(n=s[r.pos++],i|=(n&127)<<24,n<128)||(n=s[r.pos++],i|=(n&1)<<31,n<128))return Xa(t,i,e);throw new Error("Expected varint not more than 10 bytes")}function si(t){return t.type===ye.Bytes?t.readVarint()+t.pos:t.pos+1}function Xa(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function S$(t,e){var r,s;if(t>=0?(r=t%4294967296|0,s=t/4294967296|0):(r=~(-t%4294967296),s=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,s=s+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),v$(r,s,e),C$(s,e)}function v$(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function C$(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function HB(t,e,r){var s=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));r.realloc(s);for(var i=r.pos-1;i>=t;i--)r.buf[i+s]=r.buf[i]}function w$(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function GB(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function N$(t,e,r){for(var s="",i=e;i239?4:n>223?3:n>191?2:1;if(i+a>r)break;var c,l,u;a===1?n<128&&(o=n):a===2?(c=t[i+1],(c&192)===128&&(o=(n&31)<<6|c&63,o<=127&&(o=null))):a===3?(c=t[i+1],l=t[i+2],(c&192)===128&&(l&192)===128&&(o=(n&15)<<12|(c&63)<<6|l&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(c=t[i+1],l=t[i+2],u=t[i+3],(c&192)===128&&(l&192)===128&&(u&192)===128&&(o=(n&15)<<18|(c&63)<<12|(l&63)<<6|u&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,s+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),s+=String.fromCharCode(o),i+=a}return s}function D$(t,e,r){return WB.decode(t.subarray(e,r))}function U$(t,e,r){for(var s=0,i,n;s55295&&i<57344)if(n)if(i<56320){t[r++]=239,t[r++]=191,t[r++]=189,n=i;continue}else i=n-55296<<10|i-56320|65536,n=null;else{i>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):n=i;continue}else n&&(t[r++]=239,t[r++]=191,t[r++]=189,n=null);i<128?t[r++]=i:(i<2048?t[r++]=i>>6|192:(i<65536?t[r++]=i>>12|224:(t[r++]=i>>18|240,t[r++]=i>>12&63|128),t[r++]=i>>6&63|128),t[r++]=i&63|128)}return r}});var nQ={};Ke(nQ,{AGGREGATION_OPERATION:()=>Me,AmbientLight:()=>$o,ArcLayer:()=>Up,Attribute:()=>Ws,AttributeManager:()=>Xr,BitmapLayer:()=>kp,BrushingExtension:()=>cB,COORDINATE_SYSTEM:()=>X,CPUGridLayer:()=>rh,ClipExtension:()=>Em,CollisionFilterExtension:()=>RB,ColumnLayer:()=>ki,CompassWidget:()=>o_,CompositeLayer:()=>Le,ContourLayer:()=>PF,Controller:()=>Ft,DarkGlassTheme:()=>iQ,DarkTheme:()=>rQ,DataFilterExtension:()=>AB,Deck:()=>jr,DeckGL:()=>Jf,DeckRenderer:()=>Bn,DirectionalLight:()=>Ns,FillStyleExtension:()=>wB,FirstPersonController:()=>Hn,FirstPersonView:()=>TP,FirstPersonViewport:()=>Vn,FlyToInterpolator:()=>Xs,Fp64Extension:()=>bB,FullscreenWidget:()=>n_,GPUGridLayer:()=>ch,GeoJsonLayer:()=>$n,GeohashLayer:()=>hO,GoogleMapsOverlay:()=>fh,GreatCircleLayer:()=>kR,GridCellLayer:()=>Kp,GridLayer:()=>OF,H3ClusterLayer:()=>bI,H3HexagonLayer:()=>va,HeatmapLayer:()=>jF,HexagonLayer:()=>ZO,IconLayer:()=>pa,Layer:()=>he,LayerExtension:()=>tt,LayerManager:()=>Mn,LightGlassTheme:()=>sQ,LightTheme:()=>tQ,LightingEffect:()=>wi,LineLayer:()=>Vp,LinearInterpolator:()=>yt,MVTLayer:()=>cO,MapController:()=>In,MapView:()=>Ri,MapboxOverlay:()=>ph,MaskExtension:()=>BB,OPERATION:()=>Jv,OrbitController:()=>Gn,OrbitView:()=>bP,OrbitViewport:()=>kn,OrthographicController:()=>Wn,OrthographicView:()=>EP,OrthographicViewport:()=>js,PathLayer:()=>Vi,PathStyleExtension:()=>vB,PointCloudLayer:()=>zp,PointLight:()=>ea,PolygonLayer:()=>Gi,PostProcessEffect:()=>vl,QuadkeyLayer:()=>QR,S2Layer:()=>JR,ScatterplotLayer:()=>Hp,ScenegraphLayer:()=>jg,ScreenGridLayer:()=>jO,SimpleMeshLayer:()=>so,SolidPolygonLayer:()=>Hi,TRANSITION_EVENTS:()=>Ml,TerrainLayer:()=>oB,Tesselator:()=>Ys,TextLayer:()=>lg,Tile3DLayer:()=>Q3,TileLayer:()=>ro,TransitionInterpolator:()=>zs,TripsLayer:()=>_I,UNIT:()=>Fe,VERSION:()=>Gh,View:()=>Ot,Viewport:()=>Ht,WebMercatorViewport:()=>Et,ZoomWidget:()=>a_,_AggregationLayer:()=>Cs,_BinSorter:()=>ii,_CPUAggregator:()=>ni,_CameraLight:()=>_l,_Component:()=>Mp,_ComponentState:()=>Un,_GPUGridAggregator:()=>ot,_GeoCellLayer:()=>As,_GlobeController:()=>jn,_GlobeView:()=>SP,_GlobeViewport:()=>Yr,_LayersPass:()=>_t,_MultiIconLayer:()=>og,_PickLayersPass:()=>Ur,_SunLight:()=>yl,_TerrainExtension:()=>NB,_TextBackgroundLayer:()=>cg,_Tile2DHeader:()=>eo,_Tileset2D:()=>to,_WMSLayer:()=>Ea,_compareProps:()=>ha,_count:()=>wp,_deepEqual:()=>ve,_fillArray:()=>Xd,_flatten:()=>Bt,_getURLFromTemplate:()=>bs,_memoize:()=>zt,_mergeShaders:()=>ys,_registerLoggers:()=>Hh,assert:()=>Ae,createIterable:()=>ze,fp64LowPart:()=>Dr,getShaderAssembler:()=>Ko,gouraudLighting:()=>pr,log:()=>k,phongLighting:()=>vi,picking:()=>_e,project:()=>Qe,project32:()=>de,project64:()=>Tm,shadow:()=>qo});async function Kt(t,e,r,s){return s._parse(t,e,r,s)}function ne(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var is={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},JL=is.self||is.window||is.global||{},ZL=is.window||is.self||is.global||{},QL=is.global||is.self||is.window||{},eN=is.document||{};var Rs=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var VE=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),tN=VE&&parseFloat(VE[1])||0;var wh=globalThis,rN=globalThis.document||{},Ph=globalThis.process||{},sN=globalThis.console,zE=globalThis.navigator||{};function Mh(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}function At(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Mh()}function x_(t){return!t&&!At()?"Node":Mh(t)?"Electron":(t||zE.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var A_="4.0.7";function nN(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Rh=class{constructor(e,r,s="sessionStorage"){this.storage=nN(s),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function HE(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function GE(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Ih;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ih||(Ih={}));var oN=10;function WE(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ih[t]||Ih.WHITE)}function jE(t,e,r){return!At&&typeof t=="string"&&(e&&(t=`\x1B[${WE(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${WE(r)+oN}m${t}\x1B[49m`)),t}function XE(t,e=["constructor"]){let r=Object.getPrototypeOf(t),s=Object.getOwnPropertyNames(r),i=t;for(let n of s){let o=i[n];typeof o=="function"&&(e.find(a=>n===a)||(i[n]=o.bind(t)))}}function bc(t,e){if(!t)throw new Error(e||"Assertion failed")}function on(){let t;if(At()&&wh.performance)t=wh?.performance?.now?.();else if("hrtime"in Ph){let e=Ph?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var To={debug:At()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},aN={enabled:!0,level:0};function bo(){}var YE={},qE={once:!0},kt=class{constructor({id:e}={id:""}){this.VERSION=A_,this._startTs=on(),this._deltaTs=on(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Rh(`__probe-${this.id}__`,aN),this.timeStamp(`${this.id} started`),XE(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((on()-this._startTs).toPrecision(10))}getDelta(){return Number((on()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e){return this._getLogFunction(0,e,To.warn,arguments,qE)}error(e){return this._getLogFunction(0,e,To.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,To.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,To.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,To.debug||To.info,arguments,qE)}table(e,r,s){return r?this._getLogFunction(e,r,console.table||bo,s&&[s],{tag:lN(r)}):bo}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||bo)}group(e,r,s={collapsed:!1}){let i=KE({logLevel:e,message:r,opts:s}),{collapsed:n}=s;return i.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,r,s={}){return this.group(e,r,Object.assign({},s,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||bo)}withGroup(e,r,s){this.group(e,r)();try{s()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=$E(e)}_getLogFunction(e,r,s,i,n){if(this._shouldLog(e)){n=KE({logLevel:e,message:r,args:i,opts:n}),s=s||n.method,bc(s),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=on();let o=n.tag||n.message;if(n.once&&o)if(!YE[o])YE[o]=on();else return bo;return r=cN(this.id,n.message,n),s.bind(console,r,...n.args)}return bo}};kt.VERSION=A_;function $E(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return bc(Number.isFinite(e)&&e>=0),e}function KE(t){let{logLevel:e,message:r}=t;t.logLevel=$E(e);let s=t.args?Array.from(t.args):[];for(;s.length&&s.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&s.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let i=typeof t.message;return bc(i==="string"||i==="object"),Object.assign(t,{args:s},t.opts)}function cN(t,e,r){if(typeof e=="string"){let s=r.time?GE(HE(r.total)):"";e=r.time?`${t}: ${s} ${e}`:`${t}: ${e}`,e=jE(e,r.color,r.background)}return e}function lN(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var T_=new kt({id:"@probe.gl/log"});function Ec(t,e){return JE(t||{},e)}function JE(t,e,r=0){if(r>3)return e;let s={...t};for(let[i,n]of Object.entries(e))n&&typeof n=="object"&&!Array.isArray(n)?s[i]=JE(s[i]||{},e[i],r+1):s[i]=e[i];return s}function b_(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function E_(t){return globalThis.loaders?.modules?.[t]||null}var ZE="latest";function uN(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.0-beta.2"),globalThis._loadersgl_.version}var Sc=uN();function gt(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var ns={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},YQ=ns.self||ns.window||ns.global||{},qQ=ns.window||ns.self||ns.global||{},KQ=ns.global||ns.self||ns.window||{},$Q=ns.document||{};var lt=typeof process!="object"||String(process)!=="[object process]"||process.browser,vc=typeof importScripts=="function",e1=typeof window<"u"&&typeof window.orientation<"u",QE=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),JQ=QE&&parseFloat(QE[1])||0;var Cc=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((s,i)=>{this._resolve=s,this._reject=i})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){gt(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){gt(this.isRunning),this.isRunning=!1,this._reject(e)}};var Eo=class{terminate(){}};var S_=new Map;function t1(t){gt(t.source&&!t.url||!t.source&&t.url);let e=S_.get(t.source||t.url);return e||(t.url&&(e=fN(t.url),S_.set(t.url,e)),t.source&&(e=r1(t.source),S_.set(t.source,e))),gt(e),e}function fN(t){if(!t.startsWith("http"))return t;let e=hN(t);return r1(e)}function r1(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function hN(t){return`try { importScripts('${t}'); } catch (error) { console.error(error); throw error; }`}function v_(t,e=!0,r){let s=r||new Set;if(t){if(s1(t))s.add(t);else if(s1(t.buffer))s.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let i in t)v_(t[i],e,s)}}return r===void 0?Array.from(s):[]}function s1(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var C_=()=>{},ai=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&<||typeof Eo<"u"&&!lt}constructor(e){let{name:r,source:s,url:i}=e;gt(s||i),this.name=r,this.source=s,this.url=i,this.onMessage=C_,this.onError=n=>console.log(n),this.worker=lt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=C_,this.onError=C_,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||v_(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=t1({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let s=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new Eo(s,{eval:!1})}else if(this.source)e=new Eo(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var wc=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return ai.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(i,n,o)=>i.done(o),s=(i,n)=>i.error(n)){let i=new Promise(n=>(this.jobQueue.push({name:e,onMessage:r,onError:s,onStart:n}),this));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let s=new Cc(r.name,e);e.onMessage=i=>r.onMessage(s,i.type,i.payload),e.onError=i=>r.onError(s,i),r.onStart(s);try{await s.result}catch(i){console.error(`Worker exception: ${i}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!lt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},an=class{props;workerPools=new Map;static isSupported(){return ai.isSupported()}static getWorkerFarm(e={}){return an._workerFarm=an._workerFarm||new an({}),an._workerFarm.setProps(e),an._workerFarm}constructor(e){this.props={...dN},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:s,url:i}=e,n=this.workerPools.get(r);return n||(n=new wc({name:r,source:s,url:i}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},ci=an;Y(ci,"_workerFarm");function w_(t,e={}){let r=e[t.id]||{},s=lt?`${t.id}-worker.js`:`${t.id}-worker-node.js`,i=r.workerUrl;if(!i&&t.id==="compression"&&(i=e.workerUrl),e._workerType==="test"&&(lt?i=`modules/${t.module}/dist/${s}`:i=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!i){let n=t.version;n==="latest"&&(n=ZE);let o=n?`@${n}`:"";i=`https://unpkg.com/@loaders.gl/${t.module}${o}/dist/${s}`}return gt(i),i}function P_(t,e=Sc){gt(t,"no worker provided");let r=t.version;return!(!e||!r)}var M_={};async function os(t,e=null,r={},s=null){return e&&(t=i1(t,e,r,s)),M_[t]=M_[t]||pN(t),await M_[t]}function i1(t,e,r={},s=null){if(!r.useLocalLibraries&&t.startsWith("http"))return t;s=s||t;let i=r.modules||{};return i[s]?i[s]:lt?r.CDN?(gt(r.CDN.startsWith("http")),`${r.CDN}/${e}@${Sc}/dist/libs/${s}`):vc?`../src/libs/${s}`:`modules/${e}/src/libs/${s}`:`modules/${e}/dist/libs/${s}`}async function pN(t){if(t.endsWith("wasm"))return await mN(t);if(!lt)try{let{requireFromFile:r}=globalThis.loaders||{};return await r?.(t)}catch(r){return console.error(r),null}if(vc)return importScripts(t);let e=await _N(t);return gN(e,t)}function gN(t,e){if(!lt){let{requireFromString:s}=globalThis.loaders||{};return s?.(t,e)}if(vc)return eval.call(globalThis,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function mN(t){let{readFileAsArrayBuffer:e}=globalThis.loaders||{};return lt||!e||t.startsWith("http")?await(await fetch(t)).arrayBuffer():await e(t)}async function _N(t){let{readFileAsText:e}=globalThis.loaders||{};return lt||!e||t.startsWith("http")?await(await fetch(t)).text():await e(t)}function R_(t,e){return!ci.isSupported()||!lt&&!e?._nodeWorkers?!1:t.worker&&e?.worker}async function I_(t,e,r,s,i){let n=t.id,o=w_(t,r),c=ci.getWorkerFarm(r).getWorkerPool({name:n,url:o});r=JSON.parse(JSON.stringify(r)),s=JSON.parse(JSON.stringify(s||{}));let l=await c.startJob("process-on-worker",yN.bind(null,i));return l.postMessage("process",{input:e,options:r,context:s}),await(await l.result).result}async function yN(t,e,r,s){switch(r){case"done":e.done(s);break;case"error":e.error(new Error(s.error));break;case"process":let{id:i,input:n,options:o}=s;try{let a=await t(n,o);e.postMessage("done",{id:i,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:i,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function o1(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?n1(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?n1(t,0,e):""}function n1(t,e,r){if(t.byteLength<=e+r)return"";let s=new DataView(t),i="";for(let n=0;nn instanceof ArrayBuffer?new Uint8Array(n):n),r=e.reduce((n,o)=>n+o.byteLength,0),s=new Uint8Array(r),i=0;for(let n of e)s.set(n,i),i+=n.byteLength;return s.buffer}function Pc(...t){let e=t,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let s=e.reduce((o,a)=>o+a.length,0),i=new r(s),n=0;for(let o of e)i.set(o,n),n+=o.length;return i}function cn(t,e,r){let s=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(s).buffer}function li(t,e){return ne(t>=0),ne(e>0),t+(e-1)&~(e-1)}function L_(t,e,r){let s;if(t instanceof ArrayBuffer)s=new Uint8Array(t);else{let i=t.byteOffset,n=t.byteLength;s=new Uint8Array(t.buffer||t.arrayBuffer,i,n)}return e.set(s,r),r+li(s.byteLength,4)}async function N_(t){let e=[];for await(let r of t)e.push(r);return F_(...e)}function Mc(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ln=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Mc(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Mc()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Tt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:s}=e,i=this.stats[r];return i||(e instanceof ln?i=e:i=new ln(r,s),this.stats[r]=i),i}};var xN="Queued Requests",AN="Active Requests",TN="Cancelled Requests",bN="Queued Requests Ever",EN="Active Requests Ever",SN={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},ui=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...SN,...e},this.stats=new Tt({id:this.props.id}),this.stats.get(xN),this.stats.get(AN),this.stats.get(TN),this.stats.get(bN),this.stats.get(EN)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let s={handle:e,priority:0,getPriority:r},i=new Promise(n=>(s.resolve=n,s));return this.requestQueue.push(s),this.requestMap.set(e,i),this._issueNewRequests(),i}_issueRequest(e){let{handle:r,resolve:s}=e,i=!1,n=()=>{i||(i=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,s?s({done:n}):Promise.resolve({done:n})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;rr.priority-s.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var vN="",c1={};function D_(t){for(let e in c1)if(t.startsWith(e)){let r=c1[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${vN}${t}`),t}function l1(t){return t&&typeof t=="object"&&t.isBuffer}function Bh(t){if(l1(t))return t;if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}var $t={};Ke($t,{dirname:()=>wN,filename:()=>CN,join:()=>PN,resolve:()=>MN});function u1(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function CN(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):""}function wN(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function PN(...t){let e="/";return t=t.map((r,s)=>(s&&(r=r.replace(new RegExp(`^${e}`),"")),s!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function MN(...t){let e=[];for(let n=0;n=-1&&!s;n--){let o;n>=0?o=e[n]:(i===void 0&&(i=u1()),o=i),o.length!==0&&(r=`${o}/${r}`,s=o.charCodeAt(0)===Rc)}return r=RN(r,!s),s?`/${r}`:r.length>0?r:"."}var Rc=47,U_=46;function RN(t,e){let r="",s=-1,i=0,n,o=!1;for(let a=0;a<=t.length;++a){if(a2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Rc;--l);if(l!==c){r=l===-1?"":r.slice(0,l),s=a,i=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",s=a,i=0,o=!1;continue}}e&&(r.length>0?r+="/..":r="..",o=!0)}else{let c=t.slice(s+1,a);r.length>0?r+=`/${c}`:r=c,o=!1}s=a,i=0}else n===U_&&i!==-1?++i:i=-1}return r}var Oh=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(e){this.props={...e},this.loadOptions={...e.loadOptions},this.fetch=IN(this.loadOptions)}setProps(e){this.props=Object.assign(this.props,e),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(e=!0){let r=this._needsRefresh;return e&&(this._needsRefresh=!1),r}};function IN(t){let e=t?.fetch;if(e&&typeof e=="function")return(s,i)=>e(s,i);let r=t?.fetch;return r&&typeof r!="function"?s=>fetch(s,r):s=>fetch(s)}var or=class extends Oh{};Y(or,"type","template"),Y(or,"testURL",e=>!1);var BN=t=>typeof t=="boolean",Ic=t=>typeof t=="function",un=t=>t!==null&&typeof t=="object",k_=t=>un(t)&&t.constructor==={}.constructor;var f1=t=>Boolean(t)&&typeof t[Symbol.iterator]=="function",h1=t=>t&&typeof t[Symbol.asyncIterator]=="function";var ar=t=>typeof Response<"u"&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json;var cr=t=>typeof Blob<"u"&&t instanceof Blob,d1=t=>t&&typeof t=="object"&&t.isBuffer;var ON=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||un(t)&&Ic(t.tee)&&Ic(t.cancel)&&Ic(t.getReader);var FN=t=>un(t)&&Ic(t.read)&&Ic(t.pipe)&&BN(t.readable),Fh=t=>ON(t)||FN(t);var Lh=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var LN=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,NN=/^([-\w.]+\/[-\w.+]+)/;function V_(t,e){return t.toLowerCase()===e.toLowerCase()}function p1(t){let e=NN.exec(t);return e?e[1]:t}function z_(t){let e=LN.exec(t);return e?e[1]:""}var g1=/\?.*/;function m1(t){let e=t.match(g1);return e&&e[0]}function So(t){return t.replace(g1,"")}function _1(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function fn(t){return ar(t)?t.url:cr(t)?t.name||"":typeof t=="string"?t:""}function Bc(t){if(ar(t)){let e=t,r=e.headers.get("content-type")||"",s=So(e.url);return p1(r)||z_(s)}return cr(t)?t.type||"":typeof t=="string"?z_(t):""}function y1(t){return ar(t)?t.headers["content-length"]||-1:cr(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Nh(t){if(ar(t))return t;let e={},r=y1(t);r>=0&&(e["content-length"]=String(r));let s=fn(t),i=Bc(t);i&&(e["content-type"]=i);let n=await UN(t);n&&(e["x-first-bytes"]=n),typeof t=="string"&&(t=new TextEncoder().encode(t));let o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:s}),o}async function x1(t){if(!t.ok)throw await DN(t)}async function DN(t){let e=_1(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let s={reason:t.statusText,url:t.url,response:t};try{let i=t.headers.get("Content-Type");s.reason=i?.includes("application/json")?await t.json():t.text()}catch{}return new Lh(r,s)}async function UN(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(s=>{let i=new FileReader;i.onload=n=>s(n?.target?.result),i.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${kN(r)}`}return null}function kN(t){let e="",r=new Uint8Array(t);for(let s=0;s{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Uh=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var G_={fetch:null,mimeType:void 0,nothrow:!1,log:new Uh,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Rs,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},A1={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function W_(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function j_(){let t=W_();return t.globalOptions=t.globalOptions||{...G_},t.globalOptions}function E1(t,e,r,s){return r=r||[],r=Array.isArray(r)?r:[r],GN(t,r),jN(e,t,s)}function GN(t,e){T1(t,null,G_,A1,e);for(let r of e){let s=t&&t[r.id]||{},i=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};T1(s,r.id,i,n,e)}}function T1(t,e,r,s,i){let n=e||"Top level",o=e?`${e}.`:"";for(let a in t){let c=!e&&un(t[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in r)&&!l&&!u){if(a in s)H_.warn(`${n} loader option '${o}${a}' no longer supported, use '${s[a]}'`)();else if(!c){let f=WN(a,i);H_.warn(`${n} loader option '${o}${a}' not recognized. ${f}`)()}}}}function WN(t,e){let r=t.toLowerCase(),s="";for(let i of e)for(let n in i.options){if(t===n)return`Did you mean '${i.id}.${n}'?`;let o=n.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(s=s||`Did you mean '${i.id}.${n}'?`)}return s}function jN(t,e,r){let i={...t.options||{}};return XN(i,r),i.log===null&&(i.log=new Dh),b1(i,j_()),b1(i,e),i}function b1(t,e){for(let r in e)if(r in e){let s=e[r];k_(s)&&k_(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function XN(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}function Oc(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function Fc(t){ne(t,"null loader"),ne(Oc(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var S1=()=>{let t=W_();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function Lc(t){let e=S1();t=Array.isArray(t)?t:[t];for(let r of t){let s=Fc(r);e.find(i=>s===i)||e.unshift(s)}}function v1(){return S1()}var C1=new kt({id:"loaders.gl"});var YN=/\.([^.]+)$/;async function M1(t,e=[],r,s){if(!R1(t))return null;let i=w1(t,e,{...r,nothrow:!0},s);if(i)return i;if(cr(t)&&(t=await t.slice(0,10).arrayBuffer(),i=w1(t,e,r,s)),!i&&!r?.nothrow)throw new Error(I1(t));return i}function w1(t,e=[],r,s){if(!R1(t))return null;if(e&&!Array.isArray(e))return Fc(e);let i=[];e&&(i=i.concat(e)),r?.ignoreRegisteredLoaders||i.push(...v1()),KN(i);let n=qN(t,i,r,s);if(!n&&!r?.nothrow)throw new Error(I1(t));return n}function qN(t,e,r,s){let i=fn(t),n=Bc(t),o=So(i)||s?.url,a=null,c="";return r?.mimeType&&(a=X_(e,r?.mimeType),c=`match forced by supplied MIME type ${r?.mimeType}`),a=a||$N(e,o),c=c||(a?`matched url ${o}`:""),a=a||X_(e,n),c=c||(a?`matched MIME type ${n}`:""),a=a||ZN(e,t),c=c||(a?`matched initial data ${B1(t)}`:""),r?.fallbackMimeType&&(a=a||X_(e,r?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&C1.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function R1(t){return!(t instanceof Response&&t.status===204)}function I1(t){let e=fn(t),r=Bc(t),s="No valid loader found (";s+=e?`${$t.filename(e)}, `:"no url provided, ",s+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let i=t?B1(t):"";return s+=i?` first bytes: "${i}"`:"first bytes: not available",s+=")",s}function KN(t){for(let e of t)Fc(e)}function $N(t,e){let r=e&&YN.exec(e),s=r&&r[1];return s?JN(t,s):null}function JN(t,e){e=e.toLowerCase();for(let r of t)for(let s of r.extensions)if(s.toLowerCase()===e)return r;return null}function X_(t,e){for(let r of t)if(r.mimeTypes?.some(s=>V_(e,s))||V_(e,`application/x.${r.id}`))return r;return null}function ZN(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(QN(e,r))return r}else if(ArrayBuffer.isView(e)){if(P1(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&P1(e,0,r))return r;return null}function QN(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(s=>t.startsWith(s))}function P1(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(i=>eD(t,e,r,i))}function eD(t,e,r,s){if(s instanceof ArrayBuffer)return O_(s,t,s.byteLength);switch(typeof s){case"function":return s(t);case"string":let i=Y_(t,e,s.length);return s===i;default:return!1}}function B1(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Y_(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Y_(t,0,e):""}function Y_(t,e,r){if(t.byteLengthvo(i,s.fetch):e?.fetch?e?.fetch:vo}function k1(t,e,r){if(r)return r;let s={fetch:kh(e,t),...t};if(s.url){let i=So(s.url);s.baseUrl=i,s.queryString=m1(s.url),s.filename=$t.filename(i),s.baseUrl=$t.dirname(i)}return Array.isArray(s.loaders)||(s.loaders=null),s}function V1(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let s=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...s]:s}return r&&r.length?r:void 0}async function fi(t,e,r,s){e&&!Array.isArray(e)&&!Oc(e)&&(s=void 0,r=e,e=void 0),t=await t,r=r||{};let i=fn(t),o=V1(e,s),a=await M1(t,o,r);return a?(r=E1(r,a,o,i),s=k1({url:i,_parse:fi,loaders:o},r,s||null),await iD(a,t,r,s)):null}async function iD(t,e,r,s){if(P_(t),r=Ec(t.options,r),ar(e)){let n=e,{ok:o,redirected:a,status:c,statusText:l,type:u,url:f}=n,h=Object.fromEntries(n.headers.entries());s.response={headers:h,ok:o,redirected:a,status:c,statusText:l,type:u,url:f}}e=await U1(e,t,r);let i=t;if(i.parseTextSync&&typeof e=="string")return i.parseTextSync(e,r,s);if(R_(t,r))return await I_(t,e,r,s,fi);if(i.parseText&&typeof e=="string")return await i.parseText(e,r,s);if(i.parse)return await i.parse(e,r,s);throw gt(!i.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}function z1(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function Is(t){let e=1/0,r=1/0,s=1/0,i=-1/0,n=-1/0,o=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;li?u:i,n=f>n?f:n,o=h>o?h:o}return[[e,r,s],[i,n,o]]}function K_(t,e,r){let s=z1(e.value),i=r||H1(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:s}]},nullable:!1,metadata:i}}function H1(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}async function $e(t,e,r,s){let i,n;!Array.isArray(e)&&!Oc(e)?(i=[],n=e,s=void 0):(i=e,n=r);let o=kh(n),a=t;return typeof t=="string"&&(a=await o(t)),cr(t)&&(a=await o(t)),Array.isArray(i)?await fi(a,i,n):await fi(a,i,n)}var G1="4.2.0-beta.2";var nD=globalThis.loaders?.parseImageNode,$_=typeof Image<"u",J_=typeof ImageBitmap<"u",oD=Boolean(nD),Z_=Rs?!0:oD;function W1(t){switch(t){case"auto":return J_||$_||Z_;case"imagebitmap":return J_;case"image":return $_;case"data":return Z_;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function j1(){if(J_)return"imagebitmap";if($_)return"image";if(Z_)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function X1(t){let e=aD(t);if(!e)throw new Error("Not an image");return e}function Nc(t){switch(X1(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function aD(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var cD=/^data:image\/svg\+xml/,lD=/\.svg((\?|#).*)?$/;function Vh(t){return t&&(cD.test(t)||lD.test(t))}function Y1(t,e){if(Vh(e)){let s=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(s=unescape(encodeURIComponent(s)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(s)}`}return Q_(t,e)}function Q_(t,e){if(Vh(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function zh(t,e,r){let s=Y1(t,r),i=self.URL||self.webkitURL,n=typeof s!="string"&&i.createObjectURL(s);try{return await uD(n||s,e)}finally{n&&i.revokeObjectURL(n)}}async function uD(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((s,i)=>{try{r.onload=()=>s(r),r.onerror=n=>{let o=n instanceof Error?n.message:"error";i(new Error(o))}}catch(n){i(n)}})}var fD={},q1=!0;async function K1(t,e,r){let s;Vh(r)?s=await zh(t,e,r):s=Q_(t,r);let i=e&&e.imagebitmap;return await hD(s,i)}async function hD(t,e=null){if((dD(e)||!q1)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),q1=!1}return await createImageBitmap(t)}function dD(t){for(let e in t||fD)return!1;return!0}function $1(t){return!_D(t,"ftyp",4)||!(t[8]&96)?null:pD(t)}function pD(t){switch(gD(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function gD(t,e,r){return String.fromCharCode(...t.slice(e,r))}function mD(t){return[...t].map(e=>e.charCodeAt(0))}function _D(t,e,r=0){let s=mD(e);for(let i=0;i=24&&e.getUint32(0,as)===2303741511?{mimeType:"image/png",width:e.getUint32(16,as),height:e.getUint32(20,as)}:null}function AD(t){let e=Uc(t);return e.byteLength>=10&&e.getUint32(0,as)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Dc),height:e.getUint16(8,Dc)}:null}function TD(t){let e=Uc(t);return e.byteLength>=14&&e.getUint16(0,as)===16973&&e.getUint32(2,Dc)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Dc),height:e.getUint32(22,Dc)}:null}function bD(t){let e=Uc(t);if(!(e.byteLength>=3&&e.getUint16(0,as)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:s,sofMarkers:i}=ED(),n=2;for(;n+9Boolean(hn(new DataView(t)))],options:wD};var e0={};function t0(t){if(e0[t]===void 0){let e=Rs?MD(t):PD(t);e0[t]=e}return e0[t]}function PD(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,s=globalThis.loaders?.parseImageNode;return Boolean(s)&&r.includes(t)}function MD(t){switch(t){case"image/avif":case"image/webp":return RD(t);default:return!0}}function RD(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var ID=new kt({id:"deck"}),k=ID;var r0={};function Hh(t){r0=t}function Ue(t,e,r,s){k.level>0&&r0[t]&&r0[t].call(null,e,r,s)}function BD(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var Q1={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:BD,parseTextSync:JSON.parse};function OD(){let t="9.0.33",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(k.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:k,_registerLoggers:Hh},Lc([Q1,[cs,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var Gh=OD();function ls(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var s0={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function tS(t){let e={};for(let[r,s]of Object.entries(t))e[r]=FD(s);return e}function rS(t,e,r){let s={};for(let[i,n]of Object.entries(e))t&&i in t&&!n.private?(n.validate&&ls(n.validate(t[i],n),`${r}: invalid ${i}`),s[i]=t[i]):s[i]=n.value;return s}function FD(t){let e=eS(t);if(e!=="object")return{value:t,...s0[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...s0[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=eS(t.value),{...t,...s0[e],type:e}):{type:"object",value:null};throw new Error("props")}function eS(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var sS=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif `,iS=`#ifdef MODULE_MATERIAL gl_FragColor = material_filterColor(gl_FragColor); #endif #ifdef MODULE_LIGHTING gl_FragColor = lighting_filterColor(gl_FragColor); #endif #ifdef MODULE_FOG gl_FragColor = fog_filterColor(gl_FragColor); #endif #ifdef MODULE_PICKING gl_FragColor = picking_filterHighlightColor(gl_FragColor); gl_FragColor = picking_filterPickingColor(gl_FragColor); #endif #ifdef MODULE_LOGDEPTH logdepth_setFragDepth(); #endif `;var LD={vertex:sS,fragment:iS},nS=/void\s+main\s*\([^)]*\)\s*\{\n?/,oS=/}\n?[^{}]*$/,i0=[],kc="__LUMA_INJECT_DECLARATIONS__";function aS(t){let e={vertex:{},fragment:{}};for(let r in t){let s=t[r],i=ND(r);typeof s=="string"&&(s={order:0,injection:s}),e[i][r]=s}return e}function ND(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function Vc(t,e,r,s=!1){let i=e==="vertex";for(let n in r){let o=r[n];o.sort((c,l)=>c.order-l.order),i0.length=o.length;for(let c=0,l=o.length;cc+a));break;case"vs:#main-end":i&&(t=t.replace(oS,c=>a+c));break;case"fs:#decl":i||(t=t.replace(kc,a));break;case"fs:#main-start":i||(t=t.replace(nS,c=>c+a));break;case"fs:#main-end":i||(t=t.replace(oS,c=>a+c));break;default:t=t.replace(n,c=>c+a)}}return t=t.replace(kc,""),s&&(t=t.replace(/\}\s*$/,n=>n+LD[e])),t}var DD=1,Jt=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(r=>{if(r instanceof Jt)return r;ls(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${DD++}`);let s=new Jt(r);return s.dependencies=Jt.instantiateModules(r.dependencies||[]),s})}constructor(e){let{name:r,vs:s,fs:i,dependencies:n=[],uniformTypes:o={},uniformPropTypes:a={},getUniforms:c,deprecations:l=[],defines:u={},inject:f={}}=e;ls(typeof r=="string"),this.name=r,this.vs=s,this.fs=i,this.getModuleUniforms=c,this.dependencies=Jt.instantiateModules(n),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=u,this.injections=aS(f),this.uniformTypes=o,a&&(this.uniforms=tS(a))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:ls(!1)}let s=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} --------------- #define MODULE_${s} ${r} `}getUniforms(e,r){return this.getModuleUniforms?this.getModuleUniforms(e,r):rS(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,r){this.deprecations.forEach(s=>{s.regex?.test(e)&&(s.deprecated?r.deprecated(s.old,s.new)():r.removed(s.old,s.new)())})}_parseDeprecationDefinitions(e){return e.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),e}_defaultGetUniforms(e={}){let r={},s=this.uniforms;for(let i in s){let n=s[i];i in e&&!n.private?(n.validate&&ls(n.validate(e[i],n),`${this.name}: invalid ${i}`),r[i]=e[i]):r[i]=n.value}return r}};function n0(t){if(t.source&&t.platformInfo.type==="webgpu")return{...t,vs:void 0,fs:void 0};if(!t.vs)throw new Error("no vertex shader");let e=cS(t.platformInfo,t.vs),r;return t.fs&&(r=cS(t.platformInfo,t.fs)),{...t,vs:e,fs:r}}function cS(t,e){if(typeof e=="string")return e;switch(t.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function dn(t){let e=Jt.instantiateModules(t);return UD(e)}function UD(t){let e={},r={};return lS({modules:t,level:0,moduleMap:e,moduleDepth:r}),Object.keys(r).sort((s,i)=>r[i]-r[s]).map(s=>e[s])}function lS(t){let{modules:e,level:r,moduleMap:s,moduleDepth:i}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let n of e)s[n.name]=n,(i[n.name]===void 0||i[n.name]o.order-a.order);for(let o of n)r+=` ${o.injection} `}i.footer&&(r+=` ${i.footer}`),r+=`} `}return r}function c0(t){let e={vertex:{},fragment:{}};for(let r of t){let s,i;typeof r!="string"?(s=r,i=s.hook):(s={},i=r),i=i.trim();let[n,o]=i.split(":"),a=i.replace(/\(.+/,""),c=Object.assign(s,{signature:o});switch(n){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(n)}}return e}function pS(t,e){return{name:zD(t,e),language:"glsl",version:HD(t)}}function zD(t,e="unnamed"){let s=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return s?s[1]:e}function HD(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let s=parseInt(r[1],10);Number.isFinite(s)&&(e=s)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var mS=` ${kc} `,GD=`precision highp float; `;function _S(t){let e=dn(t.modules||[]);return{source:l0(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:u0(e)}}function yS(t){let e=dn(t.modules||[]);return{vs:l0(t.platformInfo,{...t,source:t.vs,stage:"vertex",modules:e}),fs:l0(t.platformInfo,{...t,source:t.fs,stage:"fragment",modules:e}),getUniforms:u0(e)}}function xS(t){let{vs:e,fs:r}=t,s=dn(t.modules||[]);return{vs:gS(t.platformInfo,{...t,source:e,stage:"vertex",modules:s}),fs:gS(t.platformInfo,{...t,source:r,stage:"fragment",modules:s}),getUniforms:u0(s)}}function l0(t,e){let{source:r,stage:s,modules:i,hookFunctions:n=[],inject:o={},log:a}=e;ls(typeof r=="string","shader source must be a string");let c=r,l="",u=c0(n),f={},h={},d={};for(let g in o){let m=typeof o[g]=="string"?{injection:o[g],order:0}:o[g],_=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(_){let y=_[2],x=_[3];y?x==="decl"?h[g]=[m]:d[g]=[m]:f[g]=[m]}else d[g]=[m]}let p=t.type!=="webgpu"?i:[];for(let g of p){a&&g.checkDeprecations(c,a);let m=g.getModuleSource(s,"wgsl");l+=m;let _=g.injections[s];for(let y in _){let x=/^(v|f)s:#([\w-]+)$/.exec(y);if(x){let P=x[2]==="decl"?h:d;P[y]=P[y]||[],P[y].push(_[y])}else f[y]=f[y]||[],f[y].push(_[y])}}return l+=mS,l=Vc(l,s,h),l+=a0(u[s],f),l+=c,l=Vc(l,s,d),l}function gS(t,e){let{id:r,source:s,stage:i,language:n="glsl",modules:o,defines:a={},hookFunctions:c=[],inject:l={},prologue:u=!0,log:f}=e;ls(typeof s=="string","shader source must be a string");let h=n==="glsl"?pS(s).version:-1,d=t.shaderLanguageVersion,p=h===100?"#version 100":"#version 300 es",m=s.split(` `).slice(1).join(` `),_={};o.forEach(L=>{Object.assign(_,L.getDefines())}),Object.assign(_,a);let y="";switch(n){case"wgsl":break;case"glsl":y=u?`${p} // ----- PROLOGUE ------------------------- ${WD({id:r,source:s,stage:i})} ${`#define SHADER_TYPE_${i.toUpperCase()}`} ${uS(t)} ${i==="fragment"?GD:""} // ----- APPLICATION DEFINES ------------------------- ${jD(_)} `:`${p} `;break}let x=c0(c),S={},P={},B={};for(let L in l){let M=typeof l[L]=="string"?{injection:l[L],order:0}:l[L],v=/^(v|f)s:(#)?([\w-]+)$/.exec(L);if(v){let T=v[2],D=v[3];T?D==="decl"?P[L]=[M]:B[L]=[M]:S[L]=[M]}else B[L]=[M]}for(let L of o){f&&L.checkDeprecations(m,f);let M=L.getModuleSource(i);y+=M;let v=L.injections[i];for(let T in v){let D=/^(v|f)s:#([\w-]+)$/.exec(T);if(D){let z=D[2]==="decl"?P:B;z[T]=z[T]||[],z[T].push(v[T])}else S[T]=S[T]||[],S[T].push(v[T])}}return y+="// ----- MAIN SHADER SOURCE -------------------------",y+=mS,y=Vc(y,i,P),y+=a0(x[i],S),y+=m,y=Vc(y,i,B),n==="glsl"&&h!==d&&(y=hS(y,i)),y.trim()}function u0(t){return function(r){let s={};for(let i of t){let n=i.getUniforms(r,s);Object.assign(s,n)}return s}}function WD(t){let{id:e,source:r,stage:s}=t;return e&&r.indexOf("SHADER_NAME")===-1?` #define SHADER_NAME ${e}_${s} `:""}function jD(t={}){let e="";for(let r in t){let s=t[r];(s||Number.isFinite(s))&&(e+=`#define ${r.toUpperCase()} ${t[r]} `)}return e}var Co=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Co.defaultShaderAssembler=Co.defaultShaderAssembler||new Co,Co.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(s=>s.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let r=this._getModuleList(e.modules),s=this._hookFunctions,i=n0(e);return{..._S({platformInfo:e.platformInfo,...i,modules:r,hookFunctions:s}),modules:r}}assembleShaderPair(e){let r=n0(e),s=this._getModuleList(e.modules),i=this._hookFunctions,{platformInfo:n}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?yS({platformInfo:n,...r,modules:s,hookFunctions:i}):xS({platformInfo:n,...r,modules:s,hookFunctions:i}),modules:s}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),s={},i=0;for(let n=0,o=this._defaultModules.length;nt.startsWith(e))}function jh(t){let e=tU.exec(t);if(e){let[,r,s,i,n,o]=e;if(r){let a=`${i}${s}`,c=Wh(a);return{format:r,components:r.length,srgb:n==="-srgb",unsized:o==="-unsized",webgl:o==="-webgl",...c}}}return sU(t)}var rU={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function sU(t){let e=rU[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var Gc=class{},Wc=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},p0=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...p0.defaultProps,...e},this.id=this.props.id||Ge(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=wo;_lumaData={};isTextureFormatCompressed(e){return ES(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)&Q.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":U.warn("indices buffer content must be of integer type")()),r}},Zt=p0;Y(Zt,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(U.get("debug")),spector:Boolean(U.get("spector")||U.get("spectorjs")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>U.error(e.message)}),Y(Zt,"VERSION",TS);function ee(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var jc=new Map,g0=class{static registerDevices(e){for(let r of e)ee(r.type&&r.isSupported&&r.create),jc.set(r.type,r)}static getAvailableDevices(){return Array.from(jc).map(e=>e.type)}static getSupportedDevices(){return Array.from(jc).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(Zt.defaultProps,e)}static async attachDevice(e){let r=SS(e.devices)||jc;if(e.handle instanceof WebGL2RenderingContext){let s=r.get("webgl");if(s)return await s.attach(e.handle)}if(e.handle===null){let s=r.get("unknown");if(s)return await s.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){e={...g0.defaultProps,...e},e.gl&&(e.type="webgl");let r=SS(e.devices)||jc,s,i;switch(e.type){case"webgpu":if(s=r.get("webgpu"),s)return await s.create(e);break;case"webgl":if(i=r.get("webgl"),i)return await i.create(e);break;case"unknown":let n=r.get("unknown");if(n)return await n.create(e);break;case"best-available":if(s=r.get("webgpu"),s?.isSupported?.())return await s.create(e);if(i=r.get("webgl"),i?.isSupported?.())return await i.create(e);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){let r=HTMLCanvasElement.prototype;if(!e&&r.originalGetContext){r.getContext=r.originalGetContext,r.originalGetContext=void 0;return}r.originalGetContext=r.getContext,r.getContext=function(s,i){return s==="webgl"||s==="experimental-webgl"?this.originalGetContext("webgl2",i):this.originalGetContext(s,i)}}},Vt=g0;Y(Vt,"defaultProps",{...Zt.defaultProps,type:"best-available",devices:void 0}),Y(Vt,"stats",wo),Y(Vt,"log",U);function SS(t){if(!t||t?.length===0)return null;let e=new Map;for(let r of t)e.set(r.type,r);return e}var iU=At()&&typeof document<"u",Xh=()=>iU&&document.readyState==="complete",nU={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},gi=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return Xh()}constructor(e){if(this.props={...nU,...e},e=this.props,!At()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=cU(e.canvas):this.canvas=e.canvas;else{let r=lU(e),s=aU(e?.container||null);s.insertBefore(r,s.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let s of r)s.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let s=this.cssToDeviceRatio(),[i,n]=this.getDrawingBufferSize();return uU(e,s,i,n,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let s="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!s||!i)&&(U.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,s=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let n=this._canvasSizeInfo;if(n.clientWidth!==s||n.clientHeight!==i||n.devicePixelRatio!==e){let o=e,a=Math.floor(s*o),c=Math.floor(i*o);this.htmlCanvas.width=a,this.htmlCanvas.height=c;let[l,u]=this.getDrawingBufferSize();(l!==a||u!==c)&&(o=Math.min(l/s,u/i),this.htmlCanvas.width=Math.floor(s*o),this.htmlCanvas.height=Math.floor(i*o),U.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=s,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};Y(gi,"pageLoaded",oU());function oU(){return Xh()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function aU(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!Xh())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function cU(t){let e=document.getElementById(t);if(!e&&!Xh())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function lU(t){let{width:e,height:r}=t,s=document.createElement("canvas");return s.id="lumagl-auto-created-canvas",s.width=e||1,s.height=r||1,s.style.width=Number.isFinite(e)?`${e}px`:"100%",s.style.height=Number.isFinite(r)?`${r}px`:"100%",s}function uU(t,e,r,s,i){let n=t,o=vS(n[0],e,r),a=CS(n[1],e,s,i),c=vS(n[0]+1,e,r),l=c===r-1?c:c-1;c=CS(n[1]+1,e,s,i);let u;return i?(c=c===0?c:c+1,u=a,a=c):u=c===s-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function vS(t,e,r){return Math.min(Math.round(t*e),r-1)}function CS(t,e,r,s){return s?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var m0=class extends te{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,s=m0.defaultProps){super(e,r,s),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}},xe=m0;Y(xe,"defaultProps",{...te.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0}),Y(xe,"COPY_SRC",1),Y(xe,"COPY_DST",2),Y(xe,"TEXTURE_BINDING",4),Y(xe,"STORAGE_BINDING",8),Y(xe,"RENDER_ATTACHMENT",16);var _0=class extends te{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,_0.defaultProps)}},mi=_0;Y(mi,"defaultProps",{...te.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function PS(t,e,r){let s="",i=e.split(/\r?\n/),n=t.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=i.length;a++)for(s+=MS(i[a-1],a,r);n.length>o&&n[o].lineNum===a;){let c=n[o++];s+=wS(c,i,c.lineNum,{...r,inlineSource:!1})}return s;case"issues":case"no":for(let a of t)s+=wS(a,i,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return s}}function wS(t,e,r,s){if(s?.inlineSource){let i=fU(e,r),n=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ `:"";return` ${i}${n}${t.type.toUpperCase()}: ${t.message} `}return s?.html?`
${t.type.toUpperCase()}: ${t.message}
`:`${t.type.toUpperCase()}: ${t.message}`}function fU(t,e,r){let s="";for(let i=e-2;i<=e;i++){let n=t[i-1];n!==void 0&&(s+=MS(n,e,r))}return s}function MS(t,e,r){let s=r?.html?dU(t):t;return`${hU(String(e),4)}: ${s}${r?.html?"
":` `}`}function hU(t,e){let r="";for(let s=t.length;s",">").replaceAll('"',""").replaceAll("'","'")}function y0(t,e){return{name:pU(t,e),language:"glsl",version:gU(t)}}function pU(t,e="unnamed"){let s=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return s?s[1]:e}function gU(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let s=parseInt(r[1],10);Number.isFinite(s)&&(e=s)}return e}var x0=class extends te{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:mU(r),...r},x0.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=y0(this.source).name,s=`${this.stage} ${r}`,i=PS(e,this.source,{showSourceCode:"all",html:!0}),n=this.getTranslatedSource();n&&(i+=`

Translated Source



${n}
`);let o=document.createElement("Button");o.innerHTML=`

Shader Compilation Error in ${s}



${i}
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);let a=document.getElementsByClassName("luma-compiler-log-error");a[0]?.scrollIntoView&&a[0].scrollIntoView(),o.onclick=()=>{let c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}},_i=x0;Y(_i,"defaultProps",{...te.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function mU(t){return y0(t.source).name||t.id||Ge(`unnamed ${t.stage}-shader`)}var A0=class extends te{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,A0.defaultProps)}},yi=A0;Y(yi,"defaultProps",{...te.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var T0=class extends te{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,T0.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[s,i]=Array.isArray(e)?e:[e.width,e.height];r=r||i!==this.height||s!==this.width,this.width=s,this.height=i}r&&(U.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(r=>{if(typeof r=="string"){let s=this.createColorTexture(r);return this.attachResource(s),s.view}return r instanceof xe?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof xe?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:xe.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:xe.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let s=0;s":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},xU={f32:4,f16:2,i32:4,u32:4};function w0(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,s]=t.split("x"),i=r,n=s?parseInt(s):1,o=Wh(i),a={type:i,components:n,byteLength:o.byteLength*n,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function Yh(t,e){let r={};for(let s of t.attributes)r[s.name]=AU(t,e,s.name);return r}function IS(t,e,r=16){let s=Yh(t,e),i=new Array(r).fill(null);for(let n of Object.values(s))i[n.location]=n;return i}function AU(t,e,r){let s=TU(t,r),i=bU(e,r);if(!s)return null;let n=RS(s.type),o=i?.vertexFormat||n.defaultVertexFormat,a=w0(o);return{attributeName:i?.attributeName||s.name,bufferName:i?.bufferName||s.name,location:s.location,shaderType:s.type,shaderDataType:n.dataType,shaderComponents:n.components,vertexFormat:o,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:n.integer,stepMode:i?.stepMode||s.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function TU(t,e){let r=t.attributes.find(s=>s.name===e);return r||U.warn(`shader layout attribute "${e}" not present in shader`),r||null}function bU(t,e){EU(t);let r=SU(t,e);return r||(r=vU(t,e),r)?r:(U.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function EU(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&U.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function SU(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function vU(t,e){for(let r of t){let s=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let o=w0(n.format);s+=o.byteLength}let i=r.attributes?.find(n=>n.attribute===e);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:s}}return null}function P0(t,e){let r={...t,attributes:t.attributes.map(s=>({...s}))};for(let s of e?.attributes||[]){let i=r.attributes.find(n=>n.name===s.name);i?(i.type=s.type||i.type,i.stepMode=s.stepMode||i.stepMode):U.warn(`shader layout attribute ${s.name} not present in shader`)}return r}var M0=class extends te{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,M0.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=IS(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}},Io=M0;Y(Io,"defaultProps",{...te.defaultProps,renderPipeline:null});var R0=class extends te{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,R0.defaultProps)}},Bo=R0;Y(Bo,"defaultProps",{...te.defaultProps,layout:void 0,buffers:{}});var I0=class extends te{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,I0.defaultProps)}},Oo=I0;Y(Oo,"defaultProps",{...te.defaultProps,type:void 0,count:void 0});var CU={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function BS(t){let e=CU[t];return ee(t),e}function OS(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}var qh;function Kh(t){return(!qh||qh.byteLengthi.type==="uniform"&&i.name===e?.name);if(!r)throw new Error(e?.name);let s=r;for(let i of s.uniforms||[])this.bindingLayout[i.name]=i}}setUniforms(e){for(let[r,s]of Object.entries(e))this._setUniform(r,s),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${s}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){LS(this.uniforms[e],r)||(this.uniforms[e]=NS(r),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Xc=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[r,s]of Object.entries(e)){let i=r,n=new $h(s.uniformTypes||{});this.uniformBufferLayouts.set(i,n);let o=new Jh({name:r});o.setUniforms(s.defaultUniforms||{}),this.uniformBlocks.set(i,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,s]of Object.entries(e))this.uniformBlocks.get(r).setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e).byteLength}getUniformBufferData(e){let r=this.uniformBlocks.get(e).getAllUniforms();return this.uniformBufferLayouts.get(e).getData(r)}createUniformBuffer(e,r,s){s&&this.setUniforms(s);let i=this.getUniformBufferByteLength(r),n=e.createBuffer({usage:Q.UNIFORM|Q.COPY_DST,byteLength:i}),o=this.getUniformBufferData(r);return n.write(o),n}getManagedUniformBuffer(e,r){if(!this.uniformBuffers.get(r)){let s=this.getUniformBufferByteLength(r),i=e.createBuffer({usage:Q.UNIFORM|Q.COPY_DST,byteLength:s});this.uniformBuffers.set(r,i)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let s=this.updateUniformBuffer(r);e||=s}return e&&U.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),s=this.uniformBuffers.get(e),i=!1;if(s&&r.needsRedraw){i||=r.needsRedraw;let n=this.getUniformBufferData(e);this.uniformBuffers.get(e).write(n);let a=this.uniformBlocks.get(e).getAllUniforms();U.log(4,`Writing to uniform buffer ${String(e)}`,n,a)()}return i}};function Zh(t){let e=ArrayBuffer.isView(t)?t.constructor:t;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function Yc(t){switch(t){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(t)}}function F0(t,e,r){if(!e||e>4)throw new Error(`size ${e}`);let s=e,i=Zh(t);if(i==="uint8"&&r&&s===1)return"unorm8-webgl";if(i==="uint8"&&r&&s===3)return"unorm8x3-webgl";if(i==="uint8"||i==="sint8"){if(s===1||s===3)throw new Error(`size: ${e}`);return r&&(i=i.replace("int","norm")),`${i}x${s}`}if(i==="uint16"||i==="sint16"){if(s===1||s===3)throw new Error(`size: ${e}`);return r&&(i=i.replace("int","norm")),`${i}x${s}`}return s===1?i:`${i}x${s}`}function DS(t){return di(t)!==null||typeof t=="number"||typeof t=="boolean"}function gn(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let s=t[r];DS(s)?e.uniforms[r]=s:e.bindings[r]=s}),e}function L0(t,e,r){let{removedProps:s={},deprecatedProps:i={},replacedProps:n={}}=r;for(let a in s)if(a in e){let l=s[a]?`${t}.${s[a]}`:"N/A";U.removed(`${t}.${a}`,l)()}for(let a in i)if(a in e){let c=i[a];U.deprecated(`${t}.${a}`,`${t}.${c}`)()}let o=null;for(let[a,c]of Object.entries(n))a in e&&(U.deprecated(`${t}.${a}`,`${t}.${c}`)(),o=o||Object.assign({},e),o[c]=e[a],delete o[a]);return o||e}var wU="";async function N0(t,e){return await new Promise((r,s)=>{try{let i=new Image;i.onload=()=>r(i),i.onerror=()=>s(new Error(`Could not load image ${t}.`)),i.crossOrigin=e?.crossOrigin||"anonymous",i.src=t.startsWith("http")?t:wU+t}catch(i){s(i)}})}async function qc(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let s=document.createElement("script");return s.setAttribute("type","text/javascript"),s.setAttribute("src",t),e&&(s.id=e),new Promise((i,n)=>{s.onload=i,s.onerror=o=>n(new Error(`Unable to load script '${t}': ${o}`)),r.appendChild(s)})}function Kc(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let s=0;s":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}search(e){this.left.search(e),this.right.search(e)}},fd=class extends Ir{constructor(){super()}},ay=class extends fd{constructor(e,r){super(),this.selector=e,this.body=r}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},cy=class extends fd{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},ly=class extends Ir{constructor(e,r,s){super(),this.name=e,this.type=r,this.attributes=s}get astNodeType(){return"argument"}},uy=class extends Ir{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},fy=class extends Ir{constructor(e,r,s){super(),this.name=e,this.type=r,this.attributes=s}get astNodeType(){return"member"}},hy=class extends Ir{constructor(e,r){super(),this.name=e,this.value=r}get astNodeType(){return"attribute"}},O,I;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(I||(I={}));var R=class{constructor(e,r,s){this.name=e,this.type=r,this.rule=s}toString(){return this.name}},E=class{};O=E;E.none=new R("",I.reserved,"");E.eof=new R("EOF",I.token,"");E.reserved={asm:new R("asm",I.reserved,"asm"),bf16:new R("bf16",I.reserved,"bf16"),do:new R("do",I.reserved,"do"),enum:new R("enum",I.reserved,"enum"),f16:new R("f16",I.reserved,"f16"),f64:new R("f64",I.reserved,"f64"),handle:new R("handle",I.reserved,"handle"),i8:new R("i8",I.reserved,"i8"),i16:new R("i16",I.reserved,"i16"),i64:new R("i64",I.reserved,"i64"),mat:new R("mat",I.reserved,"mat"),premerge:new R("premerge",I.reserved,"premerge"),regardless:new R("regardless",I.reserved,"regardless"),typedef:new R("typedef",I.reserved,"typedef"),u8:new R("u8",I.reserved,"u8"),u16:new R("u16",I.reserved,"u16"),u64:new R("u64",I.reserved,"u64"),unless:new R("unless",I.reserved,"unless"),using:new R("using",I.reserved,"using"),vec:new R("vec",I.reserved,"vec"),void:new R("void",I.reserved,"void")};E.keywords={array:new R("array",I.keyword,"array"),atomic:new R("atomic",I.keyword,"atomic"),bool:new R("bool",I.keyword,"bool"),f32:new R("f32",I.keyword,"f32"),i32:new R("i32",I.keyword,"i32"),mat2x2:new R("mat2x2",I.keyword,"mat2x2"),mat2x3:new R("mat2x3",I.keyword,"mat2x3"),mat2x4:new R("mat2x4",I.keyword,"mat2x4"),mat3x2:new R("mat3x2",I.keyword,"mat3x2"),mat3x3:new R("mat3x3",I.keyword,"mat3x3"),mat3x4:new R("mat3x4",I.keyword,"mat3x4"),mat4x2:new R("mat4x2",I.keyword,"mat4x2"),mat4x3:new R("mat4x3",I.keyword,"mat4x3"),mat4x4:new R("mat4x4",I.keyword,"mat4x4"),ptr:new R("ptr",I.keyword,"ptr"),sampler:new R("sampler",I.keyword,"sampler"),sampler_comparison:new R("sampler_comparison",I.keyword,"sampler_comparison"),struct:new R("struct",I.keyword,"struct"),texture_1d:new R("texture_1d",I.keyword,"texture_1d"),texture_2d:new R("texture_2d",I.keyword,"texture_2d"),texture_2d_array:new R("texture_2d_array",I.keyword,"texture_2d_array"),texture_3d:new R("texture_3d",I.keyword,"texture_3d"),texture_cube:new R("texture_cube",I.keyword,"texture_cube"),texture_cube_array:new R("texture_cube_array",I.keyword,"texture_cube_array"),texture_multisampled_2d:new R("texture_multisampled_2d",I.keyword,"texture_multisampled_2d"),texture_storage_1d:new R("texture_storage_1d",I.keyword,"texture_storage_1d"),texture_storage_2d:new R("texture_storage_2d",I.keyword,"texture_storage_2d"),texture_storage_2d_array:new R("texture_storage_2d_array",I.keyword,"texture_storage_2d_array"),texture_storage_3d:new R("texture_storage_3d",I.keyword,"texture_storage_3d"),texture_depth_2d:new R("texture_depth_2d",I.keyword,"texture_depth_2d"),texture_depth_2d_array:new R("texture_depth_2d_array",I.keyword,"texture_depth_2d_array"),texture_depth_cube:new R("texture_depth_cube",I.keyword,"texture_depth_cube"),texture_depth_cube_array:new R("texture_depth_cube_array",I.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new R("texture_depth_multisampled_2d",I.keyword,"texture_depth_multisampled_2d"),texture_external:new R("texture_external",I.keyword,"texture_external"),u32:new R("u32",I.keyword,"u32"),vec2:new R("vec2",I.keyword,"vec2"),vec3:new R("vec3",I.keyword,"vec3"),vec4:new R("vec4",I.keyword,"vec4"),bitcast:new R("bitcast",I.keyword,"bitcast"),block:new R("block",I.keyword,"block"),break:new R("break",I.keyword,"break"),case:new R("case",I.keyword,"case"),continue:new R("continue",I.keyword,"continue"),continuing:new R("continuing",I.keyword,"continuing"),default:new R("default",I.keyword,"default"),diagnostic:new R("diagnostic",I.keyword,"diagnostic"),discard:new R("discard",I.keyword,"discard"),else:new R("else",I.keyword,"else"),enable:new R("enable",I.keyword,"enable"),fallthrough:new R("fallthrough",I.keyword,"fallthrough"),false:new R("false",I.keyword,"false"),fn:new R("fn",I.keyword,"fn"),for:new R("for",I.keyword,"for"),function:new R("function",I.keyword,"function"),if:new R("if",I.keyword,"if"),let:new R("let",I.keyword,"let"),const:new R("const",I.keyword,"const"),loop:new R("loop",I.keyword,"loop"),while:new R("while",I.keyword,"while"),private:new R("private",I.keyword,"private"),read:new R("read",I.keyword,"read"),read_write:new R("read_write",I.keyword,"read_write"),return:new R("return",I.keyword,"return"),requires:new R("requires",I.keyword,"requires"),storage:new R("storage",I.keyword,"storage"),switch:new R("switch",I.keyword,"switch"),true:new R("true",I.keyword,"true"),alias:new R("alias",I.keyword,"alias"),type:new R("type",I.keyword,"type"),uniform:new R("uniform",I.keyword,"uniform"),var:new R("var",I.keyword,"var"),override:new R("override",I.keyword,"override"),workgroup:new R("workgroup",I.keyword,"workgroup"),write:new R("write",I.keyword,"write"),r8unorm:new R("r8unorm",I.keyword,"r8unorm"),r8snorm:new R("r8snorm",I.keyword,"r8snorm"),r8uint:new R("r8uint",I.keyword,"r8uint"),r8sint:new R("r8sint",I.keyword,"r8sint"),r16uint:new R("r16uint",I.keyword,"r16uint"),r16sint:new R("r16sint",I.keyword,"r16sint"),r16float:new R("r16float",I.keyword,"r16float"),rg8unorm:new R("rg8unorm",I.keyword,"rg8unorm"),rg8snorm:new R("rg8snorm",I.keyword,"rg8snorm"),rg8uint:new R("rg8uint",I.keyword,"rg8uint"),rg8sint:new R("rg8sint",I.keyword,"rg8sint"),r32uint:new R("r32uint",I.keyword,"r32uint"),r32sint:new R("r32sint",I.keyword,"r32sint"),r32float:new R("r32float",I.keyword,"r32float"),rg16uint:new R("rg16uint",I.keyword,"rg16uint"),rg16sint:new R("rg16sint",I.keyword,"rg16sint"),rg16float:new R("rg16float",I.keyword,"rg16float"),rgba8unorm:new R("rgba8unorm",I.keyword,"rgba8unorm"),rgba8unorm_srgb:new R("rgba8unorm_srgb",I.keyword,"rgba8unorm_srgb"),rgba8snorm:new R("rgba8snorm",I.keyword,"rgba8snorm"),rgba8uint:new R("rgba8uint",I.keyword,"rgba8uint"),rgba8sint:new R("rgba8sint",I.keyword,"rgba8sint"),bgra8unorm:new R("bgra8unorm",I.keyword,"bgra8unorm"),bgra8unorm_srgb:new R("bgra8unorm_srgb",I.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new R("rgb10a2unorm",I.keyword,"rgb10a2unorm"),rg11b10float:new R("rg11b10float",I.keyword,"rg11b10float"),rg32uint:new R("rg32uint",I.keyword,"rg32uint"),rg32sint:new R("rg32sint",I.keyword,"rg32sint"),rg32float:new R("rg32float",I.keyword,"rg32float"),rgba16uint:new R("rgba16uint",I.keyword,"rgba16uint"),rgba16sint:new R("rgba16sint",I.keyword,"rgba16sint"),rgba16float:new R("rgba16float",I.keyword,"rgba16float"),rgba32uint:new R("rgba32uint",I.keyword,"rgba32uint"),rgba32sint:new R("rgba32sint",I.keyword,"rgba32sint"),rgba32float:new R("rgba32float",I.keyword,"rgba32float"),static_assert:new R("static_assert",I.keyword,"static_assert")};E.tokens={decimal_float_literal:new R("decimal_float_literal",I.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new R("hex_float_literal",I.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new R("int_literal",I.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new R("uint_literal",I.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new R("ident",I.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new R("and",I.token,"&"),and_and:new R("and_and",I.token,"&&"),arrow:new R("arrow ",I.token,"->"),attr:new R("attr",I.token,"@"),forward_slash:new R("forward_slash",I.token,"/"),bang:new R("bang",I.token,"!"),bracket_left:new R("bracket_left",I.token,"["),bracket_right:new R("bracket_right",I.token,"]"),brace_left:new R("brace_left",I.token,"{"),brace_right:new R("brace_right",I.token,"}"),colon:new R("colon",I.token,":"),comma:new R("comma",I.token,","),equal:new R("equal",I.token,"="),equal_equal:new R("equal_equal",I.token,"=="),not_equal:new R("not_equal",I.token,"!="),greater_than:new R("greater_than",I.token,">"),greater_than_equal:new R("greater_than_equal",I.token,">="),shift_right:new R("shift_right",I.token,">>"),less_than:new R("less_than",I.token,"<"),less_than_equal:new R("less_than_equal",I.token,"<="),shift_left:new R("shift_left",I.token,"<<"),modulo:new R("modulo",I.token,"%"),minus:new R("minus",I.token,"-"),minus_minus:new R("minus_minus",I.token,"--"),period:new R("period",I.token,"."),plus:new R("plus",I.token,"+"),plus_plus:new R("plus_plus",I.token,"++"),or:new R("or",I.token,"|"),or_or:new R("or_or",I.token,"||"),paren_left:new R("paren_left",I.token,"("),paren_right:new R("paren_right",I.token,")"),semicolon:new R("semicolon",I.token,";"),star:new R("star",I.token,"*"),tilde:new R("tilde",I.token,"~"),underscore:new R("underscore",I.token,"_"),xor:new R("xor",I.token,"^"),plus_equal:new R("plus_equal",I.token,"+="),minus_equal:new R("minus_equal",I.token,"-="),times_equal:new R("times_equal",I.token,"*="),division_equal:new R("division_equal",I.token,"/="),modulo_equal:new R("modulo_equal",I.token,"%="),and_equal:new R("and_equal",I.token,"&="),or_equal:new R("or_equal",I.token,"|="),xor_equal:new R("xor_equal",I.token,"^="),shift_right_equal:new R("shift_right_equal",I.token,">>="),shift_left_equal:new R("shift_left_equal",I.token,"<<=")};E.simpleTokens={"@":O.tokens.attr,"{":O.tokens.brace_left,"}":O.tokens.brace_right,":":O.tokens.colon,",":O.tokens.comma,"(":O.tokens.paren_left,")":O.tokens.paren_right,";":O.tokens.semicolon};E.literalTokens={"&":O.tokens.and,"&&":O.tokens.and_and,"->":O.tokens.arrow,"/":O.tokens.forward_slash,"!":O.tokens.bang,"[":O.tokens.bracket_left,"]":O.tokens.bracket_right,"=":O.tokens.equal,"==":O.tokens.equal_equal,"!=":O.tokens.not_equal,">":O.tokens.greater_than,">=":O.tokens.greater_than_equal,">>":O.tokens.shift_right,"<":O.tokens.less_than,"<=":O.tokens.less_than_equal,"<<":O.tokens.shift_left,"%":O.tokens.modulo,"-":O.tokens.minus,"--":O.tokens.minus_minus,".":O.tokens.period,"+":O.tokens.plus,"++":O.tokens.plus_plus,"|":O.tokens.or,"||":O.tokens.or_or,"*":O.tokens.star,"~":O.tokens.tilde,_:O.tokens.underscore,"^":O.tokens.xor,"+=":O.tokens.plus_equal,"-=":O.tokens.minus_equal,"*=":O.tokens.times_equal,"/=":O.tokens.division_equal,"%=":O.tokens.modulo_equal,"&=":O.tokens.and_equal,"|=":O.tokens.or_equal,"^=":O.tokens.xor_equal,">>=":O.tokens.shift_right_equal,"<<=":O.tokens.shift_left_equal};E.regexTokens={decimal_float_literal:O.tokens.decimal_float_literal,hex_float_literal:O.tokens.hex_float_literal,int_literal:O.tokens.int_literal,uint_literal:O.tokens.uint_literal,ident:O.tokens.ident};E.storage_class=[O.keywords.function,O.keywords.private,O.keywords.workgroup,O.keywords.uniform,O.keywords.storage];E.access_mode=[O.keywords.read,O.keywords.write,O.keywords.read_write];E.sampler_type=[O.keywords.sampler,O.keywords.sampler_comparison];E.sampled_texture_type=[O.keywords.texture_1d,O.keywords.texture_2d,O.keywords.texture_2d_array,O.keywords.texture_3d,O.keywords.texture_cube,O.keywords.texture_cube_array];E.multisampled_texture_type=[O.keywords.texture_multisampled_2d];E.storage_texture_type=[O.keywords.texture_storage_1d,O.keywords.texture_storage_2d,O.keywords.texture_storage_2d_array,O.keywords.texture_storage_3d];E.depth_texture_type=[O.keywords.texture_depth_2d,O.keywords.texture_depth_2d_array,O.keywords.texture_depth_cube,O.keywords.texture_depth_cube_array,O.keywords.texture_depth_multisampled_2d];E.texture_external_type=[O.keywords.texture_external];E.any_texture_type=[...O.sampled_texture_type,...O.multisampled_texture_type,...O.storage_texture_type,...O.depth_texture_type,...O.texture_external_type];E.texel_format=[O.keywords.r8unorm,O.keywords.r8snorm,O.keywords.r8uint,O.keywords.r8sint,O.keywords.r16uint,O.keywords.r16sint,O.keywords.r16float,O.keywords.rg8unorm,O.keywords.rg8snorm,O.keywords.rg8uint,O.keywords.rg8sint,O.keywords.r32uint,O.keywords.r32sint,O.keywords.r32float,O.keywords.rg16uint,O.keywords.rg16sint,O.keywords.rg16float,O.keywords.rgba8unorm,O.keywords.rgba8unorm_srgb,O.keywords.rgba8snorm,O.keywords.rgba8uint,O.keywords.rgba8sint,O.keywords.bgra8unorm,O.keywords.bgra8unorm_srgb,O.keywords.rgb10a2unorm,O.keywords.rg11b10float,O.keywords.rg32uint,O.keywords.rg32sint,O.keywords.rg32float,O.keywords.rgba16uint,O.keywords.rgba16sint,O.keywords.rgba16float,O.keywords.rgba32uint,O.keywords.rgba32sint,O.keywords.rgba32float];E.const_literal=[O.tokens.int_literal,O.tokens.uint_literal,O.tokens.decimal_float_literal,O.tokens.hex_float_literal,O.keywords.true,O.keywords.false];E.literal_or_ident=[O.tokens.ident,O.tokens.int_literal,O.tokens.uint_literal,O.tokens.decimal_float_literal,O.tokens.hex_float_literal];E.element_count_expression=[O.tokens.int_literal,O.tokens.uint_literal,O.tokens.ident];E.template_types=[O.keywords.vec2,O.keywords.vec3,O.keywords.vec4,O.keywords.mat2x2,O.keywords.mat2x3,O.keywords.mat2x4,O.keywords.mat3x2,O.keywords.mat3x3,O.keywords.mat3x4,O.keywords.mat4x2,O.keywords.mat4x3,O.keywords.mat4x4,O.keywords.atomic,O.keywords.bitcast,...O.any_texture_type];E.attribute_name=[O.tokens.ident,O.keywords.block,O.keywords.diagnostic];E.assignment_operators=[O.tokens.equal,O.tokens.plus_equal,O.tokens.minus_equal,O.tokens.times_equal,O.tokens.division_equal,O.tokens.modulo_equal,O.tokens.and_equal,O.tokens.or_equal,O.tokens.xor_equal,O.tokens.shift_right_equal,O.tokens.shift_left_equal];E.increment_operators=[O.tokens.plus_plus,O.tokens.minus_minus];var hd=class{constructor(e,r,s){this.type=e,this.lexeme=r,this.line=s}toString(){return this.lexeme}isTemplateType(){return E.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==E.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},dy=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new hd(E.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==` `)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=` `;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let o=1;for(;o>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==` `)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}let r=E.simpleTokens[e];if(r)return this._addToken(r),!0;let s=E.none,i=this._isAlpha(e),n=e==="_";if(this._isAlphaNumeric(e)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)e+=this._advance(),o=this._peekAhead()}if(i){let o=E.keywords[e];if(o)return this._addToken(o),!0}if(i||n)return this._addToken(E.tokens.ident),!0;for(;;){let o=this._findType(e),a=this._peekAhead();if(e=="-"&&this._tokens.length>0){if(a=="=")return this._current++,e+=a,this._addToken(E.tokens.minus_equal),!0;if(a=="-")return this._current++,e+=a,this._addToken(E.tokens.minus_minus),!0;let c=this._tokens.length-1;if((E.literal_or_ident.indexOf(this._tokens[c].type)!=-1||this._tokens[c].type==E.tokens.paren_right)&&a!=">")return this._addToken(o),!0}if(e==">"&&(a==">"||a=="=")){let c=!1,l=this._tokens.length-1;for(let u=0;u<5&&l>=0&&E.assignment_operators.indexOf(this._tokens[l].type)===-1;++u,--l)if(this._tokens[l].type===E.tokens.less_than){l>0&&this._tokens[l-1].isArrayOrTemplateType()&&(c=!0);break}if(c)return this._addToken(o),!0}if(o===E.none){let c=e,l=0,u=2;for(let f=0;f=this._source.length}_isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}_isAlphaNumeric(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e=="_"||e>="0"&&e<="9"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let r=this._source[this._current];return e=e||0,e++,this._current+=e,r}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let r=this._source.substring(this._start,this._current);this._tokens.push(new hd(e,r,this._line))}},py=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new k0,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let r=[];for(;!this._isAtEnd();){let s=this._global_decl_or_directive();if(!s)break;r.push(s)}if(this._deferArrayCountEval.length>0){for(let s of this._deferArrayCountEval){let i=s.arrayType,n=s.countNode;if(n instanceof el){let a=n.name,c=this._context.constants.get(a);if(c)try{let l=c.evaluate(this._context);i.count=l}catch{}}}this._deferArrayCountEval.length=0}return r}_initialize(e){if(e)if(typeof e=="string"){let r=new dy(e);this._tokens=r.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,r){return{token:e,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==E.eof}_match(e){if(e instanceof R)return this._check(e)?(this._advance(),!0):!1;for(let r=0,s=e.length;r'.");let i=this._paren_expression();return new sy(s,i)}let e=this._type_decl(),r=this._argument_expression_list();return new iy(e,r)}_argument_expression_list(){if(!this._match(E.tokens.paren_left))return null;let e=[];do{if(this._check(E.tokens.paren_right))break;let r=this._short_circuit_or_expression();e.push(r)}while(this._match(E.tokens.comma));return this._consume(E.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(E.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(E.tokens.paren_right),new ld([e])}_paren_expression(){this._consume(E.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(E.tokens.paren_right,"Expected ')'."),new ld([e])}_struct_decl(){if(!this._match(E.keywords.struct))return null;let e=this._currentLine,r=this._consume(E.tokens.ident,"Expected name for struct.").toString();this._consume(E.tokens.brace_left,"Expected '{' for struct body.");let s=[];for(;!this._check(E.tokens.brace_right);){let o=this._attribute(),a=this._consume(E.tokens.ident,"Expected variable name.").toString();this._consume(E.tokens.colon,"Expected ':' for struct member type.");let c=this._attribute(),l=this._type_decl();l!=null&&(l.attributes=c),this._check(E.tokens.brace_right)?this._match(E.tokens.comma):this._consume(E.tokens.comma,"Expected ',' for struct member."),s.push(new fy(a,l,o))}this._consume(E.tokens.brace_right,"Expected '}' after struct body.");let i=this._currentLine,n=new Bs(r,s,e,i);return this._context.structs.set(r,n),n}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(E.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(E.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(E.keywords.const))return null;let e=this._consume(E.tokens.ident,"Expected variable name"),r=null;if(this._match(E.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}let s=null;if(this._match(E.tokens.equal)){let n=this._short_circuit_or_expression();if(n instanceof Ai)s=n;else if(n instanceof ad&&n.initializer instanceof Ai)s=n.initializer;else try{let o=n.evaluate(this._context);s=new cd(o)}catch{s=n}}let i=new ed(e.toString(),r,"","",s);return this._context.constants.set(i.name,i),i}_global_let_decl(){if(!this._match(E.keywords.let))return null;let e=this._consume(E.tokens.ident,"Expected variable name"),r=null;if(this._match(E.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}let s=null;return this._match(E.tokens.equal)&&(s=this._const_expression()),new Zc(e.toString(),r,"","",s)}_const_expression(){if(this._match(E.const_literal))return new nd(this._previous().toString());let e=this._type_decl();this._consume(E.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(E.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(E.tokens.comma));)this._advance();return this._consume(E.tokens.paren_right,"Expected ')'."),new Ai(e,r)}_variable_decl(){if(!this._match(E.keywords.var))return null;let e="",r="";this._match(E.tokens.less_than)&&(e=this._consume(E.storage_class,"Expected storage_class.").toString(),this._match(E.tokens.comma)&&(r=this._consume(E.access_mode,"Expected access_mode.").toString()),this._consume(E.tokens.greater_than,"Expected '>'."));let s=this._consume(E.tokens.ident,"Expected variable name"),i=null;if(this._match(E.tokens.colon)){let n=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=n)}return new Os(s.toString(),i,e,r,null)}_override_decl(){if(!this._match(E.keywords.override))return null;let e=this._consume(E.tokens.ident,"Expected variable name"),r=null;if(this._match(E.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}return new Qh(e.toString(),r,null)}_diagnostic(){this._consume(E.tokens.paren_left,"Expected '('");let e=this._consume(E.tokens.ident,"Expected severity control name.");this._consume(E.tokens.comma,"Expected ','");let r=this._consume(E.tokens.ident,"Expected diagnostic rule name.");return this._consume(E.tokens.paren_right,"Expected ')'"),new Z0(e.toString(),r.toString())}_enable_directive(){let e=this._consume(E.tokens.ident,"identity expected.");return new $0(e.toString())}_requires_directive(){let e=[this._consume(E.tokens.ident,"identity expected.").toString()];for(;this._match(E.tokens.comma);){let r=this._consume(E.tokens.ident,"identity expected.");e.push(r.toString())}return new J0(e)}_type_alias(){let e=this._consume(E.tokens.ident,"identity expected.");this._consume(E.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let s=new rd(e.toString(),r);return this._context.aliases.set(s.name,s),s}_type_decl(){if(this._check([E.tokens.ident,...E.texel_format,E.keywords.bool,E.keywords.f32,E.keywords.i32,E.keywords.u32])){let s=this._advance(),i=s.toString();return this._context.structs.has(i)?this._context.structs.get(i):this._context.aliases.has(i)?this._context.aliases.get(i).type:new Fs(s.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(E.template_types)){let s=this._advance().toString(),i=null,n=null;return this._match(E.tokens.less_than)&&(i=this._type_decl(),n=null,this._match(E.tokens.comma)&&(n=this._consume(E.access_mode,"Expected access_mode for pointer").toString()),this._consume(E.tokens.greater_than,"Expected '>' for type.")),new sd(s,i,n)}if(this._match(E.keywords.ptr)){let s=this._previous().toString();this._consume(E.tokens.less_than,"Expected '<' for pointer.");let i=this._consume(E.storage_class,"Expected storage_class for pointer");this._consume(E.tokens.comma,"Expected ',' for pointer.");let n=this._type_decl(),o=null;return this._match(E.tokens.comma)&&(o=this._consume(E.access_mode,"Expected access_mode for pointer").toString()),this._consume(E.tokens.greater_than,"Expected '>' for pointer."),new ry(s,i.toString(),n,o)}let r=this._attribute();if(this._match(E.keywords.array)){let s=null,i=-1,n=this._previous(),o=null;if(this._match(E.tokens.less_than)){s=this._type_decl(),this._context.aliases.has(s.name)&&(s=this._context.aliases.get(s.name).type);let c="";if(this._match(E.tokens.comma)){o=this._shift_expression();try{c=o.evaluate(this._context).toString(),o=null}catch{c="1"}}this._consume(E.tokens.greater_than,"Expected '>' for array."),i=c?parseInt(c):0}let a=new id(n.toString(),r,s,i);return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(E.sampler_type))return new mn(this._previous().toString(),null,null);if(this._match(E.depth_texture_type))return new mn(this._previous().toString(),null,null);if(this._match(E.sampled_texture_type)||this._match(E.multisampled_texture_type)){let e=this._previous();this._consume(E.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(E.tokens.greater_than,"Expected '>' for sampler type."),new mn(e.toString(),r,null)}if(this._match(E.storage_texture_type)){let e=this._previous();this._consume(E.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(E.texel_format,"Invalid texel format.").toString();this._consume(E.tokens.comma,"Expected ',' after texel format.");let s=this._consume(E.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(E.tokens.greater_than,"Expected '>' for sampler type."),new mn(e.toString(),r,s)}return null}_attribute(){let e=[];for(;this._match(E.tokens.attr);){let r=this._consume(E.attribute_name,"Expected attribute name"),s=new hy(r.toString(),null);if(this._match(E.tokens.paren_left)){if(s.value=this._consume(E.literal_or_ident,"Expected attribute value").toString(),this._check(E.tokens.comma)){this._advance();do{let i=this._consume(E.literal_or_ident,"Expected attribute value").toString();s.value instanceof Array||(s.value=[s.value]),s.value.push(i)}while(this._match(E.tokens.comma))}this._consume(E.tokens.paren_right,"Expected ')'")}e.push(s)}return e.length==0?null:e}},Ti=class{constructor(e,r){this.name=e,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},dd=class{constructor(e,r,s){this.name=e,this.type=r,this.attributes=s,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Fo=class extends Ti{constructor(e,r){super(e,r),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},$c=class extends Ti{constructor(e,r){super(e,r),this.count=0,this.stride=0}get isArray(){return!0}},pd=class extends Ti{constructor(e,r,s,i){super(e,s),this.format=r,this.access=i}get isTemplate(){return!0}},xi;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(xi||(xi={}));var Lo=class{constructor(e,r,s,i,n,o,a){this.name=e,this.type=r,this.group=s,this.binding=i,this.attributes=n,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},gy=class{constructor(e,r){this.name=e,this.type=r}},No=class{constructor(e,r){this.align=e,this.size=r}},my=class{constructor(e,r,s,i){this.name=e,this.type=r,this.locationType=s,this.location=i,this.interpolation=null}},gd=class{constructor(e,r,s,i){this.name=e,this.type=r,this.locationType=s,this.location=i}},_y=class{constructor(e,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=r}},yy=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},xy=class{constructor(e,r,s,i){this.name=e,this.type=r,this.attributes=s,this.id=i}},Ay=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},ur=class{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new yy,this.functions=[],this._types=new Map,this._functions=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){let s=new py().parse(e);for(let i of s)i instanceof Jc&&this._functions.set(i.name,new Ay(i));for(let i of s)if(i instanceof Bs){let n=this._getTypeInfo(i,null);n instanceof Fo&&this.structs.push(n)}for(let i of s){if(i instanceof rd){this.aliases.push(this._getAliasInfo(i));continue}if(i instanceof Qh){let n=i,o=this._getAttributeNum(n.attributes,"id",0),a=n.type!=null?this._getTypeInfo(n.type,n.attributes):null;this.overrides.push(new xy(n.name,a,n.attributes,o));continue}if(this._isUniformVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new Lo(n.name,c,o,a,n.attributes,xi.Uniform,n.access);this.uniforms.push(l);continue}if(this._isStorageVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),u=new Lo(n.name,c,o,a,n.attributes,l?xi.StorageTexture:xi.Storage,n.access);this.storage.push(u);continue}if(this._isTextureVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),u=new Lo(n.name,c,o,a,n.attributes,l?xi.StorageTexture:xi.Texture,n.access);l?this.storage.push(u):this.textures.push(u);continue}if(this._isSamplerVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new Lo(n.name,c,o,a,n.attributes,xi.Sampler,n.access);this.samplers.push(l);continue}if(i instanceof Jc){let n=this._getAttribute(i,"vertex"),o=this._getAttribute(i,"fragment"),a=this._getAttribute(i,"compute"),c=n||o||a,l=new _y(i.name,c?.name);l.startLine=i.startLine,l.endLine=i.endLine,this.functions.push(l),this._functions.get(i.name).info=l,c&&(this._functions.get(i.name).inUse=!0,l.inUse=!0,l.resources=this._findResources(i,!!c),l.inputs=this._getInputs(i.args),l.outputs=this._getOutputs(i.returnType),this.entry[c.name].push(l));continue}}for(let i of this._functions.values())i.info&&(i.info.inUse=i.inUse,this._addCalls(i.node,i.info.calls));for(let i of this.uniforms)this._markStructsInUse(i.type);for(let i of this.storage)this._markStructsInUse(i.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(let r of e.members)this._markStructsInUse(r.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{let r=this._getAlias(e.name);r&&this._markStructsInUse(r)}}_addCalls(e,r){var s;for(let i of e.calls){let n=(s=this._functions.get(i.name))===null||s===void 0?void 0:s.info;n&&r.add(n)}}findResource(e,r){for(let s of this.uniforms)if(s.group==e&&s.binding==r)return s;for(let s of this.storage)if(s.group==e&&s.binding==r)return s;for(let s of this.textures)if(s.group==e&&s.binding==r)return s;for(let s of this.samplers)if(s.group==e&&s.binding==r)return s;return null}_findResource(e){for(let r of this.uniforms)if(r.name==e)return r;for(let r of this.storage)if(r.name==e)return r;for(let r of this.textures)if(r.name==e)return r;for(let r of this.samplers)if(r.name==e)return r;return null}_markStructsFromAST(e){let r=this._getTypeInfo(e,null);this._markStructsInUse(r)}_findResources(e,r){let s=[],i=this,n=[];return e.search(o=>{if(o instanceof Do)n.push({});else if(o instanceof Uo)n.pop();else if(o instanceof Os){let a=o;r&&a.type!==null&&this._markStructsFromAST(a.type),n.length>0&&(n[n.length-1][a.name]=a)}else if(o instanceof Ai){let a=o;r&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Zc){let a=o;r&&a.type!==null&&this._markStructsFromAST(a.type),n.length>0&&(n[n.length-1][a.name]=a)}else if(o instanceof el){let a=o;if(n.length>0&&n[n.length-1][a.name])return;let c=i._findResource(a.name);c&&s.push(c)}else if(o instanceof od){let a=o,c=i._functions.get(a.name);c&&(r&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=i._findResources(c.node,r)),s.push(...c.resources))}else if(o instanceof td){let a=o,c=i._functions.get(a.name);c&&(r&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=i._findResources(c.node,r)),s.push(...c.resources))}}),[...new Map(s.map(o=>[o.name,o])).values()]}getBindGroups(){let e=[];function r(s,i){s>=e.length&&(e.length=s+1),e[s]===void 0&&(e[s]=[]),i>=e[s].length&&(e[s].length=i+1)}for(let s of this.uniforms){r(s.group,s.binding);let i=e[s.group];i[s.binding]=s}for(let s of this.storage){r(s.group,s.binding);let i=e[s.group];i[s.binding]=s}for(let s of this.textures){r(s.group,s.binding);let i=e[s.group];i[s.binding]=s}for(let s of this.samplers){r(s.group,s.binding);let i=e[s.group];i[s.binding]=s}return e}_getOutputs(e,r=void 0){if(r===void 0&&(r=[]),e instanceof Bs)this._getStructOutputs(e,r);else{let s=this._getOutputInfo(e);s!==null&&r.push(s)}return r}_getStructOutputs(e,r){for(let s of e.members)if(s.type instanceof Bs)this._getStructOutputs(s.type,r);else{let i=this._getAttribute(s,"location")||this._getAttribute(s,"builtin");if(i!==null){let n=this._getTypeInfo(s.type,s.type.attributes),o=this._parseInt(i.value),a=new gd(s.name,n,i.name,o);r.push(a)}}}_getOutputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let s=this._getTypeInfo(e,e.attributes),i=this._parseInt(r.value);return new gd("",s,r.name,i)}return null}_getInputs(e,r=void 0){r===void 0&&(r=[]);for(let s of e)if(s.type instanceof Bs)this._getStructInputs(s.type,r);else{let i=this._getInputInfo(s);i!==null&&r.push(i)}return r}_getStructInputs(e,r){for(let s of e.members)if(s.type instanceof Bs)this._getStructInputs(s.type,r);else{let i=this._getInputInfo(s);i!==null&&r.push(i)}}_getInputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let s=this._getAttribute(e,"interpolation"),i=this._getTypeInfo(e.type,e.attributes),n=this._parseInt(r.value),o=new my(e.name,i,r.name,n);return s!==null&&(o.interpolation=this._parseString(s.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let r=parseInt(e);return isNaN(r)?e:r}_getAlias(e){for(let r of this.aliases)if(r.name==e)return r.type;return null}_getAliasInfo(e){return new gy(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,r){if(this._types.has(e))return this._types.get(e);if(e instanceof id){let i=e,n=this._getTypeInfo(i.format,i.attributes),o=new $c(i.name,r);return o.format=n,o.count=i.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof Bs){let i=e,n=new Fo(i.name,r);n.startLine=i.startLine,n.endLine=i.endLine;for(let o of i.members){let a=this._getTypeInfo(o.type,o.attributes);n.members.push(new dd(o.name,a,o.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof mn){let i=e,n=i.format instanceof Fs,o=i.format?n?this._getTypeInfo(i.format,null):new Ti(i.format,null):null,a=new pd(i.name,o,r,i.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof sd){let i=e,n=i.format?this._getTypeInfo(i.format,null):null,o=new pd(i.name,n,r,i.access);return this._types.set(e,o),this._updateTypeInfo(o),o}let s=new Ti(e.name,r);return this._types.set(e,s),this._updateTypeInfo(s),s}_updateTypeInfo(e){var r,s;let i=this._getTypeSize(e);if(e.size=(r=i?.size)!==null&&r!==void 0?r:0,e instanceof $c){let n=this._getTypeSize(e.format);e.stride=(s=n?.size)!==null&&s!==void 0?s:0,this._updateTypeInfo(e.format)}e instanceof Fo&&this._updateStructInfo(e)}_updateStructInfo(e){var r;let s=0,i=0,n=0,o=0;for(let a=0,c=e.members.length;at.name);ur._samplerTypes=E.sampler_type.map(t=>t.name);function Ty(t){let e={attributes:[],bindings:[]},r;try{r=PU(t)}catch(n){return U.error(n.message)(),e}for(let n of r.uniforms){let o=[];for(let a of n.type?.members||[])o.push({name:a.name,type:US(a.type)});e.bindings.push({type:"uniform",name:n.name,location:n.binding,group:n.group,members:o})}let s=r.entry.vertex[0],i=s?.inputs.length||0;for(let n=0;n`:t.name}function PU(t){try{return new ur(t)}catch(e){if(e instanceof Error)throw e;let r="WGSL parse error";throw typeof e=="object"&&e?.message&&(r+=`: ${e.message} `),typeof e=="object"&&e?.token&&(r+=e.token.line||""),new Error(r,{cause:e})}}var MU=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND const float TWO_PI = 6.2831854820251465; const float PI_2 = 1.5707963705062866; const float PI_16 = 0.1963495463132858; const float SIN_TABLE_0 = 0.19509032368659973; const float SIN_TABLE_1 = 0.3826834261417389; const float SIN_TABLE_2 = 0.5555702447891235; const float SIN_TABLE_3 = 0.7071067690849304; const float COS_TABLE_0 = 0.9807852506637573; const float COS_TABLE_1 = 0.9238795042037964; const float COS_TABLE_2 = 0.8314695954322815; const float COS_TABLE_3 = 0.7071067690849304; const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; float sin_taylor_fp32(float a) { float r, s, t, x; if (a == 0.0) { return 0.0; } x = -a * a; s = a; r = a; r = r * x; t = r * INVERSE_FACTORIAL_3; s = s + t; r = r * x; t = r * INVERSE_FACTORIAL_5; s = s + t; r = r * x; t = r * INVERSE_FACTORIAL_7; s = s + t; r = r * x; t = r * INVERSE_FACTORIAL_9; s = s + t; return s; } void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { if (a == 0.0) { sin_t = 0.0; cos_t = 1.0; } sin_t = sin_taylor_fp32(a); cos_t = sqrt(1.0 - sin_t * sin_t); } float tan_taylor_fp32(float a) { float sin_a; float cos_a; if (a == 0.0) { return 0.0; } float z = floor(a / TWO_PI); float r = a - TWO_PI * z; float t; float q = floor(r / PI_2 + 0.5); int j = int(q); if (j < -2 || j > 2) { return 1.0 / 0.0; } t = r - PI_2 * q; q = floor(t / PI_16 + 0.5); int k = int(q); int abs_k = int(abs(float(k))); if (abs_k > 4) { return 1.0 / 0.0; } else { t = t - PI_16 * q; } float u = 0.0; float v = 0.0; float sin_t, cos_t; float s, c; sincos_taylor_fp32(t, sin_t, cos_t); if (k == 0) { s = sin_t; c = cos_t; } else { if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0; v = SIN_TABLE_0; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1; v = SIN_TABLE_1; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2; v = SIN_TABLE_2; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3; v = SIN_TABLE_3; } if (k > 0) { s = u * sin_t + v * cos_t; c = u * cos_t - v * sin_t; } else { s = u * sin_t - v * cos_t; c = u * cos_t + v * sin_t; } } if (j == 0) { sin_a = s; cos_a = c; } else if (j == 1) { sin_a = c; cos_a = -s; } else if (j == -1) { sin_a = -c; cos_a = s; } else { sin_a = -s; cos_a = -c; } return sin_a / cos_a; } #endif float tan_fp32(float a) { #ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND return tan_taylor_fp32(a); #else return tan(a); #endif } `,by={name:"fp32",vs:MU};var RU=[0,1,1,1],IU=`uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; float useFloatColors; vec3 highlightedObjectColor; vec4 highlightColor; } picking; out vec4 picking_vRGBcolor_Avalid; vec3 picking_normalizeColor(vec3 color) { return picking.useFloatColors > 0.5 ? color : color / 255.0; } vec4 picking_normalizeColor(vec4 color) { return picking.useFloatColors > 0.5 ? color : color / 255.0; } bool picking_isColorZero(vec3 color) { return dot(color, vec3(1.0)) < 0.00001; } bool picking_isColorValid(vec3 color) { return dot(color, vec3(1.0)) > 0.00001; } bool isVertexHighlighted(vec3 vertexColor) { vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); return bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); } void picking_setPickingColor(vec3 pickingColor) { pickingColor = picking_normalizeColor(pickingColor); if (bool(picking.isActive)) { picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); if (!bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.rgb = pickingColor; } } else { picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); } } void picking_setPickingAttribute(float value) { if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.r = value; } } void picking_setPickingAttribute(vec2 value) { if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.rg = value; } } void picking_setPickingAttribute(vec3 value) { if (bool(picking.isAttribute)) { picking_vRGBcolor_Avalid.rgb = value; } } `,BU=`uniform pickingUniforms { float isActive; float isAttribute; float isHighlightActive; float useFloatColors; vec3 highlightedObjectColor; vec4 highlightColor; } picking; in vec4 picking_vRGBcolor_Avalid; vec4 picking_filterHighlightColor(vec4 color) { if (picking.isActive > 0.5) { return color; } bool selected = bool(picking_vRGBcolor_Avalid.a); if (selected) { float highLightAlpha = picking.highlightColor.a; float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); float highLightRatio = highLightAlpha / blendedAlpha; vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); return vec4(blendedRGB, blendedAlpha); } else { return color; } } vec4 picking_filterPickingColor(vec4 color) { if (bool(picking.isActive)) { if (picking_vRGBcolor_Avalid.a == 0.0) { discard; } return picking_vRGBcolor_Avalid; } return color; } vec4 picking_filterColor(vec4 color) { vec4 highlightColor = picking_filterHighlightColor(color); return picking_filterPickingColor(highlightColor); } `,md={name:"picking",vs:IU,fs:BU,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:RU},getUniforms:OU};function OU(t={},e){let r={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let s=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=s}if(t.highlightColor){let s=Array.from(t.highlightColor,i=>i/255);Number.isFinite(s[3])||(s[3]=1),r.highlightColor=s}return t.isActive!==void 0&&(r.isActive=Boolean(t.isActive),r.isAttribute=Boolean(t.isAttribute)),t.useFloatColors!==void 0&&(r.useFloatColors=Boolean(t.useFloatColors)),r}function _d(t,e=[],r=0){let s=Math.fround(t),i=t-s;return e[r]=s,e[r+1]=i,e}function Ey(t){return t-Math.fround(t)}function Sy(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let s=0;s<4;++s){let i=r*4+s;_d(t[s*4+r],e,i*2)}return e}var kS=`uniform float ONE; vec2 split(float a) { const float SPLIT = 4097.0; float t = a * SPLIT; #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float a_hi = t * ONE - (t - a); float a_lo = a * ONE - a_hi; #else float a_hi = t - (t - a); float a_lo = a - a_hi; #endif return vec2(a_hi, a_lo); } vec2 split2(vec2 a) { vec2 b = split(a.x); b.y += a.y; return b; } vec2 quickTwoSum(float a, float b) { #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float sum = (a + b) * ONE; float err = b - (sum - a) * ONE; #else float sum = a + b; float err = b - (sum - a); #endif return vec2(sum, err); } vec2 twoSum(float a, float b) { float s = (a + b); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float v = (s * ONE - a) * ONE; float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v); #else float v = s - a; float err = (a - (s - v)) + (b - v); #endif return vec2(s, err); } vec2 twoSub(float a, float b) { float s = (a - b); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float v = (s * ONE - a) * ONE; float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v); #else float v = s - a; float err = (a - (s - v)) - (b + v); #endif return vec2(s, err); } vec2 twoSqr(float a) { float prod = a * a; vec2 a_fp64 = split(a); #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x * a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE; #else float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; #endif return vec2(prod, err); } vec2 twoProd(float a, float b) { float prod = a * b; vec2 a_fp64 = split(a); vec2 b_fp64 = split(b); float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y + a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y; return vec2(prod, err); } vec2 sum_fp64(vec2 a, vec2 b) { vec2 s, t; s = twoSum(a.x, b.x); t = twoSum(a.y, b.y); s.y += t.x; s = quickTwoSum(s.x, s.y); s.y += t.y; s = quickTwoSum(s.x, s.y); return s; } vec2 sub_fp64(vec2 a, vec2 b) { vec2 s, t; s = twoSub(a.x, b.x); t = twoSub(a.y, b.y); s.y += t.x; s = quickTwoSum(s.x, s.y); s.y += t.y; s = quickTwoSum(s.x, s.y); return s; } vec2 mul_fp64(vec2 a, vec2 b) { vec2 prod = twoProd(a.x, b.x); prod.y += a.x * b.y; #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) prod = split2(prod); #endif prod = quickTwoSum(prod.x, prod.y); prod.y += a.y * b.x; #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) prod = split2(prod); #endif prod = quickTwoSum(prod.x, prod.y); return prod; } vec2 div_fp64(vec2 a, vec2 b) { float xn = 1.0 / b.x; #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) vec2 yn = mul_fp64(a, vec2(xn, 0)); #else vec2 yn = a * xn; #endif float diff = (sub_fp64(a, mul_fp64(b, yn))).x; vec2 prod = twoProd(xn, diff); return sum_fp64(yn, prod); } vec2 sqrt_fp64(vec2 a) { if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); float x = 1.0 / sqrt(a.x); float yn = a.x * x; #if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) vec2 yn_sqr = twoSqr(yn) * ONE; #else vec2 yn_sqr = twoSqr(yn); #endif float diff = sub_fp64(a, yn_sqr).x; vec2 prod = twoProd(x * 0.5, diff); #if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) return sum_fp64(split(yn), prod); #else return sum_fp64(vec2(yn, 0.0), prod); #endif } `;var VS=`const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08); const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09); const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8); const vec2 TWO_PI_FP64 = vec2(6.2831854820251465, -1.7484556025237907e-7); const vec2 PI_2_FP64 = vec2(1.5707963705062866, -4.371139006309477e-8); const vec2 PI_4_FP64 = vec2(0.7853981852531433, -2.1855695031547384e-8); const vec2 PI_16_FP64 = vec2(0.19634954631328583, -5.463923757886846e-9); const vec2 PI_16_2_FP64 = vec2(0.39269909262657166, -1.0927847515773692e-8); const vec2 PI_16_3_FP64 = vec2(0.5890486240386963, -1.4906100798128818e-9); const vec2 PI_180_FP64 = vec2(0.01745329238474369, 1.3519960498364902e-10); const vec2 SIN_TABLE_0_FP64 = vec2(0.19509032368659973, -1.6704714833615242e-9); const vec2 SIN_TABLE_1_FP64 = vec2(0.3826834261417389, 6.22335089017767e-9); const vec2 SIN_TABLE_2_FP64 = vec2(0.5555702447891235, -1.1769521357507529e-8); const vec2 SIN_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617041793133e-8); const vec2 COS_TABLE_0_FP64 = vec2(0.9807852506637573, 2.9739473106360492e-8); const vec2 COS_TABLE_1_FP64 = vec2(0.9238795042037964, 2.8307490351764386e-8); const vec2 COS_TABLE_2_FP64 = vec2(0.8314695954322815, 1.6870263741530778e-8); const vec2 COS_TABLE_3_FP64 = vec2(0.7071067690849304, 1.2101617152815436e-8); const vec2 INVERSE_FACTORIAL_3_FP64 = vec2(1.666666716337204e-01, -4.967053879312289e-09); const vec2 INVERSE_FACTORIAL_4_FP64 = vec2(4.16666679084301e-02, -1.2417634698280722e-09); const vec2 INVERSE_FACTORIAL_5_FP64 = vec2(8.333333767950535e-03, -4.34617203337595e-10); const vec2 INVERSE_FACTORIAL_6_FP64 = vec2(1.3888889225199819e-03, -3.3631094437103215e-11); const vec2 INVERSE_FACTORIAL_7_FP64 = vec2(1.9841270113829523e-04, -2.725596874933456e-12); const vec2 INVERSE_FACTORIAL_8_FP64 = vec2(2.4801587642286904e-05, -3.406996025904184e-13); const vec2 INVERSE_FACTORIAL_9_FP64 = vec2(2.75573188446287533e-06, 3.7935713937038186e-14); const vec2 INVERSE_FACTORIAL_10_FP64 = vec2(2.755731998149713e-07, -7.575112367869873e-15); float nint(float d) { if (d == floor(d)) return d; return floor(d + 0.5); } vec2 nint_fp64(vec2 a) { float hi = nint(a.x); float lo; vec2 tmp; if (hi == a.x) { lo = nint(a.y); tmp = quickTwoSum(hi, lo); } else { lo = 0.0; if (abs(hi - a.x) == 0.5 && a.y < 0.0) { hi -= 1.0; } tmp = vec2(hi, lo); } return tmp; } vec2 exp_fp64(vec2 a) { const int k_power = 4; const float k = 16.0; const float inv_k = 1.0 / k; if (a.x <= -88.0) return vec2(0.0, 0.0); if (a.x >= 88.0) return vec2(1.0 / 0.0, 1.0 / 0.0); if (a.x == 0.0 && a.y == 0.0) return vec2(1.0, 0.0); if (a.x == 1.0 && a.y == 0.0) return E_FP64; float m = floor(a.x / LOG2_FP64.x + 0.5); vec2 r = sub_fp64(a, mul_fp64(LOG2_FP64, vec2(m, 0.0))) * inv_k; vec2 s, t, p; p = mul_fp64(r, r); s = sum_fp64(r, p * 0.5); p = mul_fp64(p, r); t = mul_fp64(p, INVERSE_FACTORIAL_3_FP64); s = sum_fp64(s, t); p = mul_fp64(p, r); t = mul_fp64(p, INVERSE_FACTORIAL_4_FP64); s = sum_fp64(s, t); p = mul_fp64(p, r); t = mul_fp64(p, INVERSE_FACTORIAL_5_FP64); s = sum_fp64(s, t); for (int i = 0; i < k_power; i++) { s = sum_fp64(s * 2.0, mul_fp64(s, s)); } #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) s = sum_fp64(s, vec2(ONE, 0.0)); #else s = sum_fp64(s, vec2(1.0, 0.0)); #endif return s * pow(2.0, m); } vec2 log_fp64(vec2 a) { if (a.x == 1.0 && a.y == 0.0) return vec2(0.0, 0.0); if (a.x <= 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); vec2 x = vec2(log(a.x), 0.0); vec2 s; #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) s = vec2(ONE, 0.0); #else s = vec2(1.0, 0.0); #endif x = sub_fp64(sum_fp64(x, mul_fp64(a, exp_fp64(-x))), s); return x; } vec2 sin_taylor_fp64(vec2 a) { vec2 r, s, t, x; if (a.x == 0.0 && a.y == 0.0) { return vec2(0.0, 0.0); } x = -mul_fp64(a, a); s = a; r = a; r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_3_FP64); s = sum_fp64(s, t); r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_5_FP64); s = sum_fp64(s, t); return s; } vec2 cos_taylor_fp64(vec2 a) { vec2 r, s, t, x; if (a.x == 0.0 && a.y == 0.0) { return vec2(1.0, 0.0); } x = -mul_fp64(a, a); r = x; s = sum_fp64(vec2(1.0, 0.0), r * 0.5); r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_4_FP64); s = sum_fp64(s, t); r = mul_fp64(r, x); t = mul_fp64(r, INVERSE_FACTORIAL_6_FP64); s = sum_fp64(s, t); return s; } void sincos_taylor_fp64(vec2 a, out vec2 sin_t, out vec2 cos_t) { if (a.x == 0.0 && a.y == 0.0) { sin_t = vec2(0.0, 0.0); cos_t = vec2(1.0, 0.0); } sin_t = sin_taylor_fp64(a); cos_t = sqrt_fp64(sub_fp64(vec2(1.0, 0.0), mul_fp64(sin_t, sin_t))); } vec2 sin_fp64(vec2 a) { if (a.x == 0.0 && a.y == 0.0) { return vec2(0.0, 0.0); } vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64)); vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z)); vec2 t; float q = floor(r.x / PI_2_FP64.x + 0.5); int j = int(q); if (j < -2 || j > 2) { return vec2(0.0 / 0.0, 0.0 / 0.0); } t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0))); q = floor(t.x / PI_16_FP64.x + 0.5); int k = int(q); if (k == 0) { if (j == 0) { return sin_taylor_fp64(t); } else if (j == 1) { return cos_taylor_fp64(t); } else if (j == -1) { return -cos_taylor_fp64(t); } else { return -sin_taylor_fp64(t); } } int abs_k = int(abs(float(k))); if (abs_k > 4) { return vec2(0.0 / 0.0, 0.0 / 0.0); } else { t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0))); } vec2 u = vec2(0.0, 0.0); vec2 v = vec2(0.0, 0.0); #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #else if (abs_k == 1) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs_k == 2) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs_k == 3) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs_k == 4) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #endif vec2 sin_t, cos_t; sincos_taylor_fp64(t, sin_t, cos_t); vec2 result = vec2(0.0, 0.0); if (j == 0) { if (k > 0) { result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } } else if (j == 1) { if (k > 0) { result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } else { result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } else if (j == -1) { if (k > 0) { result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t)); } else { result = -sum_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t)); } } else { if (k > 0) { result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t)); } } return result; } vec2 cos_fp64(vec2 a) { if (a.x == 0.0 && a.y == 0.0) { return vec2(1.0, 0.0); } vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64)); vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z)); vec2 t; float q = floor(r.x / PI_2_FP64.x + 0.5); int j = int(q); if (j < -2 || j > 2) { return vec2(0.0 / 0.0, 0.0 / 0.0); } t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0))); q = floor(t.x / PI_16_FP64.x + 0.5); int k = int(q); if (k == 0) { if (j == 0) { return cos_taylor_fp64(t); } else if (j == 1) { return -sin_taylor_fp64(t); } else if (j == -1) { return sin_taylor_fp64(t); } else { return -cos_taylor_fp64(t); } } int abs_k = int(abs(float(k))); if (abs_k > 4) { return vec2(0.0 / 0.0, 0.0 / 0.0); } else { t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0))); } vec2 u = vec2(0.0, 0.0); vec2 v = vec2(0.0, 0.0); #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #else if (abs_k == 1) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs_k == 2) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs_k == 3) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs_k == 4) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #endif vec2 sin_t, cos_t; sincos_taylor_fp64(t, sin_t, cos_t); vec2 result = vec2(0.0, 0.0); if (j == 0) { if (k > 0) { result = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } else { result = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } else if (j == 1) { if (k > 0) { result = -sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(v, cos_t), mul_fp64(u, sin_t)); } } else if (j == -1) { if (k > 0) { result = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } else { result = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); } } else { if (k > 0) { result = sub_fp64(mul_fp64(v, sin_t), mul_fp64(u, cos_t)); } else { result = -sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } return result; } vec2 tan_fp64(vec2 a) { vec2 sin_a; vec2 cos_a; if (a.x == 0.0 && a.y == 0.0) { return vec2(0.0, 0.0); } vec2 z = nint_fp64(div_fp64(a, TWO_PI_FP64)); vec2 r = sub_fp64(a, mul_fp64(TWO_PI_FP64, z)); vec2 t; float q = floor(r.x / PI_2_FP64.x + 0.5); int j = int(q); if (j < -2 || j > 2) { return vec2(0.0 / 0.0, 0.0 / 0.0); } t = sub_fp64(r, mul_fp64(PI_2_FP64, vec2(q, 0.0))); q = floor(t.x / PI_16_FP64.x + 0.5); int k = int(q); int abs_k = int(abs(float(k))); if (abs_k > 4) { return vec2(0.0 / 0.0, 0.0 / 0.0); } else { t = sub_fp64(t, mul_fp64(PI_16_FP64, vec2(q, 0.0))); } vec2 u = vec2(0.0, 0.0); vec2 v = vec2(0.0, 0.0); vec2 sin_t, cos_t; vec2 s, c; sincos_taylor_fp64(t, sin_t, cos_t); if (k == 0) { s = sin_t; c = cos_t; } else { #if defined(NVIDIA_FP64_WORKAROUND) || defined(INTEL_FP64_WORKAROUND) if (abs(float(abs_k) - 1.0) < 0.5) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs(float(abs_k) - 2.0) < 0.5) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs(float(abs_k) - 3.0) < 0.5) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs(float(abs_k) - 4.0) < 0.5) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #else if (abs_k == 1) { u = COS_TABLE_0_FP64; v = SIN_TABLE_0_FP64; } else if (abs_k == 2) { u = COS_TABLE_1_FP64; v = SIN_TABLE_1_FP64; } else if (abs_k == 3) { u = COS_TABLE_2_FP64; v = SIN_TABLE_2_FP64; } else if (abs_k == 4) { u = COS_TABLE_3_FP64; v = SIN_TABLE_3_FP64; } #endif if (k > 0) { s = sum_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); c = sub_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } else { s = sub_fp64(mul_fp64(u, sin_t), mul_fp64(v, cos_t)); c = sum_fp64(mul_fp64(u, cos_t), mul_fp64(v, sin_t)); } } if (j == 0) { sin_a = s; cos_a = c; } else if (j == 1) { sin_a = c; cos_a = -s; } else if (j == -1) { sin_a = -c; cos_a = s; } else { sin_a = -s; cos_a = -c; } return div_fp64(sin_a, cos_a); } vec2 radians_fp64(vec2 degree) { return mul_fp64(degree, PI_180_FP64); } vec2 mix_fp64(vec2 a, vec2 b, float x) { vec2 range = sub_fp64(b, a); return sum_fp64(a, mul_fp64(range, vec2(x, 0.0))); } void vec2_sum_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = sum_fp64(a[0], b[0]); out_val[1] = sum_fp64(a[1], b[1]); } void vec2_sub_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = sub_fp64(a[0], b[0]); out_val[1] = sub_fp64(a[1], b[1]); } void vec2_mul_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = mul_fp64(a[0], b[0]); out_val[1] = mul_fp64(a[1], b[1]); } void vec2_div_fp64(vec2 a[2], vec2 b[2], out vec2 out_val[2]) { out_val[0] = div_fp64(a[0], b[0]); out_val[1] = div_fp64(a[1], b[1]); } void vec2_mix_fp64(vec2 x[2], vec2 y[2], float a, out vec2 out_val[2]) { vec2 range[2]; vec2_sub_fp64(y, x, range); vec2 portion[2]; portion[0] = range[0] * a; portion[1] = range[1] * a; vec2_sum_fp64(x, portion, out_val); } vec2 vec2_length_fp64(vec2 x[2]) { return sqrt_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1]))); } void vec2_normalize_fp64(vec2 x[2], out vec2 out_val[2]) { vec2 length = vec2_length_fp64(x); vec2 length_vec2[2]; length_vec2[0] = length; length_vec2[1] = length; vec2_div_fp64(x, length_vec2, out_val); } vec2 vec2_distance_fp64(vec2 x[2], vec2 y[2]) { vec2 diff[2]; vec2_sub_fp64(x, y, diff); return vec2_length_fp64(diff); } vec2 vec2_dot_fp64(vec2 a[2], vec2 b[2]) { vec2 v[2]; v[0] = mul_fp64(a[0], b[0]); v[1] = mul_fp64(a[1], b[1]); return sum_fp64(v[0], v[1]); } void vec3_sub_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) { for (int i = 0; i < 3; i++) { out_val[i] = sum_fp64(a[i], b[i]); } } void vec3_sum_fp64(vec2 a[3], vec2 b[3], out vec2 out_val[3]) { for (int i = 0; i < 3; i++) { out_val[i] = sum_fp64(a[i], b[i]); } } vec2 vec3_length_fp64(vec2 x[3]) { return sqrt_fp64(sum_fp64(sum_fp64(mul_fp64(x[0], x[0]), mul_fp64(x[1], x[1])), mul_fp64(x[2], x[2]))); } vec2 vec3_distance_fp64(vec2 x[3], vec2 y[3]) { vec2 diff[3]; vec3_sub_fp64(x, y, diff); return vec3_length_fp64(diff); } void vec4_fp64(vec4 a, out vec2 out_val[4]) { out_val[0].x = a[0]; out_val[0].y = 0.0; out_val[1].x = a[1]; out_val[1].y = 0.0; out_val[2].x = a[2]; out_val[2].y = 0.0; out_val[3].x = a[3]; out_val[3].y = 0.0; } void vec4_scalar_mul_fp64(vec2 a[4], vec2 b, out vec2 out_val[4]) { out_val[0] = mul_fp64(a[0], b); out_val[1] = mul_fp64(a[1], b); out_val[2] = mul_fp64(a[2], b); out_val[3] = mul_fp64(a[3], b); } void vec4_sum_fp64(vec2 a[4], vec2 b[4], out vec2 out_val[4]) { for (int i = 0; i < 4; i++) { out_val[i] = sum_fp64(a[i], b[i]); } } void vec4_dot_fp64(vec2 a[4], vec2 b[4], out vec2 out_val) { vec2 v[4]; v[0] = mul_fp64(a[0], b[0]); v[1] = mul_fp64(a[1], b[1]); v[2] = mul_fp64(a[2], b[2]); v[3] = mul_fp64(a[3], b[3]); out_val = sum_fp64(sum_fp64(v[0], v[1]), sum_fp64(v[2], v[3])); } void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) { vec2 tmp[4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { tmp[j] = b[j + i * 4]; } vec4_dot_fp64(a, tmp, out_val[i]); } } `;var FU={ONE:1};function LU(){return FU}var Ls={name:"fp64-arithmetic",vs:kS,getUniforms:LU,fp64ify:_d,fp64LowPart:Ey,fp64ifyMatrix4:Sy},yd={name:"fp64",vs:VS,dependencies:[Ls],fp64ify:_d,fp64LowPart:Ey,fp64ifyMatrix4:Sy};var NU=1/Math.PI*180,DU=1/180*Math.PI,UU={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...UU}};var Se=globalThis.mathgl.config;function tl(t,{precision:e=Se.precision}={}){return t=kU(t),`${parseFloat(t.toPrecision(e))}`}function er(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function vy(t){return _n(t)}function Cy(t){return Je(t)}function _n(t,e){return wy(t,r=>r*DU,e)}function Je(t,e){return wy(t,r=>r*NU,e)}function fe(t,e,r){return wy(t,s=>Math.max(e,Math.min(r,s)))}function it(t,e,r){return er(t)?t.map((s,i)=>it(s,e[i],r)):r*e+(1-r)*t}function Ce(t,e,r){let s=Se.EPSILON;r&&(Se.EPSILON=r);try{if(t===e)return!0;if(er(t)&&er(e)){if(t.length!==e.length)return!1;for(let i=0;i0?", ":"")+tl(this[s],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r=0&&e=0&&eXU,angle:()=>c4,ceil:()=>YU,clone:()=>HU,copy:()=>WU,create:()=>zS,cross:()=>i4,dist:()=>_4,distance:()=>jS,div:()=>m4,divide:()=>WS,dot:()=>s4,equals:()=>h4,exactEquals:()=>f4,floor:()=>qU,forEach:()=>A4,fromValues:()=>GU,inverse:()=>t4,len:()=>d4,length:()=>YS,lerp:()=>n4,max:()=>$U,min:()=>KU,mul:()=>g4,multiply:()=>GS,negate:()=>e4,normalize:()=>r4,random:()=>o4,rotate:()=>a4,round:()=>JU,scale:()=>ZU,scaleAndAdd:()=>QU,set:()=>jU,sqrDist:()=>y4,sqrLen:()=>x4,squaredDistance:()=>XS,squaredLength:()=>qS,str:()=>u4,sub:()=>p4,subtract:()=>HS,transformMat2:()=>Py,transformMat2d:()=>My,transformMat3:()=>rl,transformMat4:()=>sl,zero:()=>l4});var we=typeof Float32Array<"u"?Float32Array:Array,fs=Math.random;function fr(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var fce=Math.PI/180;function zS(){let t=new we(2);return we!=Float32Array&&(t[0]=0,t[1]=0),t}function HU(t){let e=new we(2);return e[0]=t[0],e[1]=t[1],e}function GU(t,e){let r=new we(2);return r[0]=t,r[1]=e,r}function WU(t,e){return t[0]=e[0],t[1]=e[1],t}function jU(t,e,r){return t[0]=e,t[1]=r,t}function XU(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function HS(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function GS(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function WS(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function YU(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function qU(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function KU(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function $U(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function JU(t,e){return t[0]=fr(e[0]),t[1]=fr(e[1]),t}function ZU(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function QU(t,e,r,s){return t[0]=e[0]+r[0]*s,t[1]=e[1]+r[1]*s,t}function jS(t,e){let r=e[0]-t[0],s=e[1]-t[1];return Math.sqrt(r*r+s*s)}function XS(t,e){let r=e[0]-t[0],s=e[1]-t[1];return r*r+s*s}function YS(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function qS(t){let e=t[0],r=t[1];return e*e+r*r}function e4(t,e){return t[0]=-e[0],t[1]=-e[1],t}function t4(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function r4(t,e){let r=e[0],s=e[1],i=r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}function s4(t,e){return t[0]*e[0]+t[1]*e[1]}function i4(t,e,r){let s=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=s,t}function n4(t,e,r,s){let i=e[0],n=e[1];return t[0]=i+s*(r[0]-i),t[1]=n+s*(r[1]-n),t}function o4(t,e){e=e===void 0?1:e;let r=fs()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function Py(t,e,r){let s=e[0],i=e[1];return t[0]=r[0]*s+r[2]*i,t[1]=r[1]*s+r[3]*i,t}function My(t,e,r){let s=e[0],i=e[1];return t[0]=r[0]*s+r[2]*i+r[4],t[1]=r[1]*s+r[3]*i+r[5],t}function rl(t,e,r){let s=e[0],i=e[1];return t[0]=r[0]*s+r[3]*i+r[6],t[1]=r[1]*s+r[4]*i+r[7],t}function sl(t,e,r){let s=e[0],i=e[1];return t[0]=r[0]*s+r[4]*i+r[12],t[1]=r[1]*s+r[5]*i+r[13],t}function a4(t,e,r,s){let i=e[0]-r[0],n=e[1]-r[1],o=Math.sin(s),a=Math.cos(s);return t[0]=i*a-n*o+r[0],t[1]=i*o+n*a+r[1],t}function c4(t,e){let r=t[0],s=t[1],i=e[0],n=e[1],o=Math.sqrt((r*r+s*s)*(i*i+n*n)),a=o&&(r*i+s*n)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function l4(t){return t[0]=0,t[1]=0,t}function u4(t){return`vec2(${t[0]}, ${t[1]})`}function f4(t,e){return t[0]===e[0]&&t[1]===e[1]}function h4(t,e){let r=t[0],s=t[1],i=e[0],n=e[1];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(s-n)<=1e-6*Math.max(1,Math.abs(s),Math.abs(n))}var d4=YS,p4=HS,g4=GS,m4=WS,_4=jS,y4=XS,x4=qS,A4=function(){let t=zS();return function(e,r,s,i,n,o){let a,c;for(r||(r=2),s||(s=0),i?c=Math.min(i*r+s,e.length):c=e.length,a=s;aS4,angle:()=>Fy,bezier:()=>D4,ceil:()=>v4,clone:()=>T4,copy:()=>b4,create:()=>bd,cross:()=>yn,dist:()=>X4,distance:()=>ev,div:()=>j4,divide:()=>QS,dot:()=>il,equals:()=>H4,exactEquals:()=>z4,floor:()=>C4,forEach:()=>K4,fromValues:()=>Sd,hermite:()=>N4,inverse:()=>O4,len:()=>Ly,length:()=>Ed,lerp:()=>F4,max:()=>P4,min:()=>w4,mul:()=>W4,multiply:()=>ZS,negate:()=>B4,normalize:()=>Ry,random:()=>U4,rotateX:()=>Iy,rotateY:()=>By,rotateZ:()=>Oy,round:()=>M4,scale:()=>R4,scaleAndAdd:()=>I4,set:()=>E4,slerp:()=>L4,sqrDist:()=>Y4,sqrLen:()=>q4,squaredDistance:()=>tv,squaredLength:()=>rv,str:()=>V4,sub:()=>G4,subtract:()=>JS,transformMat3:()=>nl,transformMat4:()=>xn,transformQuat:()=>ol,zero:()=>k4});function bd(){let t=new we(3);return we!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function T4(t){let e=new we(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ed(t){let e=t[0],r=t[1],s=t[2];return Math.sqrt(e*e+r*r+s*s)}function Sd(t,e,r){let s=new we(3);return s[0]=t,s[1]=e,s[2]=r,s}function b4(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function E4(t,e,r,s){return t[0]=e,t[1]=r,t[2]=s,t}function S4(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function JS(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function ZS(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function QS(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function v4(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function C4(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function w4(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function P4(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function M4(t,e){return t[0]=fr(e[0]),t[1]=fr(e[1]),t[2]=fr(e[2]),t}function R4(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function I4(t,e,r,s){return t[0]=e[0]+r[0]*s,t[1]=e[1]+r[1]*s,t[2]=e[2]+r[2]*s,t}function ev(t,e){let r=e[0]-t[0],s=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+s*s+i*i)}function tv(t,e){let r=e[0]-t[0],s=e[1]-t[1],i=e[2]-t[2];return r*r+s*s+i*i}function rv(t){let e=t[0],r=t[1],s=t[2];return e*e+r*r+s*s}function B4(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function O4(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Ry(t,e){let r=e[0],s=e[1],i=e[2],n=r*r+s*s+i*i;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function il(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function yn(t,e,r){let s=e[0],i=e[1],n=e[2],o=r[0],a=r[1],c=r[2];return t[0]=i*c-n*a,t[1]=n*o-s*c,t[2]=s*a-i*o,t}function F4(t,e,r,s){let i=e[0],n=e[1],o=e[2];return t[0]=i+s*(r[0]-i),t[1]=n+s*(r[1]-n),t[2]=o+s*(r[2]-o),t}function L4(t,e,r,s){let i=Math.acos(Math.min(Math.max(il(e,r),-1),1)),n=Math.sin(i),o=Math.sin((1-s)*i)/n,a=Math.sin(s*i)/n;return t[0]=o*e[0]+a*r[0],t[1]=o*e[1]+a*r[1],t[2]=o*e[2]+a*r[2],t}function N4(t,e,r,s,i,n){let o=n*n,a=o*(2*n-3)+1,c=o*(n-2)+n,l=o*(n-1),u=o*(3-2*n);return t[0]=e[0]*a+r[0]*c+s[0]*l+i[0]*u,t[1]=e[1]*a+r[1]*c+s[1]*l+i[1]*u,t[2]=e[2]*a+r[2]*c+s[2]*l+i[2]*u,t}function D4(t,e,r,s,i,n){let o=1-n,a=o*o,c=n*n,l=a*o,u=3*n*a,f=3*c*o,h=c*n;return t[0]=e[0]*l+r[0]*u+s[0]*f+i[0]*h,t[1]=e[1]*l+r[1]*u+s[1]*f+i[1]*h,t[2]=e[2]*l+r[2]*u+s[2]*f+i[2]*h,t}function U4(t,e){e=e===void 0?1:e;let r=fs()*2*Math.PI,s=fs()*2-1,i=Math.sqrt(1-s*s)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=s*e,t}function xn(t,e,r){let s=e[0],i=e[1],n=e[2],o=r[3]*s+r[7]*i+r[11]*n+r[15];return o=o||1,t[0]=(r[0]*s+r[4]*i+r[8]*n+r[12])/o,t[1]=(r[1]*s+r[5]*i+r[9]*n+r[13])/o,t[2]=(r[2]*s+r[6]*i+r[10]*n+r[14])/o,t}function nl(t,e,r){let s=e[0],i=e[1],n=e[2];return t[0]=s*r[0]+i*r[3]+n*r[6],t[1]=s*r[1]+i*r[4]+n*r[7],t[2]=s*r[2]+i*r[5]+n*r[8],t}function ol(t,e,r){let s=r[0],i=r[1],n=r[2],o=r[3],a=e[0],c=e[1],l=e[2],u=i*l-n*c,f=n*a-s*l,h=s*c-i*a,d=i*h-n*f,p=n*u-s*h,g=s*f-i*u,m=o*2;return u*=m,f*=m,h*=m,d*=2,p*=2,g*=2,t[0]=a+u+d,t[1]=c+f+p,t[2]=l+h+g,t}function Iy(t,e,r,s){let i=[],n=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],n[0]=i[0],n[1]=i[1]*Math.cos(s)-i[2]*Math.sin(s),n[2]=i[1]*Math.sin(s)+i[2]*Math.cos(s),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function By(t,e,r,s){let i=[],n=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],n[0]=i[2]*Math.sin(s)+i[0]*Math.cos(s),n[1]=i[1],n[2]=i[2]*Math.cos(s)-i[0]*Math.sin(s),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Oy(t,e,r,s){let i=[],n=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],n[0]=i[0]*Math.cos(s)-i[1]*Math.sin(s),n[1]=i[0]*Math.sin(s)+i[1]*Math.cos(s),n[2]=i[2],t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Fy(t,e){let r=t[0],s=t[1],i=t[2],n=e[0],o=e[1],a=e[2],c=Math.sqrt((r*r+s*s+i*i)*(n*n+o*o+a*a)),l=c&&il(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function k4(t){return t[0]=0,t[1]=0,t[2]=0,t}function V4(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function z4(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function H4(t,e){let r=t[0],s=t[1],i=t[2],n=e[0],o=e[1],a=e[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(s-o)<=1e-6*Math.max(1,Math.abs(s),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}var G4=JS,W4=ZS,j4=QS,X4=ev,Y4=tv,Ly=Ed,q4=rv,K4=function(){let t=bd();return function(e,r,s,i,n,o){let a,c;for(r||(r=3),s||(s=0),i?c=Math.min(i*r+s,e.length):c=e.length,a=s;a0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(J4)}fromObject(e){return this.check()}fromQuaternion(e){return lv(this,e),this.check()}set(e,r,s,i,n,o,a,c,l){return this[0]=e,this[1]=r,this[2]=s,this[3]=i,this[4]=n,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,s,i,n,o,a,c,l){return this[0]=e,this[1]=i,this[2]=a,this[3]=r,this[4]=n,this[5]=c,this[6]=s,this[7]=o,this[8]=l,this.check()}determinant(){return ov(this)}transpose(){return iv(this,this),this.check()}invert(){return nv(this,this),this.check()}multiplyLeft(e){return Dy(this,e,this),this.check()}multiplyRight(e){return Dy(this,this,e),this.check()}rotate(e){return cv(this,this,e),this.check()}scale(e){return Array.isArray(e)?Uy(this,this,e):Uy(this,this,[e,e]),this.check()}translate(e){return av(this,this,e),this.check()}transform(e,r){let s;switch(e.length){case 2:s=rl(r||[-0,-0],e,this);break;case 3:s=nl(r||[-0,-0,-0],e,this);break;case 4:s=Td(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ei(s,e.length),s}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},wd,Pd=null;function Z4(){return wd||(wd=new me([0,0,0,0,0,0,0,0,0]),Object.freeze(wd)),wd}function Q4(){return Pd||(Pd=new me,Object.freeze(Pd)),Pd}var ke={};Ke(ke,{add:()=>Sk,adjoint:()=>nk,clone:()=>tk,copy:()=>rk,create:()=>ek,decompose:()=>gk,determinant:()=>Hy,equals:()=>Pk,exactEquals:()=>wk,frob:()=>Ek,fromQuat:()=>Ky,fromQuat2:()=>hk,fromRotation:()=>ck,fromRotationTranslation:()=>fv,fromRotationTranslationScale:()=>mk,fromRotationTranslationScaleOrigin:()=>_k,fromScaling:()=>ak,fromTranslation:()=>ok,fromValues:()=>sk,fromXRotation:()=>lk,fromYRotation:()=>uk,fromZRotation:()=>fk,frustum:()=>$y,getRotation:()=>pk,getScaling:()=>hv,getTranslation:()=>dk,identity:()=>uv,invert:()=>zy,lookAt:()=>Qy,mul:()=>Mk,multiply:()=>al,multiplyScalar:()=>vk,multiplyScalarAndAdd:()=>Ck,ortho:()=>Zy,orthoNO:()=>pv,orthoZO:()=>Ak,perspective:()=>Jy,perspectiveFromFieldOfView:()=>xk,perspectiveNO:()=>dv,perspectiveZO:()=>yk,rotate:()=>jy,rotateX:()=>Xy,rotateY:()=>Yy,rotateZ:()=>qy,scale:()=>Wy,set:()=>ik,str:()=>bk,sub:()=>Rk,subtract:()=>gv,targetTo:()=>Tk,translate:()=>Gy,transpose:()=>Vy});function ek(){let t=new we(16);return we!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function tk(t){let e=new we(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function rk(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function sk(t,e,r,s,i,n,o,a,c,l,u,f,h,d,p,g){let m=new we(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=s,m[4]=i,m[5]=n,m[6]=o,m[7]=a,m[8]=c,m[9]=l,m[10]=u,m[11]=f,m[12]=h,m[13]=d,m[14]=p,m[15]=g,m}function ik(t,e,r,s,i,n,o,a,c,l,u,f,h,d,p,g,m){return t[0]=e,t[1]=r,t[2]=s,t[3]=i,t[4]=n,t[5]=o,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=f,t[11]=h,t[12]=d,t[13]=p,t[14]=g,t[15]=m,t}function uv(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Vy(t,e){if(t===e){let r=e[1],s=e[2],i=e[3],n=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=s,t[9]=n,t[11]=e[14],t[12]=i,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function zy(t,e){let r=e[0],s=e[1],i=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],y=r*a-s*o,x=r*c-i*o,S=r*l-n*o,P=s*c-i*a,B=s*l-n*a,L=i*l-n*c,M=u*g-f*p,v=u*m-h*p,T=u*_-d*p,D=f*m-h*g,V=f*_-d*g,z=h*_-d*m,W=y*z-x*V+S*D+P*T-B*v+L*M;return W?(W=1/W,t[0]=(a*z-c*V+l*D)*W,t[1]=(i*V-s*z-n*D)*W,t[2]=(g*L-m*B+_*P)*W,t[3]=(h*B-f*L-d*P)*W,t[4]=(c*T-o*z-l*v)*W,t[5]=(r*z-i*T+n*v)*W,t[6]=(m*S-p*L-_*x)*W,t[7]=(u*L-h*S+d*x)*W,t[8]=(o*V-a*T+l*M)*W,t[9]=(s*T-r*V-n*M)*W,t[10]=(p*B-g*S+_*y)*W,t[11]=(f*S-u*B-d*y)*W,t[12]=(a*v-o*D-c*M)*W,t[13]=(r*D-s*v+i*M)*W,t[14]=(g*x-p*P-m*y)*W,t[15]=(u*P-f*x+h*y)*W,t):null}function nk(t,e){let r=e[0],s=e[1],i=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],y=r*a-s*o,x=r*c-i*o,S=r*l-n*o,P=s*c-i*a,B=s*l-n*a,L=i*l-n*c,M=u*g-f*p,v=u*m-h*p,T=u*_-d*p,D=f*m-h*g,V=f*_-d*g,z=h*_-d*m;return t[0]=a*z-c*V+l*D,t[1]=i*V-s*z-n*D,t[2]=g*L-m*B+_*P,t[3]=h*B-f*L-d*P,t[4]=c*T-o*z-l*v,t[5]=r*z-i*T+n*v,t[6]=m*S-p*L-_*x,t[7]=u*L-h*S+d*x,t[8]=o*V-a*T+l*M,t[9]=s*T-r*V-n*M,t[10]=p*B-g*S+_*y,t[11]=f*S-u*B-d*y,t[12]=a*v-o*D-c*M,t[13]=r*D-s*v+i*M,t[14]=g*x-p*P-m*y,t[15]=u*P-f*x+h*y,t}function Hy(t){let e=t[0],r=t[1],s=t[2],i=t[3],n=t[4],o=t[5],a=t[6],c=t[7],l=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],m=t[15],_=e*o-r*n,y=e*a-s*n,x=r*a-s*o,S=l*p-u*d,P=l*g-f*d,B=u*g-f*p,L=e*B-r*P+s*S,M=n*B-o*P+a*S,v=l*x-u*y+f*_,T=d*x-p*y+g*_;return c*L-i*M+m*v-h*T}function al(t,e,r){let s=e[0],i=e[1],n=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],m=e[13],_=e[14],y=e[15],x=r[0],S=r[1],P=r[2],B=r[3];return t[0]=x*s+S*a+P*f+B*g,t[1]=x*i+S*c+P*h+B*m,t[2]=x*n+S*l+P*d+B*_,t[3]=x*o+S*u+P*p+B*y,x=r[4],S=r[5],P=r[6],B=r[7],t[4]=x*s+S*a+P*f+B*g,t[5]=x*i+S*c+P*h+B*m,t[6]=x*n+S*l+P*d+B*_,t[7]=x*o+S*u+P*p+B*y,x=r[8],S=r[9],P=r[10],B=r[11],t[8]=x*s+S*a+P*f+B*g,t[9]=x*i+S*c+P*h+B*m,t[10]=x*n+S*l+P*d+B*_,t[11]=x*o+S*u+P*p+B*y,x=r[12],S=r[13],P=r[14],B=r[15],t[12]=x*s+S*a+P*f+B*g,t[13]=x*i+S*c+P*h+B*m,t[14]=x*n+S*l+P*d+B*_,t[15]=x*o+S*u+P*p+B*y,t}function Gy(t,e,r){let s=r[0],i=r[1],n=r[2],o,a,c,l,u,f,h,d,p,g,m,_;return e===t?(t[12]=e[0]*s+e[4]*i+e[8]*n+e[12],t[13]=e[1]*s+e[5]*i+e[9]*n+e[13],t[14]=e[2]*s+e[6]*i+e[10]*n+e[14],t[15]=e[3]*s+e[7]*i+e[11]*n+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],p=e[8],g=e[9],m=e[10],_=e[11],t[0]=o,t[1]=a,t[2]=c,t[3]=l,t[4]=u,t[5]=f,t[6]=h,t[7]=d,t[8]=p,t[9]=g,t[10]=m,t[11]=_,t[12]=o*s+u*i+p*n+e[12],t[13]=a*s+f*i+g*n+e[13],t[14]=c*s+h*i+m*n+e[14],t[15]=l*s+d*i+_*n+e[15]),t}function Wy(t,e,r){let s=r[0],i=r[1],n=r[2];return t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function jy(t,e,r,s){let i=s[0],n=s[1],o=s[2],a=Math.sqrt(i*i+n*n+o*o),c,l,u,f,h,d,p,g,m,_,y,x,S,P,B,L,M,v,T,D,V,z,W,Z;return a<1e-6?null:(a=1/a,i*=a,n*=a,o*=a,l=Math.sin(r),c=Math.cos(r),u=1-c,f=e[0],h=e[1],d=e[2],p=e[3],g=e[4],m=e[5],_=e[6],y=e[7],x=e[8],S=e[9],P=e[10],B=e[11],L=i*i*u+c,M=n*i*u+o*l,v=o*i*u-n*l,T=i*n*u-o*l,D=n*n*u+c,V=o*n*u+i*l,z=i*o*u+n*l,W=n*o*u-i*l,Z=o*o*u+c,t[0]=f*L+g*M+x*v,t[1]=h*L+m*M+S*v,t[2]=d*L+_*M+P*v,t[3]=p*L+y*M+B*v,t[4]=f*T+g*D+x*V,t[5]=h*T+m*D+S*V,t[6]=d*T+_*D+P*V,t[7]=p*T+y*D+B*V,t[8]=f*z+g*W+x*Z,t[9]=h*z+m*W+S*Z,t[10]=d*z+_*W+P*Z,t[11]=p*z+y*W+B*Z,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Xy(t,e,r){let s=Math.sin(r),i=Math.cos(r),n=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*i+l*s,t[5]=o*i+u*s,t[6]=a*i+f*s,t[7]=c*i+h*s,t[8]=l*i-n*s,t[9]=u*i-o*s,t[10]=f*i-a*s,t[11]=h*i-c*s,t}function Yy(t,e,r){let s=Math.sin(r),i=Math.cos(r),n=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*i-l*s,t[1]=o*i-u*s,t[2]=a*i-f*s,t[3]=c*i-h*s,t[8]=n*s+l*i,t[9]=o*s+u*i,t[10]=a*s+f*i,t[11]=c*s+h*i,t}function qy(t,e,r){let s=Math.sin(r),i=Math.cos(r),n=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*i+l*s,t[1]=o*i+u*s,t[2]=a*i+f*s,t[3]=c*i+h*s,t[4]=l*i-n*s,t[5]=u*i-o*s,t[6]=f*i-a*s,t[7]=h*i-c*s,t}function ok(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function ak(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ck(t,e,r){let s=r[0],i=r[1],n=r[2],o=Math.sqrt(s*s+i*i+n*n),a,c,l;return o<1e-6?null:(o=1/o,s*=o,i*=o,n*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=s*s*l+a,t[1]=i*s*l+n*c,t[2]=n*s*l-i*c,t[3]=0,t[4]=s*i*l-n*c,t[5]=i*i*l+a,t[6]=n*i*l+s*c,t[7]=0,t[8]=s*n*l+i*c,t[9]=i*n*l-s*c,t[10]=n*n*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function lk(t,e){let r=Math.sin(e),s=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function uk(t,e){let r=Math.sin(e),s=Math.cos(e);return t[0]=s,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fk(t,e){let r=Math.sin(e),s=Math.cos(e);return t[0]=s,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function fv(t,e,r){let s=e[0],i=e[1],n=e[2],o=e[3],a=s+s,c=i+i,l=n+n,u=s*a,f=s*c,h=s*l,d=i*c,p=i*l,g=n*l,m=o*a,_=o*c,y=o*l;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-_,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+m,t[7]=0,t[8]=h+_,t[9]=p-m,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function hk(t,e){let r=new we(3),s=-e[0],i=-e[1],n=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=s*s+i*i+n*n+o*o;return f>0?(r[0]=(a*o+u*s+c*n-l*i)*2/f,r[1]=(c*o+u*i+l*s-a*n)*2/f,r[2]=(l*o+u*n+a*i-c*s)*2/f):(r[0]=(a*o+u*s+c*n-l*i)*2,r[1]=(c*o+u*i+l*s-a*n)*2,r[2]=(l*o+u*n+a*i-c*s)*2),fv(t,e,r),t}function dk(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function hv(t,e){let r=e[0],s=e[1],i=e[2],n=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return t[0]=Math.sqrt(r*r+s*s+i*i),t[1]=Math.sqrt(n*n+o*o+a*a),t[2]=Math.sqrt(c*c+l*l+u*u),t}function pk(t,e){let r=new we(3);hv(r,e);let s=1/r[0],i=1/r[1],n=1/r[2],o=e[0]*s,a=e[1]*i,c=e[2]*n,l=e[4]*s,u=e[5]*i,f=e[6]*n,h=e[8]*s,d=e[9]*i,p=e[10]*n,g=o+u+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,t[3]=.25*m,t[0]=(f-d)/m,t[1]=(h-c)/m,t[2]=(a-l)/m):o>u&&o>p?(m=Math.sqrt(1+o-u-p)*2,t[3]=(f-d)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(h+c)/m):u>p?(m=Math.sqrt(1+u-o-p)*2,t[3]=(h-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(f+d)/m):(m=Math.sqrt(1+p-o-u)*2,t[3]=(a-l)/m,t[0]=(h+c)/m,t[1]=(f+d)/m,t[2]=.25*m),t}function gk(t,e,r,s){e[0]=s[12],e[1]=s[13],e[2]=s[14];let i=s[0],n=s[1],o=s[2],a=s[4],c=s[5],l=s[6],u=s[8],f=s[9],h=s[10];r[0]=Math.sqrt(i*i+n*n+o*o),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(u*u+f*f+h*h);let d=1/r[0],p=1/r[1],g=1/r[2],m=i*d,_=n*p,y=o*g,x=a*d,S=c*p,P=l*g,B=u*d,L=f*p,M=h*g,v=m+S+M,T=0;return v>0?(T=Math.sqrt(v+1)*2,t[3]=.25*T,t[0]=(P-L)/T,t[1]=(B-y)/T,t[2]=(_-x)/T):m>S&&m>M?(T=Math.sqrt(1+m-S-M)*2,t[3]=(P-L)/T,t[0]=.25*T,t[1]=(_+x)/T,t[2]=(B+y)/T):S>M?(T=Math.sqrt(1+S-m-M)*2,t[3]=(B-y)/T,t[0]=(_+x)/T,t[1]=.25*T,t[2]=(P+L)/T):(T=Math.sqrt(1+M-m-S)*2,t[3]=(_-x)/T,t[0]=(B+y)/T,t[1]=(P+L)/T,t[2]=.25*T),t}function mk(t,e,r,s){let i=e[0],n=e[1],o=e[2],a=e[3],c=i+i,l=n+n,u=o+o,f=i*c,h=i*l,d=i*u,p=n*l,g=n*u,m=o*u,_=a*c,y=a*l,x=a*u,S=s[0],P=s[1],B=s[2];return t[0]=(1-(p+m))*S,t[1]=(h+x)*S,t[2]=(d-y)*S,t[3]=0,t[4]=(h-x)*P,t[5]=(1-(f+m))*P,t[6]=(g+_)*P,t[7]=0,t[8]=(d+y)*B,t[9]=(g-_)*B,t[10]=(1-(f+p))*B,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function _k(t,e,r,s,i){let n=e[0],o=e[1],a=e[2],c=e[3],l=n+n,u=o+o,f=a+a,h=n*l,d=n*u,p=n*f,g=o*u,m=o*f,_=a*f,y=c*l,x=c*u,S=c*f,P=s[0],B=s[1],L=s[2],M=i[0],v=i[1],T=i[2],D=(1-(g+_))*P,V=(d+S)*P,z=(p-x)*P,W=(d-S)*B,Z=(1-(h+_))*B,le=(m+y)*B,ie=(p+x)*L,Re=(m-y)*L,ge=(1-(h+g))*L;return t[0]=D,t[1]=V,t[2]=z,t[3]=0,t[4]=W,t[5]=Z,t[6]=le,t[7]=0,t[8]=ie,t[9]=Re,t[10]=ge,t[11]=0,t[12]=r[0]+M-(D*M+W*v+ie*T),t[13]=r[1]+v-(V*M+Z*v+Re*T),t[14]=r[2]+T-(z*M+le*v+ge*T),t[15]=1,t}function Ky(t,e){let r=e[0],s=e[1],i=e[2],n=e[3],o=r+r,a=s+s,c=i+i,l=r*o,u=s*o,f=s*a,h=i*o,d=i*a,p=i*c,g=n*o,m=n*a,_=n*c;return t[0]=1-f-p,t[1]=u+_,t[2]=h-m,t[3]=0,t[4]=u-_,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=h+m,t[9]=d-g,t[10]=1-l-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function $y(t,e,r,s,i,n,o){let a=1/(r-e),c=1/(i-s),l=1/(n-o);return t[0]=n*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(i+s)*c,t[10]=(o+n)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*n*2*l,t[15]=0,t}function dv(t,e,r,s,i){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){let o=1/(s-i);t[10]=(i+s)*o,t[14]=2*i*s*o}else t[10]=-1,t[14]=-2*s;return t}var Jy=dv;function yk(t,e,r,s,i){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){let o=1/(s-i);t[10]=i*o,t[14]=i*s*o}else t[10]=-1,t[14]=-s;return t}function xk(t,e,r,s){let i=Math.tan(e.upDegrees*Math.PI/180),n=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(i+n);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((o-a)*c*.5),t[9]=(i-n)*l*.5,t[10]=s/(r-s),t[11]=-1,t[12]=0,t[13]=0,t[14]=s*r/(r-s),t[15]=0,t}function pv(t,e,r,s,i,n,o){let a=1/(e-r),c=1/(s-i),l=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(i+s)*c,t[14]=(o+n)*l,t[15]=1,t}var Zy=pv;function Ak(t,e,r,s,i,n,o){let a=1/(e-r),c=1/(s-i),l=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(i+s)*c,t[14]=n*l,t[15]=1,t}function Qy(t,e,r,s){let i,n,o,a,c,l,u,f,h,d,p=e[0],g=e[1],m=e[2],_=s[0],y=s[1],x=s[2],S=r[0],P=r[1],B=r[2];return Math.abs(p-S)<1e-6&&Math.abs(g-P)<1e-6&&Math.abs(m-B)<1e-6?uv(t):(f=p-S,h=g-P,d=m-B,i=1/Math.sqrt(f*f+h*h+d*d),f*=i,h*=i,d*=i,n=y*d-x*h,o=x*f-_*d,a=_*h-y*f,i=Math.sqrt(n*n+o*o+a*a),i?(i=1/i,n*=i,o*=i,a*=i):(n=0,o=0,a=0),c=h*a-d*o,l=d*n-f*a,u=f*o-h*n,i=Math.sqrt(c*c+l*l+u*u),i?(i=1/i,c*=i,l*=i,u*=i):(c=0,l=0,u=0),t[0]=n,t[1]=c,t[2]=f,t[3]=0,t[4]=o,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=u,t[10]=d,t[11]=0,t[12]=-(n*p+o*g+a*m),t[13]=-(c*p+l*g+u*m),t[14]=-(f*p+h*g+d*m),t[15]=1,t)}function Tk(t,e,r,s){let i=e[0],n=e[1],o=e[2],a=s[0],c=s[1],l=s[2],u=i-r[0],f=n-r[1],h=o-r[2],d=u*u+f*f+h*h;d>0&&(d=1/Math.sqrt(d),u*=d,f*=d,h*=d);let p=c*h-l*f,g=l*u-a*h,m=a*f-c*u;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=f*m-h*g,t[5]=h*p-u*m,t[6]=u*g-f*p,t[7]=0,t[8]=u,t[9]=f,t[10]=h,t[11]=0,t[12]=i,t[13]=n,t[14]=o,t[15]=1,t}function bk(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function Ek(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function Sk(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function gv(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function vk(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Ck(t,e,r,s){return t[0]=e[0]+r[0]*s,t[1]=e[1]+r[1]*s,t[2]=e[2]+r[2]*s,t[3]=e[3]+r[3]*s,t[4]=e[4]+r[4]*s,t[5]=e[5]+r[5]*s,t[6]=e[6]+r[6]*s,t[7]=e[7]+r[7]*s,t[8]=e[8]+r[8]*s,t[9]=e[9]+r[9]*s,t[10]=e[10]+r[10]*s,t[11]=e[11]+r[11]*s,t[12]=e[12]+r[12]*s,t[13]=e[13]+r[13]*s,t[14]=e[14]+r[14]*s,t[15]=e[15]+r[15]*s,t}function wk(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function Pk(t,e){let r=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],g=t[13],m=t[14],_=t[15],y=e[0],x=e[1],S=e[2],P=e[3],B=e[4],L=e[5],M=e[6],v=e[7],T=e[8],D=e[9],V=e[10],z=e[11],W=e[12],Z=e[13],le=e[14],ie=e[15];return Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(s-x)<=1e-6*Math.max(1,Math.abs(s),Math.abs(x))&&Math.abs(i-S)<=1e-6*Math.max(1,Math.abs(i),Math.abs(S))&&Math.abs(n-P)<=1e-6*Math.max(1,Math.abs(n),Math.abs(P))&&Math.abs(o-B)<=1e-6*Math.max(1,Math.abs(o),Math.abs(B))&&Math.abs(a-L)<=1e-6*Math.max(1,Math.abs(a),Math.abs(L))&&Math.abs(c-M)<=1e-6*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(l-v)<=1e-6*Math.max(1,Math.abs(l),Math.abs(v))&&Math.abs(u-T)<=1e-6*Math.max(1,Math.abs(u),Math.abs(T))&&Math.abs(f-D)<=1e-6*Math.max(1,Math.abs(f),Math.abs(D))&&Math.abs(h-V)<=1e-6*Math.max(1,Math.abs(h),Math.abs(V))&&Math.abs(d-z)<=1e-6*Math.max(1,Math.abs(d),Math.abs(z))&&Math.abs(p-W)<=1e-6*Math.max(1,Math.abs(p),Math.abs(W))&&Math.abs(g-Z)<=1e-6*Math.max(1,Math.abs(g),Math.abs(Z))&&Math.abs(m-le)<=1e-6*Math.max(1,Math.abs(m),Math.abs(le))&&Math.abs(_-ie)<=1e-6*Math.max(1,Math.abs(_),Math.abs(ie))}var Mk=al,Rk=gv;var It={};Ke(It,{add:()=>ex,ceil:()=>Ik,clone:()=>_v,copy:()=>xv,create:()=>mv,cross:()=>kk,dist:()=>Yk,distance:()=>Sv,div:()=>Xk,divide:()=>Ev,dot:()=>sx,equals:()=>Gk,exactEquals:()=>Cv,floor:()=>Bk,forEach:()=>Jk,fromValues:()=>yv,inverse:()=>Uk,len:()=>Kk,length:()=>Md,lerp:()=>ix,max:()=>Fk,min:()=>Ok,mul:()=>jk,multiply:()=>bv,negate:()=>Dk,normalize:()=>rx,random:()=>Vk,round:()=>Lk,scale:()=>tx,scaleAndAdd:()=>Nk,set:()=>Av,sqrDist:()=>qk,sqrLen:()=>$k,squaredDistance:()=>vv,squaredLength:()=>Rd,str:()=>Hk,sub:()=>Wk,subtract:()=>Tv,transformMat4:()=>nx,transformQuat:()=>ox,zero:()=>zk});function mv(){let t=new we(4);return we!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function _v(t){let e=new we(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function yv(t,e,r,s){let i=new we(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=s,i}function xv(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Av(t,e,r,s,i){return t[0]=e,t[1]=r,t[2]=s,t[3]=i,t}function ex(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Tv(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function bv(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function Ev(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function Ik(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function Bk(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function Ok(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function Fk(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function Lk(t,e){return t[0]=fr(e[0]),t[1]=fr(e[1]),t[2]=fr(e[2]),t[3]=fr(e[3]),t}function tx(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function Nk(t,e,r,s){return t[0]=e[0]+r[0]*s,t[1]=e[1]+r[1]*s,t[2]=e[2]+r[2]*s,t[3]=e[3]+r[3]*s,t}function Sv(t,e){let r=e[0]-t[0],s=e[1]-t[1],i=e[2]-t[2],n=e[3]-t[3];return Math.sqrt(r*r+s*s+i*i+n*n)}function vv(t,e){let r=e[0]-t[0],s=e[1]-t[1],i=e[2]-t[2],n=e[3]-t[3];return r*r+s*s+i*i+n*n}function Md(t){let e=t[0],r=t[1],s=t[2],i=t[3];return Math.sqrt(e*e+r*r+s*s+i*i)}function Rd(t){let e=t[0],r=t[1],s=t[2],i=t[3];return e*e+r*r+s*s+i*i}function Dk(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function Uk(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function rx(t,e){let r=e[0],s=e[1],i=e[2],n=e[3],o=r*r+s*s+i*i+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=s*o,t[2]=i*o,t[3]=n*o,t}function sx(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function kk(t,e,r,s){let i=r[0]*s[1]-r[1]*s[0],n=r[0]*s[2]-r[2]*s[0],o=r[0]*s[3]-r[3]*s[0],a=r[1]*s[2]-r[2]*s[1],c=r[1]*s[3]-r[3]*s[1],l=r[2]*s[3]-r[3]*s[2],u=e[0],f=e[1],h=e[2],d=e[3];return t[0]=f*l-h*c+d*a,t[1]=-(u*l)+h*o-d*n,t[2]=u*c-f*o+d*i,t[3]=-(u*a)+f*n-h*i,t}function ix(t,e,r,s){let i=e[0],n=e[1],o=e[2],a=e[3];return t[0]=i+s*(r[0]-i),t[1]=n+s*(r[1]-n),t[2]=o+s*(r[2]-o),t[3]=a+s*(r[3]-a),t}function Vk(t,e){e=e===void 0?1:e;let r,s,i,n,o,a;do r=fs()*2-1,s=fs()*2-1,o=r*r+s*s;while(o>=1);do i=fs()*2-1,n=fs()*2-1,a=i*i+n*n;while(a>=1);let c=Math.sqrt((1-o)/a);return t[0]=e*r,t[1]=e*s,t[2]=e*i*c,t[3]=e*n*c,t}function nx(t,e,r){let s=e[0],i=e[1],n=e[2],o=e[3];return t[0]=r[0]*s+r[4]*i+r[8]*n+r[12]*o,t[1]=r[1]*s+r[5]*i+r[9]*n+r[13]*o,t[2]=r[2]*s+r[6]*i+r[10]*n+r[14]*o,t[3]=r[3]*s+r[7]*i+r[11]*n+r[15]*o,t}function ox(t,e,r){let s=e[0],i=e[1],n=e[2],o=r[0],a=r[1],c=r[2],l=r[3],u=l*s+a*n-c*i,f=l*i+c*s-o*n,h=l*n+o*i-a*s,d=-o*s-a*i-c*n;return t[0]=u*l+d*-o+f*-c-h*-a,t[1]=f*l+d*-a+h*-o-u*-c,t[2]=h*l+d*-c+u*-a-f*-o,t[3]=e[3],t}function zk(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function Hk(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function Cv(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function Gk(t,e){let r=t[0],s=t[1],i=t[2],n=t[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))&&Math.abs(i-c)<=1e-6*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var Wk=Tv,jk=bv,Xk=Ev,Yk=Sv,qk=vv,Kk=Md,$k=Rd,Jk=function(){let t=mv();return function(e,r,s,i,n,o){let a,c;for(r||(r=4),s||(s=0),i?c=Math.min(i*r+s,e.length):c=e.length,a=s;aMath.PI*2)throw Error("expected radians")}function s6(t,e,r,s,i,n){let o=2*n/(r-e),a=2*n/(i-s),c=(r+e)/(r-e),l=(i+s)/(i-s),u=-1,f=-1,h=-2*n;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=u,t[11]=f,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}function Pv(){let t=new we(4);return we!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Mv(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function ux(t,e,r){r=r*.5;let s=Math.sin(r);return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=Math.cos(r),t}function fx(t,e,r){let s=e[0],i=e[1],n=e[2],o=e[3],a=r[0],c=r[1],l=r[2],u=r[3];return t[0]=s*u+o*a+i*l-n*c,t[1]=i*u+o*c+n*a-s*l,t[2]=n*u+o*l+s*c-i*a,t[3]=o*u-s*a-i*c-n*l,t}function Rv(t,e,r){r*=.5;let s=e[0],i=e[1],n=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=s*c+o*a,t[1]=i*c+n*a,t[2]=n*c-i*a,t[3]=o*c-s*a,t}function Iv(t,e,r){r*=.5;let s=e[0],i=e[1],n=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=s*c-n*a,t[1]=i*c+o*a,t[2]=n*c+s*a,t[3]=o*c-i*a,t}function Bv(t,e,r){r*=.5;let s=e[0],i=e[1],n=e[2],o=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=s*c+i*a,t[1]=i*c-s*a,t[2]=n*c+o*a,t[3]=o*c-n*a,t}function Ov(t,e){let r=e[0],s=e[1],i=e[2];return t[0]=r,t[1]=s,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-s*s-i*i)),t}function cl(t,e,r,s){let i=e[0],n=e[1],o=e[2],a=e[3],c=r[0],l=r[1],u=r[2],f=r[3],h,d,p,g,m;return h=i*c+n*l+o*u+a*f,h<0&&(h=-h,c=-c,l=-l,u=-u,f=-f),1-h>1e-6?(d=Math.acos(h),m=Math.sin(d),p=Math.sin((1-s)*d)/m,g=Math.sin(s*d)/m):(p=1-s,g=s),t[0]=p*i+g*c,t[1]=p*n+g*l,t[2]=p*o+g*u,t[3]=p*a+g*f,t}function Fv(t,e){let r=e[0],s=e[1],i=e[2],n=e[3],o=r*r+s*s+i*i+n*n,a=o?1/o:0;return t[0]=-r*a,t[1]=-s*a,t[2]=-i*a,t[3]=n*a,t}function Lv(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function hx(t,e){let r=e[0]+e[4]+e[8],s;if(r>0)s=Math.sqrt(r+1),t[3]=.5*s,s=.5/s,t[0]=(e[5]-e[7])*s,t[1]=(e[6]-e[2])*s,t[2]=(e[1]-e[3])*s;else{let i=0;e[4]>e[0]&&(i=1),e[8]>e[i*3+i]&&(i=2);let n=(i+1)%3,o=(i+2)%3;s=Math.sqrt(e[i*3+i]-e[n*3+n]-e[o*3+o]+1),t[i]=.5*s,s=.5/s,t[3]=(e[n*3+o]-e[o*3+n])*s,t[n]=(e[n*3+i]+e[i*3+n])*s,t[o]=(e[o*3+i]+e[i*3+o])*s}return t}var Nv=ex;var Dv=tx,Uv=sx,kv=ix,Vv=Md;var zv=Rd;var Hv=rx;var Gv=function(){let t=bd(),e=Sd(1,0,0),r=Sd(0,1,0);return function(s,i,n){let o=il(i,n);return o<-.999999?(yn(t,e,i),Ly(t)<1e-6&&yn(t,r,i),Ry(t,t),ux(s,t,Math.PI),s):o>.999999?(s[0]=0,s[1]=0,s[2]=0,s[3]=1,s):(yn(t,i,n),s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=1+o,Hv(s,s))}}(),$ce=function(){let t=Pv(),e=Pv();return function(r,s,i,n,o,a){return cl(t,s,o,a),cl(e,i,n,a),cl(r,t,e,2*a*(1-a)),r}}(),Jce=function(){let t=sv();return function(e,r,s,i){return t[0]=s[0],t[3]=s[1],t[6]=s[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],Hv(e,hx(e,t))}}();var i6=[0,0,0,1],hr=class extends bi{constructor(e=0,r=0,s=0,i=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,s,i)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,s,i){return this[0]=e,this[1]=r,this[2]=s,this[3]=i,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return hx(this,e),this.check()}fromAxisRotation(e,r){return ux(this,e,r),this.check()}identity(){return Mv(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=ce(e)}get y(){return this[1]}set y(e){this[1]=ce(e)}get z(){return this[2]}set z(e){this[2]=ce(e)}get w(){return this[3]}set w(e){this[3]=ce(e)}len(){return Vv(this)}lengthSquared(){return zv(this)}dot(e){return Uv(this,e)}rotationTo(e,r){return Gv(this,e,r),this.check()}add(e){return Nv(this,this,e),this.check()}calculateW(){return Ov(this,this),this.check()}conjugate(){return Lv(this,this),this.check()}invert(){return Fv(this,this),this.check()}lerp(e,r,s){return s===void 0?this.lerp(this,e,r):(kv(this,e,r,s),this.check())}multiplyRight(e){return fx(this,this,e),this.check()}multiplyLeft(e){return fx(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return Rv(this,this,e),this.check()}rotateY(e){return Iv(this,this,e),this.check()}rotateZ(e){return Bv(this,this,e),this.check()}scale(e){return Dv(this,this,e),this.check()}slerp(e,r,s){let i,n,o;switch(arguments.length){case 1:({start:i=i6,target:n,ratio:o}=e);break;case 2:i=this,n=e,o=r;break;default:i=e,n=r,o=s}return cl(this,i,n,o),this.check()}transformVector4(e,r=new zo){return ox(r,e,this),Ei(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var Wv=1e-6,n6=6371e3,Or=class{constructor({phi:e=0,theta:r=0,radius:s=1,bearing:i,pitch:n,altitude:o,radiusScale:a=n6}={}){this.phi=e,this.theta=r,this.radius=s||o||1,this.radiusScale=a||1,i!==void 0&&(this.bearing=i),n!==void 0&&(this.pitch=n),this.check()}toString(){return this.formatString(Se)}formatString({printTypes:e=!1}){let r=tl;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Ce(this.radius,e.radius)&&Ce(this.theta,e.theta)&&Ce(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-Je(this.phi)}set bearing(e){this.phi=Math.PI-_n(e)}get pitch(){return Je(this.theta)}set pitch(e){this.theta=_n(e)}get longitude(){return Je(this.phi)}get latitude(){return Je(this.theta)}get lng(){return Je(this.phi)}get lat(){return Je(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,s){return this.radius=e,this.phi=r,this.theta=s,this.check()}clone(){return new Or().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,s]){return this.radius=1+s/this.radiusScale,this.phi=_n(r),this.theta=_n(e),this.check()}fromVector3(e){return this.radius=Ed(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(fe(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new w(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(Wv,Math.min(Math.PI-Wv,this.phi)),this}check(){if(!Number.isFinite(this.phi)||!Number.isFinite(this.theta)||!(this.radius>0))throw new Error("SphericalCoordinates: some fields set to invalid numbers");return this}};var dr={};Ke(dr,{EPSILON1:()=>o6,EPSILON10:()=>g6,EPSILON11:()=>m6,EPSILON12:()=>_6,EPSILON13:()=>y6,EPSILON14:()=>x6,EPSILON15:()=>A6,EPSILON16:()=>T6,EPSILON17:()=>b6,EPSILON18:()=>E6,EPSILON19:()=>S6,EPSILON2:()=>a6,EPSILON20:()=>v6,EPSILON3:()=>c6,EPSILON4:()=>l6,EPSILON5:()=>u6,EPSILON6:()=>f6,EPSILON7:()=>h6,EPSILON8:()=>d6,EPSILON9:()=>p6,PI_OVER_FOUR:()=>w6,PI_OVER_SIX:()=>P6,PI_OVER_TWO:()=>C6,TWO_PI:()=>M6});var o6=.1,a6=.01,c6=.001,l6=1e-4,u6=1e-5,f6=1e-6,h6=1e-7,d6=1e-8,p6=1e-9,g6=1e-10,m6=1e-11,_6=1e-12,y6=1e-13,x6=1e-14,A6=1e-15,T6=1e-16,b6=1e-17,E6=1e-18,S6=1e-19,v6=1e-20,C6=Math.PI/2,w6=Math.PI/4,P6=Math.PI/6,M6=Math.PI*2;var dx=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { vec3 color; }; struct PointLight { vec3 color; vec3 position; vec3 attenuation; }; struct DirectionalLight { vec3 color; vec3 direction; }; uniform AmbientLight lighting_uAmbientLight; uniform PointLight lighting_uPointLight[MAX_LIGHTS]; uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS]; uniform int lighting_uPointLightCount; uniform int lighting_uDirectionalLightCount; uniform bool lighting_uEnabled; float getPointLightAttenuation(PointLight pointLight, float distance) { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } #endif `;var R6={lightSources:{}};function px(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(s=>s*r/255)}function I6({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let s={};return t?s["lighting_uAmbientLight.color"]=px(t):s["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((i,n)=>{s[`lighting_uPointLight[${n}].color`]=px(i),s[`lighting_uPointLight[${n}].position`]=i.position,s[`lighting_uPointLight[${n}].attenuation`]=i.attenuation||[1,0,0]}),s.lighting_uPointLightCount=e.length,r.forEach((i,n)=>{s[`lighting_uDirectionalLight[${n}].color`]=px(i),s[`lighting_uDirectionalLight[${n}].direction`]=i.direction}),s.lighting_uDirectionalLightCount=r.length,s}function jv(t=R6){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:s}=t.lightSources||{};return e||r&&r.length>0||s&&s.length>0?Object.assign({},I6({ambientLight:e,pointLights:r,directionalLights:s}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return jv({lightSources:e})}return{}}var ll={name:"lights",vs:dx,fs:dx,getUniforms:jv,defines:{MAX_LIGHTS:3}};var gx=`uniform float lighting_uAmbient; uniform float lighting_uDiffuse; uniform float lighting_uShininess; uniform vec3 lighting_uSpecularColor; vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { vec3 halfway_direction = normalize(light_direction + view_direction); float lambertian = dot(light_direction, normal_worldspace); float specular = 0.0; if (lambertian > 0.0) { float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, lighting_uShininess); } lambertian = max(lambertian, 0.0); return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color; } vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { vec3 lightColor = surfaceColor; if (lighting_uEnabled) { vec3 view_direction = normalize(cameraPosition - position_worldspace); lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color; for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting_uPointLightCount) { break; } PointLight pointLight = lighting_uPointLight[i]; vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting_uDirectionalLightCount) { break; } DirectionalLight directionalLight = lighting_uDirectionalLight[i]; lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } } return lightColor; } vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { vec3 lightColor = vec3(0, 0, 0); vec3 surfaceColor = vec3(0, 0, 0); if (lighting_uEnabled) { vec3 view_direction = normalize(cameraPosition - position_worldspace); for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting_uPointLightCount) { break; } PointLight pointLight = lighting_uPointLight[i]; vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting_uDirectionalLightCount) { break; } DirectionalLight directionalLight = lighting_uDirectionalLight[i]; lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } } return lightColor; } `;var B6={};function O6(t){let{ambient:e=.35,diffuse:r=.6,shininess:s=32,specularColor:i=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:r,lighting_uShininess:s,lighting_uSpecularColor:i.map(n=>n/255)}}function Xv(t=B6){if(!("material"in t))return{};let{material:e}=t;return e?O6(e):{lighting_uEnabled:!1}}var pr={name:"gouraud-lighting",dependencies:[ll],vs:gx,defines:{LIGHTING_VERTEX:1},getUniforms:Xv},vi={name:"phong-lighting",dependencies:[ll],fs:gx,defines:{LIGHTING_FRAGMENT:1},getUniforms:Xv};var Yv=`uniform mat4 u_MVPMatrix; uniform mat4 u_ModelMatrix; uniform mat4 u_NormalMatrix; out vec3 pbr_vPosition; out vec2 pbr_vUV; #ifdef HAS_NORMALS # ifdef HAS_TANGENTS out mat3 pbr_vTBN; # else out vec3 pbr_vNormal; # endif #endif void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv) { vec4 pos = u_ModelMatrix * position; pbr_vPosition = vec3(pos.xyz) / pos.w; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0))); vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0))); vec3 bitangentW = cross(normalW, tangentW) * tangent.w; pbr_vTBN = mat3(tangentW, bitangentW, normalW); #else pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0))); #endif #endif #ifdef HAS_UV pbr_vUV = uv; #else pbr_vUV = vec2(0.,0.); #endif } `;var qv=`precision highp float; uniform bool pbr_uUnlit; #ifdef USE_IBL uniform samplerCube u_DiffuseEnvSampler; uniform samplerCube u_SpecularEnvSampler; uniform sampler2D u_brdfLUT; uniform vec2 u_ScaleIBLAmbient; #endif #ifdef HAS_BASECOLORMAP uniform sampler2D u_BaseColorSampler; #endif #ifdef HAS_NORMALMAP uniform sampler2D u_NormalSampler; uniform float u_NormalScale; #endif #ifdef HAS_EMISSIVEMAP uniform sampler2D u_EmissiveSampler; uniform vec3 u_EmissiveFactor; #endif #ifdef HAS_METALROUGHNESSMAP uniform sampler2D u_MetallicRoughnessSampler; #endif #ifdef HAS_OCCLUSIONMAP uniform sampler2D u_OcclusionSampler; uniform float u_OcclusionStrength; #endif #ifdef ALPHA_CUTOFF uniform float u_AlphaCutoff; #endif uniform vec2 u_MetallicRoughnessValues; uniform vec4 u_BaseColorFactor; uniform vec3 u_Camera; #ifdef PBR_DEBUG uniform vec4 u_ScaleDiffBaseMR; uniform vec4 u_ScaleFGDSpec; #endif in vec3 pbr_vPosition; in vec2 pbr_vUV; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS in mat3 pbr_vTBN; #else in vec3 pbr_vNormal; #endif #endif struct PBRInfo { float NdotL; float NdotV; float NdotH; float LdotH; float VdotH; float perceptualRoughness; float metalness; vec3 reflectance0; vec3 reflectance90; float alphaRoughness; vec3 diffuseColor; vec3 specularColor; vec3 n; vec3 v; }; const float M_PI = 3.141592653589793; const float c_MinRoughness = 0.04; vec4 SRGBtoLINEAR(vec4 srgbIn) { #ifdef MANUAL_SRGB #ifdef SRGB_FAST_APPROXIMATION vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); #else vec3 bLess = step(vec3(0.04045),srgbIn.xyz); vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); #endif return vec4(linOut,srgbIn.w);; #else return srgbIn; #endif } vec3 getNormal() { #ifndef HAS_TANGENTS vec3 pos_dx = dFdx(pbr_vPosition); vec3 pos_dy = dFdy(pbr_vPosition); vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0)); vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0)); vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); #ifdef HAS_NORMALS vec3 ng = normalize(pbr_vNormal); #else vec3 ng = cross(pos_dx, pos_dy); #endif t = normalize(t - ng * dot(ng, t)); vec3 b = normalize(cross(ng, t)); mat3 tbn = mat3(t, b, ng); #else mat3 tbn = pbr_vTBN; #endif #ifdef HAS_NORMALMAP vec3 n = texture(u_NormalSampler, pbr_vUV).rgb; n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0))); #else vec3 n = normalize(tbn[2].xyz); #endif return n; } #ifdef USE_IBL vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection) { float mipCount = 9.0; float lod = (pbrInputs.perceptualRoughness * mipCount); vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT, vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb; vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb; #ifdef USE_TEX_LOD vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb; #else vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb; #endif vec3 diffuse = diffuseLight * pbrInputs.diffuseColor; vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y); diffuse *= u_ScaleIBLAmbient.x; specular *= u_ScaleIBLAmbient.y; return diffuse + specular; } #endif vec3 diffuse(PBRInfo pbrInputs) { return pbrInputs.diffuseColor / M_PI; } vec3 specularReflection(PBRInfo pbrInputs) { return pbrInputs.reflectance0 + (pbrInputs.reflectance90 - pbrInputs.reflectance0) * pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); } float geometricOcclusion(PBRInfo pbrInputs) { float NdotL = pbrInputs.NdotL; float NdotV = pbrInputs.NdotV; float r = pbrInputs.alphaRoughness; float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); return attenuationL * attenuationV; } float microfacetDistribution(PBRInfo pbrInputs) { float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; return roughnessSq / (M_PI * f * f); } void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) { pbrInputs.NdotL = 1.0; pbrInputs.NdotH = 0.0; pbrInputs.LdotH = 0.0; pbrInputs.VdotH = 1.0; } void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) { vec3 n = pbrInputs.n; vec3 v = pbrInputs.v; vec3 l = normalize(lightDirection); vec3 h = normalize(l+v); pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0); pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0); pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0); pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0); } void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) { vec3 light_direction = normalize(pointLight.position - pbr_vPosition); PBRInfo_setDirectionalLight(pbrInputs, light_direction); } vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) { vec3 F = specularReflection(pbrInputs); float G = geometricOcclusion(pbrInputs); float D = microfacetDistribution(pbrInputs); vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV); return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib); } vec4 pbr_filterColor(vec4 colorUnused) { #ifdef HAS_BASECOLORMAP vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor; #else vec4 baseColor = u_BaseColorFactor; #endif #ifdef ALPHA_CUTOFF if (baseColor.a < u_AlphaCutoff) { discard; } #endif vec3 color = vec3(0, 0, 0); if(pbr_uUnlit){ color.rgb = baseColor.rgb; } else{ float perceptualRoughness = u_MetallicRoughnessValues.y; float metallic = u_MetallicRoughnessValues.x; #ifdef HAS_METALROUGHNESSMAP vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV); perceptualRoughness = mrSample.g * perceptualRoughness; metallic = mrSample.b * metallic; #endif perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); metallic = clamp(metallic, 0.0, 1.0); float alphaRoughness = perceptualRoughness * perceptualRoughness; vec3 f0 = vec3(0.04); vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); diffuseColor *= 1.0 - metallic; vec3 specularColor = mix(f0, baseColor.rgb, metallic); float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = specularColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; vec3 n = getNormal(); vec3 v = normalize(u_Camera - pbr_vPosition); float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); vec3 reflection = -normalize(reflect(v, n)); PBRInfo pbrInputs = PBRInfo( 0.0, NdotV, 0.0, 0.0, 0.0, perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS PBRInfo_setAmbientLight(pbrInputs); color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color); for(int i = 0; i < lighting_uDirectionalLightCount; i++) { if (i < lighting_uDirectionalLightCount) { PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction); color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color); } } for(int i = 0; i < lighting_uPointLightCount; i++) { if (i < lighting_uPointLightCount) { PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]); float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation); } } #endif #ifdef USE_IBL color += getIBLContribution(pbrInputs, n, reflection); #endif #ifdef HAS_OCCLUSIONMAP float ao = texture(u_OcclusionSampler, pbr_vUV).r; color = mix(color, color * ao, u_OcclusionStrength); #endif #ifdef HAS_EMISSIVEMAP vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor; color += emissive; #endif #ifdef PBR_DEBUG color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y); color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z); color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w); #endif } return vec4(pow(color,vec3(1.0/2.2)), baseColor.a); } `;var An={name:"pbr",vs:Yv,fs:qv,defines:{LIGHTING_FRAGMENT:1},dependencies:[ll]};var Kv="#define SMOOTH_EDGE_RADIUS 0.5",F6=` ${Kv} struct VertexGeometry { vec4 position; vec3 worldPosition; vec3 worldPositionAlt; vec3 normal; vec2 uv; vec3 pickingColor; } geometry = VertexGeometry( vec4(0.0, 0.0, 1.0, 0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec2(0.0), vec3(0.0) ); `,L6=` ${Kv} struct FragmentGeometry { vec2 uv; } geometry; float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } `,$v={name:"geometry",vs:F6,fs:L6};var X={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(X,"IDENTITY",{get:()=>(k.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var bt={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Fe={common:0,meters:1,pixels:2},ul={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},Jv={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};var N6=Object.keys(X).map(t=>`const int COORDINATE_SYSTEM_${t} = ${X[t]};`).join(""),D6=Object.keys(bt).map(t=>`const int PROJECTION_MODE_${t} = ${bt[t]};`).join(""),U6=Object.keys(Fe).map(t=>`const int UNIT_${t.toUpperCase()} = ${Fe[t]};`).join(""),Zv=`${N6} ${D6} ${U6} uniform int project_uCoordinateSystem; uniform int project_uProjectionMode; uniform float project_uScale; uniform bool project_uWrapLongitude; uniform vec3 project_uCommonUnitsPerMeter; uniform vec3 project_uCommonUnitsPerWorldUnit; uniform vec3 project_uCommonUnitsPerWorldUnit2; uniform vec4 project_uCenter; uniform mat4 project_uModelMatrix; uniform mat4 project_uViewProjectionMatrix; uniform vec2 project_uViewportSize; uniform float project_uDevicePixelRatio; uniform float project_uFocalDistance; uniform vec3 project_uCameraPosition; uniform vec3 project_uCoordinateOrigin; uniform vec3 project_uCommonOrigin; uniform bool project_uPseudoMeters; const float TILE_SIZE = 512.0; const float PI = 3.1415926536; const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); const vec3 ZERO_64_LOW = vec3(0.0); const float EARTH_RADIUS = 6370972.0; const float GLOBE_RADIUS = 256.0; float project_size_at_latitude(float lat) { float y = clamp(lat, -89.9, 89.9); return 1.0 / cos(radians(y)); } float project_size() { if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR && project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT && project_uPseudoMeters == false) { if (geometry.position.w == 0.0) { return project_size_at_latitude(geometry.worldPosition.y); } float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; float y2 = y * y; float y4 = y2 * y2; float y6 = y4 * y2; return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; } return 1.0; } float project_size_at_latitude(float meters, float lat) { return meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat); } float project_size(float meters) { return meters * project_uCommonUnitsPerMeter.z * project_size(); } vec2 project_size(vec2 meters) { return meters * project_uCommonUnitsPerMeter.xy * project_size(); } vec3 project_size(vec3 meters) { return meters * project_uCommonUnitsPerMeter * project_size(); } vec4 project_size(vec4 meters) { return vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w); } mat3 project_get_orientation_matrix(vec3 up) { vec3 uz = normalize(up); vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); vec3 uy = cross(uz, ux); return mat3(ux, uy, uz); } bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { if (project_uProjectionMode == PROJECTION_MODE_GLOBE) { transform = project_get_orientation_matrix(commonPosition); return true; } return false; } vec3 project_normal(vec3 vector) { vec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0); vec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter); mat3 rotation; if (project_needs_rotation(geometry.position.xyz, rotation)) { n = rotation * n; } return n; } vec4 project_offset_(vec4 offset) { float dy = offset.y; vec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy; return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); } vec2 project_mercator_(vec2 lnglat) { float x = lnglat.x; if (project_uWrapLongitude) { x = mod(x + 180., 360.0) - 180.; } float y = clamp(lnglat.y, -89.9, 89.9); return vec2( radians(x) + PI, PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) ) * WORLD_SCALE; } vec3 project_globe_(vec3 lnglatz) { float lambda = radians(lnglatz.x); float phi = radians(lnglatz.y); float cosPhi = cos(phi); float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; return vec3( sin(lambda) * cosPhi, -cos(lambda) * cosPhi, sin(phi) ) * D; } vec4 project_position(vec4 position, vec3 position64Low) { vec4 position_world = project_uModelMatrix * position; if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) { if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { return vec4( project_mercator_(position_world.xy), project_size_at_latitude(position_world.z, position_world.y), position_world.w ); } if (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { position_world.xyz += project_uCoordinateOrigin; } } if (project_uProjectionMode == PROJECTION_MODE_GLOBE) { if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { return vec4( project_globe_(position_world.xyz), position_world.w ); } } if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { if (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) { return vec4( project_mercator_(position_world.xy) - project_uCommonOrigin.xy, project_size(position_world.z), position_world.w ); } } } if (project_uProjectionMode == PROJECTION_MODE_IDENTITY || (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT || project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { position_world.xyz -= project_uCoordinateOrigin; } return project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0)); } vec4 project_position(vec4 position) { return project_position(position, ZERO_64_LOW); } vec3 project_position(vec3 position, vec3 position64Low) { vec4 projected_position = project_position(vec4(position, 1.0), position64Low); return projected_position.xyz; } vec3 project_position(vec3 position) { vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); return projected_position.xyz; } vec2 project_position(vec2 position) { vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); return projected_position.xy; } vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { return viewProjectionMatrix * position + center; } vec4 project_common_position_to_clipspace(vec4 position) { return project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter); } vec2 project_pixel_size_to_clipspace(vec2 pixels) { vec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0; return offset * project_uFocalDistance; } float project_size_to_pixel(float meters) { return project_size(meters) * project_uScale; } float project_size_to_pixel(float size, int unit) { if (unit == UNIT_METERS) return project_size_to_pixel(size); if (unit == UNIT_COMMON) return size * project_uScale; return size; } float project_pixel_size(float pixels) { return pixels / project_uScale; } vec2 project_pixel_size(vec2 pixels) { return pixels / project_uScale; } `;function k6(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let s=0;s{for(let i in s)if(!k6(s[i],e[i])){r=t(s),e=s;break}return r}}var Qv=[0,0,0,0],V6=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],eC=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],z6=[0,0,0],tC=[0,0,0],H6=zt(W6);function mx(t,e,r=tC){r.length<3&&(r=[r[0],r[1],0]);let s=r,i,n=!0;switch(e===X.LNGLAT_OFFSETS||e===X.METER_OFFSETS?i=r:i=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case bt.WEB_MERCATOR:(e===X.LNGLAT||e===X.CARTESIAN)&&(i=[0,0,0],n=!1);break;case bt.WEB_MERCATOR_AUTO_OFFSET:e===X.LNGLAT?s=i:e===X.CARTESIAN&&(s=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],i=t.unprojectPosition(s),s[0]-=r[0],s[1]-=r[1],s[2]-=r[2]);break;case bt.IDENTITY:s=t.position.map(Math.fround),s[2]=s[2]||0;break;case bt.GLOBE:n=!1,i=null;break;default:n=!1}return{geospatialOrigin:i,shaderCoordinateOrigin:s,offsetMode:n}}function G6(t,e,r){let{viewMatrixUncentered:s,projectionMatrix:i}=t,{viewMatrix:n,viewProjectionMatrix:o}=t,a=Qv,c=Qv,l=t.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:h}=mx(t,e,r);return h&&(c=t.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=It.transformMat4([],c,o),n=s||n,o=ke.multiply([],i,n),o=ke.multiply([],o,V6)),{viewMatrix:n,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function Od({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:s=X.DEFAULT,coordinateOrigin:i=tC,autoWrapLongitude:n=!1}){s===X.DEFAULT&&(s=t.isGeospatial?X.LNGLAT:X.CARTESIAN);let o=H6({viewport:t,devicePixelRatio:e,coordinateSystem:s,coordinateOrigin:i});return o.project_uWrapLongitude=n,o.project_uModelMatrix=r||eC,o}function W6({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:s}){let{projectionCenter:i,viewProjectionMatrix:n,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=G6(t,r,s),u=t.getDistanceScales(),f=[t.width*e,t.height*e],h=It.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={project_uCoordinateSystem:r,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:c,project_uCommonOrigin:o.slice(0,3),project_uCenter:i,project_uPseudoMeters:Boolean(t._pseudoMeters),project_uViewportSize:f,project_uDevicePixelRatio:e,project_uFocalDistance:h,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:z6,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:n,project_uModelMatrix:eC,project_uCameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case X.METER_OFFSETS:d.project_uCommonUnitsPerWorldUnit=p.unitsPerMeter,d.project_uCommonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case X.LNGLAT:case X.LNGLAT_OFFSETS:t._pseudoMeters||(d.project_uCommonUnitsPerMeter=p.unitsPerMeter),d.project_uCommonUnitsPerWorldUnit=p.unitsPerDegree,d.project_uCommonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case X.CARTESIAN:d.project_uCommonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.project_uCommonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var j6={};function X6(t=j6){return"viewport"in t?Od(t):{}}var Qe={name:"project",dependencies:[by,$v],vs:Zv,getUniforms:X6};var Y6=` vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition ) { vec3 projectedPosition = project_position(position, position64Low); mat3 rotation; if (project_needs_rotation(projectedPosition, rotation)) { // offset is specified as ENU // when in globe projection, rotate offset so that the ground alighs with the surface of the globe offset = rotation * offset; } commonPosition = vec4(projectedPosition + offset, 1.0); return project_common_position_to_clipspace(commonPosition); } vec4 project_position_to_clipspace( vec3 position, vec3 position64Low, vec3 offset ) { vec4 commonPosition; return project_position_to_clipspace(position, position64Low, offset, commonPosition); } `,de={name:"project32",dependencies:[Qe],vs:Y6};function _x(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ci(t,e){let r=It.transformMat4([],e,t);return It.scale(r,r,1/r[3]),r}function yx(t,e){let r=t%e;return r<0?e+r:r}function rC(t,e,r){return r*e+(1-r)*t}function fl(t,e,r){return tr?r:t}function q6(t){return Math.log(t)*Math.LOG2E}var Go=Math.log2||q6;function Fr(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Lr=Math.PI,sC=Lr/4,gr=Lr/180,xx=180/Lr,Wo=512,Fd=4003e4,jo=85.051129,iC=1.5;function hl(t){return Math.pow(2,t)}function Ld(t){return Go(t)}function je(t){let[e,r]=t;Fr(Number.isFinite(e)),Fr(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let s=e*gr,i=r*gr,n=Wo*(s+Lr)/(2*Lr),o=Wo*(Lr+Math.log(Math.tan(sC+i*.5)))/(2*Lr);return[n,o]}function mt(t){let[e,r]=t,s=e/Wo*(2*Lr)-Lr,i=2*(Math.atan(Math.exp(r/Wo*(2*Lr)-Lr))-sC);return[s*xx,i*xx]}function dl(t){let{latitude:e}=t;Fr(Number.isFinite(e));let r=Math.cos(e*gr);return Ld(Fd*r)-9}function bn(t){let e=Math.cos(t*gr);return Wo/Fd/e}function Xo(t){let{latitude:e,longitude:r,highPrecision:s=!1}=t;Fr(Number.isFinite(e)&&Number.isFinite(r));let i=Wo,n=Math.cos(e*gr),o=i/360,a=o/n,c=i/Fd/n,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(s){let u=gr*Math.tan(e*gr)/n,f=o*u/2,h=i/Fd*u,d=h/a*c;l.unitsPerDegree2=[0,f,h],l.unitsPerMeter2=[d,0,d]}return l}function pl(t,e){let[r,s,i]=t,[n,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=Xo({longitude:r,latitude:s,highPrecision:!0}),u=je(t);u[0]+=n*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=mt(u),h=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[f[0],f[1],h]:f}function Nd(t){let{height:e,pitch:r,bearing:s,altitude:i,scale:n,center:o}=t,a=_x();ke.translate(a,a,[0,0,-i]),ke.rotateX(a,a,-r*gr),ke.rotateZ(a,a,s*gr);let c=n/e;return ke.scale(a,a,[c,c,c]),o&&ke.translate(a,a,We.negate([],o)),a}function Ax(t){let{width:e,height:r,altitude:s,pitch:i=0,offset:n,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:u=Tn(iC)}=t;s!==void 0&&(u=Tn(s));let f=u*gr,h=i*gr,d=En(u),p=d;o&&(p+=o[2]*a/Math.cos(h)/r);let g=f*(.5+(n?n[1]:0)/r),m=Math.sin(g)*p/Math.sin(fl(Math.PI/2-h-g,.01,Math.PI-.01)),_=Math.sin(h)*m+p,y=p*10,x=Math.min(_*l,y);return{fov:f,aspect:e/r,focalDistance:d,near:c,far:x}}function Tn(t){return 2*Math.atan(.5/t)*xx}function En(t){return .5/Math.tan(.5*t*gr)}function Yo(t,e){let[r,s,i=0]=t;return Fr(Number.isFinite(r)&&Number.isFinite(s)&&Number.isFinite(i)),Ci(e,[r,s,i,1])}function mr(t,e,r=0){let[s,i,n]=t;if(Fr(Number.isFinite(s)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(n))return Ci(e,[s,i,n,1]);let o=Ci(e,[s,i,0,1]),a=Ci(e,[s,i,1,1]),c=o[2],l=a[2],u=c===l?0:((r||0)-c)/(l-c);return Ze.lerp([],o,a,u)}function Dd(t){let{width:e,height:r,bounds:s,minExtent:i=0,maxZoom:n=24,offset:o=[0,0]}=t,[[a,c],[l,u]]=s,f=K6(t.padding),h=je([a,fl(u,-jo,jo)]),d=je([l,fl(c,-jo,jo)]),p=[Math.max(Math.abs(d[0]-h[0]),i),Math.max(Math.abs(d[1]-h[1]),i)],g=[e-f.left-f.right-Math.abs(o[0])*2,r-f.top-f.bottom-Math.abs(o[1])*2];Fr(g[0]>0&&g[1]>0);let m=g[0]/p[0],_=g[1]/p[1],y=(f.right-f.left)/2/m,x=(f.top-f.bottom)/2/_,S=[(d[0]+h[0])/2+y,(d[1]+h[1])/2+x],P=mt(S),B=Math.min(n,Go(Math.abs(Math.min(m,_))));return Fr(Number.isFinite(B)),{longitude:P[0],latitude:P[1],zoom:B}}function K6(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(Fr(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var nC=Math.PI/180;function Ud(t,e=0){let{width:r,height:s,unproject:i}=t,n={targetZ:e},o=i([0,s],n),a=i([r,s],n),c,l,u=t.fovy?.5*t.fovy*nC:Math.atan(.5/t.altitude),f=(90-t.pitch)*nC;return u>f-.01?(c=oC(t,0,e),l=oC(t,r,e)):(c=i([0,0],n),l=i([r,0],n)),[o,a,l,c]}function oC(t,e,r){let{pixelUnprojectionMatrix:s}=t,i=Ci(s,[e,0,1,1]),n=Ci(s,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-i[2])/(n[2]-i[2]),c=Ze.lerp([],i,n,a),l=mt(c);return l.push(r),l}var aC=512;function Tx(t){let{width:e,height:r,pitch:s=0}=t,{longitude:i,latitude:n,zoom:o,bearing:a=0}=t;(i<-180||i>180)&&(i=yx(i+180,360)-180),(a<-180||a>180)&&(a=yx(a+180,360)-180);let c=Go(r/aC);if(o<=c)o=c,n=0;else{let l=r/2/Math.pow(2,o),u=mt([0,l])[1];if(nf&&(n=f)}}return{width:e,height:r,longitude:i,latitude:n,zoom:o,pitch:s,bearing:a}}var cC=.01,J6=["longitude","latitude","zoom"],lC={curve:1.414,speed:1.2};function bx(t,e,r,s){let{startZoom:i,startCenterXY:n,uDelta:o,w0:a,u1:c,S:l,rho:u,rho2:f,r0:h}=uC(t,e,s);if(co?0:u}function uC(t,e,r){r=Object.assign({},lC,r);let s=r.curve,i=t.zoom,n=[t.longitude,t.latitude],o=hl(i),a=e.zoom,c=[e.longitude,e.latitude],l=hl(a-i),u=je(n),f=je(c),h=Ze.sub([],f,u),d=Math.max(t.width,t.height),p=d/l,g=Ze.length(h)*o,m=Math.max(g,cC),_=s*s,y=(p*p-d*d+_*_*m*m)/(2*d*_*m),x=(p*p-d*d-_*_*m*m)/(2*p*_*m),S=Math.log(Math.sqrt(y*y+1)-y),P=Math.log(Math.sqrt(x*x+1)-x),B=(P-S)/s;return{startZoom:i,startCenterXY:u,uDelta:h,w0:d,u1:g,S:B,rho:s,rho2:_,r0:S,r1:P}}var Q6=` const int max_lights = 2; uniform mat4 shadow_uViewProjectionMatrices[max_lights]; uniform vec4 shadow_uProjectCenters[max_lights]; uniform bool shadow_uDrawShadowMap; uniform bool shadow_uUseShadowMap; uniform int shadow_uLightId; uniform float shadow_uLightCount; out vec3 shadow_vPosition[max_lights]; vec4 shadow_setVertexPosition(vec4 position_commonspace) { if (shadow_uDrawShadowMap) { return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]); } if (shadow_uUseShadowMap) { for (int i = 0; i < max_lights; i++) { if(i < int(shadow_uLightCount)) { vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]); shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0; } } } return gl_Position; } `,eV=` const int max_lights = 2; uniform bool shadow_uDrawShadowMap; uniform bool shadow_uUseShadowMap; uniform sampler2D shadow_uShadowMap0; uniform sampler2D shadow_uShadowMap1; uniform vec4 shadow_uColor; uniform float shadow_uLightCount; in vec3 shadow_vPosition[max_lights]; const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0); const vec4 bitUnpackShift = 1.0 / bitPackShift; const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) { vec4 rgbaDepth = texture(shadowMap, position.xy); float z = dot(rgbaDepth, bitUnpackShift); return smoothstep(0.001, 0.01, position.z - z); } vec4 shadow_filterShadowColor(vec4 color) { if (shadow_uDrawShadowMap) { vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift); rgbaDepth -= rgbaDepth.gbaa * bitMask; return rgbaDepth; } if (shadow_uUseShadowMap) { float shadowAlpha = 0.0; shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0); if(shadow_uLightCount > 1.0) { shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1); } shadowAlpha *= shadow_uColor.a / shadow_uLightCount; float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha); return vec4( mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha), blendedAlpha ); } return color; } `,tV=zt(oV),rV=zt(aV),sV=[0,0,0,1],iV=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function nV(t,e){let[r,s,i]=t,n=mr([r,s,i],e);return Number.isFinite(i)?n:[n[0],n[1],0]}function oV({viewport:t,center:e}){return new q(t.viewProjectionMatrix).invert().transform(e)}function aV({viewport:t,shadowMatrices:e}){let r=[],s=t.pixelUnprojectionMatrix,i=t.isGeospatial?void 0:1,n=[[0,0,i],[t.width,0,i],[0,t.height,i],[t.width,t.height,i],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(o=>nV(o,s));for(let o of e){let a=o.clone().translate(new w(t.center).negate()),c=n.map(u=>a.transform(u)),l=new q().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});r.push(l.multiplyRight(o))}return r}function cV(t,e){let{shadowEnabled:r=!0}=t;if(!r||!t.shadowMatrices||!t.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let s={shadow_uDrawShadowMap:Boolean(t.drawToShadowMap),shadow_uUseShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,shadow_uColor:t.shadowColor||sV,shadow_uLightId:t.shadowLightId||0,shadow_uLightCount:t.shadowMatrices.length},i=tV({viewport:t.viewport,center:e.project_uCenter}),n=[],o=rV({shadowMatrices:t.shadowMatrices,viewport:t.viewport}).slice();for(let a=0;a"viewport"in t&&(t.drawToShadowMap||t.shadowMaps&&t.shadowMaps.length>0)?cV(t,e):{}};var _e={...md,defaultUniforms:{...md.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":` // for picking depth values picking_setPickingAttribute(position.z / position.w); `,"vs:DECKGL_FILTER_COLOR":` picking_setPickingColor(geometry.pickingColor); `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` // use highlight color if this fragment belongs to the selected object. color = picking_filterHighlightColor(color); // use picking color if rendering to picking FBO. color = picking_filterPickingColor(color); `}}};var lV=[Qe],uV=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"];function Ko(){let t=hi.getDefaultShaderAssembler();for(let e of lV)t.addDefaultModule(e);for(let e of uV)t.addShaderHook(e);return t}var fV=[255,255,255],hV=1,dV=0,$o=class{constructor(e={}){this.type="ambient";let{color:r=fV}=e,{intensity:s=hV}=e;this.id=e.id||`ambient-${dV++}`,this.color=r,this.intensity=s}};var pV=[255,255,255],gV=1,mV=[0,0,-1],_V=0,Ns=class{constructor(e={}){this.type="directional";let{color:r=pV}=e,{intensity:s=gV}=e,{direction:i=mV}=e,{_shadow:n=!1}=e;this.id=e.id||`directional-${_V++}`,this.color=r,this.intensity=s,this.type="directional",this.direction=new w(i).normalize().toArray(),this.shadow=n}getProjectedLight(e){return this}};var Sn=class{constructor(e,r={id:"pass"}){let{id:s}=r;this.id=s,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var _t=class extends Sn{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[r,s]=this.device.canvasContext.getDrawingBufferSize(),i=e.clearCanvas??!0,n=e.clearColor??(i?[0,0,0,0]:!1),o=i?1:!1,a=i?0:!1,c=e.colorMask??15,l={viewport:[0,0,r,s]};e.colorMask&&(l.colorMask=c),e.scissorRect&&(l.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:e.target,parameters:l,clearColor:n,clearDepth:o,clearStencil:a});try{return this._drawLayers(u,e)}finally{u.end()}}_drawLayers(e,r){let{target:s,moduleParameters:i,viewports:n,views:o,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let u of n){let f=o&&o[u.id];a?.(u);let h=this._getDrawLayerParams(u,r),d=u.subViewports||[u];for(let p of d){let g=this._drawLayersInViewport(e,{target:s,moduleParameters:i,viewport:p,view:f,pass:r.pass,layers:r.layers},h);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:s,isPicking:i=!1,layerFilter:n,cullRect:o,effects:a,moduleParameters:c},l=!1){let u=[],f=fC(this._lastRenderIndex+1),h={layer:r[0],viewport:e,isPicking:i,renderPass:s,cullRect:o},d={};for(let p=0;pthis.device.clearWebGL(f))}let u={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let f=0;f{let o=i.props._offset,a=i.id,c=i.parent&&i.parent.id,l;if(c&&!(c in e)&&s(i.parent,!1),c in r){let u=r[c]=r[c]||fC(e[c],e);l=u(i,n),r[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),r[a]=null):l=t;return n&&l>=t&&(t=l+1),e[a]=l,l};return s}function yV(t,{moduleParameters:e,target:r,viewport:s}){let i=e&&e.devicePixelRatio||t.canvasContext.cssToDeviceRatio(),[,n]=t.canvasContext.getDrawingBufferSize(),o=r?r.height:n,a=s;return[a.x*i,o-(a.y+a.height)*i,a.width*i,a.height*i]}var gl=class extends _t{constructor(e,r){super(e,r),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){let r=this.fbo,s=this.device.canvasContext.cssToDeviceRatio(),i=e.viewports[0],n=i.width*s,o=i.height*s,a=[1,1,1,1];(n!==r.width||o!==r.height)&&r.resize({width:n,height:o}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,s){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}};var xV={color:[255,255,255],intensity:1},hC=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],AV=[0,0,0,200/255],wi=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=AV,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:s}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),s._addDefaultShaderModule(qo),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(let r in e){let s=e[r];switch(s.type){case"ambient":this.ambientLight=s;break;case"directional":this.directionalLights.push(s);break;case"point":this.pointLights.push(s);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:s,onViewportActive:i,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;os.getProjectedLight({layer:e})),pointLights:this.pointLights.map(s=>s.getProjectedLight({layer:e}))},r}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(qo))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let s=new q().lookAt({eye:new w(r.direction).negate()});e.push(s)}return e}_createShadowPasses(e){for(let r=0;ri&&(n=i);let o=this._pool,a=e.BYTES_PER_ELEMENT*n,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,n);return s&&l.fill(0),l}return new e(n)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:s}=e,{byteLength:i}=s,n=r.findIndex(o=>o.byteLength>=i);n<0?r.push(s):(n>0||r.lengththis.opts.poolSize&&r.shift()}},Nr=new Sx;function Zo(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function vn(t,e){let r=t%e;return r<0?e+r:r}function pC(t){return[t[12],t[13],t[14]]}function gC(t){return{left:Jo(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Jo(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Jo(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Jo(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Jo(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Jo(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var dC=new w;function Jo(t,e,r,s){dC.set(t,e,r);let i=dC.len();return{distance:s/i,normal:new w(-t/i,-e/i,-r/i)}}function Dr(t){return t-Math.fround(t)}var ml;function kd(t,e){let{size:r=1,startIndex:s=0}=e,i=e.endIndex!==void 0?e.endIndex:t.length,n=(i-s)/r;ml=Nr.allocate(ml,n,{type:Float32Array,size:r*2});let o=s,a=0;for(;o0){let[i,n,o]=Hd(this.timestamp,0,0);this.direction=[i,-o,n]}else{let{latitude:i,longitude:n}=r;this.direction=Hd(this.timestamp,i,n)}return this}};var KV=1,$V=1,Pn=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:s=Number.POSITIVE_INFINITY,rate:i=1,repeat:n=1}=e,o=KV++,a={time:0,delay:r,duration:s,rate:i,repeat:n};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[r,s]of this.animations)s.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let i of r)this._setChannelTime(i,this.time);let s=this.animations.values();for(let i of s){let{animation:n,channel:o}=i;n.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let s=$V++;return this.animations.set(s,{animation:e,channel:r}),e.setTime(this.getTime(r)),s}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let s=r-e.delay,i=e.duration*e.repeat;s>=i?e.time=e.duration*e.rate:(e.time=Math.max(0,s)%e.duration,e.time*=e.rate)}};var JV=0,ZV={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:Vt.stats.get(`animation-loop-${JV++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},xl=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...ZV,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=e.stats||new Tt({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:r}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=D0(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(U0(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:s}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),s!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=s,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let s=this.props.onAddHTML(r);s&&(r.innerHTML=s)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device?.canvasContext?.getPixelSize()||[1,1],s=1,i=this.device?.canvasContext?.canvas;return i&&i.clientHeight?s=i.clientWidth/i.clientHeight:e>0&&r>0&&(s=e/r),{width:e,height:r,aspect:s}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var Gd=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Ge("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&ee(this.indices.usage===Q.INDEX)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function AC(t,e){if(e instanceof Gd)return e;let r=QV(t,e),{attributes:s,bufferLayout:i}=e8(t,e);return new Gd({topology:e.topology||"triangle-list",bufferLayout:i,vertexCount:e.vertexCount,indices:r,attributes:s})}function QV(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:Q.INDEX,data:r})}function e8(t,e){let r=[],s={};for(let[n,o]of Object.entries(e.attributes)){let a=n;switch(n){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}s[a]=t.createBuffer({data:o.value,id:`${n}-buffer`});let{value:c,size:l,normalized:u}=o;r.push({name:a,format:F0(c,l,u)})}let i=e._calculateVertexCount(e.attributes,e.indices);return{attributes:s,bufferLayout:r,vertexCount:i}}var Wd=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){let r=dn(Object.values(e).filter(s=>s.dependencies));for(let s of r)e[s.name]=s;U.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[s,i]of Object.entries(e)){let n=s;this.moduleUniforms[n]=i.defaultUniforms||{},this.moduleBindings[n]={}}}destroy(){}setProps(e){for(let r of Object.keys(e)){let s=r,i=e[s],n=this.modules[s];if(!n){U.warn(`Module ${r} not found`)();continue}let o=this.moduleUniforms[s],a=this.moduleBindings[s],c=n.getUniforms?.(i,o)||i,{uniforms:l,bindings:u}=gn(c);this.moduleUniforms[s]={...o,...l},this.moduleBindings[s]={...a,...u}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,s]of Object.entries(this.moduleUniforms))for(let[i,n]of Object.entries(s))e[`${r}.${i}`]={type:this.modules[r].uniformTypes?.[i],value:String(n)};return e}};var wx=class{device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new wx(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){let r={...Rr.defaultProps,...e},s=this._hashRenderPipeline(r);if(!this._renderPipelineCache[s]){let i=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=s,this._renderPipelineCache[s]={pipeline:i,useCount:0}}return this._renderPipelineCache[s].useCount++,this._renderPipelineCache[s].pipeline}createComputePipeline(e){let r={...pn.defaultProps,...e},s=this._hashComputePipeline(r);if(!this._computePipelineCache[s]){let i=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=s,this._computePipelineCache[s]={pipeline:i,useCount:0}}return this._computePipelineCache[s].useCount++,this._computePipelineCache[s].pipeline}release(e){let r=e.hash,s=e instanceof pn?this._computePipelineCache:this._renderPipelineCache;s[r].useCount--,s[r].useCount===0&&(s[r].pipeline.destroy(),delete s[r])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let r=this._getHash(e.vs.source),s=e.fs?this._getHash(e.fs.source):0,i="-",n=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${s}V${i}BL${n}`;default:let o=this._getHash(JSON.stringify(e.parameters));return`${r}/${s}V${i}T${e.topology}P${o}BL${n}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},Al=wx;Y(Al,"defaultProps",{...Rr.defaultProps});var Px=class{device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new Px(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){let r=this._hashShader(e),s=this._cache[r];if(!s){let i=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=s={shader:i,useCount:0}}return s.useCount++,s.shader}release(e){let r=this._hashShader(e),s=this._cache[r];s&&(s.useCount--,s.useCount===0&&(delete this._cache[r],s.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}},Tl=Px;Y(Tl,"defaultProps",{..._i.defaultProps});function TC(t,e){let r={},s="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[s]:"N/A"}};for(let i of t.attributes)if(i){let n=`${i.location} ${i.name}: ${i.type}`;r[`in ${n}`]={[s]:i.stepMode||"vertex"}}for(let i of t.varyings||[]){let n=`${i.location} ${i.name}`;r[`out ${n}`]={[s]:JSON.stringify(i.accessor)}}return r}var ft=null,Mx=null;function bC(t,{id:e,minimap:r,opaque:s,top:i="0",left:n="0",rgbaScale:o=1}){ft||(ft=document.createElement("canvas"),ft.id=e,ft.title=e,ft.style.zIndex="100",ft.style.position="absolute",ft.style.top=i,ft.style.left=n,ft.style.border="blue 1px solid",ft.style.transform="scaleY(-1)",document.body.appendChild(ft),Mx=ft.getContext("2d")),(ft.width!==t.width||ft.height!==t.height)&&(ft.width=t.width/2,ft.height=t.height/2,ft.style.width="400px",ft.style.height="400px");let a=t.device.readPixelsToArrayWebGL(t),c=Mx.createImageData(t.width,t.height),l=0;for(let u=0;u[a.name,a])||[]);this.setShaderInputs(r.shaderInputs||new Wd(s));let i=r8(e),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=Ty(this.props.source);let{source:a,getUniforms:c}=this.props.shaderAssembler.assembleShader({platformInfo:i,...this.props,modules:n});this.source=a,this._getModuleUniforms=c}else{let{vs:a,fs:c,getUniforms:l}=this.props.shaderAssembler.assembleShaderPair({platformInfo:i,...this.props,modules:n});this.vs=a,this.fs=c,this._getModuleUniforms=l}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||Al.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||Tl.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let r;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),pi(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:s}=this.vertexArray,i=s?s.byteLength/(s.indexType==="uint32"?4:2):void 0;r=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:i,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),r?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",r}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&AC(this.device,e);r&&(this.setTopology(r.topology||"triangle-list"),this.bufferLayout=EC(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)),this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?EC(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Kc(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Xc(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let s=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=s}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,r){e.indices&&U.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[s,i]of Object.entries(e)){let n=this.bufferLayout.find(c=>SC(c).includes(s));if(!n){U.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let o=SC(n),a=!1;for(let c of o){let l=this._attributeInfos[c];l&&(this.vertexArray.setBuffer(l.location,i),a=!0)}!a&&!(r?.disableWarnings??this.props.disableWarnings)&&U.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[s,i]of Object.entries(e)){let n=this._attributeInfos[s];n?this.vertexArray.setConstantWebGL(n.location,i):(r?.disableWarnings??this.props.disableWarnings)||U.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${s}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){pi(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){let{bindings:r,uniforms:s}=gn(this._getModuleUniforms(e));Object.assign(this.bindings,r),Object.assign(this.uniforms,s),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof mi?e=Math.max(e,r.texture.updateTimestamp):r instanceof Q||r instanceof xe?e=Math.max(e,r.updateTimestamp):r instanceof yi||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[s]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(i=>i.name===s)&&s!=="positions"&&delete r[s];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(U.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let s=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),i=null;this.source?i=s:this.fs&&(i=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:s,fs:i}),this._attributeInfos=Yh(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=U.level>3?0:t8;U.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:U.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=TC(this.pipeline.shaderLayout,this.id);U.table(ta,e)();let r=this.shaderInputs.getDebugTable();for(let[i,n]of Object.entries(this.uniforms))r[i]={value:n};U.table(ta,r)();let s=this._getAttributeDebugTable();U.table(ta,this._attributeInfos)(),U.table(ta,s)(),U.groupEnd(ta)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=U.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let s=e.props.framebuffer;s&&bC(s,{id:s.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,s]of Object.entries(this._attributeInfos))e[s.location]={name:r,type:s.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[s.location],s.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,s=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:s.toString()}}return e}_getBufferOrConstantValues(e,r){let s=Yc(r);return(e instanceof Q?new s(e.debugData):e).toString()}},J=Rx;Y(J,"defaultProps",{...Rr.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:hi.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function EC(t,e){let r=[...t];for(let s of e){let i=r.findIndex(n=>n.name===s.name);i<0?r.push(s):r[i]=s}return r}function r8(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function SC(t){return t.attributes?t.attributes?.map(e=>e.attribute):[t.name]}var _r=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=J.defaultProps){ee(_r.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new J(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||zc(),topology:r.topology||"point-list",...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(r instanceof Q)return r.readAsync();let{buffer:s,byteOffset:i=0,byteLength:n=s.byteLength}=r;return s.readAsync(i,n)}};var s8="transform_output",hs=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new J(this.device,{id:r.id||"texture-transform-model",fs:r.fs||zc({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:s8}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],s=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(s),s.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getData({packed:e=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:s,targetTexture:i}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,s),Object.assign(e.sourceBuffers,r),i){e.targetTexture=i;let{width:n,height:o}=i;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:o,colorAttachments:[i]}),e.framebuffer.resize({width:n,height:o})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let s in r)r[s].sampler=this.sampler}};var se=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:s=null,vertexCount:i=null}=e;this.id=e.id||Ge("geometry"),this.topology=e.topology,s&&(this.indices=ArrayBuffer.isView(s)?{value:s,size:1}:s),this.attributes={};for(let[n,o]of Object.entries(r)){let a=ArrayBuffer.isView(o)?{value:o}:o;ee(ArrayBuffer.isView(a.value),`${this._print(n)}: must be typed array or object with value as typed array`),(n==="POSITION"||n==="positions")&&!a.size&&(a.size=3),n==="indices"?(ee(!this.indices),this.indices=a):this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let s=1/0;for(let i of Object.values(e)){let{value:n,size:o,constant:a}=i;!a&&n&&o>=1&&(s=Math.min(s,n.length/o))}return ee(Number.isFinite(s)),s}};var i8=`#version 300 es in vec2 aClipSpacePosition; in vec2 aTexCoord; in vec2 aCoordinate; out vec2 position; out vec2 coordinate; out vec2 uv; void main(void) { gl_Position = vec4(aClipSpacePosition, 0., 1.); position = aClipSpacePosition; coordinate = aCoordinate; uv = aTexCoord; } `,vC=[-1,-1,1,-1,-1,1,1,1],bl=class extends J{constructor(e,r){let s=vC.map(i=>i===-1?0:i);super(e,{...r,vs:i8,vertexCount:4,geometry:new se({topology:"triangle-strip",vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(vC)},aTexCoord:{size:2,value:new Float32Array(s)},aCoordinate:{size:2,value:new Float32Array(s)}}})})}};var yr=class{id;matrix=new q;display=!0;position=new w;rotation=new w;scale=new w(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||Ge(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return ee(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return ee(e.length===3,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return ee(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:s,scale:i,update:n=!0}=e;return r&&this.setPosition(r),s&&this.setRotation(s),i&&this.setScale(i),n&&this.updateMatrix(),this}updateMatrix(){let e=this.position,r=this.rotation,s=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(r),this.matrix.scale(s),this}update(e={}){let{position:r,rotation:s,scale:i}=e;return r&&this.setPosition(r),s&&this.setRotation(s),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(e,r){ee(e),r=r||this.matrix;let s=new q(e).multiplyRight(r),i=s.invert(),n=i.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:s,worldInverseMatrix:i,worldInverseTransposeMatrix:n}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};var tr=class extends yr{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;U.assert(r.every(s=>s instanceof yr),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:s})=>{let i=r.getBounds();if(!i)return;let[n,o]=i,a=new w(n).add(o).divide([2,2,2]);s.transformAsPoint(a,a);let c=new w(o).subtract(n).divide([2,2,2]);s.transformAsVector(c,c);for(let l=0;l<8;l++){let u=new w(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let f=0;f<3;f++)e[0][f]=Math.min(e[0][f],u[f]),e[1][f]=Math.max(e[1][f],u[f])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,s=r.indexOf(e);return s>-1&&r.splice(s,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new q}={}){let s=new q(r).multiplyRight(this.matrix);for(let i of this.children)i instanceof tr?i.traverse(e,{worldMatrix:s}):e(i,{worldMatrix:s})}};var ds=class extends yr{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}};var Ds=class extends se{constructor(e={}){let{id:r=Ge("cube-geometry"),indices:s=!0}=e;super(s?{...e,id:r,topology:"triangle-list",indices:{size:1,value:n8},attributes:{...h8,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...d8,...e.attributes}})}},n8=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),o8=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),a8=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),c8=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),l8=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),u8=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),f8=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),h8={POSITION:{size:3,value:o8},NORMAL:{size:3,value:a8},TEXCOORD_0:{size:2,value:c8}},d8={POSITION:{size:3,value:l8},TEXCOORD_0:{size:2,value:u8},COLOR_0:{size:3,value:f8}};var El=class extends se{constructor(e={}){let{id:r=Ge("sphere-geometry")}=e,{indices:s,attributes:i}=p8(e);super({...e,id:r,topology:"triangle-list",indices:s,attributes:{...i,...e.attributes}})}};function p8(t){let{nlat:e=10,nlong:r=10}=t,n=Math.PI-0,o=0,c=2*Math.PI-o,l=(e+1)*(r+1),u=(_,y,x,S,P)=>t.radius||1,f=new Float32Array(l*3),h=new Float32Array(l*3),d=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,g=new p(e*r*6);for(let _=0;_<=e;_++)for(let y=0;y<=r;y++){let x=y/r,S=_/e,P=y+_*(r+1),B=P*2,L=P*3,M=c*x,v=n*S,T=Math.sin(M),D=Math.cos(M),V=Math.sin(v),z=Math.cos(v),W=D*V,Z=z,le=T*V,ie=u(W,Z,le,x,S);f[L+0]=ie*W,f[L+1]=ie*Z,f[L+2]=ie*le,h[L+0]=W,h[L+1]=Z,h[L+2]=le,d[B+0]=x,d[B+1]=1-S}let m=r+1;for(let _=0;_{let n=y8(e,s),o=`${r}-${i}`;return new Sl(t,{id:o,module:e,fs:n})})}var CC=`#version 300 es uniform sampler2D texSrc; uniform vec2 texSize; in vec2 position; in vec2 coordinate; in vec2 uv; out vec4 fragColor; `,m8=t=>`${CC} void main() { fragColor = texture(texSrc, coordinate); fragColor = ${t}(fragColor, texSize, coordinate); } `,_8=t=>`${CC} void main() { fragColor = ${t}(texSrc, texSize, coordinate); } `;function y8(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor`;return m8(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return _8(r)}return""}var x8={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"},Ur=class extends _t{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:r,views:s,viewports:i,onViewportActive:n,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:u},cullRect:f,effects:h,pass:d="picking",pickZ:p,moduleParameters:g}){this.pickZ=p;let m=this._resetColorEncoder(p),_=[a,c,l,u],y=super.render({target:o,layers:e,layerFilter:r,views:s,viewports:i,onViewportActive:n,cullRect:f,effects:h?.filter(S=>S.useInPicking),pass:d,isPicking:!0,moduleParameters:g,clearColor:[0,0,0,0],colorMask:15,scissorRect:_});return this._colorEncoderState=null,{decodePickingColor:m&&T8.bind(null,m),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:s}=e.props;return r&&s.includes("draw")||s.includes("terrain")||s.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,r,s){let i={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:n,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?i.blend=!1:n&&o.includes("draw")&&(Object.assign(i,x8),i.blend=!0,i.blendColor=A8(this._colorEncoderState,e,s)),i}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function A8(t,e,r){let{byLayer:s,byAlpha:i}=t,n,o=s.get(e);return o?(o.viewports.push(r),n=o.a):(n=s.size+1,n<=255?(o={a:n,layer:e,viewports:[r]},s.set(e,o),i[n]=o):(k.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function T8(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var Pi={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},ra=Symbol.for("component"),xr=Symbol.for("propTypes"),jd=Symbol.for("deprecatedProps"),Us=Symbol.for("asyncPropDefaults"),ps=Symbol.for("asyncPropOriginal"),kr=Symbol.for("asyncPropResolved");function Bt(t,e=()=>!0){return Array.isArray(t)?wC(t,e,[]):e(t)?[t]:[]}function wC(t,e,r){let s=-1;for(;++s0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let s=++this._loadCount,i=e;typeof e=="string"&&(i=$e(e)),i instanceof Promise?(this.isLoaded=!1,this._loader=i.then(n=>{this._loadCount===s&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===s&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let n of this._subscribers)n.onChange(this.getData())}};var wl=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:s=!1,persistent:i=!0}){let n=this._resources[e];n?n.setData(r,s):(n=new Cl(e,r,this._context),this._resources[e]=n),n.persistent=i}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let s in r){let i=r[s],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:s,requestId:i="default"}){let{_resources:n,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),n[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=n[e];if(this._track(s,i,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,s,i){let n=this._consumers,o=n[e]=n[e]||{},a=o[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),s&&(a?(a.onChange=i,a.resourceId=s.id):a={onChange:i,resourceId:s.id},o[r]=a,s.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var b8="layerManager.setLayers",E8="layerManager.activateViewport",Mn=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{Ue(E8,this,a),a&&(this.context.viewport=a)};let{deck:s,stats:i,viewport:n,timeline:o}=r||{};this.layers=[],this.resourceManager=new wl({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:s,shaderAssembler:Ko(),defaultShaderModules:[],renderPass:void 0,stats:i||new Tt({id:"deck.gl"}),viewport:n||new Ht({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Pn,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let s of this.layers){let i=s.getNeedsRedraw(e);r=r||i}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(s=>r.id.indexOf(s)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){Ue(b8,this,r,e),this._lastRenderedLayers=e;let s=Bt(e,Boolean);for(let i of s)i.context=this.context;this._updateLayers(this.layers,s)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(s=>s.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,s=r.findIndex(i=>i.name===e.name);s>=0&&(r.splice(s,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,s){s.raiseError(r,`${e} of ${s}`)}_updateLayers(e,r){let s={};for(let o of e)s[o.id]?k.warn(`Multiple old layers with same id ${o.id}`)():s[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let i=[];this._updateSublayersRecursively(r,s,i),this._finalizeOldLayers(s);let n=!1;for(let o of i)if(o.hasUniformTransition()){n=`Uniform transition in ${o}`;break}this._needsUpdate=n,this.layers=i}_updateSublayersRecursively(e,r,s){for(let i of e){i.context=this.context;let n=r[i.id];n===null&&k.warn(`Multiple new layers with same id ${i.id}`)(),r[i.id]=null;let o=null;try{this._debug&&n!==i&&i.validateProps(),n?(this._transferLayerState(n,i),this._updateLayer(i)):this._initializeLayer(i),s.push(i),o=i.isComposite?i.getSubLayers():null}catch(a){this._handleError("matching",a,i)}o&&this._updateSublayersRecursively(o,r,s)}}_finalizeOldLayers(e){for(let r in e){let s=e[r];s&&this._finalizeLayer(s)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Pi.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=Pi.MATCHED,r!==e&&(e.lifecycle=Pi.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Pi.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Pi.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function ve(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let s=0;sr.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,s=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(s):s}getViewport(e){return this._viewportMap[e]}unproject(e,r){let s=this.getViewports(),i={x:e[0],y:e[1]};for(let n=s.length-1;n>=0;--n){let o=s[n];if(o.containsPixel(i)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Bt(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!ve(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):k.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let s=r.type;return new s({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(e.id)?.makeViewport({viewState:n,width:this.width,height:this.height})})}_updateController(e,r,s,i){let n=e.controller;if(n&&s){let o={...r,...n,id:e.id,x:s.x,y:s.y,width:s.width,height:s.height};return(!i||i.constructor!==n.type)&&(i=this._createController(e,o)),i&&i.setProps(o),i}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let s=!1;for(let i=e.length;i--;){let n=e[i],o=this.getViewState(n),a=n.makeViewport({viewState:o,width:this.width,height:this.height}),c=r[n.id],l=Boolean(n.controller);l&&!c&&(s=!0),(s||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,o,a,c),a&&this._viewports.unshift(a)}for(let i in r){let n=r[i];n&&!this.controllers[i]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((s,i)=>!e[i].equals(r[i]))}};var S8=/([0-9]+\.?[0-9]*)(%|px)/;function ks(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":let e=S8.exec(t);if(e&&e.length>=3){let r=e[2]==="%",s=parseFloat(e[1]);return{position:r?s/100:s,relative:r}}default:throw new Error(`Could not parse position string ${t}`)}}function Vs(t,e){return t.relative?Math.round(t.position*e):t.position}var Ot=class{constructor(e){let{id:r,x:s=0,y:i=0,width:n="100%",height:o="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=ks(s),this._y=ks(i),this._width=ks(n),this._height=ks(o),this._padding=a&&{left:ks(a.left||0),right:ks(a.right||0),top:ks(a.top||0),bottom:ks(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.ViewportType===e.ViewportType&&ve(this.props,e.props,2)}makeViewport({width:e,height:r,viewState:s}){s=this.filterViewState(s);let i=this.getDimensions({width:e,height:r});return!i.height||!i.width?null:new this.ViewportType({...s,...this.props,...i})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let r={...e};for(let s in this.props.viewState)s!=="id"&&(r[s]=this.props.viewState[s]);return r}return e}getDimensions({width:e,height:r}){let s={x:Vs(this._x,e),y:Vs(this._y,r),width:Vs(this._width,e),height:Vs(this._height,r)};return this._padding&&(s.padding={left:Vs(this._padding.left,e),top:Vs(this._padding.top,r),right:Vs(this._padding.right,e),bottom:Vs(this._padding.bottom,r)}),s}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var Vr=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var PC=()=>{},Ml={BREAK:1,SNAP_TO_END:2,IGNORE:3},v8=t=>t,C8=Ml.BREAK,Rl=class{constructor(e){this._onTransitionUpdate=r=>{let{time:s,settings:{interpolator:i,startProps:n,endProps:o,duration:a,easing:c}}=r,l=c(s/a),u=i.interpolateProps(n,o,l);this.propsInTransition=this.getControllerState({...this.props,...u}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Vr(e.timeline),this.onViewStateChange=e.onViewStateChange||PC,this.onStateChange=e.onStateChange||PC}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,s=this.props;if(this.props=e,!s||this._shouldIgnoreViewportChange(s,e))return!1;if(this._isTransitionEnabled(e)){let i=s;if(this.transition.inProgress){let{interruption:n,endProps:o}=this.transition.settings;i={...s,...n===Ml.SNAP_TO_END?o:this.propsInTransition||s}}this._triggerTransition(i,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:s}=e;return(r>0||r==="auto")&&Boolean(s)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===Ml.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let s=this.getControllerState(e),i=this.getControllerState(r).shortestPathFrom(s),n=r.transitionInterpolator,o=n.getDuration?n.getDuration(e,r):r.transitionDuration;if(o===0)return;let a=n.initializeProps(e,i);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||v8,interpolator:n,interruption:r.transitionInterruption||C8,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function Ae(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var zs=class{constructor(e){let{compare:r,extract:s,required:i}=e;this._propsToCompare=r,this._propsToExtract=s||r,this._requiredProps=i}arePropsEqual(e,r){for(let s of this._propsToCompare)if(!(s in e)||!(s in r)||!Ce(e[s],r[s]))return!1;return!0}initializeProps(e,r){let s={},i={};for(let n of this._propsToExtract)(n in e||n in r)&&(s[n]=e[n],i[n]=r[n]);return this._checkRequiredProps(s),this._checkRequiredProps(i),{start:s,end:i}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let s=e[r];Ae(Number.isFinite(s)||Array.isArray(s),`${r} is required for transition`)})}};var w8=["longitude","latitude","zoom","bearing","pitch"],P8=["longitude","latitude","zoom"],yt=class extends zs{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,s=Array.isArray(e)?{}:e;s.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:w8,required:P8},super(s.transitionProps),this.opts=s}initializeProps(e,r){let s=super.initializeProps(e,r),{makeViewport:i,around:n}=this.opts;if(i&&n){let o=i(e),a=i(r),c=o.unproject(n);s.start.around=n,Object.assign(s.end,{around:a.project(c),aroundPosition:c,width:r.width,height:r.height})}return s}interpolateProps(e,r,s){let i={};for(let n of this._propsToExtract)i[n]=it(e[n]||0,r[n]||0,s);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...i});Object.assign(i,n.panByPosition(r.aroundPosition,it(e.around,r.around,s)))}return i}};var Mi={transitionDuration:0},M8=300,Yd=t=>1-(1-t)*(1-t),sa={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},Rn={},Ft=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new Rl({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return r?!1:this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:s}=this.props,{offsetCenter:i}=e;return[i.x-r,i.y-s]}isPointInBounds(e,r){let{width:s,height:i}=this.props;if(r&&r.handled)return!1;let n=e[0]>=0&&e[0]<=s&&e[1]>=0&&e[1]<=i;return n&&r&&r.stopPropagation(),n}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:r}=e;this.inertia=Number.isFinite(r)?r:r===!0?M8:0;let{scrollZoom:s=!0,dragPan:i=!0,dragRotate:n=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=Boolean(this.onViewStateChange);this.toggleEvents(sa.WHEEL,u&&s),this.toggleEvents(sa.PAN,u),this.toggleEvents(sa.PINCH,u&&(a||c)),this.toggleEvents(sa.TRIPLE_PAN,u&&c),this.toggleEvents(sa.DOUBLE_TAP,u&&o),this.toggleEvents(sa.KEYBOARD,u&&l),this.scrollZoom=s,this.dragPan=i,this.dragRotate=n,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(s=>{this._events[s]!==r&&(this._events[s]=r,r?this.eventManager.on(s,this.handleEvent):this.eventManager.off(s,this.handleEvent))})}updateViewport(e,r=null,s={}){let i={...e.getViewportProps(),...r},n=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(s),n){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:i,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let s=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(s=!s);let i=this.controllerState[s?"panStart":"rotateStart"]({pos:r});return this._panMove=s,this.updateViewport(i,Mi,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),s=this.controllerState.pan({pos:r});return this.updateViewport(s,Mi,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let s=this.getCenter(e),i=[s[0]+e.velocityX*r/2,s[1]+e.velocityY*r/2],n=this.controllerState.pan({pos:i}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Yd},{isDragging:!1,isPanning:!0})}else{let s=this.controllerState.panEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),s=this.controllerState.rotate({pos:r});return this.updateViewport(s,Mi,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let s=this.getCenter(e),i=[s[0]+e.velocityX*r/2,s[1]+e.velocityY*r/2],n=this.controllerState.rotate({pos:i}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Yd},{isDragging:!1,isRotating:!0})}else{let s=this.controllerState.rotateEnd();this.updateViewport(s,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:s=.01,smooth:i=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=e,o=2/(1+Math.exp(-Math.abs(n*s)));n<0&&o!==0&&(o=1/o);let a=this.controllerState.zoom({pos:r,scale:o});return this.updateViewport(a,{...this._getTransitionProps({around:r}),transitionDuration:i?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let s=this.controllerState.rotateStart({pos:r});return this.updateViewport(s,Mi,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let s=this.controllerState.rotate({pos:r});return this.updateViewport(s,Mi,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let s=this.getCenter(e),i=[s[0],s[1]+=e.velocityY*r/2],n=this.controllerState.rotate({pos:i});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Yd},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let s=this.controllerState.rotateEnd();this.updateViewport(s,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let s=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return Rn._startPinchRotation=e.rotation,Rn._lastPinchEvent=e,this.updateViewport(s,Mi,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:s}=e,i=this.getCenter(e);r=r.zoom({pos:i,scale:s})}if(this.touchRotate){let{rotation:s}=e;r=r.rotate({deltaAngleX:Rn._startPinchRotation-s})}return this.updateViewport(r,Mi,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Rn._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:s}=Rn;if(this.touchZoom&&r&&s&&e.scale!==s.scale){let i=this.getCenter(e),n=this.controllerState.rotateEnd(),o=Math.log2(e.scale),a=(o-Math.log2(s.scale))/(e.deltaTime-s.deltaTime),c=Math.pow(2,o+a*r/2);n=n.zoom({pos:i,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:i}),transitionDuration:r,transitionEasing:Yd},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let i=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Rn._startPinchRotation=null,Rn._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let s=this.isFunctionKeyPressed(e),i=this.controllerState.zoom({pos:r,scale:s?.5:2});return this.updateViewport(i,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:s,moveSpeed:i,rotateSpeedX:n,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(s).zoomOut(s):a.zoomOut(s),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(s).zoomIn(s):a.zoomIn(s),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(i),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(i),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(i),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(i),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?Mi:e?{...r,transitionInterpolator:new yt({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Hs=class{constructor(e,r){this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var MC=5,R8=1.2,Il=class extends Hs{constructor(e){let{width:r,height:s,latitude:i,longitude:n,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startBearing:y,startPitch:x,startZoom:S,normalize:P=!0}=e;Ae(Number.isFinite(n)),Ae(Number.isFinite(i)),Ae(Number.isFinite(o)),super({width:r,height:s,latitude:i,longitude:n,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:h,maxPitch:d,minPitch:p,normalize:P,position:u},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startBearing:y,startPitch:x,startZoom:S}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let s=this.getState().startPanLngLat||this._unproject(r);if(!s)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(s,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:s=0}){let{startRotatePos:i,startBearing:n,startPitch:o}=this.getState();if(!i||n===void 0||o===void 0)return this;let a;return e?a=this._getNewRotation(e,i,o,n):a={bearing:n+r,pitch:o+s},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:s}){let{startZoom:i,startZoomLngLat:n}=this.getState();if(n||(i=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(e)),!n)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=i+Math.log2(s);c=fe(c,a,o);let l=this.makeViewport({...this.getViewportProps(),zoom:c});return this._getUpdatedState({zoom:c,...l.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),s={...this.getViewportProps()},{bearing:i,longitude:n}=s;return Math.abs(i-r.bearing)>180&&(s.bearing=i<0?i+360:i-360),Math.abs(n-r.longitude)>180&&(s.longitude=n<0?n+360:n-360),s}applyConstraints(e){let{maxZoom:r,minZoom:s,zoom:i}=e;e.zoom=fe(i,s,r);let{maxPitch:n,minPitch:o,pitch:a}=e;e.pitch=fe(a,o,n);let{normalize:c=!0}=e;return c&&Object.assign(e,Tx(e)),e}_zoomFromCenter(e){let{width:r,height:s}=this.getViewportProps();return this.zoom({pos:[r/2,s/2],scale:e})}_panFromCenter(e){let{width:r,height:s}=this.getViewportProps();return this.pan({startPos:[r/2,s/2],pos:[r/2+e[0],s/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_getNewRotation(e,r,s,i){let n=e[0]-r[0],o=e[1]-r[1],a=e[1],c=r[1],{width:l,height:u}=this.getViewportProps(),f=n/l,h=0;o>0?Math.abs(u-c)>MC&&(h=o/(c-u)*R8):o<0&&c>MC&&(h=1-a/c),h=fe(h,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=i+180*f,m=s;return h>0?m=s+h*(p-s):h<0&&(m=s-h*(d-s)),{pitch:m,bearing:g}}},In=class extends Ft{constructor(){super(...arguments),this.ControllerState=Il,this.transition={transitionDuration:300,transitionInterpolator:new yt({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];let r=this.props;super.setProps(e),(!r||r.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}};var qd=class extends Ot{constructor(e={}){super(e)}get ViewportType(){return Et}get ControllerType(){return In}};qd.displayName="MapView";var Ri=qd;var I8=new wi;function B8(t,e){let r=t.order??1/0,s=e.order??1/0;return r-s}var Bl=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(s=>s.id===e.id)){let s=r.findIndex(i=>B8(i,e)>0);s<0?r.push(e):r.splice(s,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(ve(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let i of this.effects)r[i.id]=i;let s=[];for(let i of e){let n=r[i.id],o=i;n&&n!==i?n.setProps?(n.setProps(i.props),o=n):n.cleanup(this._context):n||i.setup(this._context),s.push(o),delete r[i.id]}for(let i in r)r[i].cleanup(this._context);this.effects=s,this._resolvedEffects=s.concat(this._defaultEffects),e.some(i=>i instanceof wi)||this._resolvedEffects.push(I8),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Ol=class extends _t{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}};var O8="deckRenderer.renderLayers",Bn=class{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Ol(e),this.pickLayersPass=new Ur(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,s={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};s.effects&&this._preRender(s.effects,s);let i=this.lastPostProcessEffect?this.renderBuffers[0]:s.target;this.lastPostProcessEffect&&(s.clearColor=[0,0,0,0],s.clearCanvas=!0);let n=r.render({...s,target:i});s.effects&&this._postRender(s.effects,s),this.renderCount++,Ue(O8,this,n,e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let s of e)r.preRenderStats[s.id]=s.preRender(r),s.postRender&&(this.lastPostProcessEffect=s.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize();e.length===0&&[0,1].map(s=>{let i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${s}`,colorAttachments:[i]}))});for(let s of e)s.resize(r)}_postRender(e,r){let{renderBuffers:s}=this,i={...r,inputBuffer:s[0],swapBuffer:s[1]};for(let n of e)if(n.postRender){i.target=n.id===this.lastPostProcessEffect?r.target:void 0;let o=n.postRender(i);i.inputBuffer=o,i.swapBuffer=o===s[0]?s[1]:s[0]}}};var F8={pickedColor:null,pickedObjectIndex:-1};function RC({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:s,deviceRadius:i,deviceRect:n}){let{x:o,y:a,width:c,height:l}=n,u=i*i,f=-1,h=0;for(let d=0;du)h+=4*c;else for(let m=0;m=0){let y=m+o-r,x=y*y+g;x<=u&&(u=x,f=h)}h+=4}}if(f>=0){let d=t.slice(f,f+4),p=e(d);if(p){let g=Math.floor(f/4/c),m=f/4-g*c;return{...p,pickedColor:d,pickedX:o+m,pickedY:a+g}}k.error("Picked non-existent layer. Is picking buffer corrupt?")()}return F8}function IC({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let s=0;s=0){let n=t.slice(s,s+4),o=n.join(",");if(!r.has(o)){let a=e(n);a?r.set(o,{...a,color:n}):k.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function Ix({pickInfo:t,viewports:e,pixelRatio:r,x:s,y:i,z:n}){let o=e[0];e.length>1&&(o=L8(t?.pickedViewports||e,{x:s,y:i}));let a;if(o){let c=[s-o.x,i-o.y];n!==void 0&&(c[2]=n),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:s,y:i,pixel:[s,i],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function BC(t){let{pickInfo:e,lastPickedInfo:r,mode:s,layers:i}=t,{pickedColor:n,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(s==="hover"){let f=r.index,h=r.layerId,d=o?o.props.id:null;if(d!==h||a!==f){if(d!==h){let p=i.find(g=>g.props.id===h);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=Ix(t),u=new Map;return u.set(null,l),c.forEach(f=>{let h={...l};f===o&&(h.color=n,h.index=a,h.picked=!0),h=Bx({layer:f,info:h,mode:s});let d=h.layer;f===o&&s==="hover"&&(r.info=h),u.set(d.id,h),s==="hover"&&d.updateAutoHighlight(h)}),u}function Bx({layer:t,info:e,mode:r}){for(;t&&e;){let s=e.layer||null;e.sourceLayer=s,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:s}),t=t.parent}return e}function L8(t,e){for(let r=t.length-1;r>=0;r--){let s=t[r];if(s.containsPixel(e))return s}return t[0]}var Fl=class{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Ur(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:s,viewports:i},n=this.lastPickedInfo.info){let o=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=o?s.find(h=>h.id===o):null,l=a&&i.find(h=>h.id===a)||i[0],u=l&&l.unproject([e-l.x,r-l.y]);return{...n,...{x:e,y:r,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let r=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=r}let{canvas:e}=this.device.getCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(s=>this.pickLayersPass.shouldDrawLayer(s)&&!s.isComposite);return r.length?r:null}_pickClosestObject({layers:e,views:r,viewports:s,x:i,y:n,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||s.length===0)return{result:[],emptyInfo:Ix({viewports:s,x:i,y:n,pixelRatio:h})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([i,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*h),{width:_,height:y}=this.pickingFBO,x=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:y}),S={x:i-o,y:n-o,width:o*2+1,height:o*2+1},P,B=[],L=new Set;for(let M=0;M=l);T++){let D=B[T],V={color:D.pickedColor,layer:null,index:D.pickedObjectIndex,picked:!0,x:i,y:n,pixelRatio:d};V=Bx({layer:D.pickedLayer,info:V,mode:c});let z=V.layer.id;L.has(z)||L.set(z,new Set);let W=L.get(z),Z=V.object??V.index;W.has(Z)||(W.add(Z),M.push(V))}return M}_drawAndSample({layers:e,views:r,viewports:s,onViewportActive:i,deviceRect:n,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:r,viewports:s,onViewportActive:i,pickingFBO:u,deviceRect:n,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{}};for(let y of a)y.useInPicking&&(f.preRenderStats[y.id]=y.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:p,width:g,height:m}=n,_=new(l?Float32Array:Uint8Array)(g*m*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:p,sourceWidth:g,sourceHeight:m,target:_}),{pickedColors:_,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:s,deviceWidth:i,deviceHeight:n}){let o=Math.max(0,e-s),a=Math.max(0,r-s),c=Math.min(i,e+s+1)-o,l=Math.min(n,r+s+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var N8={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},D8="top-left",OC="__root",Kd=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!ve(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(let e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){let r={};for(let s of this.resolvedWidgets)r[s.id]=s;this.resolvedWidgets.length=0;for(let s of this.defaultWidgets)r[s.id]=null,this.resolvedWidgets.push(s);for(let s of e){let i=r[s.id];i?i.viewId!==s.viewId||i.placement!==s.placement?(this._remove(i),this._add(s)):s!==i&&(i.setProps(s.props),s=i):this._add(s),r[s.id]=null,this.resolvedWidgets.push(s)}for(let s in r){let i=r[s];i&&this._remove(i)}this.widgets=e}_add(e){let{viewId:r=null,placement:s=D8}=e,i=e.onAdd({deck:this.deck,viewId:r});i&&this._getContainer(r,s).append(i),e._element=i}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,r){let s=e||OC,i=this.containers[s];i||(i=document.createElement("div"),i.style.pointerEvents="none",i.style.position="absolute",i.style.overflow="hidden",this.parentElement?.append(i),this.containers[s]=i);let n=i.querySelector(`.${r}`);return n||(n=document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,N8[r]),i.append(n)),n}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let s in this.containers){let i=this.lastViewports[s]||null,n=s===OC||i,o=this.containers[s];n?(o.style.display="block",o.style.left=`${i?i.x:0}px`,o.style.top=`${i?i.y:0}px`,o.style.width=`${i?i.width:e}px`,o.style.height=`${i?i.height:r}px`):o.style.display="none"}}onRedraw({viewports:e,layers:r}){let s=e.reduce((n,o)=>(n[o.id]=o,n),{}),{lastViewports:i}=this;for(let n of this.getWidgets()){let{viewId:o}=n;if(o){let a=s[o];a&&(n.onViewportChange&&!a.equals(i[o])&&n.onViewportChange(a),n.onRedraw?.({viewports:[a],layers:r}))}else{if(n.onViewportChange)for(let a of e)a.equals(i[a.id])||n.onViewportChange(a);n.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=s,this._updateContainers()}onHover(e,r){for(let s of this.getWidgets()){let{viewId:i}=s;(!i||i===e.viewport?.id)&&s.onHover?.(e,r)}}onEvent(e,r){let s=ul[r.type];if(s)for(let i of this.getWidgets()){let{viewId:n}=i;(!n||n===e.viewport?.id)&&i[s.handler]?.(e,r)}}};var U8={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Ll=class{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){let r=document.createElement("div");return r.className="deck-tooltip",Object.assign(r.style,U8),this.deck=e,this.element=r,r}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){let{deck:r}=this,s=r&&r.props.getTooltip;if(!s)return;let i=s(e);this.lastViewport=e.viewport,this.setTooltip(i,e.x,e.y)}setTooltip(e,r,s){let i=this.element;if(i){if(typeof e=="string")i.innerText=e;else if(e)e.text&&(i.innerText=e.text),e.html&&(i.innerHTML=e.html),e.className&&(i.className=e.className);else{this.isVisible=!1,i.style.display="none";return}this.isVisible=!0,i.style.display="block",i.style.transform=`translate(${r}px, ${s}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(i.style,e.style)}}};var Ii;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Ii||(Ii={}));var Dl={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},et=(t,e,r)=>e?t.enable(r):t.disable(r),FC=(t,e,r)=>t.hint(r,e),rr=(t,e,r)=>t.pixelStorei(r,e),LC=(t,e,r)=>{let s=r===36006?36009:36008;return t.bindFramebuffer(s,e)},Nl=(t,e,r)=>{let i={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(i,e)};function Ox(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var NC={[3042]:et,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:et,[2885]:(t,e)=>t.cullFace(e),[2929]:et,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:et,[35723]:FC,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:LC,[36010]:LC,[34964]:Nl,[36662]:Nl,[36663]:Nl,[35053]:Nl,[35055]:Nl,[2886]:(t,e)=>t.frontFace(e),[33170]:FC,[2849]:(t,e)=>t.lineWidth(e),[32823]:et,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:et,[32926]:et,[32928]:et,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:et,[3088]:(t,e)=>t.scissor(...e),[2960]:et,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.stencilMaskSeparate(1029,e),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(t,e)=>t.viewport(...e),[34383]:et,[10754]:et,[12288]:et,[12289]:et,[12290]:et,[12291]:et,[12292]:et,[12293]:et,[12294]:et,[12295]:et,[3333]:rr,[3317]:rr,[37440]:rr,[37441]:rr,[37443]:rr,[3330]:rr,[3332]:rr,[3331]:rr,[3314]:rr,[32878]:rr,[3316]:rr,[3315]:rr,[32877]:rr,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Ox(e)?e:[e,e];let[r,s]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,s)},stencilFunc:(t,e)=>{e=Ox(e)&&e.length===3?[...e,...e]:e;let[r,s,i,n,o,a]=e;t.stencilFuncSeparate(1028,r,s,i),t.stencilFuncSeparate(1029,n,o,a)},stencilOp:(t,e)=>{e=Ox(e)&&e.length===3?[...e,...e]:e;let[r,s,i,n,o,a]=e;t.stencilOpSeparate(1028,r,s,i),t.stencilOpSeparate(1029,n,o,a)},viewport:(t,e)=>t.viewport(...e)};function Ve(t,e,r){return e[t]!==void 0?e[t]:r[t]}var DC={blendEquation:(t,e,r)=>t.blendEquationSeparate(Ve(32777,e,r),Ve(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(Ve(32969,e,r),Ve(32968,e,r),Ve(32971,e,r),Ve(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(Ve(32824,e,r),Ve(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(Ve(32938,e,r),Ve(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,Ve(2962,e,r),Ve(2967,e,r),Ve(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,Ve(34816,e,r),Ve(36003,e,r),Ve(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,Ve(2964,e,r),Ve(2965,e,r),Ve(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,Ve(34817,e,r),Ve(34818,e,r),Ve(34819,e,r))},Fx={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let s={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return s?t({[s]:r}):{valueChanged:!0}},blendColor:(t,e,r,s,i)=>t({[32773]:new Float32Array([e,r,s,i])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,s,i)=>t({[32969]:e,[32968]:r,[32971]:s,[32970]:i}),clearColor:(t,e,r,s,i)=>t({[3106]:new Float32Array([e,r,s,i])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,s,i)=>t({[3107]:[e,r,s,i]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,s,i)=>t({[3088]:new Int32Array([e,r,s,i])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,s)=>t({[2962]:e,[2967]:r,[2963]:s,[34816]:e,[36003]:r,[36004]:s}),stencilFuncSeparate:(t,e,r,s,i)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:s,[e===1028?2963:36004]:i}),stencilOp:(t,e,r,s)=>t({[2964]:e,[2965]:r,[2966]:s,[34817]:e,[34818]:r,[34819]:s}),stencilOpSeparate:(t,e,r,s,i)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:s,[e===1028?2966:34819]:i}),viewport:(t,e,r,s,i)=>t({[2978]:[e,r,s,i]})},gs=(t,e)=>t.isEnabled(e),Lx={[3042]:gs,[2884]:gs,[2929]:gs,[3024]:gs,[32823]:gs,[32926]:gs,[32928]:gs,[3089]:gs,[2960]:gs,[35977]:gs},UC=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function zr(t,e){if(k8(e))return;let r={};for(let i in e){let n=Number(i),o=NC[i];o&&(typeof o=="string"?r[o]=!0:o(t,e[i],n))}let s=t.state&&t.state.cache;if(s)for(let i in r){let n=DC[i];n(t,e,s)}}function $d(t,e=Dl){if(typeof e=="number"){let i=e,n=Lx[i];return n?n(t,i):t.getParameter(i)}let r=Array.isArray(e)?e:Object.keys(e),s={};for(let i of r){let n=Lx[i];s[i]=n?n(t,Number(i)):t.getParameter(Number(i))}return s}function kC(t){zr(t,Dl)}function k8(t){for(let e in t)return!1;return!0}function VC(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),s=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&s&&t.length===e.length){for(let i=0;i{}}={}){this.gl=e,this.cache=r?$d(e):Object.assign({},Dl),this.log=s,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){ee(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];zr(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,s,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in e){ee(n!==void 0);let o=e[n],a=this.cache[n];VC(o,a)||(r=!0,s=a,i&&!(n in i)&&(i[n]=a),this.cache[n]=o)}return{valueChanged:r,oldValue:s}}};function On(t){return t.state}function Dx(t,e){let{enable:r=!0,copyState:s}=e;if(ee(s!==void 0),!t.state){t.state=new Nx(t,{copyState:s}),z8(t);for(let n in Fx){let o=Fx[n];V8(t,n,o)}zC(t,"getParameter"),zC(t,"isEnabled")}let i=On(t);return i.enable=r,t}function Bi(t){let e=On(t);e||(Dx(t,{copyState:!1}),e=On(t)),e.push()}function Gs(t){let e=On(t);ee(e),e.pop()}function zC(t,e){let r=t[e].bind(t);t[e]=function(i){if(i===void 0||UC.has(i))return r(i);let n=On(t);return i in n.cache||(n.cache[i]=r(i)),n.enable?n.cache[i]:r(i)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function V8(t,e,r){if(!t[e])return;let s=t[e].bind(t);t[e]=function(...n){let o=On(t),{valueChanged:a,oldValue:c}=r(o._updateCache,...n);return a&&s(...n),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function z8(t){let e=t.useProgram.bind(t);t.useProgram=function(s){let i=On(t);i.program!==s&&(e(s),i.program=s)}}var H8={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function HC(t,e){e={...H8,...e};let r=null,s=n=>r=n.statusMessage||r;t.addEventListener("webglcontextcreationerror",s,!1);let i=null;if(i||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",s,!1),!i)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:n}=e;t.addEventListener("webglcontextlost",o=>n(o),!1)}if(e.onContextRestored){let{onContextRestored:n}=e;t.addEventListener("webglcontextrestored",o=>n(o),!1)}return i}function Ar(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function GC(t,e){let r=t.getParameter(7936),s=t.getParameter(7937);Ar(t,"WEBGL_debug_renderer_info",e);let i=e.WEBGL_debug_renderer_info,n=t.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=t.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=o||s,l=t.getParameter(7938),u=WC(a,c),f=G8(a,c),h=W8(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function WC(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function G8(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function W8(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(WC(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function Jd(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}var St="texture-compression-bc",Pe="texture-compression-astc",ms="texture-compression-etc2",j8="texture-compression-etc1-webgl",Zd="texture-compression-pvrtc-webgl",Ux="texture-compression-atc-webgl",Ul="float32-renderable-webgl",kx="float16-renderable-webgl",X8="rgb9e5ufloat_renderable-webgl",Vx="snorm8-renderable-webgl",kl="norm16-renderable-webgl",zx="snorm16-renderable-webgl",Qd="float32-filterable",jC="float16-filterable-webgl",Vl="WEBGL_compressed_texture_s3tc",zl="WEBGL_compressed_texture_s3tc_srgb",ia="EXT_texture_compression_rgtc",na="EXT_texture_compression_bptc",Y8="WEBGL_compressed_texture_etc",q8="WEBGL_compressed_texture_astc",K8="WEBGL_compressed_texture_etc1",$8="WEBGL_compressed_texture_pvrtc",J8="WEBGL_compressed_texture_atc",XC="EXT_texture_norm16",YC="EXT_render_snorm",Z8="EXT_color_buffer_float",ep={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[YC],"norm16-renderable-webgl":[XC],"snorm16-renderable-webgl":[XC,YC],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Vl,zl,ia,na],"texture-compression-bc5-webgl":[ia],"texture-compression-bc7-webgl":[na],"texture-compression-etc2":[Y8],"texture-compression-astc":[q8],"texture-compression-etc1-webgl":[K8],"texture-compression-pvrtc-webgl":[$8],"texture-compression-atc-webgl":[J8]};function qC(t){return t in ep}function KC(t,e,r){return(ep[e]||[]).every(i=>Ar(t,i,r))}var tp={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:Vx},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:Vx},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:kx,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:kl,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:zx},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:Vx},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:kx,filter:jC,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:kl},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:zx},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:Ul,filter:Qd},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:X8},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Ul,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:kl},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:kl},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:Ul,filter:Qd,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:kx,filter:jC},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:kl,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:zx},"rgb32float-webgl":{gl:34837,render:Ul,filter:Qd,gl2ext:Z8,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:Ul,filter:Qd,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Vl,f:St},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:zl,f:St},"bc1-rgba-unorm":{gl:33777,x:Vl,f:St},"bc1-rgba-unorm-srgb":{gl:35916,x:zl,f:St},"bc2-rgba-unorm":{gl:33778,x:Vl,f:St},"bc2-rgba-unorm-srgb":{gl:35918,x:zl,f:St},"bc3-rgba-unorm":{gl:33779,x:Vl,f:St},"bc3-rgba-unorm-srgb":{gl:35919,x:zl,f:St},"bc4-r-unorm":{gl:36283,x:ia,f:St},"bc4-r-snorm":{gl:36284,x:ia,f:St},"bc5-rg-unorm":{gl:36285,x:ia,f:St},"bc5-rg-snorm":{gl:36286,x:ia,f:St},"bc6h-rgb-ufloat":{gl:36495,x:na,f:St},"bc6h-rgb-float":{gl:36494,x:na,f:St},"bc7-rgba-unorm":{gl:36492,x:na,f:St},"bc7-rgba-unorm-srgb":{gl:36493,x:na,f:St},"etc2-rgb8unorm":{gl:37492,f:ms},"etc2-rgb8unorm-srgb":{gl:37494,f:ms},"etc2-rgb8a1unorm":{gl:37496,f:ms},"etc2-rgb8a1unorm-srgb":{gl:37497,f:ms},"etc2-rgba8unorm":{gl:37493,f:ms},"etc2-rgba8unorm-srgb":{gl:37495,f:ms},"eac-r11unorm":{gl:37488,f:ms},"eac-r11snorm":{gl:37489,f:ms},"eac-rg11unorm":{gl:37490,f:ms},"eac-rg11snorm":{gl:37491,f:ms},"astc-4x4-unorm":{gl:37808,f:Pe},"astc-4x4-unorm-srgb":{gl:37840,f:Pe},"astc-5x4-unorm":{gl:37809,f:Pe},"astc-5x4-unorm-srgb":{gl:37841,f:Pe},"astc-5x5-unorm":{gl:37810,f:Pe},"astc-5x5-unorm-srgb":{gl:37842,f:Pe},"astc-6x5-unorm":{gl:37811,f:Pe},"astc-6x5-unorm-srgb":{gl:37843,f:Pe},"astc-6x6-unorm":{gl:37812,f:Pe},"astc-6x6-unorm-srgb":{gl:37844,f:Pe},"astc-8x5-unorm":{gl:37813,f:Pe},"astc-8x5-unorm-srgb":{gl:37845,f:Pe},"astc-8x6-unorm":{gl:37814,f:Pe},"astc-8x6-unorm-srgb":{gl:37846,f:Pe},"astc-8x8-unorm":{gl:37815,f:Pe},"astc-8x8-unorm-srgb":{gl:37847,f:Pe},"astc-10x5-unorm":{gl:37819,f:Pe},"astc-10x5-unorm-srgb":{gl:37851,f:Pe},"astc-10x6-unorm":{gl:37817,f:Pe},"astc-10x6-unorm-srgb":{gl:37849,f:Pe},"astc-10x8-unorm":{gl:37818,f:Pe},"astc-10x8-unorm-srgb":{gl:37850,f:Pe},"astc-10x10-unorm":{gl:37819,f:Pe},"astc-10x10-unorm-srgb":{gl:37851,f:Pe},"astc-12x10-unorm":{gl:37820,f:Pe},"astc-12x10-unorm-srgb":{gl:37852,f:Pe},"astc-12x12-unorm":{gl:37821,f:Pe},"astc-12x12-unorm-srgb":{gl:37853,f:Pe},"pvrtc-rgb4unorm-webgl":{gl:35840,f:Zd},"pvrtc-rgba4unorm-webgl":{gl:35842,f:Zd},"pvrtc-rbg2unorm-webgl":{gl:35841,f:Zd},"pvrtc-rgba2unorm-webgl":{gl:35843,f:Zd},"etc1-rbg-unorm-webgl":{gl:36196,f:j8},"atc-rgb-unorm-webgl":{gl:35986,f:Ux},"atc-rgba-unorm-webgl":{gl:35986,f:Ux},"atc-rgbai-unorm-webgl":{gl:34798,f:Ux}},Q8={[6403]:1,[36244]:1,[33319]:2,[33320]:2,[6407]:3,[36248]:3,[6408]:4,[36249]:4,[6402]:1,[34041]:1,[6406]:1,[6409]:1,[6410]:2},ez={[5126]:4,[5125]:4,[5124]:4,[5123]:2,[5122]:2,[5131]:2,[5120]:1,[5121]:1};function rp(t,e,r){let s=tp[e];if(!s||s.gl===void 0)return!1;let i=s.x||s.gl2ext;return i?Boolean(Ar(t,i,r)):!0}function Hx(t){let r=tp[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function $C(t,e,r){if(!rp(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(jh(e).signed)return!1}catch{return!1}return e.endsWith("32float")?Boolean(Ar(t,"OES_texture_float_linear, extensions",r)):e.endsWith("16float")?Boolean(Ar(t,"OES_texture_half_float_linear, extensions",r)):!0}function JC(t,e,r){return!(!rp(t,e,r)||typeof e=="number")}function oa(t){let e=tp[t],r=Hx(t),s=jh(t);return{format:r,dataFormat:e?.dataFormat||tz(s.format,s.integer,s.normalized,r),type:s.dataType?Jd(s.dataType):e?.types?.[0]||5121,compressed:s.compressed}}function ZC(t){let e=tp[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function Gx(t){let e=oa(t),r=Q8[e.dataFormat]||4,s=ez[e.type]||1;return r*s}function tz(t,e,r,s){if(s===6408||s===6407)return s;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;default:return 6408}}var QC={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},sp=class extends Wc{gl;extensions;testedFeatures=new Set;constructor(e,r,s){super([],s),this.gl=e,this.extensions=r,Ar(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),qC(e)&&KC(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(QC),...Object.keys(ep)]}getWebGLFeature(e){let r=QC[e];return Boolean(typeof r=="string"?Ar(this.gl,r,this.extensions):r)}};var ip=class extends Gc{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};function Tr(t,e,r){if(rz(e))return r(t);let{nocatch:s=!0}=e;Bi(t),zr(t,e);let i;if(s)i=r(t),Gs(t);else try{i=r(t)}finally{Gs(t)}return i}function rz(t){for(let e in t)return!1;return!0}function tw(t,e,r,s){if(pi(e))return s(t);let i=t;Bi(i.gl);try{return sz(t,e),zr(i.gl,r),s(t)}finally{Gs(i.gl)}}function sz(t,e){let r=t,{gl:s}=r;if(e.cullMode)switch(e.cullMode){case"none":s.disable(2884);break;case"front":s.enable(2884),s.cullFace(1028);break;case"back":s.enable(2884),s.cullFace(1029);break}if(e.frontFace&&s.frontFace(Fn("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&s.enable(34383),e.depthBias!==void 0&&(s.enable(32823),s.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Fn("provokingVertex",e.provokingVertex,{first:36429,last:36430});n?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Fn("polygonMode",e.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,o),n?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&s.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&s.enable(12288),e.clipDistance1&&s.enable(12289),e.clipDistance2&&s.enable(12290),e.clipDistance3&&s.enable(12291),e.clipDistance4&&s.enable(12292),e.clipDistance5&&s.enable(12293),e.clipDistance6&&s.enable(12294),e.clipDistance7&&s.enable(12295)),e.depthWriteEnabled!==void 0&&s.depthMask(nz("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?s.enable(2929):s.disable(2929),s.depthFunc(op("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;s.stencilMaskSeparate(1028,i),s.stencilMaskSeparate(1029,i)}if(e.stencilReadMask&&U.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,n=op("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?s.enable(2960):s.disable(2960),s.stencilFuncSeparate(1028,n,0,i),s.stencilFuncSeparate(1029,n,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=Wx("stencilPassOperation",e.stencilPassOperation),n=Wx("stencilFailOperation",e.stencilFailOperation),o=Wx("stencilDepthFailOperation",e.stencilDepthFailOperation);s.stencilOpSeparate(1028,n,o,i),s.stencilOpSeparate(1029,n,o,i)}if(e.blendColorOperation||e.blendAlphaOperation){s.enable(3042);let i=ew("blendColorOperation",e.blendColorOperation||"add"),n=ew("blendAlphaOperation",e.blendAlphaOperation||"add");s.blendEquationSeparate(i,n);let o=np("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=np("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=np("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=np("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");s.blendFuncSeparate(o,a,c,l)}}function op(t,e){return Fn(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Wx(t,e){return Fn(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function ew(t,e){return Fn(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function np(t,e){return Fn(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function iz(t,e){return`Illegal parameter ${e} for ${t}`}function Fn(t,e,r){if(!(e in r))throw new Error(iz(t,e));return r[e]}function nz(t,e){return e}function ap(t){let e={};return t.addressModeU&&(e[10242]=jx(t.addressModeU)),t.addressModeV&&(e[10243]=jx(t.addressModeV)),t.addressModeW&&(e[32882]=jx(t.addressModeW)),t.magFilter&&(e[10240]=rw(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=oz(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=op("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function jx(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function rw(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function oz(t,e){if(!e)return rw(t);switch(t){case"nearest":return e==="nearest"?9984:9986;case"linear":return e==="nearest"?9985:9987}}var Lt=class extends Q{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let s=typeof r=="object"?r.handle:void 0;this.handle=s||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=az(this.props.usage),this.glUsage=cz(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,s=e.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,s,this.glUsage),this.gl.bufferSubData(i,r,e),this.gl.bindBuffer(i,null),this.bytesUsed=s,this.byteLength=s,this._setDebugData(e,r,s),this.trackAllocatedMemory(s)}_initWithByteLength(e){ee(e>=0);let r=e;e===0&&(r=new Float32Array(0));let s=this.glTarget;return this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,r,this.glUsage),this.gl.bindBuffer(s,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,e),this.gl.bindBuffer(36663,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let s=new Uint8Array(r),i=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,s,i,r),this.gl.bindBuffer(36662,null),this._setDebugData(s,e,r),s}};function az(t){return t&Q.INDEX?34963:t&Q.VERTEX?34962:t&Q.UNIFORM?35345:34962}function cz(t){return t&Q.INDEX||t&Q.VERTEX?35044:t&Q.UNIFORM?35048:35044}var Ln=class extends yi{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=ap(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,s]of Object.entries(e)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,s);break;default:this.device.gl.samplerParameteri(this.handle,i,s);break}}}};var Hr=class extends mi{device;gl;handle;texture;constructor(e,r){super(e,{...xe.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var lz={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},cp=class extends xe{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{...lz,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=uz(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:N0(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new Hr(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(m=>this.initialize(Object.assign({},e,{pixels:m,data:m}))),this;let s=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(s&&r.readyStatethis.initialize(e)),this;let{parameters:i={}}=e,{pixels:n=null,pixelStore:o={},textureUnit:a=void 0,mipmaps:c=!0}=e;r||(r=n);let{width:l,height:u,dataFormat:f,type:h,compressed:d=!1}=e,{depth:p=0}=e,g=Hx(e.format);return{width:l,height:u,compressed:d,dataFormat:f,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:f,compressed:d,data:r,width:l,height:u}),this.width=l,this.height=u,this.glFormat=g,this.type=h,this.dataFormat=f,this.textureUnit=a,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=c,this.setImageData({data:r,width:l,height:u,depth:p,format:e.format,type:h,dataFormat:f,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(i),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),c&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),s&&(this._video={video:r,parameters:i,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:s={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(s)}),this}setSampler(e={}){let r;e instanceof Ln?(this.sampler=e,r=e.props):(this.sampler=new Ln(this.device,e),r=e);let s=ap(r);return this._setSamplerParameters(s),this}resize(e){let{height:r,width:s,mipmaps:i=!1}=e;return s!==this.width||r!==this.height?this.initialize({width:s,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:e,parameters:r,lastTime:s}=this._video;if(s===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:s=null,level:i=0,glFormat:n=this.glFormat,offset:o=0,parameters:a={}}=e,{data:c=null,type:l=this.type,width:u=this.width,height:f=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;c||(c=s),{type:l,dataFormat:h,compressed:d,width:u,height:f}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:c,width:u,height:f});let{gl:p}=this;p.bindTexture(this.target,this.handle);let g=null;if({data:c,dataType:g}=this._getDataType({data:c,compressed:d}),Tr(this.gl,a,()=>{switch(g){case"null":p.texImage2D(r,i,n,u,f,0,h,l,c);break;case"typed-array":p.texImage2D(r,i,n,u,f,0,h,l,c,o);break;case"buffer":this.device.gl.bindBuffer(35052,c.handle||c),this.device.gl.texImage2D(r,i,n,u,f,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"browser-object":p.texImage2D(r,i,n,u,f,0,h,l,c);break;case"compressed":for(let[m,_]of c.entries())p.compressedTexImage2D(r,m,_.format,_.width,_.height,0,_.data);break;default:ee(!1,"Unknown image data type")}}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let m=Gx(this.props.format);this.trackAllocatedMemory(this.width*this.height*m,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:s=null,x:i=0,y:n=0,width:o=this.width,height:a=this.height,level:c=0,glFormat:l=this.glFormat,type:u=this.type,dataFormat:f=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if({type:u,dataFormat:f,compressed:h,width:o,height:a}=this._deduceParameters({format:this.props.format,type:u,dataFormat:f,compressed:h,data:s,width:o,height:a}),ee(this.depth===1,"texSubImage not supported for 3D textures"),s||(s=r),s&&s.data){let g=s;s=g.data,o=g.shape[0],a=g.shape[1]}s instanceof Lt&&(s=s.handle),this.gl.bindTexture(this.target,this.handle),Tr(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,c,i,n,o,a,l,s):s===null?this.gl.texSubImage2D(e,c,i,n,o,a,f,u,null):ArrayBuffer.isView(s)?this.gl.texSubImage2D(e,c,i,n,o,a,f,u,s,d):typeof WebGLBuffer<"u"&&s instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,s),this.device.gl.texSubImage2D(e,c,i,n,o,a,f,u,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,c,i,n,o,a,f,u,s)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return U.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof Lt?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:s}=e,{width:i,height:n,dataFormat:o,type:a,compressed:c}=e,l=oa(r);return o=o||l.dataFormat,a=a||l.type,c=c||l.compressed,{width:i,height:n}=this._deduceImageSize(s,i,n),{dataFormat:o,type:a,compressed:c,width:i,height:n,format:r,data:s}}_deduceImageSize(e,r,s){let i;return typeof ImageData<"u"&&e instanceof ImageData?i={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?i={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?i={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?i={width:e.videoWidth,height:e.videoHeight}:e?i={width:r,height:s}:i={width:r>=0?r:1,height:s>=0?s:1},ee(i,"Could not deduced texture size"),ee(r===void 0||i.width===r,"Deduced texture width does not match supplied width"),ee(s===void 0||i.height===s,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(e){let{gl:r}=this,{width:s,height:i,pixels:n,data:o,format:a=6408,type:c=5121}=e,l=n||o,u=await Promise.all(cp.FACES.map(f=>{let h=l[f];return Promise.all(Array.isArray(h)?h:[h])}));this.bind(),cp.FACES.forEach((f,h)=>{u[h].length>1&&this.props.mipmaps!==!1&&U.warn(`${this.id} has mipmap and multiple LODs.`)(),u[h].forEach((d,p)=>{s&&i?r.texImage2D(f,p,a,s,i,0,a,c,d):r.texImage2D(f,p,a,a,c,d)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:s,height:i,pixels:n,data:o,format:a=6408,type:c=5121}=e,{gl:l}=this,u=n||o;return this.bind(),u instanceof Promise?u.then(f=>this.setImageDataForFace(Object.assign({},e,{face:r,data:f,pixels:f}))):this.width||this.height?l.texImage2D(r,0,a,s,i,0,a,c,u):l.texImage2D(r,0,a,a,c,u),this}setImageData3D(e){let{level:r=0,dataFormat:s,format:i,type:n,width:o,height:a,depth:c=1,offset:l=0,data:u,parameters:f={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let h=oa(i);if(Tr(this.gl,f,()=>{ArrayBuffer.isView(u)&&this.gl.texImage3D(this.target,r,h.format,o,a,c,0,h.dataFormat,h.type,u),u instanceof Lt&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,r,s,o,a,c,0,i,n,l))}),u&&u.byteLength)this.trackAllocatedMemory(u.byteLength,"Texture");else{let d=Gx(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*d,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!pi(e)){fz(e),this.gl.bindTexture(this.target,this.handle);for(let[r,s]of Object.entries(e)){let i=Number(r),n=s;switch(i){case 33082:case 33083:this.gl.texParameterf(this.target,i,n);break;default:this.gl.texParameteri(this.target,i,n);break}}this.gl.bindTexture(this.target,null)}}},Nt=cp;Y(Nt,"FACES",[34069,34070,34071,34072,34073,34074]);function uz(t){switch(t.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function fz(t){U.log(1,"texture sampler parameters",t)()}var _s=class extends us{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let s=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||s?this.props.handle:this.gl.createFramebuffer(),!s){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let i=this.gl.bindFramebuffer(36160,this.handle);for(let n=0;nU.info("Spector capture started:",e)()),Gt?.onCapture.add(e=>{U.info("Spector capture complete:",e)(),Gt?.getResultUI(),Gt?.resultView.display(),Gt?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return Gt;Gt?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{U.info("Spector capture stopped after 2 seconds")(),Gt?.stopCapture()})}return Gt}var _z="https://unpkg.com/webgl-debug@2.0.1/index.js";function ow(t){return t.luma=t.luma||{},t.luma}async function aw(){At()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await qc(_z))}function cw(t,e={}){return t?e.debug?xz(t,e):yz(t):null}function yz(t){let e=ow(t);return e.realContext?e.realContext:t}function xz(t,e){if(!globalThis.WebGLDebugUtils)return U.warn("webgl-debug not loaded")(),t;let r=ow(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Ii,...t});let s=globalThis.WebGLDebugUtils.makeDebugContext(t,Az.bind(null,e),Tz.bind(null,e));for(let o in Ii)!(o in s)&&typeof Ii[o]=="number"&&(s[o]=Ii[o]);class i{}Object.setPrototypeOf(s,Object.getPrototypeOf(t)),Object.setPrototypeOf(i,s);let n=Object.create(i);return r.realContext=t,r.debugContext=n,n.debug=!0,n}function Xx(t,e){e=Array.from(e).map(s=>s===void 0?"undefined":s);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Az(t,e,r,s){s=Array.from(s).map(a=>a===void 0?"undefined":a);let i=globalThis.WebGLDebugUtils.glEnumToString(e),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,s),o=`${i} in gl.${r}(${n})`;U.error(o)();debugger;if(t.throwOnError)throw new Error(o)}function Tz(t,e,r){let s="";if(U.level>=1&&(s=Xx(e,r),U.log(1,s)()),t.break&&t.break.length>0&&(s=s||Xx(e,r),t.break.every(n=>s.indexOf(n)!==-1)))debugger;for(let i of r)if(i===void 0){if(s=s||Xx(e,r),t.throwOnError)throw new Error(`Undefined argument: ${s}`);U.error(`Undefined argument: ${s}`)();debugger}}function uw(t){let e=t.split(/\r?\n/),r=[];for(let s of e){if(s.length<=1)continue;let i=s.split(":");if(i.length===2){let[f,h]=i;r.push({message:h.trim(),type:lw(f),lineNum:0,linePos:0});continue}let[n,o,a,...c]=i,l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),r.push({message:c.join(":").trim(),type:lw(n),lineNum:l,linePos:u})}return r}function lw(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var up=class extends _i{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return uw(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(i=>i.startsWith("#version ")?i:`#version 100 ${i}`)(e);let{gl:s}=this.device;if(s.shaderSource(this.handle,e),s.compileShader(this.handle),U.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}U.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),U.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(n=>setTimeout(n,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:s}=this.device;for(;;){if(s.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var bz=256,Ez=1024,Sz=16384,Yx=6144,vz=[1,2,4,8],fp=class extends Po{device;glParameters;constructor(e,r){super(e,r),this.device=e,Bi(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Gs(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(r.colorMask=vz.map(s=>Boolean(s&e.colorMask))),this.glParameters=r,zr(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=Sz,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=bz,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=Ez,e.clearStencil=this.props.clearStencil),r!==0&&Tr(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){Tr(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(Yx,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(Yx,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(Yx,e,r);break}})}};var Cz="Failed to deduce GL constant from typed array";function fw(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(Cz)}}function Hl(t,e){let{clamped:r=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var wz={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},Pz={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},Oi=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return Hl(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return ee(e.size),Hl(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new Oi(wz,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return Oi.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return Oi.getBytesPerVertex(this)}_assign(e={}){return e=L0("Accessor",e,Pz),e.type!==void 0&&(this.type=e.type,(e.type===5124||e.type===5125)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function hw(t){return Mz.includes(t)}var Mz=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],dw={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2","float32x2"],[35665]:[5126,3,"vec3","vec3","float32x3"],[35666]:[5126,4,"vec4","vec4","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2","sint32x2"],[35668]:[5124,3,"ivec3","vec3","sint32x3"],[35669]:[5124,4,"ivec4","vec4","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2","uint32x2"],[36295]:[5125,3,"uvec3","vec3","uint32x3"],[36296]:[5125,4,"uvec4","vec4","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2","float32x2"],[35672]:[5126,3,"bvec3","vec3","float32x3"],[35673]:[5126,4,"bvec4","vec4","float32x4"],[35674]:[5126,8,"mat2","mat2x2"],[35685]:[5126,8,"mat2x3","mat2x3"],[35686]:[5126,8,"mat2x4","mat2x4"],[35687]:[5126,12,"mat3x2","mat3x2"],[35675]:[5126,12,"mat3","mat3x3"],[35688]:[5126,12,"mat3x4","mat3x4"],[35689]:[5126,16,"mat4x2","mat4x2"],[35690]:[5126,16,"mat4x3","mat4x3"],[35676]:[5126,16,"mat4","mat4x4"]};function qx(t){let e=dw[t];if(!e)throw new Error("uniform");let[r,s,,i]=e;return{format:i,components:s,glType:r}}function pw(t){let e=dw[t];if(!e)throw new Error("attribute");let[,r,,s,i]=e;return{attributeType:s,vertexFormat:i,components:r}}function gw(t,e){let r={attributes:[],bindings:[]};r.attributes=Rz(t,e);let s=Oz(t,e);for(let a of s){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let i=Bz(t,e),n=0;for(let a of i)if(hw(a.type)){let{viewDimension:c,sampleType:l}=Lz(a.type);r.bindings.push({type:"texture",name:a.name,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}i.length&&(r.uniforms=i);let o=Iz(t,e);return o?.length&&(r.varyings=o),r}function Rz(t,e){let r=[],s=t.getProgramParameter(e,35721);for(let i=0;i=0){let{attributeType:l}=pw(a),u=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:u,type:l})}}return r.sort((i,n)=>i.location-n.location),r}function Iz(t,e){let r=[],s=t.getProgramParameter(e,35971);for(let i=0;ii.location-n.location),r}function Bz(t,e){let r=[],s=t.getProgramParameter(e,35718);for(let i=0;i1)for(let d=0;dt.getActiveUniformBlockParameter(e,n,o),s=[],i=t.getProgramParameter(e,35382);for(let n=0;nn.location-o.location),s}var Fz={[35678]:["2d","float"],[35680]:["cube","float"],[35679]:["3d","float"],[35682]:["3d","depth"],[36289]:["2d-array","float"],[36292]:["2d-array","depth"],[36293]:["cube","float"],[36298]:["2d","sint"],[36299]:["3d","sint"],[36300]:["cube","sint"],[36303]:["2d-array","uint"],[36306]:["2d","uint"],[36307]:["3d","uint"],[36308]:["cube","uint"],[36311]:["2d-array","uint"]};function Lz(t){let e=Fz[t];if(!e)throw new Error("sampler");let[r,s]=e;return{viewDimension:r,sampleType:s}}function Nz(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function mw(t,e,r,s){let i=t,n=s;n===!0&&(n=1),n===!1&&(n=0);let o=typeof n=="number"?[n]:n;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof s!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,s);case 5126:return t.uniform1fv(e,o);case 35664:return t.uniform2fv(e,o);case 35665:return t.uniform3fv(e,o);case 35666:return t.uniform4fv(e,o);case 5124:return t.uniform1iv(e,o);case 35667:return t.uniform2iv(e,o);case 35668:return t.uniform3iv(e,o);case 35669:return t.uniform4iv(e,o);case 35670:return t.uniform1iv(e,o);case 35671:return t.uniform2iv(e,o);case 35672:return t.uniform3iv(e,o);case 35673:return t.uniform4iv(e,o);case 5125:return i.uniform1uiv(e,o,1);case 36294:return i.uniform2uiv(e,o,2);case 36295:return i.uniform3uiv(e,o,3);case 36296:return i.uniform4uiv(e,o,4);case 35674:return t.uniformMatrix2fv(e,!1,o);case 35675:return t.uniformMatrix3fv(e,!1,o);case 35676:return t.uniformMatrix4fv(e,!1,o);case 35685:return i.uniformMatrix2x3fv(e,!1,o);case 35686:return i.uniformMatrix2x4fv(e,!1,o);case 35687:return i.uniformMatrix3x2fv(e,!1,o);case 35688:return i.uniformMatrix3x4fv(e,!1,o);case 35689:return i.uniformMatrix4x2fv(e,!1,o);case 35690:return i.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function _w(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(t)}}function yw(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(t)}}var xw=4,hp=class extends Rr{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:s,bufferMode:i=35981}=r;switch(s&&s.length>0&&(this.varyings=s,this.device.gl.transformFeedbackVaryings(this.handle,s,i)),this._linkShaders(),U.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=gw(this.device.gl,this.handle),U.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=P0(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":U.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,r){for(let[s,i]of Object.entries(e)){let n=this.shaderLayout.bindings.find(o=>o.name===s)||this.shaderLayout.bindings.find(o=>o.name===`${s}Uniforms`);if(!n){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||U.warn(`Unknown binding "${s}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(i||U.warn(`Unsetting binding "${s}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(i instanceof Lt)&&!(i.buffer instanceof Lt))throw new Error("buffer value");break;case"texture":if(!(i instanceof Hr||i instanceof Nt||i instanceof _s))throw new Error("texture value");break;case"sampler":U.warn(`Ignoring sampler ${s}`)();break;default:throw new Error(n.type)}this.bindings[s]=i}}draw(e){let{renderPass:r,parameters:s=this.props.parameters,topology:i=this.props.topology,vertexArray:n,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u}=e,f=_w(i),h=Boolean(n.indexBuffer),d=n.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return U.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||o===0)return U.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(o===0)return U.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let p=r;return tw(this.device,s,p.glParameters,()=>{h&&c?this.device.gl.drawElementsInstanced(f,o||0,d,l,a||0):h?this.device.gl.drawElements(f,o||0,d,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,a||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=gn(e);Object.keys(r).forEach(s=>{U.warn(`Unsupported value "${JSON.stringify(r[s])}" used in setUniforms() for key ${s}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),U.time(xw,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),U.timeEnd(xw,`linkProgram for ${this.id}`)(),U.level,!this.device.features.has("compilation-status-async-webgl")){let s=this._getLinkStatus();this._reportLinkStatus(s);return}U.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),U.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(n=>setTimeout(n,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:s}=this.device;for(;;){if(s.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof Nt&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,s=0;for(let i of this.shaderLayout.bindings){let n=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:o}=i,a=e.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,s,a),n instanceof Lt?e.bindBufferBase(35345,s,n.handle):e.bindBufferRange(35345,s,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),s+=1;break;case"texture":if(!(n instanceof Hr||n instanceof Nt||n instanceof _s))throw new Error("texture");let c;if(n instanceof Hr)c=n.texture;else if(n instanceof Nt)c=n;else if(n instanceof _s&&n.colorAttachments[0]instanceof Hr)U.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=n.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+r),e.bindTexture(c.target,c.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:s,type:i,textureUnit:n}=e,o=this.uniforms[r]??n;o!==void 0&&mw(this.device.gl,s,i,o)}}};var dp=class extends Ro{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":Dz(this.device,r.options);break;case"copy-buffer-to-texture":Uz(this.device,r.options);break;case"copy-texture-to-buffer":kz(this.device,r.options);break;case"copy-texture-to-texture":Vz(this.device,r.options);break}}};function Dz(t,e){let r=e.source,s=e.destination;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,s.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function Uz(t,e){throw new Error("Not implemented")}function kz(t,e){let{source:r,mipLevel:s=0,aspect:i="all",width:n=e.source.width,height:o=e.source.height,depthOrArrayLayers:a=0,origin:c=[0,0],destination:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(i!=="all")throw new Error("not supported");if(s!==0||a!==0||f||h)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=Aw(r),g;try{let m=l,_=n||d.width,y=o||d.height,x=oa(d.texture.props.format),S=x.dataFormat,P=x.type;t.gl.bindBuffer(35051,m.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],_,y,S,P,u)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function Vz(t,e){let{source:r,destinationMipLevel:s=0,origin:i=[0,0],destinationOrigin:n=[0,0],destination:o}=e,{width:a=e.destination.width,height:c=e.destination.height}=e,{framebuffer:l,destroyFramebuffer:u}=Aw(r),[f,h]=i,[d,p,g]=n,m=t.gl.bindFramebuffer(36160,l.handle),_=null,y;if(o instanceof Nt)_=o,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_.bind(0),y=_.target;else throw new Error("invalid destination");switch(y){case 3553:case 34067:t.gl.copyTexSubImage2D(y,s,d,p,f,h,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(y,s,d,p,g,f,h,a,c);break;default:}_&&_.unbind(),t.gl.bindFramebuffer(36160,m),u&&l.destroy()}function Aw(t){if(t instanceof xe){let{width:e,height:r,id:s}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${s}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var pp=class extends Mo{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new dp(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,s){}};var aa=class extends Io{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return x_()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let s=r;if(s.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:n,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,s.handle),l?this.device.gl.vertexAttribIPointer(e,i,n,o,a):this.device.gl.vertexAttribPointer(e,i,n,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=s,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let s=this._getVaryingIndex(e),{buffer:i,byteLength:n,byteOffset:o}=this._getBufferRange(r);if(s<0){this.unusedBuffers[e]=i,U.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[s]={buffer:i,byteLength:n,byteOffset:o},this.bindOnUse||this._bindBuffer(s,i,o,n)}getBuffer(e){if(Tw(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Lt)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:s=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:r,byteOffset:s,byteLength:i}}_getVaryingIndex(e){if(Tw(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:s,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,i,s)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,s=0,i){let n=r&&r.handle;!n||i===void 0?this.gl.bindBufferBase(35982,e,n):this.gl.bindBufferRange(35982,e,n,s,i)}};function Tw(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var mp=class extends Oo{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((s,i)=>{let n=()=>{this.isResultAvailable()?(s(this.getResult()),this._pollingPromise=null):r++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}};function Kx(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return ee(!1),0}}function bw(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return ee(!1),0}}function Ew(t,e){let{sourceX:r=0,sourceY:s=0,sourceFormat:i=6408,sourceAttachment:n=36064}=e||{},{target:o=null,sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=vw(t);ee(u);let{gl:h,handle:d}=u;a=a||u.width,c=c||u.height;let p=n-36064;l=l||u.colorAttachments[p]?.texture?.type||5121,o=Wz(o,l,i,a,c),l=l||fw(o);let g=h.bindFramebuffer(36160,d);return h.readPixels(r,s,a,c,i,l,o),h.bindFramebuffer(36160,g||null),f&&u.destroy(),o}function Sw(t,e){let{target:r,sourceX:s=0,sourceY:i=0,sourceFormat:n=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=vw(t);ee(u),a=a||u.width,c=c||u.height;let h=u;l=l||5121;let d=r;if(!d){let g=Kx(n),m=bw(l),_=o+a*c*g*m;d=h.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({source:t,width:a,height:c,origin:[s,i],destination:d,byteOffset:o}),p.destroy(),f&&u.destroy(),d}function vw(t){return t instanceof us?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:Gz(t),deleteFramebuffer:!0}}function Gz(t,e){let{device:r,width:s,height:i,id:n}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${n}`,width:s,height:i,colorAttachments:[t]})}function Wz(t,e,r,s,i){if(t)return t;e=e||5121;let n=Hl(e,{clamped:!1}),o=Kx(r);return new n(s*i*o)}var jz=256,Xz=1024,Yz=16384;var qz="clear: bad arguments";function Cw(t,e){let{framebuffer:r=null,color:s=null,depth:i=null,stencil:n=null}=e||{},o={};r&&(o.framebuffer=r);let a=0;s&&(a|=Yz,s!==!0&&(o.clearColor=s)),i&&(a|=jz,i!==!0&&(o.clearDepth=i)),n&&(a|=Xz,i!==!0&&(o.clearStencil=i)),ee(a!==0,qz);let c=t.gl;Tr(c,o,()=>{c.clear(a)})}var Gl=1,ca=class extends Zt{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof ca)return e;if(e?.device instanceof Zt)return e.device;if(!Kz(e))throw new Error("Invalid WebGL2RenderingContext");return new ca({gl:e})}static async create(e={}){U.groupCollapsed(Gl,"WebGLDevice created")();let r=[];e.debug&&r.push(aw()),e.spector&&r.push(iw()),typeof e.canvas=="string"&&r.push(gi.pageLoaded);let s=await Promise.allSettled(r);for(let o of s)o.status==="rejected"&&U.error(`Failed to initialize debug libraries ${o.reason}`)();if(U.probe(Gl+1,"DOM is loaded")(),e.gl?.device)return U.warn("reattaching existing device")(),ca.attach(e.gl);let i=new ca(e),n=`Created ${i.type}${i.debug?" debug":""} context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return U.probe(Gl,n)(),U.table(Gl,i.info)(),U.groupEnd(Gl)(),i}constructor(e){super({...e,id:e.id||Ge("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let s=e.gl?.canvas||e.canvas;this.canvasContext=new lp(this,{...e,canvas:s}),this.lost=new Promise(a=>{this._resolveContextLost=a});let i=e.gl||null;if(i||=HC(this.canvasContext.canvas,{...e,onContextLost:a=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!i)throw new Error("WebGL context creation failed");this.handle=i,this.gl=i,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=nw({...this.props,canvas:this.handle.canvas})),this.info=GC(this.gl,this._extensions),this.limits=new ip(this.gl),this.features=new sp(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:n=!0,copyState:o=!1}=e;Dx(this.gl,{enable:n,copyState:o,log:(...a)=>U.log(1,...a)()}),e.debug&&(this.gl=cw(this.gl,{...e,throwOnError:!0}),this.debug=!0,U.level=Math.max(U.level,1),U.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return rp(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return $C(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return JC(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new Lt(this,r)}_createTexture(e){return new Nt(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new Ln(this,e)}createShader(e){return new up(this,e)}createFramebuffer(e){return new _s(this,e)}createVertexArray(e){return new aa(this,e)}createTransformFeedback(e){return new gp(this,e)}createQuerySet(e){return new mp(this,e)}createRenderPipeline(e){return new hp(this,e)}beginRenderPass(e){return new fp(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new pp(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return Ew(e,r)}readPixelsToBufferWebGL(e,r){return Sw(e,r)}setParametersWebGL(e){zr(this.gl,e)}getParametersWebGL(e){return $d(this.gl,e)}withParametersWebGL(e,r){return Tr(this.gl,e,r)}clearWebGL(e){Cw(this,e)}resetWebGL(){U.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),kC(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,s=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return s&&(e=!0,s.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Bi(this.gl)}popState(){Gs(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let s=Number(e);for(let i in r)if(r[i]===s)return`GL.${i}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let s=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(s).fill(null);let i=this._constants[e];switch(i&&Qz(i,r)&&U.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:$z(this,e,r);break;case Int32Array:Jz(this,e,r);break;case Uint32Array:Zz(this,e,r);break;default:ee(!1)}}getExtension(e){return Ar(this.gl,e,this._extensions),this._extensions}},Fi=ca;Y(Fi,"type","webgl");function Kz(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&Number.isFinite(t._version))}function $z(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:ee(!1)}}function Jz(t,e,r){t.gl.vertexAttribI4iv(e,r)}function Zz(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function Qz(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r0&&s.type==="pointerdown"&&(t5(i,n=>n.pointerId===s.pointerId)||i.push(s)),e.call(this,s)}}function Mw(t){t.prototype.handler=function(r){let s=e5[r.type];s&1&&r.button>=0&&(this.pressed=!0),s&2&&r.which===0&&(s=4),this.pressed&&(s&4&&(this.pressed=!1),this.callback(this.manager,s,{pointers:[r],changedPointers:[r],pointerType:"mouse",srcEvent:r}))}}Pw(Nn.PointerEventInput);Mw(Nn.MouseInput);var Rw=Nn.Manager,Gr=Nn;var Wr=class{constructor(e,r,s){this.element=e,this.callback=r,this.options={enable:!0,...s}}};var Iw=Gr?[[Gr.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Gr.Rotate,{enable:!1}],[Gr.Pinch,{enable:!1}],[Gr.Swipe,{enable:!1}],[Gr.Pan,{threshold:0,enable:!1}],[Gr.Press,{enable:!1}],[Gr.Tap,{event:"doubletap",taps:2,enable:!1}],[Gr.Tap,{event:"anytap",enable:!1}],[Gr.Tap,{enable:!1}]]:null,$x={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Bw={doubletap:["tap"]},Ow={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},la={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},Fw={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},Jx={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var Lw=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Dn=typeof window<"u"?window:global;var yp=!1;try{let t={get passive(){return yp=!0,!0}};Dn.addEventListener("test",null,t),Dn.removeEventListener("test",null)}catch{yp=!1}var r5=Lw.indexOf("firefox")!==-1,{WHEEL_EVENTS:s5}=la,Nw="wheel",Dw=4.000244140625,i5=40,n5=.25,Wl=class extends Wr{constructor(e,r,s){super(e,r,s),this.handleEvent=i=>{if(!this.options.enable)return;let n=i.deltaY;Dn.WheelEvent&&(r5&&i.deltaMode===Dn.WheelEvent.DOM_DELTA_PIXEL&&(n/=Dn.devicePixelRatio),i.deltaMode===Dn.WheelEvent.DOM_DELTA_LINE&&(n*=i5)),n!==0&&n%Dw===0&&(n=Math.floor(n/Dw)),i.shiftKey&&n&&(n=n*n5),this.callback({type:Nw,center:{x:i.clientX,y:i.clientY},delta:-n,srcEvent:i,pointerType:"mouse",target:i.target})},this.events=(this.options.events||[]).concat(s5),this.events.forEach(i=>e.addEventListener(i,this.handleEvent,yp?{passive:!1}:!1))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===Nw&&(this.options.enable=r)}};var{MOUSE_EVENTS:o5}=la,Uw="pointermove",kw="pointerover",Vw="pointerout",zw="pointerenter",Hw="pointerleave",jl=class extends Wr{constructor(e,r,s){super(e,r,s),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:i}=this.options;this.enableMoveEvent=i,this.enableLeaveEvent=i,this.enableEnterEvent=i,this.enableOutEvent=i,this.enableOverEvent=i,this.events=(this.options.events||[]).concat(o5),this.events.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===Uw&&(this.enableMoveEvent=r),e===kw&&(this.enableOverEvent=r),e===Vw&&(this.enableOutEvent=r),e===zw&&(this.enableEnterEvent=r),e===Hw&&(this.enableLeaveEvent=r)}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit(kw,e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit(Vw,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit(zw,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit(Hw,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.which===0&&(this.pressed=!1),this.pressed||this._emit(Uw,e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var{KEY_EVENTS:a5}=la,Gw="keydown",Ww="keyup",Xl=class extends Wr{constructor(e,r,s){super(e,r,s),this.handleEvent=i=>{let n=i.target||i.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&i.type==="keydown"&&this.callback({type:Gw,srcEvent:i,key:i.key,target:i.target}),this.enableUpEvent&&i.type==="keyup"&&this.callback({type:Ww,srcEvent:i,key:i.key,target:i.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(a5),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(i=>e.addEventListener(i,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===Gw&&(this.enableDownEvent=r),e===Ww&&(this.enableUpEvent=r)}};var jw="contextmenu",Yl=class extends Wr{constructor(e,r,s){super(e,r,s),this.handleEvent=i=>{this.options.enable&&this.callback({type:jw,center:{x:i.clientX,y:i.clientY},srcEvent:i,pointerType:"mouse",target:i.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e===jw&&(this.options.enable=r)}};var c5={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},l5=1,u5=2,f5=3,h5=0,d5=1,p5=2,g5=1,m5=2,_5=4;function Xw(t){let e=c5[t.srcEvent.type];if(!e)return null;let{buttons:r,button:s,which:i}=t.srcEvent,n=!1,o=!1,a=!1;return e===4||e===2&&!Number.isFinite(r)?(n=i===l5,o=i===u5,a=i===f5):e===2?(n=Boolean(r&g5),o=Boolean(r&_5),a=Boolean(r&m5)):e===1&&(n=s===h5,o=s===d5,a=s===p5),{leftButton:n,middleButton:o,rightButton:a}}function Yw(t,e){let r=t.center;if(!r)return null;let s=e.getBoundingClientRect(),i=s.width/e.offsetWidth||1,n=s.height/e.offsetHeight||1,o={x:(r.x-s.left-e.clientLeft)/i,y:(r.y-s.top-e.clientTop)/n};return{center:r,offsetCenter:o}}var Zx={srcElement:"root",priority:0},ql=class{constructor(e){this.handleEvent=r=>{if(this.isEmpty())return;let s=this._normalizeEvent(r),i=r.srcEvent.target;for(;i&&i!==s.rootElement;){if(this._emit(s,i),s.handled)return;i=i.parentNode}this._emit(s,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,s,i=!1,n=!1){let{handlers:o,handlersByElement:a}=this,c=Zx;typeof s=="string"||s&&s.addEventListener?c={...Zx,srcElement:s}:s&&(c={...Zx,...s});let l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};i&&(u.once=!0),n&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,r){let{handlers:s,handlersByElement:i}=this;for(let n=s.length-1;n>=0;n--){let o=s[n];if(o.type===e&&o.handler===r){s.splice(n,1);let a=i.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&i.delete(o.srcElement)}}this._active=s.some(n=>!n.passive)}_emit(e,r){let s=this.handlersByElement.get(r);if(s){let i=!1,n=()=>{e.handled=!0},o=()=>{e.handled=!0,i=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};var y5={events:null,recognizers:null,recognizerOptions:{},Manager:Rw,touchAction:"none",tabIndex:0},ua=class{constructor(e=null,r){this._onBasicInput=i=>{let{srcEvent:n}=i,o=Ow[n.type];o&&this.manager.emit(o,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={...y5,...r},this.events=new Map,this.setElement(e);let{events:s}=this.options;s&&this.on(s)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;let{options:r}=this,s=r.Manager;this.manager=new s(e,{touchAction:r.touchAction,recognizers:r.recognizers||Iw}).on("hammer.input",this._onBasicInput),r.recognizers||Object.keys($x).forEach(i=>{let n=this.manager.get(i);n&&$x[i].forEach(o=>{n.recognizeWith(o)})});for(let i in r.recognizerOptions){let n=this.manager.get(i);if(n){let o=r.recognizerOptions[i];delete o.enable,n.set(o)}}this.wheelInput=new Wl(e,this._onOtherEvent,{enable:!1}),this.moveInput=new jl(e,this._onOtherEvent,{enable:!1}),this.keyInput=new Xl(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new Yl(e,this._onOtherEvent,{enable:!1});for(let[i,n]of this.events)n.isEmpty()||(this._toggleRecognizer(n.recognizerName,!0),this.manager.on(i,n.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(e,r,s){this._addEventHandler(e,r,s,!1)}once(e,r,s){this._addEventHandler(e,r,s,!0)}watch(e,r,s){this._addEventHandler(e,r,s,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:s}=this;if(!s)return;let i=s.get(e);if(i&&i.options.enable!==r){i.set({enable:r});let n=Bw[e];n&&!this.options.recognizers&&n.forEach(o=>{let a=s.get(o);r?(a.requireFailure(e),i.dropRequireFailure(o)):a.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,r),this.moveInput.enableEventType(e,r),this.keyInput.enableEventType(e,r),this.contextmenuInput.enableEventType(e,r)}_addEventHandler(e,r,s,i,n){if(typeof e!="string"){s=r;for(let u in e)this._addEventHandler(u,e[u],s,i,n);return}let{manager:o,events:a}=this,c=Jx[e]||e,l=a.get(c);l||(l=new ql(this),a.set(c,l),l.recognizerName=Fw[c]||c,o&&o.on(c,l.handleEvent)),l.add(e,r,s,i,n),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let o in e)this._removeEventHandler(o,e[o]);return}let{events:s}=this,i=Jx[e]||e,n=s.get(i);if(n&&(n.remove(e,r),n.isEmpty())){let{recognizerName:o}=n,a=!1;for(let c of s.values())if(c.recognizerName===o&&!c.isEmpty()){a=!0;break}a||this._toggleRecognizer(o,!1)}}};function Li(){}var x5=({isDragging:t})=>t?"grabbing":"grab",qw={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{type:"webgl"},gl:null,glOptions:{},canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Li,onWebGLInitialized:Li,onResize:Li,onViewStateChange:Li,onInteractionStateChange:Li,onBeforeRender:Li,onAfterRender:Li,onLoad:Li,onError:t=>k.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:x5,getTooltip:null,debug:!1,drawPickingColors:!1},Kl=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Tt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=s=>{let{_pickRequest:i}=this;if(s.type==="pointerleave")i.x=-1,i.y=-1,i.radius=0;else{if(s.leftButton||s.rightButton)return;{let n=s.offsetCenter;if(!n)return;i.x=n.x,i.y=n.y,i.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:i.x,y:i.y}),i.event=s},this._onEvent=s=>{let i=ul[s.type],n=s.offsetCenter;if(!i||!n||!this.layerManager)return;let o=this.layerManager.getLayers(),a=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:o,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:c}=a,l=c&&(c[i.handler]||c.props[i.handler]),u=this.props[i.handler],f=!1;l&&(f=l.call(c,a,s)),f||(u?.(a,s),this.widgetManager.onEvent(a,s))},this._onPointerDown=s=>{let i=s.offsetCenter,n=this._pick("pickObject","pickObject Time",{x:i.x,y:i.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=n.result[0]||n.emptyInfo},this.props={...qw,...e},e=this.props,e.viewState&&e.initialViewState&&k.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device?this.device=e.device:e.gl&&(e.gl instanceof WebGLRenderingContext&&k.error("WebGL1 context not supported.")(),this.device=Fi.attach(e.gl));let r=this.device;r||(Vt.registerDevices([Fi]),r=Vt.createDevice({...e.deviceProps,canvas:this._createCanvas(e)})),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Nr.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&k.removed("onLayerHover","onHover")(),"onLayerClick"in e&&k.removed("onLayerClick","onClick")(),e.initialViewState&&!ve(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop?.setProps(r),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let s=this.viewManager.needsRedraw(e),i=this.layerManager.needsRedraw(e),n=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return r=r||s||i||n||o,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return Ae(this.viewManager),this.viewManager.views}getViewports(e){return Ae(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,r=!1){for(let s in e)this.layerManager.resourceManager.add({resourceId:s,data:e[s],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,r,s){Ae(this.deckPicker);let{stats:i}=this;i.get("Pick Count").incrementCount(),i.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(s),views:this.viewManager.getViews(),viewports:this.getViewports(s),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...s});return i.get(r).timeEnd(),n}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),Ae(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:s}=e;if(r||r===0){let i=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=i}if(s||s===0){let i=Number.isFinite(s)?`${s}px`:s;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=i}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,s=e.clientHeight??e.height;(r!==this.width||s!==this.height)&&(this.width=r,this.height=s,this.viewManager?.setProps({width:r,height:s}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:s}))}_createAnimationLoop(e,r){let{gl:s,onError:i,useDevicePixels:n}=r;return new xl({device:e,useDevicePixels:n,autoResizeDrawingBuffer:!s,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:i})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new Ri({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let{result:r,emptyInfo:s}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=r.length>0;let i=s,n=!1;for(let o of r)i=o,n=o.layer?.onHover(o,e.event)||n;n||(this.props.onHover?.(i,e.event),this.widgetManager.onHover(i,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas),this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device instanceof Fi&&this.props.onWebGLInitialized(this.device.gl);let r=new Pn;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new ua(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in ul)this.eventManager.on(i,this._onEvent);this.viewManager=new Pl({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let s=this.viewManager.getViewports()[0];this.layerManager=new Mn(this.device,{deck:this,stats:this.stats,viewport:s,timeline:r}),this.effectManager=new Bl({deck:this,device:this.device}),this.deckRenderer=new Bn(this.device),this.deckPicker=new Fl(this.device),this.widgetManager=new Kd({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Ll),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:s,gl:i}=this.layerManager.context;this.props.onBeforeRender({device:s,gl:i});let n={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(n),n.pass==="screen"&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:s,gl:i})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),k.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let s=Vt.stats.get("Memory Usage");e.bufferMemory=s.get("Buffer Memory").count,e.textureMemory=s.get("Texture Memory").count,e.renderbufferMemory=s.get("Renderbuffer Memory").count,e.gpuMemory=s.get("GPU Memory").count}};Kl.defaultProps=qw;Kl.VERSION=Gh;var jr=Kl;function Kw(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Yc(t)}}var $w=Zh;function $l(t,e){return{attribute:t,format:e.size>1?`${e.type}x${e.size}`:e.type,byteOffset:e.offset||0}}function Ni(t){return t.stride||t.size*t.bytesPerElement}function Jw(t,e){return t.type===e.type&&t.size===e.size&&Ni(t)===Ni(e)&&(t.offset||0)===(e.offset||0)}function Qx(t,e){e.offset&&k.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Ni(t),s=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,i=e.elementOffset||0,n=s*r+i*t.bytesPerElement+(t.offset||0);return{...e,offset:n,stride:r}}function A5(t,e){let r=Qx(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Jl=class{constructor(e,r,s){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let i=r.logicalType||r.type,n=i==="float64",{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;n?a="float32":!i&&r.isIndexed?a="uint32":a=i||"float32";let c=Kw(i||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:o,logicalType:i,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...s,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Ni(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Nr.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let s={};if(this.state.constant){let i=this.value;if(r){let n=Qx(this.getAccessor(),r),o=n.offset/i.BYTES_PER_ELEMENT,a=n.size||this.size;s[e]=i.subarray(o,o+a)}else s[e]=i}else s[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?s[`${e}64Low`]=s[e]:s[`${e}64Low`]=new Float32Array(this.size)),s}_getBufferLayout(e=this.id,r=null){let s=this.getAccessor(),i=[],n={name:this.id,byteStride:Ni(s),attributes:i};if(this.doublePrecision){let o=A5(s,r||{});i.push($l(e,{...s,...o.high}),$l(`${e}64Low`,{...s,...o.low}))}else if(r){let o=Qx(s,r);i.push($l(e,{...s,...o}))}else i.push($l(e,s));return n}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:s,size:i}=this,n=s*i;if(r&&n&&r.length>=n){let o=new Array(i).fill(1/0),a=new Array(i).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,s;ArrayBuffer.isView(e)?s={value:e}:e instanceof Q?s={buffer:e}:s=e;let i={...this.settings,...s};if(ArrayBuffer.isView(s.value)){if(!s.type)if(this.doublePrecision&&s.value instanceof Float64Array)i.type="float32";else{let o=$w(s.value);i.type=i.normalized?o.replace("int","norm"):o}i.bytesPerElement=s.value.BYTES_PER_ELEMENT,i.stride=Ni(i)}if(r.bounds=null,s.constant){let n=s.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(s.buffer){let n=s.buffer;r.externalBuffer=n,r.constant=!1,this.value=s.value||null}else if(s.value){this._checkExternalBuffer(s);let n=s.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:o}=this,a=Ni(i),c=(i.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=kd(n,i)),this.settings.isIndexed){let u=this.settings.defaultType;n.constructor!==u&&(n=new u(n))}let l=n.byteLength+c+a*2;(!o||o.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,s){let{defaultValue:i,size:n}=this.settings;if(Number.isFinite(e))return r[s]=e,r;if(!e){let o=n;for(;--o>=0;)r[s+o]=i[o];return r}switch(n){case 4:r[s+3]=Number.isFinite(e[3])?e[3]:i[3];case 3:r[s+2]=Number.isFinite(e[2])?e[2]:i[2];case 2:r[s+1]=Number.isFinite(e[1])?e[1]:i[1];case 1:r[s+0]=Number.isFinite(e[0])?e[0]:i[0];break;default:let o=n;for(;--o>=0;)r[s+o]=Number.isFinite(e[o])?e[o]:i[o]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:s}=this;for(let i=0;i0&&(Qw.length=t.length,s=Qw):s=Zw,(e>0||Number.isFinite(r))&&(s=(Array.isArray(s)?s:Array.from(s)).slice(e,r),i.index=e-1),{iterable:s,objectInfo:i}}function xp(t){return t&&t[Symbol.asyncIterator]}function Ap(t,e){let{size:r,stride:s,offset:i,startIndices:n,nested:o}=e,a=t.BYTES_PER_ELEMENT,c=s?s/a:r,l=i?i/a:0,u=Math.floor((t.length-l)/c);return(f,{index:h,target:d})=>{if(!n){let _=h*c+l;for(let y=0;y=e[1]))return t;let r=[],s=t.length,i=0;for(let n=0;ne[1]?r.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return r.splice(i,0,e),r}var b5={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Tp(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...b5[r],...e,...t,type:r}}var Ws=class extends Jl{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Zl}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!Jw(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,s=this.settings.transition,i=Array.isArray(r)?e[r.find(n=>e[n])]:e[r];return Tp(i,s)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:s=0,endRow:i=1/0}=r;this.state.updateRanges=tP(this.state.updateRanges,[s,i])}else this.state.updateRanges=Zl}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=eP}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:s}=this;return s.noAlloc?!1:s.update?(super.allocate(e,r.updateRanges!==Zl),!0):!1}updateBuffer({numInstances:e,data:r,props:s,context:i}){if(!this.needsUpdate())return!1;let{state:{updateRanges:n},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of n)o.call(i,this,{data:r,startRow:l,endRow:u,props:s,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(x,g):(e._normalizeValue(x,_.target,0),Xd({target:l,source:_.target,start:g,count:S}));g+=S*u}else e._normalizeValue(x,l,g),g+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let s=!0;switch(r){case 4:s=s&&Number.isFinite(e[3]);case 3:s=s&&Number.isFinite(e[2]);case 2:s=s&&Number.isFinite(e[1]);case 1:s=s&&Number.isFinite(e[0]);break;default:s=!1}if(!s)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function eA(t){let{source:e,target:r,start:s=0,size:i,getData:n}=t,o=t.end||r.length,a=e.length,c=o-s;if(a>c){r.set(e.subarray(0,c),s);return}if(r.set(e,s),!n)return;let l=a;for(;ls(u+a,f)),l=Math.min(i.length,n.length);for(let u=1;ua}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,u=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,f=r.startIndices,h=n&&f,d=r.isConstant;if(!h&&e&&s>=i)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,i*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let x=o;o=(S,P)=>r.normalizeConstant(x(S,P))}let m=d?(x,S)=>o(g,S):(x,S)=>o(g.subarray(x+l,x+l+c),S),_=e?new Float32Array(e.readSyncWebGL(u,s*4).buffer):new Float32Array(0),y=new Float32Array(i);return rP({source:_,target:y,sourceStartIndices:n,targetStartIndices:f,size:c,getData:m}),(!e||e.byteLength0||i.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},C5=`#version 300 es #define SHADER_NAME spring-transition-vertex-shader #define EPSILON 0.00001 uniform float stiffness; uniform float damping; in ATTRIBUTE_TYPE aPrev; in ATTRIBUTE_TYPE aCur; in ATTRIBUTE_TYPE aTo; out ATTRIBUTE_TYPE vNext; out float vIsTransitioningFlag; ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { ATTRIBUTE_TYPE velocity = cur - prev; ATTRIBUTE_TYPE delta = dest - cur; ATTRIBUTE_TYPE spring = delta * stiffness; ATTRIBUTE_TYPE damper = velocity * -1.0 * damping; return spring + damper + velocity + cur; } void main(void) { bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; vNext = getNextValue(aCur, aPrev, aTo); gl_Position = vec4(0, 0, 0, 1); gl_PointSize = 100.0; } `,w5=`#version 300 es #define SHADER_NAME spring-transition-is-transitioning-fragment-shader in float vIsTransitioningFlag; out vec4 fragColor; void main(void) { if (vIsTransitioningFlag == 0.0) { discard; } fragColor = vec4(1.0); }`;function P5(t,e){let r=bp(e.size),s=Ep(e.size);return new _r(t,{vs:C5,fs:w5,bufferLayout:[{name:"aPrev",format:s},{name:"aCur",format:s},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function M5(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",mipmaps:!1,width:1,height:1})}function R5(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var I5={interpolation:Ql,spring:eu},tu=class{constructor(e,{id:r,timeline:s}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=s,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:s}){this.numInstances=s||1;for(let i in e){let n=e[i],o=n.getTransitionSetting(r);o&&this._updateAttribute(i,n,o)}for(let i in this.transitions){let n=e[i];(!n||!n.getTransitionSetting(r))&&this._removeTransition(i)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let s=this.transitions[r];s.inProgress&&(e[r]=s.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,s){let i=this.transitions[e],n=!i||i.type!==s.type;if(n){i&&this._removeTransition(e);let o=I5[s.type];o?this.transitions[e]=new o({attribute:r,timeline:this.timeline,device:this.device}):(k.error(`unsupported transition type '${s.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(s,this.numInstances))}};var oP="attributeManager.invalidate",B5="attributeManager.updateStart",O5="attributeManager.updateEnd",F5="attribute.updateStart",L5="attribute.allocate",N5="attribute.updateEnd",Xr=class{constructor(e,{id:r="attribute-manager",stats:s,timeline:i}={}){this.mergeBoundsMemoized=zt(mC),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=s,this.attributeTransitionManager=new tu(e,{id:`${r}-transitions`,timeline:i}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let s=this._invalidateTrigger(e,r);Ue(oP,this,e,s)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);Ue(oP,this,"all")}update({data:e,numInstances:r,startIndices:s=null,transitions:i,props:n={},buffers:o={},context:a={}}){let c=!1;Ue(B5,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=s,u.numInstances=r,n[l]&&k.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(n[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:r,data:e,props:n,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&Ue(O5,this,r),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:i})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(s=>this.attributes[s]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:s}=this,i={...s.getAttributes()};for(let n in r){let o=r[n];o.needsRedraw(e)&&!s.hasAttribute(n)&&(i[n]=o)}return i}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let s in e){let i=e[s],n={...i,id:s,size:i.isIndexed&&1||i.size||1,...r};this.attributes[s]=new Ws(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(i=>{e[i]||(e[i]=[]),e[i].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:s,updateTriggers:i}=this,n=i[e];return n&&n.forEach(o=>{let a=s[o];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(e){let{attribute:r,numInstances:s}=e;if(Ue(F5,r),r.constant){r.setConstantValue(r.value);return}r.allocate(s)&&Ue(L5,r,s),r.updateBuffer(e)&&(this.needsRedraw=!0,Ue(N5,r,s))}};var ru=class extends Vr{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:s,duration:i,easing:n}}=this,o=n(e/i);this._value=it(r,s,o)}};var aP=1e-5;function cP(t,e,r,s,i){let n=e-t,a=(r-e)*i,c=-n*s;return a+c+n+e}function D5(t,e,r,s,i){if(Array.isArray(r)){let n=[];for(let o=0;o0}add(e,r,s,i){let{transitions:n}=this;if(n.has(e)){let c=n.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(i=Tp(i),!i)return;let o=U5[i.type];if(!o){k.error(`unsupported transition type '${i.type}'`)();return}let a=new o(this.timeline);a.start({...i,fromValue:r,toValue:s}),n.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,s]of this.transitions)s.update(),e[r]=s.value,s.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function fP(t){let e=t[xr];for(let r in e){let s=e[r],{validate:i}=s;if(i&&!i(t[r],s))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function hP(t,e){let r=ha({newProps:t,oldProps:e,propTypes:t[xr],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),s=V5(t,e),i=!1;return s||(i=z5(t,e)),{dataChanged:s,propsChanged:r,updateTriggersChanged:i,extensionsChanged:H5(t,e),transitionsChanged:k5(t,e)}}function k5(t,e){if(!t.transitions)return!1;let r={},s=t[xr],i=!1;for(let n in t.transitions){let o=s[n],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&tA(t[n],e[n],o)&&(r[n]=!0,i=!0)}return i?r:!1}function ha({newProps:t,oldProps:e,ignoreProps:r={},propTypes:s={},triggerName:i="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${i} changed shallowly`;if(typeof e!="object"||e===null)return`${i} changed shallowly`;for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${i}.${n} added`;let o=tA(t[n],e[n],s[n]);if(o)return`${i}.${n} ${o}`}for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${i}.${n} dropped`;if(!Object.hasOwnProperty.call(t,n)){let o=tA(t[n],e[n],s[n]);if(o)return`${i}.${n} ${o}`}}return!1}function tA(t,e,r){let s=r&&r.equal;return s&&!s(t,e,r)||!s&&(s=t&&e&&t.equals,s&&!s.call(t,e))?"changed deeply":!s&&e!==t?"changed shallowly":null}function V5(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:s,_dataDiff:i}=t;return s?s(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&i&&(r=i(t.data,e.data)||r),r}function z5(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&uP(t,e,"all"))return{all:!0};let r={},s=!1;for(let i in t.updateTriggers)i!=="all"&&uP(t,e,i)&&(r[i]=!0,s=!0);return s?r:!1}function H5(t,e){if(e===null)return!0;let r=e.extensions,{extensions:s}=t;if(s===r)return!1;if(!r||!s||s.length!==r.length)return!0;for(let i=0;is.name==="project64"))){let s=r.modules.findIndex(i=>i.name==="project32");s>=0&&r.modules.splice(s,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let s={...t.inject};for(let i in e.inject)s[i]=(s[i]||"")+e.inject[i];r.inject=s}return r}var Y5={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},rA={};function dP(t,e,r,s){if(r instanceof xe)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let i=null;r.compressed&&(i={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let n=e.createTexture({...r,sampler:{...Y5,...i,...s}});return rA[n.id]=t,n}function pP(t,e){!e||!(e instanceof xe)||rA[e.id]===t&&(e.delete(),delete rA[e.id])}var q5={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||sA(t)&&(t.length===3||t.length===4)},equal(t,e,r){return ve(t,e,1)}},accessor:{validate(t,e){let r=Pp(t);return r==="function"||r===Pp(e.value)},equal(t,e,r){return typeof e=="function"?!0:ve(t,e,1)}},array:{validate(t,e){return e.optional&&!t||sA(t)},equal(t,e,r){let{compare:s}=r,i=Number.isInteger(s)?s:s?1:0;return s?ve(t,e,i):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:s}=r,i=Number.isInteger(s)?s:s?1:0;return s?ve(t,e,i):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:s}=r.props;return s?s(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let s=r.context;return!s||!s.device?null:dP(r.id,s.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{pP(r.id,t)}}};function gP(t){let e={},r={},s={};for(let[i,n]of Object.entries(t)){let o=n?.deprecatedFor;if(o)s[i]=Array.isArray(o)?o:[o];else{let a=K5(i,n);e[i]=a,r[i]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:s}}function K5(t,e){switch(Pp(e)){case"object":return nu(t,e);case"array":return nu(t,{type:"array",value:e,compare:!1});case"boolean":return nu(t,{type:"boolean",value:e});case"number":return nu(t,{type:"number",value:e});case"function":return nu(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function nu(t,e){return"type"in e?{name:t,...q5[e.type],...e}:"value"in e?{name:t,type:Pp(e.value),...e}:{name:t,type:"object",value:e}}function sA(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function Pp(t){return sA(t)?"array":t===null?"null":typeof t}function mP(t,e){let r;for(let n=e.length-1;n>=0;n--){let o=e[n];"extensions"in o&&(r=o.extensions)}let s=iA(t.constructor,r),i=Object.create(s);i[ra]=t,i[ps]={},i[kr]={};for(let n=0;n{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||iH}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[ra]||this.component;let r=e[kr]||{},s=e[ps]||e,i=e[Us]||{};for(let n in r){let o=r[n];this._createAsyncPropData(n,i[n]),this._updateAsyncProp(n,o),r[n]=this.getAsyncProp(n)}for(let n in s){let o=s[n];this._createAsyncPropData(n,i[n]),this._updateAsyncProp(n,o)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(xp(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let s=this.asyncProps[e];return r===s.resolvedValue||r===s.lastValue?!1:(s.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let s=this.asyncProps[e];s&&(r=this._postProcessValue(s,r),s.resolvedValue=r,s.pendingLoadCount++,s.resolvedLoadCount=s.pendingLoadCount)}_setAsyncPropValue(e,r,s){let i=this.asyncProps[e];i&&s>=i.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),i.resolvedValue=r,i.resolvedLoadCount=s,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let s=this.asyncProps[e];if(s){s.pendingLoadCount++;let i=s.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(s,n),this._setAsyncPropValue(e,n,i),this._onResolve(e,n))}).catch(n=>{this._onError(e,n)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let s=this.asyncProps[e];if(!s)return;s.pendingLoadCount++;let i=s.pendingLoadCount,n=[],o=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:o,endRow:n.length}]}),o=n.length,this._setAsyncPropValue(e,n,i)}this._onResolve(e,n)}_postProcessValue(e,r){let s=e.type;return s&&this.component&&(s.release&&s.release(e.resolvedValue,s,this.component),s.transform)?s.transform(r,s,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let i=this.component&&this.component.props[xr];this.asyncProps[e]={type:i&&i[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var au=class extends Un{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let s=this.layer,i=s?.props.fetch;return i?i(r,{propName:e,layer:s}):super._fetch(e,r)}_onResolve(e,r){let s=this.layer;if(s){let i=s.props.onDataLoad;e==="data"&&i&&i(r,{propName:e,layer:s})}}_onError(e,r){let s=this.layer;s&&s.raiseError(r,`loading ${e} of ${this.layer}`)}};var nH="layer.changeFlag",oH="layer.initialize",aH="layer.update",cH="layer.finalize",lH="layer.matched",yP=2**24-1,uH=Object.freeze([]),fH=zt(({oldViewport:t,viewport:e})=>t.equals(e)),xs=new Uint8ClampedArray(0),hH={data:{type:"data",value:uH,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:s,loadOptions:i,signal:n})=>{let{resourceManager:o}=r.context;i=i||r.getLoadOptions(),s=s||r.props.loaders,n&&(i={...i,fetch:{...i?.fetch,signal:n}});let a=o.contains(t);return!a&&!i&&(o.add({resourceId:t,data:$e(t,s),persistent:!1}),a=!0),a?o.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):$e(t,s,i)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:X.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},cu=class extends Mp{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Pi.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){Ae(this.internalState);let r=this.internalState.viewport||this.context.viewport,s=Cx(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[i,n,o]=Yo(s,r.pixelProjectionMatrix);return e.length===2?[i,n]:[i,n,o]}unproject(e){return Ae(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){Ae(this.internalState);let s=this.internalState.viewport||this.context.viewport;return Vd(e,{viewport:s,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setModuleParameters(e){for(let r of this.getModels())r.updateModuleSettings(e)}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===X.DEFAULT||e===X.LNGLAT||e===X.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){Ae(e instanceof Uint8Array);let[r,s,i]=e;return r+s*256+i*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:wp(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=ys(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=ys(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:s}=e.changeFlags;if(s&&r)if(Array.isArray(s))for(let i of s)r.invalidateAll(i);else r.invalidateAll();if(r){let{props:i}=e,n=this.internalState.hasPickingBuffer,o=Number.isInteger(i.highlightedObjectIndex)||i.pickable||i.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let s of this.getModels())s.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e)}getPickingInfo({info:e,mode:r,sourceLayer:s}){let{index:i}=e;return i>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[i]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!fH({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let s in e)e[s].layoutChanged()&&(r=!0);for(let s of this.getModels())this._setModelAttributes(s,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,s=this.getNumInstances(),i=this.getStartIndices();e.update({data:r.data,numInstances:s,startIndices:i,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let n=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),s=Object.create(this.props);for(let i in r)Object.defineProperty(s,i,{value:r[i]});return s}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let s=Math.floor(xs.length/4);if(this.internalState.usesPickingColorCache=!0,syP&&k.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),xs=Nr.allocate(xs,r,{size:4,copy:!0,maxCount:Math.max(r,yP)});let i=Math.floor(xs.length/4),n=[];for(let o=s;o(k.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new iu(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Ue(lH,this,this===e);let{state:r,internalState:s}=e;this!==e&&(this.internalState=s,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Ue(aH,this,e),!e)return;let r=this.props,s=this.context,i=this.internalState,n=s.viewport,o=this._updateUniformTransition();i.propsInTransition=o,s.viewport=i.viewport||n,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(s.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{s.viewport=n,this.props=r,this._clearChangeFlags(),i.needsUpdate=!1,i.resetOldProps()}}_finalize(){Ue(cH,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,moduleParameters:r=null,uniforms:s={},parameters:i={}}){this._updateAttributeTransition();let n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;let a=this.props.opacity;s.opacity=Math.pow(a,1/2.2);try{if(r){let{isActive:u,isAttribute:f}=r.picking;this.setModuleParameters(r),this.setShaderModuleProps({picking:{isActive:u,isAttribute:f}})}let{getPolygonOffset:c}=this.props,l=c&&c(s)||[0,0];o.device.setParametersWebGL({polygonOffset:l});for(let u of this.getModels())u.setParameters(i);o.device.withParametersWebGL(i,()=>{let u={renderPass:e,moduleParameters:r,uniforms:s,parameters:i,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)})}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let i in e)if(e[i]){let n=!1;switch(i){case"dataChanged":let o=e[i],a=r[i];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,n=!0);default:r[i]||(r[i]=e[i],n=!0)}n&&Ue(nH,this,i,e)}let s=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=s,r.somethingChanged=s||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let s=hP(e,r);if(s.updateTriggersChanged)for(let i in s.updateTriggersChanged)s.updateTriggersChanged[i]&&this.invalidateAttribute(i);if(s.transitionsChanged)for(let i in s.transitionsChanged)this.internalState.uniformTransitions.add(i,r[i],e[i],e.transitions?.[i]);return this.setChangeFlags(s)}validateProps(){fP(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:s}=this.props;e.picked&&typeof s=="function"&&(r.highlightColor=s(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new Xr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:s,oldProps:i}=e;this.setNeedsRedraw(),this._updateAttributes();let n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=s;if(r||i.autoHighlight!==o||i.highlightedObjectIndex!==a||i.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||i.autoHighlight!==o||a!==i.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let s=this.getAttributeManager(),i=s?s.getNeedsRedraw(e):!1;if(r=r||i,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};cu.defaultProps=hH;cu.layerName="Layer";var he=cu;var dH="compositeLayer.renderLayers",Rp=class extends he{get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:s}=this.props;return s&&s[e]&&s[e].type||r}getSubLayerRow(e,r,s){return e.__source={parent:this,object:r,index:s},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(s,i)=>s&&s.__source?(r.index=s.__source.index,e(s.__source.object,r)):e(s,i)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:s,visible:i,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_,_subLayerProps:y}=this.props,x={id:"",updateTriggers:{},opacity:r,pickable:s,visible:i,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_},S=y&&e.id&&y[e.id],P=S&&S.updateTriggers,B=e.id||"sublayer";if(S){let L=this.props[xr],M=e.type?e.type._propTypes:{};for(let v in S){let T=M[v]||L[v];T&&T.type==="accessor"&&(S[v]=this.getSubLayerAccessor(S[v]))}}Object.assign(x,e,S),x.id=`${this.props.id}-${B}`,x.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...P};for(let L of g){let M=L.getSubLayerProps.call(this,L);M&&Object.assign(x,M,{updateTriggers:Object.assign(x.updateTriggers,M.updateTriggers)})}return x}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let s=this.internalState.subLayers,i=!s||this.needsUpdate();if(i){let n=this.renderLayers();s=Bt(n,Boolean),this.internalState.subLayers=s}Ue(dH,this,i,s);for(let n of s)n.parent=this}};Rp.layerName="CompositeLayer";var Le=Rp;var Ip=Math.PI/180,xP=180/Math.PI,Bp=6370972,da=256;function pH(){let t=da/Bp,e=Math.PI/180*da;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var Yr=class extends Ht{constructor(e={}){let{latitude:r=0,longitude:s=0,zoom:i=0,nearZMultiplier:n=.1,farZMultiplier:o=2,resolution:a=10}=e,{height:c,altitude:l=1.5}=e;c=c||1,l=Math.max(.75,l);let u=new q().lookAt({eye:[0,-l,0],up:[0,0,1]}),f=Math.pow(2,i);u.rotateX(r*Ip),u.rotateZ(-s*Ip),u.scale(f/c);let h=Math.atan(.5/l),d=da*2*f/c;super({...e,height:c,viewMatrix:u,longitude:s,latitude:r,zoom:i,distanceScales:pH(),fovyRadians:h*2,focalDistance:l,near:n,far:Math.min(2,1/d+1)*l*o}),this.latitude=r,this.longitude=s,this.resolution=a}get projectionMode(){return bt.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},s=this.unproject([0,this.height/2],r),i=this.unproject([this.width/2,0],r),n=this.unproject([this.width,this.height/2],r),o=this.unproject([this.width/2,this.height],r);return n[0]this.longitude&&(s[0]-=360),[Math.min(s[0],n[0],i[0],o[0]),Math.min(s[1],n[1],i[1],o[1]),Math.max(s[0],n[0],i[0],o[0]),Math.max(s[1],n[1],i[1],o[1])]}unproject(e,{topLeft:r=!0,targetZ:s}={}){let[i,n,o]=e,a=r?n:this.height-n,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(o))l=oA(c,[i,a,o,1]);else{let d=oA(c,[i,a,-1,1]),p=oA(c,[i,a,1,1]),g=((s||0)/Bp+1)*da,m=We.sqrLen(We.sub([],d,p)),_=We.sqrLen(d),y=We.sqrLen(p),S=4*((4*_*y-(m-_-y)**2)/16)/m,P=Math.sqrt(_-S),B=Math.sqrt(Math.max(0,g*g-S)),L=(P-B)/Math.sqrt(m);l=We.lerp([],d,p,L)}let[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(s)?[u,f,s]:[u,f]}projectPosition(e){let[r,s,i=0]=e,n=r*Ip,o=s*Ip,a=Math.cos(o),c=(i/Bp+1)*da;return[Math.sin(n)*a*c,-Math.cos(n)*a*c,Math.sin(o)*c]}unprojectPosition(e){let[r,s,i]=e,n=We.len(e),o=Math.asin(i/n),c=Math.atan2(r,-s)*xP,l=o*xP,u=(n/da-1)*Bp;return[c,l,u]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition(e,r){let s=this.unproject(r);return{longitude:e[0]-s[0]+this.longitude,latitude:e[1]-s[1]+this.latitude}}};function oA(t,e){let r=It.transformMat4([],e,t);return It.scale(r,r,1/r[3]),r}var aA=Math.PI/180;function gH({height:t,focalDistance:e,orbitAxis:r,rotationX:s,rotationOrbit:i,zoom:n}){let o=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new q().lookAt({eye:a,up:o});c.rotateX(s*aA),r==="Z"?c.rotateZ(i*aA):c.rotateY(i*aA);let l=Math.pow(2,n)/t;return c.scale(l),c}var kn=class extends Ht{constructor(e){let{height:r,projectionMatrix:s,fovy:i=50,orbitAxis:n="Z",target:o=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,u=s?s[5]/2:En(i);super({...e,longitude:void 0,viewMatrix:gH({height:r||1,focalDistance:u,orbitAxis:n,rotationX:a,rotationOrbit:c,zoom:l}),fovy:i,focalDistance:u,position:o,zoom:l}),this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[s,i,n=this.projectedCenter[2]]=e,o=r?i:this.height-i,[a,c,l]=mr([s,o,n],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r){let s=this.project(e),i=[this.width/2+s[0]-r[0],this.height/2+s[1]-r[1],this.projectedCenter[2]];return{target:this.unproject(i)}}};var mH=new q().lookAt({eye:[0,0,1]});function _H({width:t,height:e,near:r,far:s,padding:i}){let n=-t/2,o=t/2,a=-e/2,c=e/2;if(i){let{left:l=0,right:u=0,top:f=0,bottom:h=0}=i,d=fe((l+t-u)/2,0,t)-t/2,p=fe((f+e-h)/2,0,e)-e/2;n-=d,o-=d,a+=p,c+=p}return new q().ortho({left:n,right:o,bottom:a,top:c,near:r,far:s})}var js=class extends Ht{constructor(e){let{width:r,height:s,near:i=.1,far:n=1e3,zoom:o=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,u=Array.isArray(o)?o[0]:o,f=Array.isArray(o)?o[1]:o,h=Math.min(u,f),d=Math.pow(2,h),p;if(u!==f){let g=Math.pow(2,u),m=Math.pow(2,f);p={unitsPerMeter:[g/d,m/d,1],metersPerUnit:[d/g,d/m,1]}}super({...e,longitude:void 0,position:a,viewMatrix:mH.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:_H({width:r||1,height:s||1,padding:c,near:i,far:n}),zoom:h,distanceScales:p})}projectFlat([e,r]){let{unitsPerMeter:s}=this.distanceScales;return[e*s[0],r*s[1]]}unprojectFlat([e,r]){let{metersPerUnit:s}=this.distanceScales;return[e*s[0],r*s[1]]}panByPosition(e,r){let s=mr(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),n=Ze.add([],i,Ze.negate([],s)),o=Ze.add([],this.center,n);return{target:this.unprojectFlat(o)}}};var Vn=class extends Ht{constructor(e){let{longitude:r,latitude:s,modelMatrix:i,bearing:n=0,pitch:o=0,up:a=[0,0,1]}=e,l=new Or({bearing:n,pitch:o===-90?1e-4:90+o}).toVector3().normalize(),u=i?new q(i).transformAsVector(l):l,f=Number.isFinite(s)?dl({latitude:s}):0,h=Math.pow(2,f),d=new q().lookAt({eye:[0,0,0],center:u,up:a}).scale(h);super({...e,zoom:f,viewMatrix:d}),this.latitude=s,this.longitude=r}};var zn=20,AP=500,lu=class extends Hs{constructor(e){let{width:r,height:s,position:i=[0,0,0],bearing:n=0,pitch:o=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:u=-90,startRotatePos:f,startBearing:h,startPitch:d,startZoomPosition:p,startPanPos:g,startPanPosition:m}=e;super({width:r,height:s,position:i,bearing:n,pitch:o,longitude:a,latitude:c,maxPitch:l,minPitch:u},{startRotatePos:f,startBearing:h,startPitch:d,startZoomPosition:p,startPanPos:g,startPanPosition:m}),this.makeViewport=e.makeViewport}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:s=[0,0]}=this.getState(),{width:i,height:n,bearing:o,pitch:a}=this.getViewportProps(),c=AP*(e[0]-r[0])/i,l=AP*(e[1]-r[1])/n,u=new Or({bearing:o,pitch:a}),f=new Or({bearing:o,pitch:-90}),h=u.toVector3().normalize(),d=f.toVector3().cross(h).normalize();return this._getUpdatedState({position:new w(s).add(d.scale(c)).add(h.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:s=0}){let{startRotatePos:i,startBearing:n,startPitch:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!i||n===void 0||o===void 0)return this;let l;if(e){let u=(e[0]-i[0])/a,f=(e[1]-i[1])/c;l={bearing:n-u*180,pitch:o-f*90}}else l={bearing:n-r,pitch:o-s};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:r}){let s=this.getViewportProps(),i=this.getState().startZoomPosition||s.position,n=this.makeViewport(s),{projectionMatrix:o,width:a}=n,l=2*Math.atan(1/o[0])*(e[0]/a-.5),u=this.getDirection(!0);return this._move(u.rotateZ({radians:-l}),Math.log2(r)*zn,i)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=zn){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=zn){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=zn){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=zn){let r=this.getDirection(!0);return this._move(r.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=zn){return this._move(new w(0,0,1),e)}zoomOut(e=zn){return this._move(new w(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),s={...this.getViewportProps()},{bearing:i,longitude:n}=s;return Math.abs(i-r.bearing)>180&&(s.bearing=i<0?i+360:i-360),n!==null&&r.longitude!==null&&Math.abs(n-r.longitude)>180&&(s.longitude=n<0?n+360:n-360),s}_move(e,r,s=this.getViewportProps().position){let i=e.scale(r);return this._getUpdatedState({position:new w(s).add(i)})}getDirection(e=!1){return new Or({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new lu({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:s,minPitch:i,longitude:n,bearing:o}=e;return e.pitch=fe(r,i,s),n!==null&&(n<-180||n>180)&&(e.longitude=vn(n+180,360)-180),(o<-180||o>180)&&(e.bearing=vn(o+180,360)-180),e}},Hn=class extends Ft{constructor(){super(...arguments),this.ControllerState=lu,this.transition={transitionDuration:300,transitionInterpolator:new yt(["position","pitch","bearing"])}}};var Op=class extends Ot{constructor(e={}){super(e)}get ViewportType(){return Vn}get ControllerType(){return Hn}};Op.displayName="FirstPersonView";var TP=Op;var uu=class extends Hs{constructor(e){let{width:r,height:s,rotationX:i=0,rotationOrbit:n=0,target:o=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:u=-1/0,maxZoom:f=1/0,startPanPosition:h,startRotatePos:d,startRotationX:p,startRotationOrbit:g,startZoomPosition:m,startZoom:_}=e;super({width:r,height:s,rotationX:i,rotationOrbit:n,target:o,zoom:a,minRotationX:c,maxRotationX:l,minZoom:u,maxZoom:f},{startPanPosition:h,startRotatePos:d,startRotationX:p,startRotationOrbit:g,startZoomPosition:m,startZoom:_}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let s=this.getState().startPanPosition||r;if(!s)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(s,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:s=0}){let{startRotatePos:i,startRotationX:n,startRotationOrbit:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!i||n===void 0||o===void 0)return this;let l;if(e){let u=(e[0]-i[0])/a,f=(e[1]-i[1])/c;(n<-90||n>90)&&(u*=-1),l={rotationX:n+f*180,rotationOrbit:o+u*180}}else l={rotationX:n+s,rotationOrbit:o+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),s={...this.getViewportProps()},{rotationOrbit:i}=s;return Math.abs(i-r.rotationOrbit)>180&&(s.rotationOrbit=i<0?i+360:i-360),s}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:s}){let{startZoom:i,startZoomPosition:n}=this.getState();if(n||(i=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(e)),!n)return this;let o=this._calculateNewZoom({scale:s,startZoom:i}),a=this.makeViewport({...this.getViewportProps(),zoom:o});return this._getUpdatedState({zoom:o,...a.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{maxZoom:s,minZoom:i}=this.getViewportProps();r===void 0&&(r=this.getViewportProps().zoom);let n=r+Math.log2(e);return fe(n,i,s)}_panFromCenter(e){let{width:r,height:s,target:i}=this.getViewportProps();return this.pan({startPosition:i,pos:[r/2+e[0],s/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxZoom:r,minZoom:s,zoom:i,maxRotationX:n,minRotationX:o,rotationOrbit:a}=e;return e.zoom=Array.isArray(i)?[fe(i[0],s,r),fe(i[1],s,r)]:fe(i,s,r),e.rotationX=fe(e.rotationX,o,n),(a<-180||a>180)&&(e.rotationOrbit=vn(a+180,360)-180),e}},Gn=class extends Ft{constructor(){super(...arguments),this.ControllerState=uu,this.transition={transitionDuration:300,transitionInterpolator:new yt({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})}}};var Fp=class extends Ot{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}get ViewportType(){return kn}get ControllerType(){return Gn}};Fp.displayName="OrbitView";var bP=Fp;var cA=class extends uu{constructor(e){super(e),this.zoomAxis=e.zoomAxis||"all"}_calculateNewZoom({scale:e,startZoom:r}){let{maxZoom:s,minZoom:i}=this.getViewportProps();r===void 0&&(r=this.getViewportProps().zoom);let n=Math.log2(e);if(Array.isArray(r)){let[o,a]=r;switch(this.zoomAxis){case"X":o=fe(o+n,i,s);break;case"Y":a=fe(a+n,i,s);break;default:let c=Math.min(o+n,a+n);cs&&(n+=s-c),o+=n,a+=n}return[o,a]}return fe(r+n,i,s)}},Wn=class extends Ft{constructor(){super(...arguments),this.ControllerState=cA,this.transition={transitionDuration:300,transitionInterpolator:new yt(["target","zoom"])},this.dragMode="pan"}_onPanRotate(){return!1}};var Lp=class extends Ot{constructor(e={}){super(e)}get ViewportType(){return js}get ControllerType(){return Wn}};Lp.displayName="OrthographicView";var EP=Lp;var lA=class extends Il{applyConstraints(e){let{maxZoom:r,minZoom:s,zoom:i}=e;e.zoom=fe(i,s,r);let{longitude:n,latitude:o}=e;return(n<-180||n>180)&&(e.longitude=vn(n+180,360)-180),e.latitude=fe(o,-89,89),e}},jn=class extends Ft{constructor(){super(...arguments),this.ControllerState=lA,this.transition={transitionDuration:300,transitionInterpolator:new yt(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var Np=class extends Ot{constructor(e={}){super(e)}get ViewportType(){return Yr}get ControllerType(){return jn}};Np.displayName="GlobeView";var SP=Np;var fu=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&ve(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,s={updateTriggers:{}};for(let i in r)if(i in this.props){let n=r[i],o=this.props[i];s[i]=o,n&&n.type==="accessor"&&(s.updateTriggers[i]=this.props.updateTriggers[i],typeof o=="function"&&(s[i]=this.getSubLayerAccessor(o)))}return s}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};fu.defaultProps={};fu.extensionName="LayerExtension";var tt=fu;var uA={bearing:0,pitch:0,position:[0,0,0]},yH={speed:1.2,curve:1.414},Xs=class extends zs{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...yH,...e}}interpolateProps(e,r,s){let i=bx(e,r,s,this.opts);for(let n in uA)i[n]=it(e[n]||uA[n],r[n]||uA[n],s);return i}getDuration(e,r){let{transitionDuration:s}=r;return s==="auto"&&(s=Ex(e,r,this.opts)),s}};var Ys=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Nr,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:s={},getGeometry:i,geometryBuffer:n,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=i,this.positionSize=n&&n.size||(o==="XY"?2:3),this.buffers=s,this.normalize=c,n&&(Ae(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(s.vertexPositions=n)),this.geometryBuffer=s.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Ap(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:s,buffers:i,_attributeDefs:n,typedArrayManager:o}=this;for(let a in n)if(a in i)o.release(s[a]),s[a]=null;else{let c=n[a];c.copy=r,s[a]=o.allocate(s[a],e,c)}}_forEachGeometry(e,r,s){let{data:i,getGeometry:n}=this,{iterable:o,objectInfo:a}=ze(i,r,s);for(let c of o){a.index++;let l=n?n(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:s,instanceCount:i}=this,{data:n,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],s=[0]),this.normalize||!o)this._forEachGeometry((f,h)=>{let d=f&&this.normalizeGeometry(f);l[h]=d,s[h+1]=s[h]+(d?this.getGeometrySize(d):0)},a,c),i=s[s.length-1];else if(s=n.startIndices,i=s[n.length]||0,ArrayBuffer.isView(o))i=i||o.length/this.positionSize;else if(o instanceof Q){let f=this.positionSize*4;i=i||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;i=i||o.buffer.byteLength/f}else if(o.value){let f=o.value,h=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;i=i||f.length/h}this._allocate(i,Boolean(e)),this.indexStarts=r,this.vertexStarts=s,this.instanceCount=i;let u={};this._forEachGeometry((f,h)=>{let d=l[h]||f;u.vertexStart=s[h],u.indexStart=r[h];let p=h 180.0) { indexDir = -1.0; isValid = 0.0; } else if (abs(currPos.x - nextPos.x) > 180.0) { indexDir = 1.0; isValid = 0.0; } nextPos = indexDir < 0.0 ? prevPos : nextPos; nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; if (isValid == 0.0) { nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0; float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x); currPos = mix(currPos, nextPos, t); segmentRatio = mix(segmentRatio, nextSegmentRatio, t); } vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio); vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio); curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position); next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0)); } else { vec3 source_world = instanceSourcePositions; vec3 target_world = instanceTargetPositions; if (useShortestPath) { source_world.x = mod(source_world.x + 180., 360.0) - 180.; target_world.x = mod(target_world.x + 180., 360.0) - 180.; float deltaLng = target_world.x - source_world.x; if (deltaLng > 180.) target_world.x -= 360.; if (deltaLng < -180.) source_world.x -= 360.; } source = project_position(source_world, instanceSourcePositions64Low); target = project_position(target_world, instanceTargetPositions64Low); float antiMeridianX = 0.0; if (useShortestPath) { if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { antiMeridianX = -(project_uCoordinateOrigin.x + 180.) / 360. * TILE_SIZE; } float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x); if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) { isValid = 0.0; indexDir = sign(segmentRatio - thresholdRatio); segmentRatio = thresholdRatio; } } nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; vec3 currPos = interpolateFlat(source, target, segmentRatio); vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio); if (useShortestPath) { if (nextPos.x < antiMeridianX) { currPos.x += TILE_SIZE; nextPos.x += TILE_SIZE; } } curr = project_common_position_to_clipspace(vec4(currPos, 1.0)); next = project_common_position_to_clipspace(vec4(nextPos, 1.0)); geometry.position = vec4(currPos, 1.0); } float widthPixels = clamp( project_size_to_pixel(instanceWidths * widthScale, widthUnits), widthMinPixels, widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, widthPixels), 0.0); DECKGL_FILTER_SIZE(offset, geometry); DECKGL_FILTER_GL_POSITION(curr, geometry); gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio); vColor = vec4(color.rgb, color.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var CP=`#version 300 es #define SHADER_NAME arc-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 uv; in float isValid; out vec4 fragColor; void main(void) { if (isValid == 0.0) { discard; } fragColor = vColor; geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var Dp=[0,0,0,255],xH={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:Dp},getTargetColor:{type:"accessor",value:Dp},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},hu=class extends he{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:vP,fs:CP,modules:[de,_e]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:Dp},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:Dp},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e);let{props:r,oldProps:s,changeFlags:i}=e;(i.extensionsChanged||r.numSegments!==s.numSegments)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:s,widthMinPixels:i,widthMaxPixels:n,greatCircle:o,wrapLongitude:a}=this.props,c=this.state.model;c.setUniforms(e),c.setUniforms({greatCircle:o,widthUnits:Fe[r],widthScale:s,widthMinPixels:i,widthMaxPixels:n,useShortestPath:a}),c.draw(this.context.renderPass)}_getModel(){let{numSegments:e}=this.props,r=[];for(let i=0;i0&&p>0&&(a[f++]=u-n,a[f++]=u-n-1,a[f++]=u-1,a[f++]=u-n,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function bH(t){let e=new Float64Array(12);for(let r=0;r 0.5) { vTexPos = geometry.worldPosition.xy; } vec4 color = vec4(0.0); DECKGL_FILTER_COLOR(color, geometry); } `;var SH=` vec3 packUVsIntoRGB(vec2 uv) { // Extract the top 8 bits. We want values to be truncated down so we can add a fraction vec2 uv8bit = floor(uv * 256.); // Calculate the normalized remainders of u and v parts that do not fit into 8 bits // Scale and clamp to 0-1 range vec2 uvFraction = fract(uv * 256.); vec2 uvFraction4bit = floor(uvFraction * 16.); // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; return vec3(uv8bit, fractions) / 255.; } `,PP=`#version 300 es #define SHADER_NAME bitmap-layer-fragment-shader #ifdef GL_ES precision highp float; #endif uniform sampler2D bitmapTexture; in vec2 vTexCoord; in vec2 vTexPos; out vec4 fragColor; uniform float desaturate; uniform vec4 transparentColor; uniform vec3 tintColor; uniform float opacity; uniform float coordinateConversion; uniform vec4 bounds; /* projection utils */ const float TILE_SIZE = 512.0; const float PI = 3.1415926536; const float WORLD_SCALE = TILE_SIZE / PI / 2.0; // from degrees to Web Mercator vec2 lnglat_to_mercator(vec2 lnglat) { float x = lnglat.x; float y = clamp(lnglat.y, -89.9, 89.9); return vec2( radians(x) + PI, PI + log(tan(PI * 0.25 + radians(y) * 0.5)) ) * WORLD_SCALE; } // from Web Mercator to degrees vec2 mercator_to_lnglat(vec2 xy) { xy /= WORLD_SCALE; return degrees(vec2( xy.x - PI, atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 )); } /* End projection utils */ // apply desaturation vec3 color_desaturate(vec3 color) { float luminance = (color.r + color.g + color.b) * 0.333333333; return mix(color, vec3(luminance), desaturate); } // apply tint vec3 color_tint(vec3 color) { return color * tintColor; } // blend with background color vec4 apply_opacity(vec3 color, float alpha) { if (transparentColor.a == 0.0) { return vec4(color, alpha); } float blendedAlpha = alpha + transparentColor.a * (1.0 - alpha); float highLightRatio = alpha / blendedAlpha; vec3 blendedRGB = mix(transparentColor.rgb, color, highLightRatio); return vec4(blendedRGB, blendedAlpha); } vec2 getUV(vec2 pos) { return vec2( (pos.x - bounds[0]) / (bounds[2] - bounds[0]), (pos.y - bounds[3]) / (bounds[1] - bounds[3]) ); } ${SH} void main(void) { vec2 uv = vTexCoord; if (coordinateConversion < -0.5) { vec2 lnglat = mercator_to_lnglat(vTexPos); uv = getUV(lnglat); } else if (coordinateConversion > 0.5) { vec2 commonPos = lnglat_to_mercator(vTexPos); uv = getUV(commonPos); } vec4 bitmapColor = texture(bitmapTexture, uv); fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity); geometry.uv = uv; DECKGL_FILTER_COLOR(fragColor, geometry); if (bool(picking.isActive) && !bool(picking.isAttribute)) { // Since instance information is not used, we can use picking color for pixel index fragColor.rgb = packUVsIntoRGB(uv); } } `;var vH={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:X.DEFAULT,desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},du=class extends he{getShaders(){return super.getShaders({vs:wP,fs:PP,modules:[de,_e]})}initializeState(){let e=this.getAttributeManager();e.remove(["instancePickingColors"]);let r=!0;e.add({indices:{size:1,isIndexed:!0,update:s=>s.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:s=>s.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:s=>s.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:e,oldProps:r,changeFlags:s}){let i=this.getAttributeManager();if(s.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll()),e.bounds!==r.bounds){let n=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)n&&n[a]!==o[a]&&i.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:r}=this.props,s=e.info;if(!s.color||!r)return s.bitmap=null,s;let{width:i,height:n}=r;s.index=0;let o=CH(s.color);return s.bitmap={size:{width:i,height:n},uv:o,pixel:[Math.floor(o[0]*i),Math.floor(o[1]*n)]},s}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,r=e;return MP(e)&&(r=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),fA(r,this.context.viewport.resolution)}_getModel(){return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){let{uniforms:r,moduleParameters:s}=e,{model:i,coordinateConversion:n,bounds:o,disablePicking:a}=this.state,{image:c,desaturate:l,transparentColor:u,tintColor:f}=this.props;s.picking.isActive&&a||c&&i&&(i.setUniforms(r),i.setBindings({bitmapTexture:c}),i.setUniforms({desaturate:l,transparentColor:u.map(h=>h/255),tintColor:f.slice(0,3).map(h=>h/255),coordinateConversion:n,bounds:o}),i.draw(this.context.renderPass))}_getCoordinateUniforms(){let{LNGLAT:e,CARTESIAN:r,DEFAULT:s}=X,{_imageCoordinateSystem:i}=this.props;if(i!==s){let{bounds:n}=this.props;if(!MP(n))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?e:r;if(i=i===e?e:r,i===e&&o===r)return{coordinateConversion:-1,bounds:n};if(i===r&&o===e){let a=je([n[0],n[1]]),c=je([n[2],n[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],c[0],c[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};du.layerName="BitmapLayer";du.defaultProps=vH;var kp=du;function CH(t){let[e,r,s]=t,i=(s&240)/256,n=(s&15)/16;return[(e+n)/256,(r+i)/256]}function MP(t){return Number.isFinite(t[0])}var RP=`#version 300 es #define SHADER_NAME icon-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceSizes; in float instanceAngles; in vec4 instanceColors; in vec3 instancePickingColors; in vec4 instanceIconFrames; in float instanceColorModes; in vec2 instanceOffsets; in vec2 instancePixelOffset; uniform float sizeScale; uniform vec2 iconsTextureDim; uniform float sizeMinPixels; uniform float sizeMaxPixels; uniform bool billboard; uniform int sizeUnits; out float vColorMode; out vec4 vColor; out vec2 vTextureCoords; out vec2 uv; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = angle * PI / 180.0; float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vec2 iconSize = instanceIconFrames.zw; float sizePixels = clamp( project_size_to_pixel(instanceSizes * sizeScale, sizeUnits), sizeMinPixels, sizeMaxPixels ); float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y; vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; pixelOffset += instancePixelOffset; pixelOffset.y *= -1.0; if (billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); DECKGL_FILTER_SIZE(offset_common, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vTextureCoords = mix( instanceIconFrames.xy, instanceIconFrames.xy + iconSize, (positions.xy + 1.0) / 2.0 ) / iconsTextureDim; vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); vColorMode = instanceColorModes; } `;var IP=`#version 300 es #define SHADER_NAME icon-layer-fragment-shader precision highp float; uniform float opacity; uniform sampler2D iconsTexture; uniform float alphaCutoff; in float vColorMode; in vec4 vColor; in vec2 vTextureCoords; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; vec4 texColor = texture(iconsTexture, vTextureCoords); vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode); float a = texColor.a * opacity * vColor.a; if (a < alphaCutoff) { discard; } fragColor = vec4(color, a); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var wH=1024,PH=4,BP=()=>{},OP={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},MH={x:0,y:0,width:0,height:0};function RH(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function IH(t,e,r,s){let i=Math.min(r/e.width,s/e.height),n=Math.floor(e.width*i),o=Math.floor(e.height*i);return i===1?{data:e,width:n,height:o}:(t.canvas.height=o,t.canvas.width=n,t.clearRect(0,0,n,o),t.drawImage(e,0,0,e.width,e.height,0,0,n,o),{data:t.canvas,width:n,height:o})}function pu(t){return t&&(t.id||t.url)}function BH(t,e,r,s){let{width:i,height:n,device:o}=t,a=o.createTexture({format:"rgba8unorm",width:e,height:r,sampler:s}),c=o.createCommandEncoder();return c.copyTextureToTexture({source:t,destination:a,width:i,height:n}),c.finish(),t.destroy(),a}function FP(t,e,r){for(let s=0;so&&(FP(r,a,i),s=0,i=n+i+e,n=0,a=[]),a.push({icon:l,xOffset:s}),s=s+h+e,n=Math.max(n,f)}}return a.length>0&&FP(r,a,i),{mapping:r,rowHeight:n,xOffset:s,yOffset:i,canvasWidth:o,canvasHeight:RH(n+i+e)}}function FH(t,e,r){if(!t||!e)return null;r=r||{};let s={},{iterable:i,objectInfo:n}=ze(t);for(let o of i){n.index++;let a=e(o,n),c=pu(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!s[c]&&(!r[c]||a.url!==r[c].url)&&(s[c]={...a,source:o,sourceIndex:n.index})}return s}var gu=class{constructor(e,{onUpdate:r=BP,onError:s=BP}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._textureParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=PH,this._canvasWidth=wH,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=r,this.onError=s}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let r=this._autoPacking?pu(e):e;return this._mapping[r]||MH}setProps({loadOptions:e,autoPacking:r,iconAtlas:s,iconMapping:i,textureParameters:n}){e&&(this._loadOptions=e),r!==void 0&&(this._autoPacking=r),i&&(this._mapping=i),s&&(this._texture?.delete(),this._texture=null,this._externalTexture=s),n&&(this._textureParameters=n)}get isLoaded(){return this._pendingCount===0}packIcons(e,r){if(!this._autoPacking||typeof document>"u")return;let s=Object.values(FH(e,r,this._mapping)||{});if(s.length>0){let{mapping:i,xOffset:n,yOffset:o,rowHeight:a,canvasHeight:c}=OH({icons:s,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=i,this._xOffset=n,this._yOffset=o,this._canvasHeight=c,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",width:this._canvasWidth,height:this._canvasHeight,sampler:this._textureParameters||OP})),this._texture.height!==this._canvasHeight&&(this._texture=BH(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||OP)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(s)}}_loadIcons(e){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let s of e)this._pendingCount++,$e(s.url,this._loadOptions).then(i=>{let n=pu(s),o=this._mapping[n],{x:a,y:c,width:l,height:u}=o,{data:f,width:h,height:d}=IH(r,i,l,u);this._texture.setSubImageData({data:f,x:a+(l-h)/2,y:c+(u-d)/2,width:h,height:d}),o.width=h,o.height=d,this._texture.generateMipmap(),this.onUpdate()}).catch(i=>{this.onError({url:s.url,source:s.source,sourceIndex:s.sourceIndex,loadOptions:this._loadOptions,error:i})}).finally(()=>{this._pendingCount--})}};var LP=[0,0,0,255],LH={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:LP},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},mu=class extends he{getShaders(){return super.getShaders({vs:RP,fs:IP,modules:[de,_e]})}initializeState(){this.state={iconManager:new gu(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceOffsets:{size:2,accessor:"getIcon",transform:this.getInstanceOffset},instanceIconFrames:{size:4,accessor:"getIcon",transform:this.getInstanceIconFrame},instanceColorModes:{size:1,type:"uint8",accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:LP},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);let{props:r,oldProps:s,changeFlags:i}=e,n=this.getAttributeManager(),{iconAtlas:o,iconMapping:a,data:c,getIcon:l,textureParameters:u}=r,{iconManager:f}=this.state;if(typeof o=="string")return;let h=o||this.internalState.isAsyncPropLoading("iconAtlas");f.setProps({loadOptions:r.loadOptions,autoPacking:!h,iconAtlas:o,iconMapping:h?a:null,textureParameters:u}),h?s.iconMapping!==r.iconMapping&&n.invalidate("getIcon"):(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getIcon))&&f.packIcons(c,l),i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:r,sizeMinPixels:s,sizeMaxPixels:i,sizeUnits:n,billboard:o,alphaCutoff:a}=this.props,{iconManager:c}=this.state,l=c.getTexture();if(l){let u=this.state.model;u.setBindings({iconsTexture:l}),u.setUniforms(e),u.setUniforms({iconsTextureDim:[l.width,l.height],sizeUnits:Fe[n],sizeScale:r,sizeMinPixels:s,sizeMaxPixels:i,billboard:o,alphaCutoff:a}),u.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new se({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){let r=this.getCurrentLayer()?.props.onIconError;r?r(e):k.error(e.error.message)()}getInstanceOffset(e){let{width:r,height:s,anchorX:i=r/2,anchorY:n=s/2}=this.state.iconManager.getIconMapping(e);return[r/2-i,s/2-n]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){let{x:r,y:s,width:i,height:n}=this.state.iconManager.getIconMapping(e);return[r,s,i,n]}};mu.defaultProps=LH;mu.layerName="IconLayer";var pa=mu;var NP=`#version 300 es #define SHADER_NAME line-layer-vertex-shader in vec3 positions; in vec3 instanceSourcePositions; in vec3 instanceTargetPositions; in vec3 instanceSourcePositions64Low; in vec3 instanceTargetPositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in float instanceWidths; uniform float opacity; uniform float widthScale; uniform float widthMinPixels; uniform float widthMaxPixels; uniform float useShortestPath; uniform int widthUnits; out vec4 vColor; out vec2 uv; vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize); dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); return dir_screenspace * offset_direction * width / 2.0; } vec3 splitLine(vec3 a, vec3 b, float x) { float t = (x - a.x) / (b.x - a.x); return vec3(x, mix(a.yz, b.yz, t)); } void main(void) { geometry.worldPosition = instanceSourcePositions; geometry.worldPositionAlt = instanceTargetPositions; vec3 source_world = instanceSourcePositions; vec3 target_world = instanceTargetPositions; vec3 source_world_64low = instanceSourcePositions64Low; vec3 target_world_64low = instanceTargetPositions64Low; if (useShortestPath > 0.5 || useShortestPath < -0.5) { source_world.x = mod(source_world.x + 180., 360.0) - 180.; target_world.x = mod(target_world.x + 180., 360.0) - 180.; float deltaLng = target_world.x - source_world.x; if (deltaLng * useShortestPath > 180.) { source_world.x += 360. * useShortestPath; source_world = splitLine(source_world, target_world, 180. * useShortestPath); source_world_64low = vec3(0.0); } else if (deltaLng * useShortestPath < -180.) { target_world.x += 360. * useShortestPath; target_world = splitLine(source_world, target_world, 180. * useShortestPath); target_world_64low = vec3(0.0); } else if (useShortestPath < 0.) { gl_Position = vec4(0.); return; } } vec4 source_commonspace; vec4 target_commonspace; vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace); vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace); float segmentIndex = positions.x; vec4 p = mix(source, target, segmentIndex); geometry.position = mix(source_commonspace, target_commonspace, segmentIndex); uv = positions.xy; geometry.uv = uv; geometry.pickingColor = instancePickingColors; float widthPixels = clamp( project_size_to_pixel(instanceWidths * widthScale, widthUnits), widthMinPixels, widthMaxPixels ); vec3 offset = vec3( getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels), 0.0); DECKGL_FILTER_SIZE(offset, geometry); DECKGL_FILTER_GL_POSITION(p, geometry); gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); vColor = vec4(instanceColors.rgb, instanceColors.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var DP=`#version 300 es #define SHADER_NAME line-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 uv; out vec4 fragColor; void main(void) { geometry.uv = uv; fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var NH=[0,0,0,255],DH={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:NH},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},_u=class extends he{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:NP,fs:DP,modules:[de,_e]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:s,widthMinPixels:i,widthMaxPixels:n,wrapLongitude:o}=this.props,a=this.state.model;a.setUniforms(e),a.setUniforms({widthUnits:Fe[r],widthScale:s,widthMinPixels:i,widthMaxPixels:n,useShortestPath:o?1:0}),a.draw(this.context.renderPass),o&&(a.setUniforms({useShortestPath:-1}),a.draw(this.context.renderPass))}_getModel(){let e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new se({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};_u.layerName="LineLayer";_u.defaultProps=DH;var Vp=_u;var UP=`#version 300 es #define SHADER_NAME point-cloud-layer-vertex-shader in vec3 positions; in vec3 instanceNormals; in vec4 instanceColors; in vec3 instancePositions; in vec3 instancePositions64Low; in vec3 instancePickingColors; uniform float opacity; uniform float radiusPixels; uniform int sizeUnits; out vec4 vColor; out vec2 unitPosition; void main(void) { geometry.worldPosition = instancePositions; geometry.normal = project_normal(instanceNormals); unitPosition = positions.xy; geometry.uv = unitPosition; geometry.pickingColor = instancePickingColors; vec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, instanceColors.a * opacity); DECKGL_FILTER_COLOR(vColor, geometry); } `;var kP=`#version 300 es #define SHADER_NAME point-cloud-layer-fragment-shader precision highp float; in vec4 vColor; in vec2 unitPosition; out vec4 fragColor; void main(void) { geometry.uv = unitPosition; float distToCenter = length(unitPosition); if (distToCenter > 1.0) { discard; } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var VP=[0,0,0,255],zP=[0,0,1],UH={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:zP},getColor:{type:"accessor",value:VP},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function kH(t){let{header:e,attributes:r}=t;if(!(!e||!r)&&(t.length=e.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:s,value:i}=r.COLOR_0;r.instanceColors={size:s,type:"unorm8",value:i}}}var yu=class extends he{getShaders(){return super.getShaders({vs:UP,fs:kP,modules:[de,pr,_e]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:zP},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:VP}})}updateState(e){let{changeFlags:r,props:s}=e;super.updateState(e),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&kH(s.data)}draw({uniforms:e}){let{pointSize:r,sizeUnits:s}=this.props,i=this.state.model;i.setUniforms(e),i.setUniforms({sizeUnits:Fe[s],radiusPixels:r}),i.draw(this.context.renderPass)}_getModel(){let e=[];for(let r=0;r<3;r++){let s=r/3*Math.PI*2;e.push(Math.cos(s)*2,Math.sin(s)*2,0)}return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new se({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}};yu.layerName="PointCloudLayer";yu.defaultProps=UH;var zp=yu;var HP=`#version 300 es #define SHADER_NAME scatterplot-layer-vertex-shader in vec3 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in float instanceRadius; in float instanceLineWidths; in vec4 instanceFillColors; in vec4 instanceLineColors; in vec3 instancePickingColors; uniform float opacity; uniform float radiusScale; uniform float radiusMinPixels; uniform float radiusMaxPixels; uniform float lineWidthScale; uniform float lineWidthMinPixels; uniform float lineWidthMaxPixels; uniform float stroked; uniform bool filled; uniform bool antialiasing; uniform bool billboard; uniform int radiusUnits; uniform int lineWidthUnits; out vec4 vFillColor; out vec4 vLineColor; out vec2 unitPosition; out float innerUnitRadius; out float outerRadiusPixels; void main(void) { geometry.worldPosition = instancePositions; outerRadiusPixels = clamp( project_size_to_pixel(radiusScale * instanceRadius, radiusUnits), radiusMinPixels, radiusMaxPixels ); float lineWidthPixels = clamp( project_size_to_pixel(lineWidthScale * instanceLineWidths, lineWidthUnits), lineWidthMinPixels, lineWidthMaxPixels ); outerRadiusPixels += stroked * lineWidthPixels / 2.0; float edgePadding = antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; unitPosition = edgePadding * positions.xy; geometry.uv = unitPosition; geometry.pickingColor = instancePickingColors; innerUnitRadius = 1.0 - stroked * lineWidthPixels / outerRadiusPixels; if (billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = edgePadding * positions * outerRadiusPixels; DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); DECKGL_FILTER_SIZE(offset, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity); DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } `;var GP=`#version 300 es #define SHADER_NAME scatterplot-layer-fragment-shader precision highp float; uniform bool filled; uniform float stroked; uniform bool antialiasing; in vec4 vFillColor; in vec4 vLineColor; in vec2 unitPosition; in float innerUnitRadius; in float outerRadiusPixels; out vec4 fragColor; void main(void) { geometry.uv = unitPosition; float distToCenter = length(unitPosition) * outerRadiusPixels; float inCircle = antialiasing ? smoothedge(distToCenter, outerRadiusPixels) : step(distToCenter, outerRadiusPixels); if (inCircle == 0.0) { discard; } if (stroked > 0.5) { float isLine = antialiasing ? smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : step(innerUnitRadius * outerRadiusPixels, distToCenter); if (filled) { fragColor = mix(vFillColor, vLineColor, isLine); } else { if (isLine == 0.0) { discard; } fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); } } else if (!filled) { discard; } else { fragColor = vFillColor; } fragColor.a *= inCircle; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var WP=[0,0,0,255],VH={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:WP},getLineColor:{type:"accessor",value:WP},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},xu=class extends he{getShaders(){return super.getShaders({vs:HP,fs:GP,modules:[de,_e]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:r,radiusScale:s,radiusMinPixels:i,radiusMaxPixels:n,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props,p=this.state.model;p.setUniforms(e),p.setUniforms({stroked:o?1:0,filled:a,billboard:c,antialiasing:l,radiusUnits:Fe[r],radiusScale:s,radiusMinPixels:i,radiusMaxPixels:n,lineWidthUnits:Fe[u],lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}),p.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new se({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};xu.defaultProps=VH;xu.layerName="ScatterplotLayer";var Hp=xu;var ga={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function Xn(t,e,r={}){return jP(t,r)!==e?(zH(t,r),!0):!1}function jP(t,e={}){return Math.sign(Di(t,e))}var Au={x:0,y:1,z:2};function Di(t,e={}){let{start:r=0,end:s=t.length,plane:i="xy"}=e,n=e.size||2,o=0,a=Au[i[0]],c=Au[i[1]];for(let l=r,u=s-n;l80*r){h=u=t[0],d=f=t[1];for(let m=r;mu&&(u=p),g>f&&(f=g);l=Math.max(u-h,f-d),l=l!==0?32767/l:0}return Tu(a,c,r,h,d,l,0),c}function YP(t,e,r,s,i,n,o){let a,c;n===void 0&&(n=Di(t,{start:e,end:r,size:s,plane:o}));let l=Au[o[0]],u=Au[o[1]];if(i===n<0)for(a=e;a=e;a-=s)c=XP(a,t[a+l],t[a+u],c);return c&&jp(c,c.next)&&(Eu(c),c=c.next),c}function Yn(t,e){if(!t)return t;e||(e=t);let r=t,s;do if(s=!1,!r.steiner&&(jp(r,r.next)||Ne(r.prev,r,r.next)===0)){if(Eu(r),r=e=r.prev,r===r.next)break;s=!0}else r=r.next;while(s||r!==e);return e}function Tu(t,e,r,s,i,n,o){if(!t)return;!o&&n&&ZH(t,s,i,n);let a=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,n?WH(t,s,i,n):GH(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),Eu(t),t=l.next,a=l.next;continue}if(t=l,t===a){o?o===1?(t=jH(Yn(t),e,r),Tu(t,e,r,s,i,n,2)):o===2&&XH(t,e,r,s,i,n):Tu(Yn(t),e,r,s,i,n,1);break}}}function GH(t){let e=t.prev,r=t,s=t.next;if(Ne(e,r,s)>=0)return!1;let i=e.x,n=r.x,o=s.x,a=e.y,c=r.y,l=s.y,u=in?i>o?i:o:n>o?n:o,d=a>c?a>l?a:l:c>l?c:l,p=s.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&ma(i,a,n,c,o,l,p.x,p.y)&&Ne(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function WH(t,e,r,s){let i=t.prev,n=t,o=t.next;if(Ne(i,n,o)>=0)return!1;let a=i.x,c=n.x,l=o.x,u=i.y,f=n.y,h=o.y,d=ac?a>l?a:l:c>l?c:l,m=u>f?u>h?u:h:f>h?f:h,_=hA(d,p,e,r,s),y=hA(g,m,e,r,s),x=t.prevZ,S=t.nextZ;for(;x&&x.z>=_&&S&&S.z<=y;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&ma(a,u,c,f,l,h,x.x,x.y)&&Ne(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=d&&S.x<=g&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&ma(a,u,c,f,l,h,S.x,S.y)&&Ne(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=_;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&ma(a,u,c,f,l,h,x.x,x.y)&&Ne(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=y;){if(S.x>=d&&S.x<=g&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&ma(a,u,c,f,l,h,S.x,S.y)&&Ne(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function jH(t,e,r){let s=t;do{let i=s.prev,n=s.next.next;!jp(i,n)&&qP(i,s,s.next,n)&&bu(i,n)&&bu(n,i)&&(e.push(i.i/r|0),e.push(s.i/r|0),e.push(n.i/r|0),Eu(s),Eu(s.next),s=t=n),s=s.next}while(s!==t);return Yn(s)}function XH(t,e,r,s,i,n){let o=t;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&t9(o,a)){let c=KP(o,a);o=Yn(o,o.next),c=Yn(c,c.next),Tu(o,e,r,s,i,n,0),Tu(c,e,r,s,i,n,0);return}a=a.next}o=o.next}while(o!==t)}function YH(t,e,r,s,i,n){let o=[],a,c,l,u,f;for(a=0,c=e.length;a=r.next.y&&r.next.y!==r.y){let h=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=s&&h>n&&(n=h,o=r.x=r.x&&r.x>=c&&s!==r.x&&ma(io.x||r.x===o.x&&JH(o,r)))&&(o=r,u=f)),r=r.next;while(r!==a);return o}function JH(t,e){return Ne(t.prev,t,e.prev)<0&&Ne(e.next,t,t.next)<0}function ZH(t,e,r,s){let i=t;do i.z===0&&(i.z=hA(i.x,i.y,e,r,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,QH(i)}function QH(t){let e,r,s=1,i,n,o,a,c,l;do{for(n=t,t=null,l=null,i=0;n;){for(i++,a=n,o=0,r=0;r0||c>0&&a;)o!==0&&(c===0||!a||n.z<=a.z)?(e=n,n=n.nextZ,o--):(e=a,a=a.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;n=a}l.nextZ=null,s*=2}while(i>1);return t}function hA(t,e,r,s,i){return t=(t-r)*i|0,e=(e-s)*i|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function e9(t){let e=t,r=t;do(e.x=(t-o)*(n-a)&&(t-o)*(s-a)>=(r-o)*(e-a)&&(r-o)*(n-a)>=(i-o)*(s-a)}function t9(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!r9(t,e)&&(bu(t,e)&&bu(e,t)&&s9(t,e)&&(Ne(t.prev,t,e.prev)||Ne(t,e.prev,e))||jp(t,e)&&Ne(t.prev,t,t.next)>0&&Ne(e.prev,e,e.next)>0)}function Ne(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function jp(t,e){return t.x===e.x&&t.y===e.y}function qP(t,e,r,s){let i=Wp(Ne(t,e,r)),n=Wp(Ne(t,e,s)),o=Wp(Ne(r,s,t)),a=Wp(Ne(r,s,e));return!!(i!==n&&o!==a||i===0&&Gp(t,r,e)||n===0&&Gp(t,s,e)||o===0&&Gp(r,t,s)||a===0&&Gp(r,e,s))}function Gp(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Wp(t){return t>0?1:t<0?-1:0}function r9(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&qP(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function bu(t,e){return Ne(t.prev,t,t.next)<0?Ne(t,e,t.next)>=0&&Ne(t,t.prev,e)>=0:Ne(t,e,t.prev)<0||Ne(t,t.next,e)<0}function s9(t,e){let r=t,s=!1,i=(t.x+e.x)/2,n=(t.y+e.y)/2;do r.y>n!=r.next.y>n&&r.next.y!==r.y&&i<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next;while(r!==t);return s}function KP(t,e){let r=new Su(t.i,t.x,t.y),s=new Su(e.i,e.x,e.y),i=t.next,n=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,s.next=r,r.prev=s,n.next=s,s.prev=n,s}function XP(t,e,r,s){let i=new Su(t,e,r);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function Eu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var Su=class{constructor(e,r,s){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=s}};function Wt(t,e){let r=e.length,s=t.length;if(s>0){let i=!0;for(let n=0;ne[2]&&(r|=2),t[1]e[3]&&(r|=8),r}function wu(t,e){let{size:r=2,broken:s=!1,gridResolution:i=10,gridOffset:n=[0,0],startIndex:o=0,endIndex:a=t.length}=e||{},c=(a-o)/r,l=[],u=[l],f=Ui(t,0,r,o),h,d,p=ZP(f,i,n,[]),g=[];Wt(l,f);for(let m=1;mr&&(l=[],u.push(l),Wt(l,f)),d=Cu(h,p)}Wt(l,h),vu(f,h)}return s?u:u[0]}var $P=0,i9=1;function Pu(t,e=null,r){if(!t.length)return[];let{size:s=2,gridResolution:i=10,gridOffset:n=[0,0],edgeTypes:o=!1}=r||{},a=[],c=[{pos:t,types:o?new Array(t.length/s).fill(i9):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:h,holes:d}=c.shift();o9(f,s,d[0]||f.length,l),u=ZP(l[0],i,n,u);let p=Cu(l[1],u);if(p){let g=JP(f,h,s,0,d[0]||f.length,u,p),m={pos:g[0].pos,types:g[0].types,holes:[]},_={pos:g[1].pos,types:g[1].types,holes:[]};c.push(m,_);for(let y=0;y=0?(Wt(l,d)&&f.push(g),S+=p):f.length&&(f[f.length-1]=$P),vu(m,d),_=p,y=g;return[x?{pos:c,types:e&&u}:null,S?{pos:l,types:e&&f}:null]}function ZP(t,e,r,s){let i=Math.floor((t[0]-r[0])/e)*e+r[0],n=Math.floor((t[1]-r[1])/e)*e+r[1];return s[0]=i,s[1]=n,s[2]=i+e,s[3]=n+e,s}function n9(t,e,r){r&8?(t[1]+=e,t[3]+=e):r&4?(t[1]-=e,t[3]-=e):r&2?(t[0]+=e,t[2]+=e):r&1&&(t[0]-=e,t[2]-=e)}function o9(t,e,r,s){let i=1/0,n=-1/0,o=1/0,a=-1/0;for(let c=0;cn?l:n,o=ua?u:a}return s[0][0]=i,s[0][1]=o,s[1][0]=n,s[1][1]=a,s}function Yp(t,e){for(let r=0;ri&&(i=a,n=o-1)}return n}function l9(t,e,r,s,i=a9){let n=t[r],o=t[s-e];if(Math.abs(n-o)>180){let a=Ui(t,0,e,r);a[0]+=Math.round((o-n)/360)*360,Wt(t,a),a[1]=Math.sign(a[1])*i,Wt(t,a),a[0]=n,Wt(t,a)}}function QP(t,e,r,s){let i=t[0],n;for(let o=r;o180||a<-180)&&(n-=Math.round(a/360)*360),t[o]=i=n}}function eM(t,e){let r,s=t.length/e;for(let n=0;n=s),i=i.flatMap(d=>[d[0],d[1]]),Xn(i,ga.COUNTER_CLOCKWISE));let n=r>0,o=s+1,a=n?o*3+1:s,c=Math.PI*2/s,l=new Uint16Array(n?s*3*2:0),u=new Float32Array(a*3),f=new Float32Array(a*3),h=0;if(n){for(let d=0;d 0.0 && instanceElevations >= 0.0); float dotRadius = radius * coverage * shouldRender; geometry.pickingColor = instancePickingColors; vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation); vec3 centroidPosition64Low = instancePositions64Low; vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + offset) * dotRadius; if (radiusUnits == UNIT_METERS) { offset = project_size(offset); } vec3 pos = vec3(offset, 0.); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position); geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z)); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); if (extruded && !isStroke) { #ifdef FLAT_SHADING position_commonspace = geometry.position; vColor = vec4(color.rgb, color.a * opacity); #else vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, color.a * opacity); #endif } else { vColor = vec4(color.rgb, color.a * opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var rM=`#version 300 es #define SHADER_NAME column-layer-fragment-shader precision highp float; uniform vec3 project_uCameraPosition; uniform bool extruded; uniform bool isStroke; out vec4 fragColor; in vec4 vColor; #ifdef FLAT_SHADING in vec4 position_commonspace; #endif void main(void) { fragColor = vColor; geometry.uv = vec2(0.); #ifdef FLAT_SHADING if (extruded && !isStroke && !bool(picking.isActive)) { vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); fragColor.rgb = lighting_getLightColor(vColor.rgb, project_uCameraPosition, position_commonspace.xyz, normal); } #endif DECKGL_FILTER_COLOR(fragColor, geometry); } `;var qp=[0,0,0,255],h9={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:qp},getLineColor:{type:"accessor",value:qp},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},Ru=class extends he{getShaders(){let e={},{flatShading:r}=this.props;return r&&(e.FLAT_SHADING=1),super.getShaders({vs:tM,fs:rM,defines:e,modules:[de,r?vi:pr,_e]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:qp},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:qp},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);let{props:r,oldProps:s,changeFlags:i}=e,n=i.extensionsChanged||r.flatShading!==s.flatShading;n&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let o=this.getNumInstances();this.state.fillModel.setInstanceCount(o),this.state.wireframeModel.setInstanceCount(o),(n||r.diskResolution!==s.diskResolution||r.vertices!==s.vertices||(r.extruded||r.stroked)!==(s.extruded||s.stroked))&&this._updateGeometry(r)}getGeometry(e,r,s){let i=new Mu({radius:1,height:s?2:0,vertices:r,nradial:e}),n=0;if(r)for(let o=0;o=e.length&&(r+=1-e.length/i);let n=r*i;return s[0]=e[n],s[1]=e[n+1],s[2]=i===3&&e[n+2]||0,s}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);let{positionSize:r}=this,s=e.length-r;return e[0]===e[s]&&e[1]===e[s+1]&&(r===2||e[2]===e[s+2])}};function iM(t){return Array.isArray(t[0])}var nM=`#version 300 es #define SHADER_NAME path-layer-vertex-shader in vec2 positions; in float instanceTypes; in vec3 instanceStartPositions; in vec3 instanceEndPositions; in vec3 instanceLeftPositions; in vec3 instanceRightPositions; in vec3 instanceLeftPositions64Low; in vec3 instanceStartPositions64Low; in vec3 instanceEndPositions64Low; in vec3 instanceRightPositions64Low; in float instanceStrokeWidths; in vec4 instanceColors; in vec3 instancePickingColors; uniform float widthScale; uniform float widthMinPixels; uniform float widthMaxPixels; uniform float jointType; uniform float capType; uniform float miterLimit; uniform bool billboard; uniform int widthUnits; uniform float opacity; out vec4 vColor; out vec2 vCornerOffset; out float vMiterLength; out vec2 vPathPosition; out float vPathLength; out float vJointType; const float EPSILON = 0.001; const vec3 ZERO_OFFSET = vec3(0.0); float flipIfTrue(bool flag) { return -(float(flag) * 2. - 1.); } vec3 getLineJoinOffset( vec3 prevPoint, vec3 currPoint, vec3 nextPoint, vec2 width ) { bool isEnd = positions.x > 0.0; float sideOfPath = positions.y; float isJoint = float(sideOfPath == 0.0); vec3 deltaA3 = (currPoint - prevPoint); vec3 deltaB3 = (nextPoint - currPoint); mat3 rotationMatrix; bool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix); if (needsRotation) { deltaA3 = deltaA3 * rotationMatrix; deltaB3 = deltaB3 * rotationMatrix; } vec2 deltaA = deltaA3.xy / width; vec2 deltaB = deltaB3.xy / width; float lenA = length(deltaA); float lenB = length(deltaB); vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); vec2 perpA = vec2(-dirA.y, dirA.x); vec2 perpB = vec2(-dirB.y, dirB.x); vec2 tangent = dirA + dirB; tangent = length(tangent) > 0. ? normalize(tangent) : perpA; vec2 miterVec = vec2(-tangent.y, tangent.x); vec2 dir = isEnd ? dirA : dirB; vec2 perp = isEnd ? perpA : perpB; float L = isEnd ? lenA : lenB; float sinHalfA = abs(dot(miterVec, perp)); float cosHalfA = abs(dot(dirA, miterVec)); float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); float cornerPosition = sideOfPath * turnDirection; float miterSize = 1.0 / max(sinHalfA, EPSILON); miterSize = mix( min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), miterSize, step(0.0, cornerPosition) ); vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) * (sideOfPath + isJoint * turnDirection); bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); bool isCap = isStartCap || isEndCap; if (isCap) { offsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint); vJointType = capType; } else { vJointType = jointType; } vPathLength = L; vCornerOffset = offsetVec; vMiterLength = dot(vCornerOffset, miterVec * turnDirection); vMiterLength = isCap ? isJoint : vMiterLength; vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); vPathPosition = vec2( dot(offsetFromStartOfPath, perp), dot(offsetFromStartOfPath, dir) ); geometry.uv = vPathPosition; float isValid = step(instanceTypes, 3.5); vec3 offset = vec3(offsetVec * width * isValid, 0.0); if (needsRotation) { offset = rotationMatrix * offset; } return offset; } void clipLine(inout vec4 position, vec4 refPosition) { if (position.w < EPSILON) { float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); position = refPosition + (position - refPosition) * r; } } void main() { geometry.pickingColor = instancePickingColors; vColor = vec4(instanceColors.rgb, instanceColors.a * opacity); float isEnd = positions.x; vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); geometry.worldPosition = currPosition; vec2 widthPixels = vec2(clamp( project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits), widthMinPixels, widthMaxPixels) / 2.0); vec3 width; if (billboard) { vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET); vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET); clipLine(prevPositionScreen, currPositionScreen); clipLine(nextPositionScreen, currPositionScreen); clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); width = vec3(widthPixels, 0.0); DECKGL_FILTER_SIZE(width, geometry); vec3 offset = getLineJoinOffset( prevPositionScreen.xyz / prevPositionScreen.w, currPositionScreen.xyz / currPositionScreen.w, nextPositionScreen.xyz / nextPositionScreen.w, project_pixel_size_to_clipspace(width.xy) ); DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); } else { prevPosition = project_position(prevPosition, prevPosition64Low); currPosition = project_position(currPosition, currPosition64Low); nextPosition = project_position(nextPosition, nextPosition64Low); width = vec3(project_pixel_size(widthPixels), 0.0); DECKGL_FILTER_SIZE(width, geometry); vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy); geometry.position = vec4(currPosition + offset, 1.0); gl_Position = project_common_position_to_clipspace(geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var oM=`#version 300 es #define SHADER_NAME path-layer-fragment-shader precision highp float; uniform float miterLimit; in vec4 vColor; in vec2 vCornerOffset; in float vMiterLength; in vec2 vPathPosition; in float vPathLength; in float vJointType; out vec4 fragColor; void main(void) { geometry.uv = vPathPosition; if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { discard; } if (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) { discard; } } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var aM=[0,0,0,255],m9={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:aM},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},_A={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},Ou=class extends he{getShaders(){return super.getShaders({vs:nM,fs:oM,modules:[de,_e]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:_A,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:_A,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:_A,defaultValue:aM},instancePickingColors:{size:4,type:"uint8",accessor:(s,{index:i,target:n})=>this.encodePickingColor(s&&s.__source?s.__source.index:i,n)}}),this.setState({pathTesselator:new Bu({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:r,changeFlags:s}=e,i=this.getAttributeManager();if(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getPath)){let{pathTesselator:o}=this.state,a=r.data.attributes||{};o.updateGeometry({data:r.data,geometryBuffer:a.getPath,buffers:a,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:s.dataChanged}),this.setState({numInstances:o.instanceCount,startIndices:o.vertexStarts}),s.dataChanged||i.invalidateAll()}s.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),i.invalidateAll())}getPickingInfo(e){let r=super.getPickingInfo(e),{index:s}=r,i=this.props.data;return i[0]&&i[0].__source&&(r.object=i.find(n=>n.__source.index===s)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let s=0;s=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function L9(t){let e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]}function N9(t,e,r,s){for(let i=0;ia/e));let n=ya(t),o=s&&e===3;if(r){let a=n.length;n=n.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(r||(n=n.slice()),mM(n,0,2,1)):(r||(n=n.slice()),mM(n,2,0,1)))}return(0,_M.default)(n,i,e)}var Uu=class extends Ys{constructor(e){let{fp64:r,IndexType:s=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:s,size:1}}})}get(e){let{attributes:r}=this;return e==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[e]}updateGeometry(e){super.updateGeometry(e);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let r=tg(e,this.positionSize);return this.opts.resolution?Pu(ya(r),Du(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?gA(ya(r),Du(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return e}getGeometrySize(e){if(AM(e)){let r=0;for(let s of e)r+=this.getGeometrySize(s);return r}return ya(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,r){if(e&&AM(e))for(let s of e){let i=this.getGeometrySize(s);r.geometrySize=i,this.updateGeometryAttributes(s,r),r.vertexStart+=i,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let s=e;this._updateIndices(s,r),this._updatePositions(s,r),this._updateVertexValid(s,r)}}_updateIndices(e,{geometryIndex:r,vertexStart:s,indexStart:i}){let{attributes:n,indexStarts:o,typedArrayManager:a}=this,c=n.indices;if(!c||!e)return;let l=i,u=yM(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,i+u.length,{copy:!0});for(let f=0;f2?o[c*n+2]:0;i[a*3]=l,i[a*3+1]=u,i[a*3+2]=f}}_updateVertexValid(e,{vertexStart:r,geometrySize:s}){let{positionSize:i}=this,n=this.attributes.vertexValid,o=e&&Du(e);if(e&&e.edgeTypes?n.set(e.edgeTypes,r):n.fill(1,r,r+s),o)for(let a=0;a0&&!Number.isFinite(t[0])}var rg=`uniform bool extruded; uniform bool isWireframe; uniform float elevationScale; uniform float opacity; in vec4 fillColors; in vec4 lineColors; in vec3 pickingColors; out vec4 vColor; struct PolygonProps { vec3 positions; vec3 positions64Low; vec3 normal; float elevations; }; vec3 project_offset_normal(vec3 vector) { if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT || project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { return normalize(vector * project_uCommonUnitsPerWorldUnit); } return project_normal(vector); } void calculatePosition(PolygonProps props) { vec3 pos = props.positions; vec3 pos64Low = props.positions64Low; vec3 normal = props.normal; vec4 colors = isWireframe ? lineColors : fillColors; geometry.worldPosition = props.positions; geometry.pickingColor = pickingColors; if (extruded) { pos.z += props.elevations * elevationScale; } gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); if (extruded) { #ifdef IS_SIDE_VERTEX normal = project_offset_normal(normal); #else normal = project_normal(normal); #endif geometry.normal = normal; vec3 lightColor = lighting_getLightColor(colors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal); vColor = vec4(lightColor, colors.a * opacity); } else { vColor = vec4(colors.rgb, colors.a * opacity); } DECKGL_FILTER_COLOR(vColor, geometry); } `;var TM=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader in vec3 vertexPositions; in vec3 vertexPositions64Low; in float elevations; ${rg} void main(void) { PolygonProps props; props.positions = vertexPositions; props.positions64Low = vertexPositions64Low; props.elevations = elevations; props.normal = vec3(0.0, 0.0, 1.0); calculatePosition(props); } `;var bM=`#version 300 es #define SHADER_NAME solid-polygon-layer-vertex-shader-side #define IS_SIDE_VERTEX in vec2 positions; in vec3 vertexPositions; in vec3 nextVertexPositions; in vec3 vertexPositions64Low; in vec3 nextVertexPositions64Low; in float elevations; in float instanceVertexValid; ${rg} void main(void) { if(instanceVertexValid < 0.5){ gl_Position = vec4(0.); return; } PolygonProps props; vec3 pos; vec3 pos64Low; vec3 nextPos; vec3 nextPos64Low; #if RING_WINDING_ORDER_CW == 1 pos = vertexPositions; pos64Low = vertexPositions64Low; nextPos = nextVertexPositions; nextPos64Low = nextVertexPositions64Low; #else pos = nextVertexPositions; pos64Low = nextVertexPositions64Low; nextPos = vertexPositions; nextPos64Low = vertexPositions64Low; #endif props.positions = mix(pos, nextPos, positions.x); props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); props.normal = vec3( pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), 0.0); props.elevations = elevations * positions.y; calculatePosition(props); } `;var EM=`#version 300 es #define SHADER_NAME solid-polygon-layer-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main(void) { fragColor = vColor; geometry.uv = vec2(0.); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var ig=[0,0,0,255],D9={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:ig},getLineColor:{type:"accessor",value:ig},material:!0},sg={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},ku=class extends he{getShaders(e){return super.getShaders({vs:e==="top"?TM:bM,fs:EM,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[de,pr,_e]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:r}=this.props,{_full3d:s}=this.props;e.isGeospatial&&r===X.DEFAULT&&(r=X.LNGLAT);let i;r===X.LNGLAT&&(s?i=e.projectPosition.bind(e):i=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new Uu({preproject:i,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let n=this.getAttributeManager(),o=!0;n.remove(["instancePickingColors"]),n.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:sg,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:sg,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:sg,accessor:"getFillColor",defaultValue:ig},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:sg,accessor:"getLineColor",defaultValue:ig},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:s}=r,i=this.props.data;return i[0]&&i[0].__source&&(r.object=i.find(n=>n.__source.index===s)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let s=0;sa.destroy()),this.setState(this._getModels()),n.invalidateAll())}updateGeometry({props:e,oldProps:r,changeFlags:s}){if(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getPolygon)){let{polygonTesselator:n}=this.state,o=e.data.attributes||{};n.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:s.dataChanged,full3d:e._full3d}),this.setState({numInstances:n.instanceCount,startIndices:n.vertexStarts}),s.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:r,extruded:s}=this.props,i,n,o;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});i=new J(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",uniforms:{isWireframe:!1},bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(s){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});n=new J(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,uniforms:{isWireframe:!1},geometry:new se({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new J(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,uniforms:{isWireframe:!0},geometry:new se({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[n,o,i].filter(Boolean),topModel:i,sideModel:n,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:r}=this.state;e.startIndices=r.indexStarts,e.value=r.get("indices")}calculatePositions(e){let{polygonTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}};ku.defaultProps=D9;ku.layerName="SolidPolygonLayer";var Hi=ku;function ng({data:t,getIndex:e,dataRange:r,replace:s}){let{startRow:i=0,endRow:n=1/0}=r,o=t.length,a=o,c=o;for(let h=0;hh&&d>=i&&(a=h),d>=n){c=h;break}}let l=a,f=c-a!==s.length?t.slice(c):void 0;for(let h=0;ht.polygon},getFillColor:{type:"accessor",value:U9},getLineColor:{type:"accessor",value:SM},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},Vu=class extends Le{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&k.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){let r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(r&&Array.isArray(e.dataChanged)){let s=this.state.paths.slice(),i=e.dataChanged.map(n=>ng({data:s,getIndex:o=>o.__source.index,dataRange:n,replace:this._getPaths(n)}));this.setState({paths:s,pathsDiff:i})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){let{data:r,getPolygon:s,positionFormat:i,_normalize:n}=this.props,o=[],a=i==="XY"?2:3,{startRow:c,endRow:l}=e,{iterable:u,objectInfo:f}=ze(r,c,l);for(let h of u){f.index++;let d=s(h,f);n&&(d=tg(d,a));let{holeIndices:p}=d,g=d.positions||d;if(p)for(let m=0;m<=p.length;m++){let _=g.slice(p[m-1]||0,p[m]||g.length);o.push(this.getSubLayerRow({path:_},h,f.index))}else o.push(this.getSubLayerRow({path:g},h,f.index))}return o}renderLayers(){let{data:e,_dataDiff:r,stroked:s,filled:i,extruded:n,wireframe:o,_normalize:a,_windingOrder:c,elevationScale:l,transitions:u,positionFormat:f}=this.props,{lineWidthUnits:h,lineWidthScale:d,lineWidthMinPixels:p,lineWidthMaxPixels:g,lineJointRounded:m,lineMiterLimit:_,lineDashJustified:y}=this.props,{getFillColor:x,getLineColor:S,getLineWidth:P,getLineDashArray:B,getElevation:L,getPolygon:M,updateTriggers:v,material:T}=this.props,{paths:D,pathsDiff:V}=this.state,z=this.getSubLayerClass("fill",Hi),W=this.getSubLayerClass("stroke",Vi),Z=this.shouldRenderSubLayer("fill",D)&&new z({_dataDiff:r,extruded:n,elevationScale:l,filled:i,wireframe:o,_normalize:a,_windingOrder:c,getElevation:L,getFillColor:x,getLineColor:n&&o?S:SM,material:T,transitions:u},this.getSubLayerProps({id:"fill",updateTriggers:v&&{getPolygon:v.getPolygon,getElevation:v.getElevation,getFillColor:v.getFillColor,lineColors:n&&o,getLineColor:v.getLineColor}}),{data:e,positionFormat:f,getPolygon:M}),le=!n&&s&&this.shouldRenderSubLayer("stroke",D)&&new W({_dataDiff:V&&(()=>V),widthUnits:h,widthScale:d,widthMinPixels:p,widthMaxPixels:g,jointRounded:m,miterLimit:_,dashJustified:y,_pathType:"loop",transitions:u&&{getWidth:u.getLineWidth,getColor:u.getLineColor,getPath:u.getPolygon},getColor:this.getSubLayerAccessor(S),getWidth:this.getSubLayerAccessor(P),getDashArray:this.getSubLayerAccessor(B)},this.getSubLayerProps({id:"stroke",updateTriggers:v&&{getWidth:v.getLineWidth,getColor:v.getLineColor,getDashArray:v.getLineDashArray}}),{data:D,positionFormat:f,getPath:ie=>ie.path});return[!n&&Z,le,n&&Z]}};Vu.layerName="PolygonLayer";Vu.defaultProps=k9;var Gi=Vu;function vM(t,e){if(!t)return null;let r="startIndices"in t?t.startIndices[e]:e,s=t.featureIds.value[r];return r!==-1?V9(t,s,r):null}function V9(t,e,r){let s={properties:{...t.properties[e]}};for(let i in t.numericProps)s.properties[i]=t.numericProps[i].value[r];return s}function CM(t,e){let r={points:null,lines:null,polygons:null};for(let s in r){let i=t[s].globalFeatureIds.value;r[s]=new Uint8ClampedArray(i.length*3);let n=[];for(let o=0;o 0.0) { float inFill = alpha; float inBorder = smoothstep(outlineBuffer - gamma, outlineBuffer + gamma, distance); color = mix(outlineColor, vColor, inFill); alpha = inBorder; } } float a = alpha * color.a; if (a < alphaCutoff) { discard; } fragColor = vec4(color.rgb, a * opacity); } DECKGL_FILTER_COLOR(fragColor, geometry); } `;var EA=192/256,PM=[],z9={getIconOffsets:{type:"accessor",value:t=>t.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},zu=class extends pa{getShaders(){return{...super.getShaders(),fs:wM}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(r,{index:s,target:i})=>this.encodePickingColor(s,i)}})}updateState(e){super.updateState(e);let{props:r,oldProps:s}=e,{outlineColor:i}=r;i!==s.outlineColor&&(i=i.map(n=>n/255),i[3]=Number.isFinite(i[3])?i[3]:1,this.setState({outlineColor:i})),!r.sdf&&r.outlineWidth&&k.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:r,smoothing:s,outlineWidth:i}=this.props,{outlineColor:n}=this.state,o=i?Math.max(s,EA*(1-i)):-1;if(e.uniforms={...e.uniforms,sdfBuffer:EA,outlineBuffer:o,gamma:s,sdf:Boolean(r),outlineColor:n},super.draw(e),r&&i){let{iconManager:a}=this.state,c=a.getTexture(),l=this.state.model;c&&(l.setUniforms({outlineBuffer:EA}),l.draw(this.context.renderPass))}}getInstanceOffset(e){return e?Array.from(e).flatMap(r=>super.getInstanceOffset(r)):PM}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(r=>super.getInstanceIconFrame(r)):PM}};zu.defaultProps=z9;zu.layerName="MultiIconLayer";var og=zu;var Hu=class{constructor({fontSize:e=24,buffer:r=3,radius:s=8,cutoff:i=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=i,this.radius=s;let c=this.size=e+r*4,l=this._createCanvas(c),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){let r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:s,actualBoundingBoxDescent:i,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(s),c=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),u=Math.min(this.size-this.buffer,a+Math.ceil(i)),f=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(f*h,0),p=new Uint8ClampedArray(d),g={data:p,width:f,height:h,glyphWidth:l,glyphHeight:u,glyphTop:a,glyphLeft:c,glyphAdvance:r};if(l===0||u===0)return g;let{ctx:m,buffer:_,gridInner:y,gridOuter:x}=this;m.clearRect(_,_,l,u),m.fillText(e,_,_+a);let S=m.getImageData(_,_,l,u);x.fill(1e20,0,d),y.fill(0,0,d);for(let P=0;P0?v*v:0,y[M]=v<0?v*v:0}}MM(x,0,0,f,h,f,this.f,this.v,this.z),MM(y,_,_,l,u,f,this.f,this.v,this.z);for(let P=0;P-1);c++,n[c]=a,o[c]=l,o[c+1]=1e20}for(let a=0,c=0;ai&&(l=0,c++),n[f]={x:l+s,y:a+c*u+s,width:h,height:u,layoutWidth:h,layoutHeight:r},l+=h+s*2}return{mapping:n,xOffset:l,yOffset:a+c*u,canvasHeight:W9(a+(c+1)*u)}}function BM(t,e,r,s){let i=0;for(let n=e;ns&&(oa){let f=BM(t,a,c,i);l+f>s&&(os&&(f=OM(t,a,c,s,i,n),o=n[n.length-1])),a=c,l+=f}return l}function X9(t,e,r,s,i=0,n){n===void 0&&(n=t.length);let o=[];return e==="break-all"?OM(t,i,n,r,s,o):j9(t,i,n,r,s,o),o}function Y9(t,e,r,s,i,n){let o=0,a=0;for(let c=e;c0,f=[0,0],h=[0,0],d=0,p=0,g=0;for(let m=0;m<=o;m++){let _=n[m];if((_===` `||m===o)&&(g=m),g>p){let y=u?X9(n,r,s,i,p,g):G9;for(let x=0;x<=y.length;x++){let S=x===0?p:y[x-1],P=x1||c>0){let d=t.constructor;h=new d(l);for(let p=0;p=0&&this._order.splice(r,1)}_appendOrder(e){this._order.push(e)}};function q9(){let t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}var Kn={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:q9(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},NM=1024,DM=.9,UM=1.2,VM=3,ag=new xa(VM);function K9(t,e){let r;typeof e=="string"?r=new Set(Array.from(e)):r=new Set(e);let s=ag.get(t);if(!s)return r;for(let i in s.mapping)r.has(i)&&r.delete(i);return r}function $9(t,e){for(let r=0;r=VM,"Invalid cache limit"),ag=new xa(t)}var Gu=class{constructor(){this.props={...Kn}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){let{fontSize:e,buffer:r}=this.props;return(e*UM+r*2)/e}setProps(e={}){Object.assign(this.props,e),this._key=this._getKey();let r=K9(this._key,this.props.characterSet),s=ag.get(this._key);if(s&&r.size===0){this._atlas!==s&&(this._atlas=s);return}let i=this._generateFontAtlas(r,s);this._atlas=i,ag.set(this._key,i)}_generateFontAtlas(e,r){let{fontFamily:s,fontWeight:i,fontSize:n,buffer:o,sdf:a,radius:c,cutoff:l}=this.props,u=r&&r.data;u||(u=document.createElement("canvas"),u.width=NM);let f=u.getContext("2d",{willReadFrequently:!0});kM(f,s,n,i);let{mapping:h,canvasHeight:d,xOffset:p,yOffset:g}=IM({getFontWidth:m=>f.measureText(m).width,fontHeight:n*UM,buffer:o,characterSet:e,maxCanvasWidth:NM,...r&&{mapping:r.mapping,xOffset:r.xOffset,yOffset:r.yOffset}});if(u.height!==d){let m=f.getImageData(0,0,u.width,u.height);u.height=d,f.putImageData(m,0,0)}if(kM(f,s,n,i),a){let m=new Hu({fontSize:n,buffer:o,radius:c,cutoff:l,fontFamily:s,fontWeight:`${i}`});for(let _ of e){let{data:y,width:x,height:S,glyphTop:P}=m.draw(_);h[_].width=x,h[_].layoutOffsetY=n*DM-P;let B=f.createImageData(x,S);$9(y,B),f.putImageData(B,h[_].x,h[_].y)}}else for(let m of e)f.fillText(m,h[m].x,h[m].y+o+n*DM);return{xOffset:p,yOffset:g,mapping:h,data:u,width:u.width,height:u.height}}_getKey(){let{fontFamily:e,fontWeight:r,fontSize:s,buffer:i,sdf:n,radius:o,cutoff:a}=this.props;return n?`${e} ${r} ${s} ${i} ${o} ${a}`:`${e} ${r} ${s} ${i}`}};var HM=`#version 300 es #define SHADER_NAME text-background-layer-vertex-shader in vec2 positions; in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceRects; in float instanceSizes; in float instanceAngles; in vec2 instancePixelOffsets; in float instanceLineWidths; in vec4 instanceFillColors; in vec4 instanceLineColors; in vec3 instancePickingColors; uniform bool billboard; uniform float opacity; uniform float sizeScale; uniform float sizeMinPixels; uniform float sizeMaxPixels; uniform vec4 padding; uniform int sizeUnits; out vec4 vFillColor; out vec4 vLineColor; out float vLineWidth; out vec2 uv; out vec2 dimensions; vec2 rotate_by_angle(vec2 vertex, float angle) { float angle_radian = radians(angle); float cos_angle = cos(angle_radian); float sin_angle = sin(angle_radian); mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); return rotationMatrix * vertex; } void main(void) { geometry.worldPosition = instancePositions; geometry.uv = positions; geometry.pickingColor = instancePickingColors; uv = positions; vLineWidth = instanceLineWidths; float sizePixels = clamp( project_size_to_pixel(instanceSizes * sizeScale, sizeUnits), sizeMinPixels, sizeMaxPixels ); dimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw; vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions); pixelOffset = rotate_by_angle(pixelOffset, instanceAngles); pixelOffset += instancePixelOffsets; pixelOffset.y *= -1.0; if (billboard) { gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); vec3 offset = vec3(pixelOffset, 0.0); DECKGL_FILTER_SIZE(offset, geometry); gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); } else { vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); DECKGL_FILTER_SIZE(offset_common, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); DECKGL_FILTER_GL_POSITION(gl_Position, geometry); } vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity); DECKGL_FILTER_COLOR(vFillColor, geometry); vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity); DECKGL_FILTER_COLOR(vLineColor, geometry); } `;var GM=`#version 300 es #define SHADER_NAME text-background-layer-fragment-shader precision highp float; uniform bool stroked; in vec4 vFillColor; in vec4 vLineColor; in float vLineWidth; in vec2 uv; in vec2 dimensions; out vec4 fragColor; void main(void) { geometry.uv = uv; vec2 pixelPosition = uv * dimensions; if (stroked) { float distToEdge = min( min(pixelPosition.x, dimensions.x - pixelPosition.x), min(pixelPosition.y, dimensions.y - pixelPosition.y) ); float isBorder = smoothedge(distToEdge, vLineWidth); fragColor = mix(vFillColor, vLineColor, isBorder); } else { fragColor = vFillColor; } DECKGL_FILTER_COLOR(fragColor, geometry); } `;var J9={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},Wu=class extends he{getShaders(){return super.getShaders({vs:HM,fs:GM,modules:[de,_e]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:r}=e;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:r,sizeScale:s,sizeUnits:i,sizeMinPixels:n,sizeMaxPixels:o,getLineWidth:a}=this.props,{padding:c}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]);let l=this.state.model;l.setUniforms(e),l.setUniforms({billboard:r,stroked:Boolean(a),padding:c,sizeUnits:Fe[i],sizeScale:s,sizeMinPixels:n,sizeMaxPixels:o}),l.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,1,1,0,1];return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new se({topology:"triangle-fan-webgl",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};Wu.defaultProps=J9;Wu.layerName="TextBackgroundLayer";var cg=Wu;var WM={start:1,middle:0,end:-1},jM={top:1,center:0,bottom:-1},SA=[0,0,0,255],Z9=1,Q9={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:SA},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Kn.characterSet},fontFamily:Kn.fontFamily,fontWeight:Kn.fontWeight,lineHeight:Z9,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:SA},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:SA},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},ju=class extends Le{constructor(){super(...arguments),this.getBoundingRect=(e,r)=>{let{size:[s,i]}=this.transformParagraph(e,r),{fontSize:n}=this.state.fontAtlasManager.props;s/=n,i/=n;let{getTextAnchor:o,getAlignmentBaseline:a}=this.props,c=WM[typeof o=="function"?o(e,r):o],l=jM[typeof a=="function"?a(e,r):a];return[(c-1)*s/2,(l-1)*i/2,s,i]},this.getIconOffsets=(e,r)=>{let{getTextAnchor:s,getAlignmentBaseline:i}=this.props,{x:n,y:o,rowWidth:a,size:[c,l]}=this.transformParagraph(e,r),u=WM[typeof s=="function"?s(e,r):s],f=jM[typeof i=="function"?i(e,r):i],h=n.length,d=new Array(h*2),p=0;for(let g=0;g0&&k.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){let{props:r,oldProps:s,changeFlags:i}=e;(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==s.lineHeight||r.wordBreak!==s.wordBreak||r.maxWidth!==s.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:r,fontWeight:s}=this.props,{fontAtlasManager:i,characterSet:n}=this.state,o={...e,characterSet:n,fontFamily:r,fontWeight:s};if(!i.mapping)return i.setProps(o),!0;for(let a in o)if(o[a]!==i.props[a])return i.setProps(o),!0;return!1}_updateText(){let{data:e,characterSet:r}=this.props,s=e.attributes?.getText,{getText:i}=this.props,n=e.startIndices,o,a=r==="auto"&&new Set;if(s&&n){let{texts:c,characterCount:l}=LM({...ArrayBuffer.isView(s)?{value:s}:s,length:e.length,startIndices:n,characterSet:a});o=l,i=(u,{index:f})=>c[f]}else{let{iterable:c,objectInfo:l}=ze(e);n=[0],o=0;for(let u of c){l.index++;let f=Array.from(i(u,l)||"");a&&f.forEach(a.add,a),o+=f.length,n.push(o)}}this.setState({getText:i,startIndices:n,numInstances:o,characterSet:a||r})}transformParagraph(e,r){let{fontAtlasManager:s}=this.state,i=s.mapping,n=this.state.getText,{wordBreak:o,lineHeight:a,maxWidth:c}=this.props,l=n(e,r)||"";return FM(l,a,o,c*s.props.fontSize,i)}renderLayers(){let{startIndices:e,numInstances:r,getText:s,fontAtlasManager:{scale:i,atlas:n,mapping:o},styleVersion:a}=this.state,{data:c,_dataDiff:l,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,getBackgroundColor:g,getBorderColor:m,getBorderWidth:_,backgroundPadding:y,background:x,billboard:S,fontSettings:P,outlineWidth:B,outlineColor:L,sizeScale:M,sizeUnits:v,sizeMinPixels:T,sizeMaxPixels:D,transitions:V,updateTriggers:z}=this.props,W=this.getSubLayerClass("characters",og),Z=this.getSubLayerClass("background",cg);return[x&&new Z({getFillColor:g,getLineColor:m,getLineWidth:_,padding:y,getPosition:u,getSize:h,getAngle:d,getPixelOffset:p,billboard:S,sizeScale:M,sizeUnits:v,sizeMinPixels:T,sizeMaxPixels:D,transitions:V&&{getPosition:V.getPosition,getAngle:V.getAngle,getSize:V.getSize,getFillColor:V.getBackgroundColor,getLineColor:V.getBorderColor,getLineWidth:V.getBorderWidth,getPixelOffset:V.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:z.getPosition,getAngle:z.getAngle,getSize:z.getSize,getFillColor:z.getBackgroundColor,getLineColor:z.getBorderColor,getLineWidth:z.getBorderWidth,getPixelOffset:z.getPixelOffset,getBoundingRect:{getText:z.getText,getTextAnchor:z.getTextAnchor,getAlignmentBaseline:z.getAlignmentBaseline,styleVersion:a}}}),{data:c.attributes&&c.attributes.background?{length:c.length,attributes:c.attributes.background}:c,_dataDiff:l,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new W({sdf:P.sdf,smoothing:Number.isFinite(P.smoothing)?P.smoothing:Kn.smoothing,outlineWidth:B/(P.radius||Kn.radius),outlineColor:L,iconAtlas:n,iconMapping:o,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,billboard:S,sizeScale:M*i,sizeUnits:v,sizeMinPixels:T*i,sizeMaxPixels:D*i,transitions:V&&{getPosition:V.getPosition,getAngle:V.getAngle,getColor:V.getColor,getSize:V.getSize,getPixelOffset:V.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:z.getText,getPosition:z.getPosition,getAngle:z.getAngle,getColor:z.getColor,getSize:z.getSize,getPixelOffset:z.getPixelOffset,getIconOffsets:{getTextAnchor:z.getTextAnchor,getAlignmentBaseline:z.getAlignmentBaseline,styleVersion:a}}}),{data:c,_dataDiff:l,startIndices:e,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:s})]}static set fontAtlasCacheLimit(e){zM(e)}};ju.defaultProps=Q9;ju.layerName="TextLayer";var lg=ju;var Xu={circle:{type:Hp,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:pa,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:lg,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Yu={type:Vi,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},ug={type:Hi,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Aa({type:t,props:e}){let r={};for(let s in e)r[s]=t.defaultProps[e[s]];return r}function fg(t,e){let{transitions:r,updateTriggers:s}=t.props,i={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let n in e){let o=e[n],a=t.props[n];n.startsWith("get")&&(a=t.getSubLayerAccessor(a),i.updateTriggers[o]=s[n],r&&(i.transitions[o]=r[n])),i[o]=a}return i}function YM(t){if(Array.isArray(t))return t;switch(k.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return k.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function vA(t,e,r={}){let s={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:i=0,endRow:n=t.length}=r;for(let o=i;o{a.push(r({geometry:{type:"Point",coordinates:f}},s,i))});break;case"LineString":c.push(r({geometry:t},s,i));break;case"MultiLineString":o.forEach(f=>{c.push(r({geometry:{type:"LineString",coordinates:f}},s,i))});break;case"Polygon":l.push(r({geometry:t},s,i)),o.forEach(f=>{u.push(r({geometry:{type:"LineString",coordinates:f}},s,i))});break;case"MultiPolygon":o.forEach(f=>{l.push(r({geometry:{type:"Polygon",coordinates:f}},s,i)),f.forEach(h=>{u.push(r({geometry:{type:"LineString",coordinates:h}},s,i))})});break;default:}}var eG={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function tG(t,e){let r=eG[t];for(k.assert(r,`Unknown GeoJSON type ${t}`);e&&--r>0;)e=e[0];return e&&Number.isFinite(e[0])}function qM(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function hg(t){return t.geometry.coordinates}function KM(t,e){let r=qM(),{pointFeatures:s,lineFeatures:i,polygonFeatures:n,polygonOutlineFeatures:o}=t;return r.points.data=s,r.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),r.points.getPosition=hg,r.lines.data=i,r.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),r.lines.getPath=hg,r.polygons.data=n,r.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),r.polygons.getPolygon=hg,r.polygonsOutline.data=o,r.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),r.polygonsOutline.getPath=hg,r}function $M(t,e){let r=qM(),{points:s,lines:i,polygons:n}=t,o=CM(t,e);return r.points.data={length:s.positions.value.length/s.positions.size,attributes:{...s.attributes,getPosition:s.positions,instancePickingColors:{size:3,value:o.points}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},r.lines.data={length:i.pathIndices.value.length-1,startIndices:i.pathIndices.value,attributes:{...i.attributes,getPath:i.positions,instancePickingColors:{size:3,value:o.lines}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.lines._pathType="open",r.polygons.data={length:n.polygonIndices.value.length-1,startIndices:n.polygonIndices.value,attributes:{...n.attributes,getPolygon:n.positions,pickingColors:{size:3,value:o.polygons}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.polygons._normalize=!1,n.triangles&&(r.polygons.data.attributes.indices=n.triangles.value),r.polygonsOutline.data={length:n.primitivePolygonIndices.value.length-1,startIndices:n.primitivePolygonIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:3,value:o.polygons}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.polygonsOutline._pathType="open",r}var rG=["points","linestrings","polygons"],sG={...Aa(Xu.circle),...Aa(Xu.icon),...Aa(Xu.text),...Aa(Yu),...Aa(ug),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},qu=class extends Le{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:r}){if(!r.dataChanged)return;let{data:s}=this.props,i=s&&"points"in s&&"polygons"in s&&"lines"in s;this.setState({binary:i}),i?this._updateStateBinary({props:e,changeFlags:r}):this._updateStateJSON({props:e,changeFlags:r})}_updateStateBinary({props:e,changeFlags:r}){let s=$M(e.data,this.encodePickingColor);this.setState({layerProps:s})}_updateStateJSON({props:e,changeFlags:r}){let s=YM(e.data),i=this.getSubLayerRow.bind(this),n={},o={};if(Array.isArray(r.dataChanged)){let c=this.state.features;for(let l in c)n[l]=c[l].slice(),o[l]=[];for(let l of r.dataChanged){let u=vA(s,i,l);for(let f in c)o[f].push(ng({data:n[f],getIndex:h=>h.__source.index,dataRange:l,replace:u[f]}))}}else n=vA(s,i);let a=KM(n,o);this.setState({features:n,featuresDiff:o,layerProps:a})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:s,sourceLayer:i}=r;return r.featureType=rG.find(n=>i.id.startsWith(`${this.id}-${n}-`)),s>=0&&i.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[s]),r}_updateAutoHighlight(e){let r=`${this.id}-points-`,s=e.featureType==="points";for(let i of this.getSubLayers())i.id.startsWith(r)===s&&i.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:r}=this.props,{layerProps:s}=this.state,i="polygons-fill",n=this.shouldRenderSubLayer(i,s.polygons?.data)&&this.getSubLayerClass(i,ug.type);if(n){let o=fg(this,ug.props),a=e&&r;return a||delete o.getLineColor,o.updateTriggers.lineColors=a,new n(o,this.getSubLayerProps({id:i,updateTriggers:o.updateTriggers}),s.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:r}=this.props,{layerProps:s}=this.state,i="polygons-stroke",n="linestrings",o=!e&&r&&this.shouldRenderSubLayer(i,s.polygonsOutline?.data)&&this.getSubLayerClass(i,Yu.type),a=this.shouldRenderSubLayer(n,s.lines?.data)&&this.getSubLayerClass(n,Yu.type);if(o||a){let c=fg(this,Yu.props);return[o&&new o(c,this.getSubLayerProps({id:i,updateTriggers:c.updateTriggers}),s.polygonsOutline),a&&new a(c,this.getSubLayerProps({id:n,updateTriggers:c.updateTriggers}),s.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:r,binary:s}=this.state,{highlightedObjectIndex:i}=this.props;!s&&Number.isFinite(i)&&(i=r.points.data.findIndex(a=>a.__source.index===i));let n=new Set(e.split("+")),o=[];for(let a of n){let c=`points-${a}`,l=Xu[a],u=l&&this.shouldRenderSubLayer(c,r.points?.data)&&this.getSubLayerClass(c,l.type);if(u){let f=fg(this,l.props),h=r.points;if(a==="text"&&s){let{instancePickingColors:d,...p}=h.data.attributes;h={...h,data:{...h.data,attributes:p}}}o.push(new u(f,this.getSubLayerProps({id:c,updateTriggers:f.updateTriggers,highlightedObjectIndex:i}),h))}}return o}renderLayers(){let{extruded:e}=this.props,r=this._renderPolygonLayer(),s=this._renderLineLayers(),i=this._renderPointLayers();return[!e&&r,s,i,e&&r]}getSubLayerAccessor(e){let{binary:r}=this.state;return!r||typeof e!="function"?super.getSubLayerAccessor(e):(s,i)=>{let{data:n,index:o}=i,a=vM(n,o);return e(a,i)}}};qu.layerName="GeoJsonLayer";qu.defaultProps=sG;var $n=qu;function iG(t){return typeof t=="string"?t.charAt(0).toLowerCase()+t.slice(1):t}function dg(t){if(Array.isArray(t))return t.map(e=>dg(e));if(t&&typeof t=="object"){let e={};for(let[r,s]of Object.entries(t))e[iG(r)]=dg(s);return e}return t}var MR=ss(PR(),1);function FA(t,e){if(e?._parser&&e._parser!=="fast-xml-parser")throw new Error(e?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:e?.removeNSPrefix,textNodeName:e?.textNodeName,isArray:(i,n,o,a)=>Boolean(e?.arrayPaths?.some(l=>n===l)),...e?._fastXML},s=dW(t,r);return e?.uncapitalizeKeys?dg(s):s}function dW(t,e){return new MR.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...e}).parse(t)}var pW="4.2.0-beta.2",qr={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:pW,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:gW,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(t,e)=>FA(new TextDecoder().decode(t),{...qr.options.xml,...e?.xml}),parseTextSync:(t,e)=>FA(t,{...qr.options.xml,...e?.xml})};function gW(t){return t.startsWith("LA(new TextDecoder().decode(t),e),parseSync:(t,e)=>LA(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>LA(t,e)};function _W(t){return t.startsWith("0&&e.every(r=>typeof r=="string")?e:[]}function Qu(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseFloat(t);default:return}}function gg(t,e=void 0){switch(typeof t){case"number":return t;case"string":return parseInt(t,10);default:return}}function Qn(t){switch(t){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function NA(t,e){let r=qr.parseTextSync?.(t,e),s=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,i=yW(s);if(e?.inheritedLayerProps)for(let n of i.layers)BR(n,null);return e?.includeRawJSON&&(i.json=s),e?.includeXMLText&&(i.xml=t),i}function yW(t){let e={version:String(t.version||""),name:String(t.Service?.Name||"unnamed"),title:t.Service?.Title?String(t.Service?.Title):void 0,abstract:t.Service?.Abstract?String(t.Service?.Abstract):void 0,keywords:Zu(t.Service?.KeywordList?.Keyword),fees:t.Service?.Fees?JSON.stringify(t.Service?.Fees):void 0,accessConstraints:t.Service?.AccessConstraints?JSON.stringify(t.Service?.AccessConstraints):void 0,layerLimit:gg(t.Service?.LayerLimit),maxWidth:gg(t.Service?.maxWidth),maxHeight:gg(t.Service?.maxHeight),layers:[],requests:xW(t.Capability?.Request),exceptions:AW(t.Exception)},r=Zn(t.Capability?.Layer);for(let s of r)e.layers.push(IR(s));for(let[s,i]of Object.entries(e))i===void 0&&delete e[s];return e}function xW(t){let e={};for(let[r,s]of Object.entries(t||{})){let i=Zu(s?.Format);e[r]={mimeTypes:i}}return e}function AW(t){if(Zn(t?.Format).length>0)return{mimeTypes:Zu(t)}}function IR(t){let e={title:String(t?.Title||""),name:t?.Name&&String(t?.Name),abstract:t?.Name&&String(t?.Abstract),keywords:Zu(t.KeywordList?.Keyword)},r=t?.CRS||t?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(e.crs=r);let s=t?.EX_GeographicBoundingBox&&TW(t?.EX_GeographicBoundingBox);s&&(e.geographicBoundingBox=s),s=t?.LatLonBoundingBox&&bW(t?.LatLonBoundingBox),s&&(e.geographicBoundingBox=s);let i=t?.BoundingBox&&EW(t?.BoundingBox);i&&i.length>0&&(e.boundingBoxes=i);let o=Zn(t?.Dimension).map(l=>vW(l));o.length&&(e.dimensions=o),t?.opaque&&(e.opaque=Qn(t?.opaque)),t?.cascaded&&(e.cascaded=Qn(t?.cascaded)),t?.queryable&&(e.queryable=Qn(t?.queryable));let a=Zn(t?.Layer),c=[];for(let l of a)c.push(IR(l));c.length>0&&(e.layers=c);for(let[l,u]of Object.entries(e))u===void 0&&delete e[l];return e}function TW(t){let{westBoundLongitude:e,northBoundLatitude:r,eastBoundLongitude:s,southBoundLatitude:i}=t;return[[e,i],[s,r]]}function bW(t){let{minx:e,miny:r,maxx:s,maxy:i}=t;return[[e,r],[s,i]]}function EW(t){return Zn(t).map(r=>SW(r))}function SW(t){let{CRS:e,SRS:r,minx:s,miny:i,maxx:n,maxy:o,resx:a,resy:c}=t,l={crs:e||r,boundingBox:[[Qu(s),Qu(i)],[Qu(n),Qu(o)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function vW(t){let{name:e,units:r,value:s}=t,i={name:e,units:r,extent:s};return t.unitSymbol&&(i.unitSymbol=t.unitSymbol),t.default&&(i.defaultValue=t.default),t.multipleValues&&(i.multipleValues=Qn(t.multipleValues)),t.nearestValue&&(i.nearestValue=Qn(t.nearestValue)),t.current&&(i.current=Qn(t.current)),i}function BR(t,e){e?.geographicBoundingBox&&!t.geographicBoundingBox&&(t.geographicBoundingBox=[...e.geographicBoundingBox]),e?.crs&&!t.crs&&(t.crs=[...e.crs]),e?.boundingBoxes&&!t.boundingBoxes&&(t.boundingBoxes=[...e.boundingBoxes]),e?.dimensions&&!t.dimensions&&(t.dimensions=[...e.dimensions]);for(let r of t.layers||[])BR(r,t)}var CW="4.2.0-beta.2",Ta={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:CW,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:wW,options:{wms:{}},parse:async(t,e)=>NA(new TextDecoder().decode(t),e?.wms),parseTextSync:(t,e)=>NA(t,e?.wms)};function wW(t){return t.startsWith("PW(n))}}function PW(t){return{attributes:t||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var OR={...Ta,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(t,e)=>DA(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>DA(t,e)};function UA(t,e){return qr.parseTextSync?.(t,e)}var FR={...Ta,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(t,e)=>UA(new TextDecoder().decode(t),e),parseTextSync:(t,e)=>UA(t,e)};function LR(t,e){let{type:r="auto"}=t,s=r==="auto"?RW(t.url,e):MW(r,e);if(!s)throw new Error("Not a valid image source type");return s.create(t)}function MW(t,e){for(let r of e)if(r.type===t)return r;return null}function RW(t,e){for(let r of e)if(r.testURL&&r.testURL(t))return r;return null}var NR={type:"wms",testURL:t=>t.toLowerCase().includes("wms"),create:t=>new kA(t)},kA=class extends or{url;data;substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(e){super(e),this.url=e.url,this.data=e.url,this.substituteCRS84=e.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...e.wmsParameters},this.vendorParameters=e.vendorParameters||{}}async getMetadata(){let e=await this.getCapabilities();return this.normalizeMetadata(e)}async getImage(e){let{boundingBox:r,bbox:s,...i}=e,n={bbox:r?[...r[0],...r[1]]:s,...i};return await this.getMap(n)}normalizeMetadata(e){return e}async getCapabilities(e,r){let s=this.getCapabilitiesURL(e,r),i=await this.fetch(s),n=await i.arrayBuffer();this._checkResponse(i,n);let o=await Ta.parse(n,this.loadOptions);return this.capabilities=o,o}async getMap(e,r){let s=this.getMapURL(e,r),i=await this.fetch(s),n=await i.arrayBuffer();this._checkResponse(i,n);try{return await cs.parse(n,this.loadOptions)}catch{throw this._parseError(n)}}async getFeatureInfo(e,r){let s=this.getFeatureInfoURL(e,r),i=await this.fetch(s),n=await i.arrayBuffer();return this._checkResponse(i,n),await OR.parse(n,this.loadOptions)}async getFeatureInfoText(e,r){let s=this.getFeatureInfoURL(e,r),i=await this.fetch(s),n=await i.arrayBuffer();return this._checkResponse(i,n),new TextDecoder().decode(n)}async describeLayer(e,r){let s=this.describeLayerURL(e,r),i=await this.fetch(s),n=await i.arrayBuffer();return this._checkResponse(i,n),await FR.parse(n,this.loadOptions)}async getLegendGraphic(e,r){let s=this.getLegendGraphicURL(e,r),i=await this.fetch(s),n=await i.arrayBuffer();this._checkResponse(i,n);try{return await cs.parse(n,this.loadOptions)}catch{throw this._parseError(n)}}getCapabilitiesURL(e,r){let s={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetCapabilities",s,r)}getMapURL(e,r){e=this._getWMS130Parameters(e);let s={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetMap",s,r)}getFeatureInfoURL(e,r){e=this._getWMS130Parameters(e);let{boundingBox:s,bbox:i}=e;e.bbox=s?[...s[0],...s[1]]:i;let n={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...e};return this._getWMSUrl("GetFeatureInfo",n,r)}describeLayerURL(e,r){let s={version:this.wmsParameters.version,...e};return this._getWMSUrl("DescribeLayer",s,r)}getLegendGraphicURL(e,r){let s={version:this.wmsParameters.version,...e};return this._getWMSUrl("GetLegendGraphic",s,r)}_parseWMSUrl(e){let[r,s]=e.split("?"),i=s.split("&"),n={};for(let o of i){let[a,c]=o.split("=");n[a]=c}return{url:r,parameters:n}}_getWMSUrl(e,r,s){let i=this.url,n=!0,o={service:"WMS",version:r.version,request:e,...r,...this.vendorParameters,...s},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(o))(!a.includes(c)||l)&&(i+=n?"?":"&",n=!1,i+=this._getURLParameter(c,l,r));return encodeURI(i)}_getWMS130Parameters(e){let r={...e};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(e,r,s){switch(e){case"crs":s.version!=="1.3.0"?e="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":s.version==="1.3.0"&&(e="crs");break;case"bbox":let i=this._flipBoundingBox(r,s);i&&(r=i);break;case"x":s.version==="1.3.0"&&(e="i");break;case"y":s.version==="1.3.0"&&(e="j");break;default:}return e=e.toUpperCase(),Array.isArray(r)?`${e}=${r.join(",")}`:`${e}=${r?String(r):""}`}_flipBoundingBox(e,r){if(!Array.isArray(e)||e.length!==4)return null;let s=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),i=e;return s?[i[1],i[0],i[3],i[2]]:i}async _fetchArrayBuffer(e){let r=await this.fetch(e),s=await r.arrayBuffer();return this._checkResponse(r,s),s}_checkResponse(e,r){let s=e.headers["content-type"];if(!e.ok||Ju.mimeTypes.includes(s)){let i=Ec(this.loadOptions,{wms:{throwOnError:!0}}),n=Ju.parseSync?.(r,i);throw new Error(n)}}_parseError(e){let r=Ju.parseSync?.(e,this.loadOptions);return new Error(r)}};var ba=class extends or{constructor(e){super(e)}async getMetadata(){throw new Error("ImageSource.getMetadata not implemented")}async getImage(e){let r=this.getGranularParameters(e),s=this.getURLFromTemplate(r),n=await(await this.fetch(s)).arrayBuffer();return await cs.parse(n)}getGranularParameters(e){let[[r,s],[i,n]]=e.boundingBox;return{...e,east:r,north:s,south:n,west:i}}getURLFromTemplate(e){let r=this.props.url;for(let[s,i]of Object.entries(e))r=r.replace(`\${${s}}`,String(i)),r=r.replace(`{${s}}`,String(i));return r}};Y(ba,"type","template"),Y(ba,"testURL",e=>e.toLowerCase().includes("{"));var VA=class extends ba{data;constructor(e){super(e),this.data=e.url}async getMetadata(){return await this.metadata()}async getImage(e){throw new Error("not implemented")}async metadata(){throw new Error("not implemented")}exportImage(e){throw new Error("not implemented")}metadataURL(e){return`${this.props.url}?f=pjson`}exportImageURL(e){let r=`bbox=${e.bbox[0]},${e.bbox[1]},${e.bbox[2]},${e.bbox[3]}`,s=`size=${e.width},${e.height}`,i={...e,bbox:r,size:s};return delete i.width,delete i.height,this.getUrl("exportImage",i)}getUrl(e,r,s){let i=`${this.props.url}/${e}`,n=!0;for(let[o,a]of Object.entries(r))i+=n?"?":"&",n=!1,Array.isArray(a)?i+=`${o.toUpperCase()}=${a.join(",")}`:i+=`${o.toUpperCase()}=${a?String(a):""}`;return i}async checkResponse(e){if(!e.ok)throw new Error("error")}},DR={type:"arcgis-image-server",testURL:t=>t.toLowerCase().includes("ImageServer"),create:t=>new VA(t)};var IW=[NR,DR];function zA(t){return LR(t,IW)}var UR=6378137*Math.PI;function HA(t){let e=je(t);return e[0]=(e[0]/256-1)*UR,e[1]=(e[1]/256-1)*UR,e}var BW={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(t,e)=>console.error(e,t)}},Ea=class extends Le{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:e,props:r,oldProps:s}){let{viewport:i}=this.context;e.dataChanged||r.serviceType!==s.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(i,"image source changed"),0)):ve(r.layers,s.layers,1)?e.viewportChanged&&this.debounce(()=>this.loadImage(i,"viewport changed")):this.debounce(()=>this.loadImage(i,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:e,image:r,lastRequestParameters:s}=this.state;return r&&new kp({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:s.srs==="EPSG:4326"?X.LNGLAT:X.CARTESIAN,bounds:e,image:r})}async getFeatureInfoText(e,r){let{lastRequestParameters:s}=this.state;return s?await this.state.imageSource.getFeatureInfoText?.({...s,query_layers:s.layers,x:e,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(e){if(e.data instanceof or)return e.data;if(typeof e.data=="string")return zA({url:e.data,loadOptions:e.loadOptions,type:e.serviceType});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:e}=this.state;try{this.state.loadCounter++;let r=await e.getMetadata();this.state.imageSource===e&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(e,r){let{layers:s,serviceType:i}=this.props;if(i==="wms"&&s.length===0)return;let n=e.getBounds(),{width:o,height:a}=e,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=e.resolution?"EPSG:4326":"EPSG:3857");let u={width:o,height:a,boundingBox:[[n[0],n[1]],[n[2],n[3]]],layers:s,crs:l};if(l==="EPSG:3857"){let f=HA([n[0],n[1]]),h=HA([n[2],n[3]]);u.boundingBox=[f,h]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let f=await this.state.imageSource.getImage(u);this.state.lastRequestIde(),r)}};Ea.layerName="WMSLayer";Ea.defaultProps=BW;var OW={getHeight:{type:"accessor",value:0},greatCircle:!0},ef=class extends Up{};ef.layerName="GreatCircleLayer";ef.defaultProps=OW;var kR=ef;var FW={...Gi.defaultProps},tf=class extends Le{indexToBounds(){return null}renderLayers(){let{elevationScale:e,extruded:r,wireframe:s,filled:i,stroked:n,lineWidthUnits:o,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:h,getElevation:d,getFillColor:p,getLineColor:g,getLineWidth:m}=this.props,{updateTriggers:_,material:y,transitions:x}=this.props,S=this.getSubLayerClass("cell",Gi),{updateTriggers:P,...B}=this.indexToBounds()||{};return new S({filled:i,wireframe:s,extruded:r,elevationScale:e,stroked:n,lineWidthUnits:o,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:h,material:y,transitions:x,getElevation:d,getFillColor:p,getLineColor:g,getLineWidth:m},this.getSubLayerProps({id:"cell",updateTriggers:_&&{...P,getElevation:_.getElevation,getFillColor:_.getFillColor,getLineColor:_.getLineColor,getLineWidth:_.getLineWidth}}),B)}};tf.layerName="GeoCellLayer";tf.defaultProps=FW;var As=tf;var mg=ss(GA(),1),LW=3,NW=30,DW=2*NW+1,zR=180/Math.PI;function GR(t,e,r){let s=1<=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function WR(t){return[HR(t[0]),HR(t[1])]}function jR(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function XR([t,e,r]){let s=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*zR,s*zR]}function YR(t){let e=mg.default.fromString(t,!0,10).toString(2);for(;e.length=0;a--){o=i-a;let c=s[a],l=0,u=0;c==="1"?u=1:c==="2"?(l=1,u=1):c==="3"&&(l=1);let f=Math.pow(2,o-1);UW(f,n,l,u),n[0]+=f*l,n[1]+=f*u}if(r%2===1){let a=n[0];n[0]=n[1],n[1]=a}return{face:r,ij:n,level:o}}var KR=ss(GA(),1);function kW(t){let e=t.padEnd(16,"0");return KR.default.fromString(e,16)}var VW=100;function zW({face:t,ij:e,level:r}){let s=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(VW*Math.pow(2,-r))),n=new Float64Array(4*i*2+2),o=0,a=0;for(let c=0;c<4;c++){let l=s[c].slice(0),u=s[c+1],f=(u[0]-l[0])/i,h=(u[1]-l[1])/i;for(let d=0;d89.999&&(_[0]=a);let y=_[0]-a;_[0]+=y>180?-360:y<-180?360:0,n[o++]=_[0],n[o++]=_[1],a=_[0]}}return n[o++]=n[0],n[o++]=n[1],n}function HW(t){if(typeof t=="string"){if(t.indexOf("/")>0)return t;t=kW(t)}return YR(t.toString())}function $R(t){let e=HW(t),r=qR(e);return zW(r)}var GW={getS2Token:{type:"accessor",value:t=>t.token}},sf=class extends As{indexToBounds(){let{data:e,getS2Token:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(s,i)=>$R(r(s,i))}}};sf.layerName="S2Layer";sf.defaultProps=GW;var JR=sf;var WA=512;function WW(t,e){let r=0,s=0,i=1<>=1;let a=parseInt(t[o]);a%2&&(r|=i),a>1&&(s|=i)}return[[r/n,WA-s/n],[(r+e)/n,WA-(s+e)/n]]}function ZR(t,e=1){let[r,s]=WW(t,e),[i,n]=mt(r),[o,a]=mt(s);return[o,n,o,a,i,a,i,n,o,n]}var jW={getQuadkey:{type:"accessor",value:t=>t.quadkey}},nf=class extends As{indexToBounds(){let{data:e,extruded:r,getQuadkey:s}=this.props,i=r?.99:1;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>ZR(s(n,o),i),updateTriggers:{getPolygon:i}}}};nf.layerName="QuadkeyLayer";nf.defaultProps=jW;var QR=nf;var eo=class{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:r,onLoad:s,onError:i}){let{index:n,id:o,bbox:a,userData:c,zoom:l}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,h=await r.scheduleRequest(this,g=>g.isSelected?1:-1);if(!h){this._isCancelled=!0;return}if(this._isCancelled){h.done();return}let d=null,p;try{d=await e({index:n,id:o,bbox:a,userData:c,zoom:l,signal:f})}catch(g){p=g||!0}finally{h.done()}if(u===this._loaderId){if(this._loader=void 0,this.content=d,this._isCancelled&&!d){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,p?i(p,this):s(this)}}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var Xe={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var eI=new w,XW=new w,ji=class{constructor(e=[0,0,0],r=[0,0,0],s){s=s||eI.copy(e).add(r).scale(.5),this.center=new w(s),this.halfDiagonal=new w(r).subtract(this.center),this.minimum=new w(e),this.maximum=new w(r)}clone(){return new ji(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){let{halfDiagonal:r}=this,s=XW.from(e.normal),i=r.x*Math.abs(s.x)+r.y*Math.abs(s.y)+r.z*Math.abs(s.z),n=this.center.dot(s)+e.distance;return n-i>0?Xe.INSIDE:n+i<0?Xe.OUTSIDE:Xe.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=eI.from(e).subtract(this.center),{halfDiagonal:s}=this,i=0,n;return n=Math.abs(r.x)-s.x,n>0&&(i+=n*n),n=Math.abs(r.y)-s.y,n>0&&(i+=n*n),n=Math.abs(r.z)-s.z,n>0&&(i+=n*n),i}};var of=new w,tI=new w,br=class{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new w,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=of.from(r),this.center=new w().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new br(this.center,this.radius)}union(e){let r=this.center,s=this.radius,i=e.center,n=e.radius,o=of.copy(i).subtract(r),a=o.magnitude();if(s>=a+n)return this.clone();if(n>=a+s)return e.clone();let c=(s+a+n)*.5;return tI.copy(o).scale((-s+c)/a).add(r),this.center.copy(tI),this.radius=c,this}expand(e){let s=of.from(e).subtract(this.center).magnitude();return s>this.radius&&(this.radius=s),this}transform(e){this.center.transform(e);let r=ke.getScaling(of,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let s=of.from(e).subtract(this.center);return Math.max(0,s.len()-this.radius)}intersectPlane(e){let r=this.center,s=this.radius,n=e.normal.dot(r)+e.distance;return n<-s?Xe.OUTSIDE:n=c?Xe.INSIDE:Xe.INTERSECTING}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=qW.from(e).subtract(this.center),s=this.halfAxes,i=s.getColumn(0,_g),n=s.getColumn(1,yg),o=s.getColumn(2,xg),a=i.magnitude(),c=n.magnitude(),l=o.magnitude();i.normalize(),n.normalize(),o.normalize();let u=0,f;return f=Math.abs(r.dot(i))-a,f>0&&(u+=f*f),f=Math.abs(r.dot(n))-c,f>0&&(u+=f*f),f=Math.abs(r.dot(o))-l,f>0&&(u+=f*f),u}computePlaneDistances(e,r,s=[-0,-0]){let i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,c=a.getColumn(0,_g),l=a.getColumn(1,yg),u=a.getColumn(2,xg),f=KW.copy(c).add(l).add(u).add(o),h=$W.copy(f).subtract(e),d=r.dot(h);return i=Math.min(d,i),n=Math.max(d,n),f.copy(o).add(c).add(l).subtract(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),f.copy(o).add(c).subtract(l).add(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),f.copy(o).add(c).subtract(l).subtract(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),o.copy(f).subtract(c).add(l).add(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),o.copy(f).subtract(c).add(l).subtract(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),o.copy(f).subtract(c).subtract(l).add(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),o.copy(f).subtract(c).subtract(l).subtract(u),h.copy(f).subtract(e),d=r.dot(h),i=Math.min(d,i),n=Math.max(d,n),s[0]=i,s[1]=n,s}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,_g);r.transformAsPoint(e);let s=this.halfAxes.getColumn(1,yg);s.transformAsPoint(e);let i=this.halfAxes.getColumn(2,xg);return i.transformAsPoint(e),this.halfAxes=new me([...r,...s,...i]),this}getTransform(){throw new Error("not implemented")}};var rI=new w,sI=new w,ht=class{constructor(e=[0,0,1],r=0){this.normal=new w,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return ut(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=rI.from(e),this.normal.from(r).normalize();let s=-this.normal.dot(e);return this.distance=s,this}fromCoefficients(e,r,s,i){return this.normal.set(e,r,s),ut(Ce(this.normal.len(),1)),this.distance=i,this}clone(){return new ht(this.normal,this.distance)}equals(e){return Ce(this.distance,e.distance)&&Ce(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=sI.copy(this.normal).transformAsVector(e).normalize(),s=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(s,r)}projectPointOntoPlane(e,r=[0,0,0]){let s=rI.from(e),i=this.getPointDistance(s),n=sI.copy(this.normal).scale(i);return s.subtract(n).to(r)}};var iI=[new w([1,0,0]),new w([0,1,0]),new w([0,0,1])],nI=new w,JW=new w,st=class{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*iI.length;let r=e.center,s=e.radius,i=0;for(let n of iI){let o=this.planes[i],a=this.planes[i+1];o||(o=this.planes[i]=new ht),a||(a=this.planes[i+1]=new ht);let c=nI.copy(n).scale(-s).add(r);o.fromPointNormal(c,n);let l=nI.copy(n).scale(s).add(r),u=JW.copy(n).negate();a.fromPointNormal(l,u),i+=2}return this}computeVisibility(e){let r=Xe.INSIDE;for(let s of this.planes)switch(e.intersectPlane(s)){case Xe.OUTSIDE:return Xe.OUTSIDE;case Xe.INTERSECTING:r=Xe.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(ut(Number.isFinite(r),"parentPlaneMask is required."),r===st.MASK_OUTSIDE||r===st.MASK_INSIDE)return r;let s=st.MASK_INSIDE,i=this.planes;for(let n=0;nc;)sj(a,Ag),oI.copy(Ag).transpose(),a.multiplyRight(Ag),a.multiplyLeft(oI),o.multiplyRight(Ag),++i>2&&(++n,i=0);return e.unitary=o.toTarget(e.unitary),e.diagonal=a.toTarget(e.diagonal),e}function tj(t){let e=0;for(let r=0;r<9;++r){let s=t[r];e+=s*s}return Math.sqrt(e)}var jA=[1,0,0],XA=[2,2,1];function rj(t){let e=0;for(let r=0;r<3;++r){let s=t[Ts.getElementIndex(XA[r],jA[r])];e+=2*s*s}return Math.sqrt(e)}function sj(t,e){let r=dr.EPSILON15,s=0,i=1;for(let l=0;l<3;++l){let u=Math.abs(t[Ts.getElementIndex(XA[l],jA[l])]);u>s&&(i=l,s=u)}let n=jA[i],o=XA[i],a=1,c=0;if(Math.abs(t[Ts.getElementIndex(o,n)])>r){let l=t[Ts.getElementIndex(o,o)],u=t[Ts.getElementIndex(n,n)],f=t[Ts.getElementIndex(o,n)],h=(l-u)/2/f,d;h<0?d=-1/(-h+Math.sqrt(1+h*h)):d=1/(h+Math.sqrt(1+h*h)),a=1/Math.sqrt(1+d*d),c=d*a}return me.IDENTITY.to(e),e[Ts.getElementIndex(n,n)]=e[Ts.getElementIndex(o,o)]=a,e[Ts.getElementIndex(o,n)]=c,e[Ts.getElementIndex(n,o)]=-c,e}var Xi=new w,ij=new w,nj=new w,oj=new w,aj=new w,cj=new me,lj={diagonal:new me,unitary:new me};function af(t,e=new Kr){if(!t||t.length===0)return e.halfAxes=new me([0,0,0,0,0,0,0,0,0]),e.center=new w,e;let r=t.length,s=new w(0,0,0);for(let v of t)s.add(v);let i=1/r;s.multiplyByScalar(i);let n=0,o=0,a=0,c=0,l=0,u=0;for(let v of t){let T=Xi.copy(v).subtract(s);n+=T.x*T.x,o+=T.x*T.y,a+=T.x*T.z,c+=T.y*T.y,l+=T.y*T.z,u+=T.z*T.z}n*=i,o*=i,a*=i,c*=i,l*=i,u*=i;let f=cj;f[0]=n,f[1]=o,f[2]=a,f[3]=o,f[4]=c,f[5]=l,f[6]=a,f[7]=l,f[8]=u;let{unitary:h}=YA(f,lj),d=e.halfAxes.copy(h),p=d.getColumn(0,nj),g=d.getColumn(1,oj),m=d.getColumn(2,aj),_=-Number.MAX_VALUE,y=-Number.MAX_VALUE,x=-Number.MAX_VALUE,S=Number.MAX_VALUE,P=Number.MAX_VALUE,B=Number.MAX_VALUE;for(let v of t)Xi.copy(v),_=Math.max(Xi.dot(p),_),y=Math.max(Xi.dot(g),y),x=Math.max(Xi.dot(m),x),S=Math.min(Xi.dot(p),S),P=Math.min(Xi.dot(g),P),B=Math.min(Xi.dot(m),B);p=p.multiplyByScalar(.5*(S+_)),g=g.multiplyByScalar(.5*(P+y)),m=m.multiplyByScalar(.5*(B+x)),e.center.copy(p).add(g).add(m);let L=ij.set(_-S,y-P,x-B).multiplyByScalar(.5),M=new me([L[0],0,0,0,L[1],0,0,0,L[2]]);return e.halfAxes.multiplyRight(M),e}var Sa=512,aI=3,cI=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],lI=cI.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),uj=lI.concat([[.25,.5],[.75,.5]]),Yi=class{constructor(e,r,s){this.x=e,this.y=r,this.z=s}get children(){if(!this._children){let e=this.x*2,r=this.y*2,s=this.z+1;this._children=[new Yi(e,r,s),new Yi(e,r+1,s),new Yi(e+1,r,s),new Yi(e+1,r+1,s)]}return this._children}update(e){let{viewport:r,cullingVolume:s,elevationBounds:i,minZ:n,maxZ:o,bounds:a,offset:c,project:l}=e,u=this.getBoundingVolume(i,c,l);if(a&&!this.insideBounds(a)||s.computeVisibility(u)<0)return!1;if(!this.childVisible){let{z:h}=this;if(h=n){let d=u.distanceTo(r.cameraPosition)*r.scale/r.height;h+=Math.floor(Math.log2(d))}if(h>=o)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let h of this.children)h.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(let r of this._children)r.getSelected(e);return e}insideBounds([e,r,s,i]){let n=Math.pow(2,this.z),o=Sa/n;return this.x*oe&&(this.y+1)*o>r}getBoundingVolume(e,r,s){if(s){let c=this.z<1?uj:this.z<2?lI:cI,l=[];for(let u of c){let f=Tg(this.x+u[0],this.y+u[1],this.z);f[2]=e[0],l.push(s(f)),e[0]!==e[1]&&(f[2]=e[1],l.push(s(f)))}return af(l)}let i=Math.pow(2,this.z),n=Sa/i,o=this.x*n+r*Sa,a=Sa-(this.y+1)*n;return new ji([o,a,e[0]],[o+n,a+n,e[1]])}};function uI(t,e,r,s){let i=t instanceof Yr&&t.resolution?t.projectPosition:null,n=Object.values(t.getFrustumPlanes()).map(({normal:d,distance:p})=>new ht(d.clone().negate(),p)),o=new st(n),a=t.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,u=t instanceof Et&&t.pitch<=60?e:0;if(s){let[d,p,g,m]=s,_=je([d,m]),y=je([g,p]);s=[_[0],Sa-_[1],y[0],Sa-y[1]]}let f=new Yi(0,0,0),h={viewport:t,project:i,cullingVolume:o,elevationBounds:[c,l],minZ:u,maxZ:e,bounds:s,offset:0};if(f.update(h),t instanceof Et&&t.subViewports&&t.subViewports.length>1){for(h.offset=-1;f.update(h)&&!(--h.offset<-aI););for(h.offset=1;f.update(h)&&!(++h.offset>aI););}return f.getSelected()}var $s=512,fj=[-1/0,-1/0,1/0,1/0],qi={type:"object",value:null,validate:(t,e)=>e.optional&&t===null||typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string"),equal:(t,e)=>{if(t===e)return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;let r=t.length;if(r!==e.length)return!1;for(let s=0;si[0])),Math.min(...r.map(i=>i[1])),Math.max(...r.map(i=>i[0])),Math.max(...r.map(i=>i[1]))]}function hj(t){return Math.abs(t.split("").reduce((e,r)=>(e<<5)-e+r.charCodeAt(0)|0,0))}function bs(t,e){if(!t||!t.length)return null;let{index:r,id:s}=e;if(Array.isArray(t)){let n=hj(s)%t.length;t=t[n]}let i=t;for(let n of Object.keys(r)){let o=new RegExp(`{${n}}`,"g");i=i.replace(o,String(r[n]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(i=i.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),i}function dj(t,e,r){let s;if(e&&e.length===2){let[i,n]=e,o=t.getBounds({z:i}),a=t.getBounds({z:n});s=[Math.min(o[0],a[0]),Math.min(o[1],a[1]),Math.max(o[2],a[2]),Math.max(o[3],a[3])]}else s=t.getBounds();return t.isGeospatial?[Math.max(s[0],r[0]),Math.max(s[1],r[1]),Math.min(s[2],r[2]),Math.min(s[3],r[3])]:[Math.max(Math.min(s[0],r[2]),r[0]),Math.max(Math.min(s[1],r[3]),r[1]),Math.min(Math.max(s[2],r[0]),r[2]),Math.min(Math.max(s[3],r[1]),r[3])]}function dI({viewport:t,z:e,cullRect:r}){return(t.subViewports||[t]).map(i=>qA(i,e||0,r))}function qA(t,e,r){if(!Array.isArray(e)){let n=r.x-t.x,o=r.y-t.y,{width:a,height:c}=r,l={targetZ:e},u=t.unproject([n,o],l),f=t.unproject([n+a,o],l),h=t.unproject([n,o+c],l),d=t.unproject([n+a,o+c],l);return[Math.min(u[0],f[0],h[0],d[0]),Math.min(u[1],f[1],h[1],d[1]),Math.max(u[0],f[0],h[0],d[0]),Math.max(u[1],f[1],h[1],d[1])]}let s=qA(t,e[0],r),i=qA(t,e[1],r);return[Math.min(s[0],i[0]),Math.min(s[1],i[1]),Math.max(s[2],i[2]),Math.max(s[3],i[3])]}function pj(t,e,r){return r?hI(t,r).map(i=>i*e/$s):t.map(s=>s*e/$s)}function KA(t,e){return Math.pow(2,t)*$s/e}function Tg(t,e,r){let s=KA(r,$s),i=t/s*360-180,n=Math.PI-2*Math.PI*e/s,o=180/Math.PI*Math.atan(.5*(Math.exp(n)-Math.exp(-n)));return[i,o]}function fI(t,e,r,s){let i=KA(r,s);return[t/i*$s,e/i*$s]}function $A(t,e,r,s,i=$s){if(t.isGeospatial){let[l,u]=Tg(e,r,s),[f,h]=Tg(e+1,r+1,s);return{west:l,north:u,east:f,south:h}}let[n,o]=fI(e,r,s,i),[a,c]=fI(e+1,r+1,s,i);return{left:n,top:o,right:a,bottom:c}}function gj(t,e,r,s,i){let n=dj(t,null,s),o=KA(e,r),[a,c,l,u]=pj(n,o,i),f=[];for(let h=Math.floor(a);he&&(l=e);let u=i;return o&&a&&i&&!t.isGeospatial&&(u=hI(i,o)),t.isGeospatial?uI(t,l,s,i):gj(t,l,n,u||fj,a)}function ZA(t){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(t)}function QA(t){return Number.isFinite(t.west)&&Number.isFinite(t.north)&&Number.isFinite(t.east)&&Number.isFinite(t.south)}function pI(t){let e={},r;return s=>{for(let i in s)if(!mj(s[i],e[i])){r=t(s),e=s;break}return r}}function mj(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let s=0;s{}},Tj={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}},to=class{constructor(e){this._getCullBounds=pI(dI),this.opts={...Tj,...e},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!=null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new ui({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new q,this._modelMatrixInverse=new q}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom))}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let e of this._cache.keys()){let r=this._cache.get(e);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(e):r.setNeedsReload()}}update(e,{zRange:r,modelMatrix:s}={zRange:null,modelMatrix:null}){let i=s?new q(s):new q,n=!i.equals(this._modelMatrix);if(!this._viewport||!e.equals(this._viewport)||!Ce(this._zRange,r)||n){n&&(this._modelMatrixInverse=i.clone().invert(),this._modelMatrix=i),this._viewport=e,this._zRange=r;let a=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));let o=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),o&&this._frameNumber++,this._frameNumber}isTileVisible(e,r){if(!e.isVisible)return!1;if(r&&this._viewport){let s=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:i}=e;for(let[n,o,a,c]of s){let l;if("west"in i)l=i.westn&&i.southo;else{let u=Math.min(i.top,i.bottom),f=Math.max(i.top,i.bottom);l=i.leftn&&uo}if(l)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:r,minZoom:s,zRange:i,modelMatrix:n,modelMatrixInverse:o}){let{tileSize:a,extent:c,zoomOffset:l}=this.opts;return JA({viewport:e,maxZoom:r,minZoom:s,zRange:i,tileSize:a,extent:c,modelMatrix:n,modelMatrixInverse:o,zoomOffset:l})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){let{tileSize:r}=this.opts;return{bbox:$A(this._viewport,e.x,e.y,e.z,r)}}getParentIndex(e){let r=Math.floor(e.x/2),s=Math.floor(e.y/2),i=e.z-1;return{x:r,y:s,z:i}}updateTileStates(){let e=this.opts.refinementStrategy||cf,r=new Array(this._cache.size),s=0;for(let i of this._cache.values())r[s++]=i.isVisible,i.isSelected=!1,i.isVisible=!1;for(let i of this._selectedTiles)i.isSelected=!0,i.isVisible=!0;(typeof e=="function"?e:Aj[e])(Array.from(this._cache.values())),s=0;for(let i of this._cache.values())if(r[s++]!==i.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=[],s=0;for(let i of this._cache.values())i.isLoading&&(s++,!i.isSelected&&!i.isVisible&&r.push(i));for(;e>0&&s>e&&r.length>0;)r.shift().abort(),s--}_rebuildTree(){let{_cache:e}=this;for(let r of e.values())r.parent=null,r.children&&(r.children.length=0);for(let r of e.values()){let s=this._getNearestAncestor(r);r.parent=s,s?.children&&s.children.push(r)}}_resizeCache(){let{_cache:e,opts:r}=this,s=r.maxCacheSize??(r.maxCacheByteSize!=null?1/0:xj*this.selectedTiles.length),i=r.maxCacheByteSize??1/0;if(e.size>s||this._cacheByteSize>i){for(let[o,a]of e)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!=null?a.byteLength:0,e.delete(o),this.opts.onTileUnload?.(a)),e.size<=s&&this._cacheByteSize<=i)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((o,a)=>o.zoom-a.zoom),this._dirty=!1)}_getTile(e,r){let s=this.getTileId(e),i=this._cache.get(s),n=!1;return!i&&r?(i=new eo(e),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:s,zoom:this.getTileZoom(i.index)}),n=!0,this._cache.set(s,i),this._dirty=!0):i&&i.needsReload&&(n=!0),i&&n&&i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),i}_getNearestAncestor(e){let{_minZoom:r=0}=this,s=e.index;for(;this.getTileZoom(s)>r;){s=this.getParentIndex(s);let i=this._getTile(s);if(i)return i}return null}};function bj(t){for(let e of t)e.state=0;for(let e of t)e.isSelected&&!mI(e)&&eT(e);for(let e of t)e.isVisible=Boolean(e.state&bg)}function Ej(t){for(let r of t)r.state=0;for(let r of t)r.isSelected&&mI(r);let e=Array.from(t).sort((r,s)=>r.zoom-s.zoom);for(let r of e)if(r.isVisible=Boolean(r.state&bg),r.children&&(r.isVisible||r.state&gI))for(let s of r.children)s.state=gI;else r.isSelected&&eT(r)}function mI(t){let e=t;for(;e;){if(e.isLoaded||e.content)return e.state|=bg,!0;e=e.parent}return!1}function eT(t){for(let e of t.children)e.isLoaded||e.content?e.state|=bg:eT(e)}var Sj={TilesetClass:to,data:{type:"data",value:[]},dataComparator:qi.equal,renderSubLayers:{type:"function",value:t=>new $n(t)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:t=>console.error(t)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:cf,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},lf=class extends Le{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&e.layers&&e.layers.every(r=>r.isLoaded)))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:r}=this.state,s=e.propsOrDataChanged||e.updateTriggersChanged,i=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);r?s&&(r.setOptions(this._getTilesetOptions()),i?r.reloadAll():r.tiles.forEach(n=>{n.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:e,maxCacheSize:r,maxCacheByteSize:s,refinementStrategy:i,extent:n,maxZoom:o,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:u}=this.props;return{maxCacheSize:r,maxCacheByteSize:s,maxZoom:o,minZoom:a,tileSize:e,refinementStrategy:i,extent:n,maxRequests:c,debounceTime:l,zoomOffset:u,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let e=this.state.tileset,{zRange:r,modelMatrix:s}=this.props,i=e.update(this.context.viewport,{zRange:r,modelMatrix:s}),{isLoaded:n}=e,o=this.state.isLoaded!==n,a=this.state.frameNumber!==i;n&&(o||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:i}),this.state.isLoaded=n}_onViewportLoad(){let{tileset:e}=this.state,{onViewportLoad:r}=this.props;r&&r(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,r){this.props.onTileError(e),r.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){let{data:r,getTileData:s,fetch:i}=this.props,{signal:n}=e;return e.url=typeof r=="string"||Array.isArray(r)?bs(r,e):null,s?s(e):i&&e.url?i(e.url,{propName:"data",layer:this,signal:n}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){let r=e.sourceLayer,s=r.props.tile,i=e.info;return i.picked&&(i.tile=s),i.sourceTile=s,i.sourceTileSubLayer=r,i}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){return this.state.tileset.tiles.map(e=>{let r=this.getSubLayerPropsByTile(e);if(!(!e.isLoaded&&!e.content))if(e.layers)r&&e.layers[0]&&Object.keys(r).some(s=>e.layers[0].props[s]!==r[s])&&(e.layers=e.layers.map(s=>s.clone(r)));else{let s=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=Bt(s,Boolean).map(i=>i.clone({tile:e,...r}))}return e.layers})}filterSubLayer({layer:e,cullRect:r}){let{tile:s}=e.props;return this.state.tileset.isTileVisible(s,r)}};lf.defaultProps=Sj;lf.layerName="TileLayer";var ro=lf;var vj={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:t=>t.timestamps}},uf=class extends Vi{getShaders(){let e=super.getShaders();return e.inject={"vs:#decl":`uniform float trailLength; in float instanceTimestamps; in float instanceNextTimestamps; out float vTime; `,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength; `,"fs:#decl":`uniform bool fadeTrail; uniform float trailLength; uniform float currentTime; in float vTime; `,"fs:#main-start":`if(vTime > currentTime || (fadeTrail && (vTime < currentTime - trailLength))) { discard; } `,"fs:DECKGL_FILTER_COLOR":`if(fadeTrail) { color.a *= 1.0 - (currentTime - vTime) / trailLength; } `},e}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(e){let{fadeTrail:r,trailLength:s,currentTime:i}=this.props;e.uniforms={...e.uniforms,fadeTrail:r,trailLength:s,currentTime:i},super.draw(e)}};uf.layerName="TripsLayer";uf.defaultProps=vj;var _I=uf;var TI=ss(ff(),1);var Er=ss(ff(),1);var hf=ss(ff(),1);function Eg(t,e){e=e===void 0?t[0][0]:e;for(let r of t){let s=r[0]-e;s>180?r[0]-=360:s<-180&&(r[0]+=360)}}function Cj(t,e,r){let[s,i]=(0,hf.cellToLatLng)(t),n=e.length;Eg(e,i);let o=e[0]===e[n-1]?n-1:n;for(let a=0;at.hexagon},extruded:!0},Ki=class extends Le{initializeState(){Ki._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:e}){return this._shouldUseHighPrecision()?e.propsOrDataChanged:e.somethingChanged}updateState({props:e,changeFlags:r}){if(e.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let s=this._calculateH3DataProps();this.setState(s)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let e=-1,r=!1,s=!1,{iterable:i,objectInfo:n}=ze(this.props.data);for(let o of i){n.index++;let a=this.props.getHexagon(o,n),c=(0,Er.getResolution)(a);if(e<0){if(e=c,!this.props.highPrecision)break}else if(e!==c){s=!0;break}if((0,Er.isPentagon)(a)){r=!0;break}}return{resolution:e,edgeLengthKM:e>=0?(0,Er.getHexagonEdgeLengthAvg)(e,"km"):0,hasMultipleRes:s,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:e,hasPentagon:r,hasMultipleRes:s}=this.state,{viewport:i}=this.context;return Boolean(i?.resolution)||s||r||e>=0&&e<=5}return this.props.highPrecision}_updateVertices(e){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:s,centerHex:i}=this.state;if(r<0)return;let n=this.props.centerHexagon||(0,Er.latLngToCell)(e.latitude,e.longitude,r);if(i===n)return;if(i)try{if((0,Er.gridDistance)(i,n)*s{let d=e.projectFlat(h);return[(d[0]-u)/o[0],(d[1]-f)/o[1]]}),this.setState({centerHex:n,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:e,material:r,coverage:s,extruded:i,wireframe:n,stroked:o,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:u,lineWidthMaxPixels:f,getFillColor:h,getElevation:d,getLineColor:p,getLineWidth:g,transitions:m,updateTriggers:_}=this.props;return{elevationScale:e,extruded:i,coverage:s,wireframe:n,stroked:o,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:u,lineWidthMaxPixels:f,material:r,getElevation:d,getFillColor:h,getLineColor:p,getLineWidth:g,transitions:m,updateTriggers:{getFillColor:_.getFillColor,getElevation:_.getElevation,getLineColor:_.getLineColor,getLineWidth:_.getLineWidth}}}_renderPolygonLayer(){let{data:e,getHexagon:r,updateTriggers:s,coverage:i}=this.props,n=this.getSubLayerClass("hexagon-cell-hifi",Gi),o=this._getForwardProps();return o.updateTriggers.getPolygon=Pj(s.getHexagon,i),new n(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:e,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return AI(tT(l,i))}})}_renderColumnLayer(){let{data:e,getHexagon:r,updateTriggers:s}=this.props,i=this.getSubLayerClass("hexagon-cell",ki),n=this._getForwardProps();return n.updateTriggers.getPosition=s.getHexagon,new i(n,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:n.updateTriggers}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:xI.bind(null,r)})}};Ki.defaultProps=Mj;Ki.layerName="H3HexagonLayer";Ki._checkH3Lib=()=>{};var va=Ki;var Rj={getHexagons:{type:"accessor",value:t=>t.hexagons}},df=class extends As{initializeState(){va._checkH3Lib()}updateState({props:e,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:s,getHexagons:i}=e,n=[],{iterable:o,objectInfo:a}=ze(s);for(let c of o){a.index++;let l=i(c,a),u=(0,TI.cellsToMultiPolygon)(l,!0);for(let f of u){for(let h of f)Eg(h);n.push(this.getSubLayerRow({polygon:f},c,a.index))}}this.setState({polygons:n})}}indexToBounds(){let{getElevation:e,getFillColor:r,getLineColor:s,getLineWidth:i}=this.props;return{data:this.state.polygons,getPolygon:n=>n.polygon,getElevation:this.getSubLayerAccessor(e),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(s),getLineWidth:this.getSubLayerAccessor(i)}}};df.layerName="H3ClusterLayer";df.defaultProps=Rj;var bI=df;var rT=Math.PI/180,Sg=new Float32Array(16),EI=new Float32Array(12);function SI(t,e,r){let s=e[0]*rT,i=e[1]*rT,n=e[2]*rT,o=Math.sin(n),a=Math.sin(s),c=Math.sin(i),l=Math.cos(n),u=Math.cos(s),f=Math.cos(i),h=r[0],d=r[1],p=r[2];t[0]=h*f*u,t[1]=h*c*u,t[2]=h*-a,t[3]=d*(-c*l+f*a*o),t[4]=d*(f*l+c*a*o),t[5]=d*u*o,t[6]=p*(c*o+f*a*l),t[7]=p*(-f*o+c*a*l),t[8]=p*u*l}function vI(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var vg={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(t,{startRow:e,endRow:r}){let{data:s,getOrientation:i,getScale:n,getTranslation:o,getTransformMatrix:a}=this.props,c=Array.isArray(a),l=c&&a.length===16,u=Array.isArray(n),f=Array.isArray(i),h=Array.isArray(o),d=l||!c&&Boolean(a(s[0]));d?t.constant=l:t.constant=f&&u&&h;let p=t.value;if(t.constant){let g;d?(Sg.set(a),g=vI(Sg)):(g=EI,SI(g,i,n),g.set(o,9)),t.value=new Float32Array(g)}else{let g=e*t.size,{iterable:m,objectInfo:_}=ze(s,e,r);for(let y of m){_.index++;let x;if(d)Sg.set(l?a:a(y,_)),x=vI(Sg);else{x=EI;let S=f?i:i(y,_),P=u?n:n(y,_);SI(x,S,P),x.set(h?o:o(y,_),9)}p[g++]=x[0],p[g++]=x[1],p[g++]=x[2],p[g++]=x[3],p[g++]=x[4],p[g++]=x[5],p[g++]=x[6],p[g++]=x[7],p[g++]=x[8],p[g++]=x[9],p[g++]=x[10],p[g++]=x[11]}}}};function Cg(t,e){return e===X.CARTESIAN||e===X.METER_OFFSETS||e===X.DEFAULT&&!t.isGeospatial}var CI=`#version 300 es #define SHADER_NAME simple-mesh-layer-vs uniform float sizeScale; uniform bool composeModelMatrix; in vec3 positions; in vec3 normals; in vec3 colors; in vec2 texCoords; in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; out vec2 vTexCoord; out vec3 cameraPosition; out vec3 normals_commonspace; out vec4 position_commonspace; out vec4 vColor; void main(void) { geometry.worldPosition = instancePositions; geometry.uv = texCoords; geometry.pickingColor = instancePickingColors; vTexCoord = texCoords; cameraPosition = project_uCameraPosition; vColor = vec4(colors * instanceColors.rgb, instanceColors.a); mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation; if (composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); normals_commonspace = project_normal(instanceModelMatrix * normals); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace); geometry.position = position_commonspace; } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace); geometry.position = position_commonspace; normals_commonspace = project_normal(instanceModelMatrix * normals); } geometry.normal = normals_commonspace; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); DECKGL_FILTER_COLOR(vColor, geometry); } `;var wI=`#version 300 es #define SHADER_NAME simple-mesh-layer-fs precision highp float; uniform bool hasTexture; uniform sampler2D sampler; uniform bool flatShading; uniform float opacity; in vec2 vTexCoord; in vec3 cameraPosition; in vec3 normals_commonspace; in vec4 position_commonspace; in vec4 vColor; out vec4 fragColor; void main(void) { geometry.uv = vTexCoord; vec3 normal; if (flatShading) { normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); } else { normal = normals_commonspace; } vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor; DECKGL_FILTER_COLOR(color, geometry); vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); fragColor = vec4(lightColor, color.a * opacity); } `;function sT(t){let e=t.positions||t.POSITION;k.assert(e,'no "postions" or "POSITION" attribute in mesh');let r=e.value.length/e.size,s=t.COLOR_0||t.colors;s||(s={size:3,value:new Float32Array(r*3).fill(1)});let i=t.NORMAL||t.normals;i||(i={size:3,value:new Float32Array(r*3).fill(0)});let n=t.TEXCOORD_0||t.texCoords;return n||(n={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:s,normals:i,texCoords:n}}function PI(t){return t instanceof se?(t.attributes=sT(t.attributes),t):t.attributes?new se({...t,topology:"triangle-list",attributes:sT(t.attributes)}):new se({topology:"triangle-list",attributes:sT(t)})}var Ij=[0,0,0,255],Bj={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:Ij},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}},pf=class extends he{getShaders(){return super.getShaders({vs:CI,fs:wI,modules:[de,vi,_e]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;let{mesh:r}=this.props;if(!r)return null;if(e=r.header?.boundingBox,!e){let{attributes:s}=PI(r);s.POSITION=s.POSITION||s.positions,e=Is(s)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:vg}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);let{props:r,oldProps:s,changeFlags:i}=e;if(r.mesh!==s.mesh||i.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),r.mesh){this.state.model=this.getModel(r.mesh);let n=r.mesh.attributes||r.mesh;this.setState({hasNormals:Boolean(n.NORMAL||n.normals)})}this.getAttributeManager().invalidateAll()}r.texture!==s.texture&&r.texture instanceof xe&&this.setTexture(r.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){let{model:r}=this.state;if(!r)return;let{viewport:s,renderPass:i}=this.context,{sizeScale:n,coordinateSystem:o,_instanced:a}=this.props;r.setUniforms(e),r.setUniforms({sizeScale:n,composeModelMatrix:!a||Cg(s,o),flatShading:!this.state.hasNormals}),r.draw(i)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){let r=new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:PI(e),isInstanced:!0}),{texture:s}=this.props,{emptyTexture:i}=this.state;return r.setBindings({sampler:s||i}),r.setUniforms({hasTexture:Boolean(s)}),r}setTexture(e){let{emptyTexture:r,model:s}=this.state;s&&(s.setBindings({sampler:e||r}),s.setUniforms({hasTexture:Boolean(e)}))}};pf.defaultProps=Bj;pf.layerName="SimpleMeshLayer";var so=pf;var $r;(function(t){t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.LINEAR=9729]="LINEAR",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})($r||($r={}));function mf(t,e,r,s){let i={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};i.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:n}=s;return n&&(i.bindings.u_DiffuseEnvSampler=n.diffuseEnvSampler,i.bindings.u_SpecularEnvSampler=n.specularEnvSampler,i.bindings.u_brdfLUT=n.brdfLutTexture,i.uniforms.u_ScaleIBLAmbient=[1,1]),s?.pbrDebug&&(i.defines.PBR_DEBUG=1,i.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],i.uniforms.u_ScaleFGDSpec=[0,0,0,0]),r.NORMAL&&(i.defines.HAS_NORMALS=1),r.TANGENT&&s?.useTangents&&(i.defines.HAS_TANGENTS=1),r.TEXCOORD_0&&(i.defines.HAS_UV=1),s?.imageBasedLightingEnvironment&&(i.defines.USE_IBL=1),s?.lights&&(i.defines.USE_LIGHTS=1),e&&Oj(t,e,i),i}function Oj(t,e,r){if(r.uniforms.pbr_uUnlit=Boolean(e.unlit),e.pbrMetallicRoughness&&Fj(t,e.pbrMetallicRoughness,r),e.normalTexture){gf(t,e.normalTexture,"u_NormalSampler","HAS_NORMALMAP",r);let{scale:s=1}=e.normalTexture;r.uniforms.u_NormalScale=s}if(e.occlusionTexture){gf(t,e.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",r);let{strength:s=1}=e.occlusionTexture;r.uniforms.u_OcclusionStrength=s}switch(e.emissiveTexture&&(gf(t,e.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",r),r.uniforms.u_EmissiveFactor=e.emissiveFactor||[0,0,0]),e.alphaMode){case"MASK":let{alphaCutoff:s=.5}=e;r.defines.ALPHA_CUTOFF=1,r.uniforms.u_AlphaCutoff=s;break;case"BLEND":U.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),r.parameters.blendColorOperation="add",r.parameters.blendColorSrcFactor="src-alpha",r.parameters.blendColorDstFactor="one-minus-src-alpha",r.parameters.blendAlphaOperation="add",r.parameters.blendAlphaSrcFactor="one",r.parameters.blendAlphaDstFactor="one-minus-src-alpha",r.glParameters.blend=!0,r.glParameters.blendEquation=$r.FUNC_ADD,r.glParameters.blendFunc=[$r.SRC_ALPHA,$r.ONE_MINUS_SRC_ALPHA,$r.ONE,$r.ONE_MINUS_SRC_ALPHA];break}}function Fj(t,e,r){e.baseColorTexture&&gf(t,e.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",r),r.uniforms.u_BaseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&gf(t,e.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",r);let{metallicFactor:s=1,roughnessFactor:i=1}=e;r.uniforms.u_MetallicRoughnessValues=[s,i]}function gf(t,e,r,s=null,i){let n=e?.texture?.sampler?.parameters||{},o=e.texture.source.image,a,c={};o.compressed?(a=o,c={[$r.TEXTURE_MIN_FILTER]:o.data.length>1?$r.LINEAR_MIPMAP_NEAREST:$r.LINEAR}):a={data:o};let l=t.createTexture({id:e.uniformName||e.id,parameters:{...n,...c},pixelStore:{[$r.UNPACK_FLIP_Y_WEBGL]:!1},...a});i.bindings[r]=l,s&&(i.defines[s]=1),i.generatedTextures.push(l)}var MI="4.2.0-beta.2";var wg={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},RI;async function nT(t){b_(t.modules);let e=E_("basis");return e||(RI||=Lj(t),await RI)}async function Lj(t){let e=null,r=null;return[e,r]=await Promise.all([await os(wg.TRANSCODER,"textures",t),await os(wg.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await Nj(e,r)}function Nj(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(s=>{t(r).then(i=>{let{BasisFile:n,initializeBasis:o}=i;o(),s({BasisFile:n})})})}var iT;async function oT(t){let e=t.modules||{};return e.basisEncoder?e.basisEncoder:(iT=iT||Dj(t),await iT)}async function Dj(t){let e=null,r=null;return[e,r]=await Promise.all([await os(wg.ENCODER,"textures",t),await os(wg.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await Uj(e,r)}function Uj(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(s=>{t(r).then(i=>{let{BasisFile:n,KTX2File:o,initializeBasis:a,BasisEncoder:c}=i;a(),s({BasisFile:n,KTX2File:o,BasisEncoder:c})})})}var io={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919};var kj=["","WEBKIT_","MOZ_"],II={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},Pg=null;function BI(t){if(!Pg){t=t||Vj()||void 0,Pg=new Set;for(let e of kj)for(let r in II)if(t&&t.getExtension(`${e}${r}`)){let s=II[r];Pg.add(s)}}return Pg}function Vj(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var EPe=new Uint8Array([0]);var OI,FI,LI,NI,DI,UI,kI,VI;(function(t){t[t.NONE=0]="NONE",t[t.BASISLZ=1]="BASISLZ",t[t.ZSTD=2]="ZSTD",t[t.ZLIB=3]="ZLIB"})(OI||(OI={})),function(t){t[t.BASICFORMAT=0]="BASICFORMAT"}(FI||(FI={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ETC1S=163]="ETC1S",t[t.UASTC=166]="UASTC"}(LI||(LI={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SRGB=1]="SRGB"}(NI||(NI={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LINEAR=1]="LINEAR",t[t.SRGB=2]="SRGB",t[t.ITU=3]="ITU",t[t.NTSC=4]="NTSC",t[t.SLOG=5]="SLOG",t[t.SLOG2=6]="SLOG2"}(DI||(DI={})),function(t){t[t.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",t[t.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(UI||(UI={})),function(t){t[t.RGB=0]="RGB",t[t.RRR=3]="RRR",t[t.GGG=4]="GGG",t[t.AAA=15]="AAA"}(kI||(kI={})),function(t){t[t.RGB=0]="RGB",t[t.RGBA=3]="RGBA",t[t.RRR=4]="RRR",t[t.RRRG=5]="RRRG"}(VI||(VI={}));var sr=[171,75,84,88,32,50,48,187,13,10,26,10];function zI(t){let e=new Uint8Array(t);return!(e.byteLength{Jj(s,i,n,o),Yj(n,n._node)})}},Rg=class{animations;constructor(e){this.animations=e.animations.map((r,s)=>{let i=r.name||`Animation-${s}`,n=r.samplers.map(({input:a,interpolation:c="LINEAR",output:l})=>({input:jI(e.accessors[a]),interpolation:c,output:jI(e.accessors[l])})),o=r.channels.map(({sampler:a,target:c})=>({sampler:n[a],target:e.nodes[c.node],path:c.path}));return new fT({name:i,channels:o})})}animate(e){this.setTime(e)}setTime(e){this.animations.forEach(r=>r.animate(e))}getAnimations(){return this.animations}};function jI(t){if(!t._animation){let e=jj[t.componentType],r=Wj[t.type],s=r*t.count,{buffer:i,byteOffset:n}=t.bufferView.data,o=new e(i,n+(t.byteOffset||0),s);if(r===1)t._animation=Array.from(o);else{let a=[];for(let c=0;ch>=a),l=Math.max(0,c-1);if(!Array.isArray(i[n]))switch(n){case"translation":i[n]=[0,0,0];break;case"rotation":i[n]=[0,0,0,1];break;case"scale":i[n]=[1,1,1];break;default:U.warn(`Bad animation path ${n}`)()}ee(i[n].length===s[l].length);let u=e[l],f=e[c];switch(r){case"STEP":$j(i,n,s[l]);break;case"LINEAR":if(f>u){let h=(a-u)/(f-u);qj(i,n,s[l],s[c],h)}break;case"CUBICSPLINE":if(f>u){let h=(a-u)/(f-u),d=f-u,p=s[3*l+1],g=s[3*l+2],m=s[3*c+0],_=s[3*c+1];Kj(i,n,{p0:p,outTangent0:g,inTangent1:m,p1:_,tDiff:d,ratio:h})}break;default:U.warn(`Interpolation ${r} not supported`)();break}}var Zj=` #pragma vscode_glsllint_stage: vert #if (__VERSION__ < 300) #define _attr attribute #else #define _attr in #endif // _attr vec4 POSITION; _attr vec4 positions; #ifdef HAS_NORMALS // _attr vec4 NORMAL; _attr vec4 normals; #endif #ifdef HAS_TANGENTS _attr vec4 TANGENT; #endif #ifdef HAS_UV // _attr vec2 TEXCOORD_0; _attr vec2 texCoords; #endif void main(void) { vec4 _NORMAL = vec4(0.); vec4 _TANGENT = vec4(0.); vec2 _TEXCOORD_0 = vec2(0.); #ifdef HAS_NORMALS _NORMAL = normals; #endif #ifdef HAS_TANGENTS _TANGENT = TANGENT; #endif #ifdef HAS_UV _TEXCOORD_0 = texCoords; #endif pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0); gl_Position = u_MVPMatrix * positions; } `,Qj=` #pragma vscode_glsllint_stage: frag #if (__VERSION__ < 300) #define fragmentColor gl_FragColor #else out vec4 fragmentColor; #endif void main(void) { vec3 pos = pbr_vPosition; fragmentColor = pbr_filterColor(vec4(1.0)); } `;function YI(t,e){let{id:r,geometry:s,material:i,vertexCount:n,materialOptions:o,modelOptions:a}=e,c=mf(t,i,s.attributes,o);U.info(4,"createGLTFModel defines: ",c.defines)();let l=[],u={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},f={id:r,geometry:s,topology:s.topology,vertexCount:n,modules:[An],vs:XI(t,Zj),fs:XI(t,Qj),...a,bindings:{...c.bindings,...a.bindings},defines:{...c.defines,...a.defines},parameters:{...u,...c.parameters,...a.parameters},uniforms:{...c.uniforms,...a.uniforms}},h=new J(t,f);return new ds({managedResources:l,model:h})}function XI(t,e){return`#version 300 es ${e}`}var eX={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},Ig=class{device;options;gltf;constructor(e,r={}){this.device=e,this.options={...eX,...r}}instantiate(e){return this.gltf=e,(e.scenes||[]).map(s=>this.createScene(s))}createAnimator(){return Array.isArray(this.gltf.animations)?new Rg(this.gltf):null}createScene(e){let s=(e.nodes||[]).map(n=>this.createNode(n));return new tr({id:e.name||e.id,children:s})}createNode(e){if(!e._node){let s=(e.children||[]).map(n=>this.createNode(n));e.mesh&&s.push(this.createMesh(e.mesh));let i=new tr({id:e.name||e.id,children:s});if(e.matrix)i.setMatrix(e.matrix);else{if(i.matrix.identity(),e.translation&&i.matrix.translate(e.translation),e.rotation){let n=new q().fromQuaternion(e.rotation);i.matrix.multiplyRight(n)}e.scale&&i.matrix.scale(e.scale)}e._node=i}return e._node}createMesh(e){if(!e._mesh){let s=(e.primitives||[]).map((n,o)=>this.createPrimitive(n,o,e)),i=new tr({id:e.name||e.id,children:s});e._mesh=i}return e._mesh}createPrimitive(e,r,s){let i=e.name||`${s.name||s.id}-primitive-${r}`,n=tX(e.mode||4),o=e.indices?e.indices.count:this.getVertexCount(e.attributes),a=YI(this.device,{id:i,geometry:this.createGeometry(i,e,n),material:e.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});return a.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],a}getVertexCount(e){throw new Error("getVertexCount not implemented")}createGeometry(e,r,s){let i={};for(let[n,o]of Object.entries(r.attributes)){let{components:a,size:c,value:l}=o;i[n]={size:c??a,value:l}}return new se({id:e,topology:s,indices:r.indices.value,attributes:i})}createBuffer(e,r){e.bufferView||(e.bufferView={});let{bufferView:s}=e;return s.lumaBuffers||(s.lumaBuffers={}),s.lumaBuffers[r]||(s.lumaBuffers[r]=this.device.createBuffer({id:`from-${s.id}`,data:s.data||e.value})),s.lumaBuffers[r]}createSampler(e){return e}needsPOT(){return!1}},Js;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(Js||(Js={}));function tX(t){switch(t){case Js.POINTS:return"point-list";case Js.LINES:return"line-list";case Js.LINE_STRIP:return"line-strip";case Js.LINE_LOOP:return"line-loop-webgl";case Js.TRIANGLES:return"triangle-list";case Js.TRIANGLE_STRIP:return"triangle-strip";case Js.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(t)}}function hT(t,e,r){let s=new Ig(t,r),i=s.instantiate(e),n=s.createAnimator();return{scenes:i,animator:n}}var dT={};Ke(dT,{decode:()=>dX,name:()=>hX});function nt(t,e){if(!t)throw new Error(e||"assert failed: gltf")}var Bg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Og={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var rX=1.33,qI=["SCALAR","VEC2","VEC3","VEC4"],sX=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],iX=new Map(sX),nX={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oX={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},aX={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Fg(t){return qI[t-1]||qI[0]}function Ca(t){let e=iX.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function wa(t,e){let r=aX[t.componentType],s=nX[t.type],i=oX[t.componentType],n=t.count*s,o=t.count*s*i;nt(o>=0&&o<=e.byteLength);let a=Og[t.componentType],c=Bg[t.type];return{ArrayType:r,length:n,byteLength:o,componentByteSize:a,numberOfComponentsInElement:c}}function _f(t){let{images:e,bufferViews:r}=t;e=e||[],r=r||[];let s=e.map(o=>o.bufferView);r=r.filter(o=>!s.includes(o));let i=r.reduce((o,a)=>o+a.byteLength,0),n=e.reduce((o,a)=>{let{width:c,height:l}=a.image;return o+c*l},0);return i+Math.ceil(4*n*rX)}function KI(t,e,r){let s=t.bufferViews[r];nt(s);let i=s.buffer,n=e[i];nt(n);let o=(s.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,s.byteLength)}function $I(t,e,r){let s=typeof r=="number"?t.accessors?.[r]:r;if(!s)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let i=t.bufferViews?.[s.bufferView||0];if(!i)throw new Error(`No gltf buffer view for accessor ${i}`);let{arrayBuffer:n,byteOffset:o}=e[i.buffer],a=(o||0)+(s.byteOffset||0)+(i.byteOffset||0),{ArrayType:c,length:l,componentByteSize:u,numberOfComponentsInElement:f}=wa(s,i),h=u*f,d=i.byteStride||h;if(typeof i.byteStride>"u"||i.byteStride===h)return new c(n,a,l);let p=new c(l);for(let g=0;gi===e),s=this.getRequiredExtensions().find(i=>i===e);return typeof r=="string"||typeof s=="string"}getExtension(e){let r=this.getUsedExtensions().find(i=>i===e),s=this.json.extensions||{};return r?s[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(s=>s===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,r){return(e.extensions||{})[r]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,r){if(typeof r=="object")return r;let s=this.json[e]&&this.json[e][r];if(!s)throw new Error(`glTF file error: Could not find ${e}[${r}]`);return s}getTypedArrayForBufferView(e){e=this.getBufferView(e);let r=e.buffer,s=this.gltf.buffers[r];nt(s);let i=(e.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,e.byteLength)}getTypedArrayForAccessor(e){let r=this.getAccessor(e);return $I(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);let r=this.getBufferView(e.bufferView),i=this.getBuffer(r.buffer).data,n=r.byteOffset||0;return new Uint8Array(i,n,r.byteLength)}addApplicationData(e,r){return this.json[e]=r,this}addExtraData(e,r){return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addObjectExtension(e,r,s){return e.extensions=e.extensions||{},e.extensions[r]=s,this.registerUsedExtension(r),this}setObjectExtension(e,r,s){let i=e.extensions||{};i[r]=s}removeObjectExtension(e,r){let s=e?.extensions||{};if(s[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let i=this.json.extensionsRemoved;i.includes(r)||i.push(r)}delete s[r]}addExtension(e,r={}){return nt(r),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),r}addRequiredExtension(e,r={}){return nt(r),this.addExtension(e,r),this.registerRequiredExtension(e),r}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(e)||r.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){let{nodeIndices:r}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(e){let{meshIndex:r,matrix:s}=e;this.json.nodes=this.json.nodes||[];let i={mesh:r};return s&&(i.matrix=s),this.json.nodes.push(i),this.json.nodes.length-1}addMesh(e){let{attributes:r,indices:s,material:i,mode:n=4}=e,a={primitives:[{attributes:this._addAttributes(r),mode:n}]};if(s){let c=this._addIndices(s);a.primitives[0].indices=c}return Number.isFinite(i)&&(a.primitives[0].material=i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){let s={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addImage(e,r){let s=hn(e),i=r||s?.mimeType,o={bufferView:this.addBufferView(e),mimeType:i};return this.json.images=this.json.images||[],this.json.images.push(o),this.json.images.length-1}addBufferView(e,r=0,s=this.byteLength){let i=e.byteLength;nt(Number.isFinite(i)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);let n={buffer:r,byteOffset:s,byteLength:i};return this.byteLength+=li(i,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(e,r){let s={bufferView:e,type:Fg(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(s),this.json.accessors.length-1}addBinaryBuffer(e,r={size:3}){let s=this.addBufferView(e),i={min:r.min,max:r.max};(!i.min||!i.max)&&(i=this._getAccessorMinMax(e,r.size));let n={size:r.size,componentType:Ca(e),count:Math.round(e.length/r.size),min:i.min,max:i.max};return this.addAccessor(s,Object.assign(n,r))}addTexture(e){let{imageIndex:r}=e,s={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(s),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];let e=this.byteLength,r=new ArrayBuffer(e),s=new Uint8Array(r),i=0;for(let n of this.sourceBuffers||[])i=L_(n,s,i);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=r,this.sourceBuffers=[r]}_removeStringFromArray(e,r){let s=!0;for(;s;){let i=e.indexOf(r);i>-1?e.splice(i,1):s=!1}}_addAttributes(e={}){let r={};for(let s in e){let i=e[s],n=this._getGltfAttributeName(s),o=this.addBinaryBuffer(i.value,i);r[n]=o}return r}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,r){let s={min:null,max:null};if(e.lengthh===u);f===-1&&(f=s.push(u)-1),n.push(f)}let o=new Uint32Array(n),a=t.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,c=t.addBufferView(o,a,0),l=t.addAccessor(c,{size:1,componentType:Ca(o),count:o.length});i.attributes[e]=l}function uX(t,e,r,s,i=[0]){let n={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},o=r[s],a=r[s+1],c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);let l=fX(o,a,t,c),u=0;for(let f of i){let h=typeof f=="number"?Object.values(n)[f]:n[f],d=l+h.offset,p=Nc(t);if(p.data.length<=d)throw new Error(`${p.data.length} <= ${d}`);let g=p.data[d];u|=g<s)break;let l=a/i,u=c/i;n.push(t.slice(l,l+u))}return n}function Dg(t,e,r){let s=[];for(let i=0;i_X,name:()=>mX});var pT="EXT_structural_metadata",mX=pT;async function _X(t,e){let r=new Te(t);yX(r,e)}function yX(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(pT);r&&(e.gltf?.loadImages&&xX(t,r),AX(t,r))}function xX(t,e){let r=e.propertyTextures,s=t.gltf.json;if(r&&s.meshes)for(let i of s.meshes)for(let n of i.primitives)bX(t,r,n,e)}function AX(t,e){let r=e.schema;if(!r)return;let s=r.classes,i=e.propertyTables;if(s&&i)for(let n in s){let o=TX(i,n);o&&SX(t,r,o)}}function TX(t,e){for(let r of t)if(r.class===e)return r;return null}function bX(t,e,r,s){if(!e)return;let n=r.extensions?.[pT]?.propertyTextures;if(n)for(let o of n){let a=e[o];EX(t,a,r,s)}}function EX(t,e,r,s){if(!e.properties)return;s.dataAttributeNames||(s.dataAttributeNames=[]);let i=e.class;for(let n in e.properties){let o=`${i}_${n}`,a=e.properties?.[n];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=Ra(t,a,r);l!==null&&(Lg(t,o,l,c,r),a.data=c,s.dataAttributeNames.push(o))}}function SX(t,e,r){let s=e.classes?.[r.class];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let i=r.count;for(let n in s.properties){let o=s.properties[n],a=r.properties?.[n];if(a){let c=vX(t,e,o,i,a);a.data=c}}}function vX(t,e,r,s,i){let n=[],o=i.values,a=t.getTypedArrayForBufferView(o),c=CX(t,r,i,s),l=wX(t,i,s);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{n=PX(r,s,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{n=Ug(s,a,c,l);break}case"ENUM":{n=MX(e,r,s,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return n}function CX(t,e,r,s){return e.array&&typeof e.count>"u"&&typeof r.arrayOffsets<"u"?Pa(t,r.arrayOffsets,r.arrayOffsetType||"UINT32",s):null}function wX(t,e,r){return typeof e.stringOffsets<"u"?Pa(t,e.stringOffsets,e.stringOffsetType||"UINT32",r):null}function PX(t,e,r,s){let i=t.array,n=t.count,o=yf(t.type,t.componentType),a=r.byteLength/o,c;return t.componentType?c=Ma(r,t.type,t.componentType,a):c=r,i?s?Ng(c,e,s,r.length,o):n?Dg(c,e,n):[]:c}function MX(t,e,r,s,i){let n=e.enumType;if(!n)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let o=t.enums?.[n];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${n}`);let a=o.valueType||"UINT16",c=yf(e.type,a),l=s.byteLength/c,u=Ma(s,e.type,a,l);if(u||(u=s),e.array){if(i)return RX({valuesData:u,numberOfElements:r,arrayOffsets:i,valuesDataBytesLength:s.length,elementSize:c,enumEntry:o});let f=e.count;return f?IX(u,r,f,o):[]}return gT(u,0,r,o)}function RX(t){let{valuesData:e,numberOfElements:r,arrayOffsets:s,valuesDataBytesLength:i,elementSize:n,enumEntry:o}=t,a=[];for(let c=0;ci)break;let f=l/n,h=u/n,d=gT(e,f,h,o);a.push(d)}return a}function IX(t,e,r,s){let i=[];for(let n=0;nFX,name:()=>OX});var t2="EXT_feature_metadata",OX=t2;async function FX(t,e){let r=new Te(t);LX(r,e)}function LX(t,e){if(!e.gltf?.loadBuffers)return;let r=t.getExtension(t2);r&&(e.gltf?.loadImages&&NX(t,r),DX(t,r))}function NX(t,e){let r=e.schema;if(!r)return;let s=r.classes,{featureTextures:i}=e;if(s&&i)for(let n in s){let o=s[n],a=kX(i,n);a&&zX(t,a,o)}}function DX(t,e){let r=e.schema;if(!r)return;let s=r.classes,i=e.featureTables;if(s&&i)for(let n in s){let o=UX(i,n);o&&VX(t,r,o)}}function UX(t,e){for(let r in t){let s=t[r];if(s.class===e)return s}return null}function kX(t,e){for(let r in t){let s=t[r];if(s.class===e)return s}return null}function VX(t,e,r){if(!r.class)return;let s=e.classes?.[r.class];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let i=r.count;for(let n in s.properties){let o=s.properties[n],a=r.properties?.[n];if(a){let c=HX(t,e,o,i,a);a.data=c}}}function zX(t,e,r){let s=e.class;for(let i in r.properties){let n=e?.properties?.[i];if(n){let o=YX(t,n,s);n.data=o}}}function HX(t,e,r,s,i){let n=[],o=i.bufferView,a=t.getTypedArrayForBufferView(o),c=GX(t,r,i,s),l=WX(t,r,i,s);return r.type==="STRING"||r.componentType==="STRING"?n=Ug(s,a,c,l):jX(r)&&(n=XX(r,s,a,c)),n}function GX(t,e,r,s){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Pa(t,r.arrayOffsetBufferView,r.offsetType||"UINT32",s):null}function WX(t,e,r,s){return typeof r.stringOffsetBufferView<"u"?Pa(t,r.stringOffsetBufferView,r.offsetType||"UINT32",s):null}function jX(t){let e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function XX(t,e,r,s){let i=t.type==="ARRAY",n=t.componentCount,o="SCALAR",a=t.componentType||t.type,c=yf(o,a),l=r.byteLength/c,u=Ma(r,o,a,l);return i?s?Ng(u,e,s,r.length,c):n?Dg(u,e,n):[]:u}function YX(t,e,r){let s=t.gltf.json;if(!s.meshes)return[];let i=[];for(let n of s.meshes)for(let o of n.primitives)qX(t,r,e,i,o);return i}function qX(t,e,r,s,i){let n={channels:r.channels,...r.texture},o=Ra(t,n,i);o&&Lg(t,e,o,s,i)}var r2="4.2.0-beta.2";var Ia=!0,s2=1735152710,AT=12,kg=8,KX=1313821514,$X=5130562,JX=0,ZX=0,QX=1;function e7(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function i2(t,e=0,r={}){let s=new DataView(t),{magic:i=s2}=r,n=s.getUint32(e,!1);return n===i||n===s2}function n2(t,e,r=0,s={}){let i=new DataView(e),n=e7(i,r+0),o=i.getUint32(r+4,Ia),a=i.getUint32(r+8,Ia);switch(Object.assign(t,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:n,version:o,json:{},binChunks:[]}),r+=AT,t.version){case 1:return t7(t,i,r);case 2:return r7(t,i,r,s={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function t7(t,e,r){ne(t.header.byteLength>AT+kg);let s=e.getUint32(r+0,Ia),i=e.getUint32(r+4,Ia);return r+=kg,ne(i===JX),yT(t,e,r,s),r+=s,r+=xT(t,e,r,t.header.byteLength),r}function r7(t,e,r,s){return ne(t.header.byteLength>AT+kg),s7(t,e,r,s),r+t.header.byteLength}function s7(t,e,r,s){for(;r+8<=t.header.byteLength;){let i=e.getUint32(r+0,Ia),n=e.getUint32(r+4,Ia);switch(r+=kg,n){case KX:yT(t,e,r,i);break;case $X:xT(t,e,r,i);break;case ZX:s.strict||yT(t,e,r,i);break;case QX:s.strict||xT(t,e,r,i);break;default:break}r+=li(i,4)}return r}function yT(t,e,r,s){let i=new Uint8Array(e.buffer,r,s),o=new TextDecoder("utf8").decode(i);return t.json=JSON.parse(o),li(s,4)}function xT(t,e,r,s){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:r,byteLength:s,arrayBuffer:e.buffer}),li(s,4)}function TT(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;let s=e.baseUri||e.uri;if(!s)throw new Error(`'baseUri' must be provided to resolve relative url ${t}`);return s.substr(0,s.lastIndexOf("/")+1)+t}var ET={};Ke(ET,{decode:()=>g7,name:()=>p7});var i7="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",n7="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",o7=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),a7=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),c7={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},l7={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function o2(t,e,r,s,i,n="NONE"){let o=await u7();d7(o,o.exports[l7[i]],t,e,r,s,o.exports[c7[n||"NONE"]])}var bT;async function u7(){return bT||(bT=f7()),bT}async function f7(){let t=i7;WebAssembly.validate(o7)&&(t=n7,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let e=await WebAssembly.instantiate(h7(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function h7(t){let e=new Uint8Array(t.length);for(let s=0;s96?i-71:i>64?i-65:i>47?i+4:i>46?63:62}let r=0;for(let s=0;s_7,preprocess:()=>y7});var Ba="EXT_texture_webp",_7=Ba;function y7(t,e){let r=new Te(t);if(!t0("image/webp")){if(r.getRequiredExtensions().includes(Ba))throw new Error(`gltf: Required extension ${Ba} not supported by browser`);return}let{json:s}=r;for(let i of s.textures||[]){let n=r.getObjectExtension(i,Ba);n&&(i.source=n.source),r.removeObjectExtension(i,Ba)}r.removeExtension(Ba)}var vT={};Ke(vT,{name:()=>x7,preprocess:()=>A7});var zg="KHR_texture_basisu",x7=zg;function A7(t,e){let r=new Te(t),{json:s}=r;for(let i of s.textures||[]){let n=r.getObjectExtension(i,zg);n&&(i.source=n.source,r.removeObjectExtension(i,zg))}r.removeExtension(zg)}var RT={};Ke(RT,{decode:()=>N7,encode:()=>D7,name:()=>F7,preprocess:()=>L7});var a2="4.2.0-beta.2";var c2={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:a2,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function u2(t,e,r){let s=f2(e.metadata),i=[],n=T7(e.attributes);for(let o in t){let a=t[o],c=l2(o,a,n[o]);i.push(c)}if(r){let o=l2("indices",r);i.push(o)}return{fields:i,metadata:s}}function T7(t){let e={};for(let r in t){let s=t[r];e[s.name||"undefined"]=s}return e}function l2(t,e,r){let s=r?f2(r.metadata):void 0;return K_(t,e,s)}function f2(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var h2={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},b7={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},E7=4,xf=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let s=new this.draco.DecoderBuffer;s.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let i=this.decoder.GetEncodedGeometryType(s),n=i===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let o;switch(i){case this.draco.TRIANGULAR_MESH:o=this.decoder.DecodeBufferToMesh(s,n);break;case this.draco.POINT_CLOUD:o=this.decoder.DecodeBufferToPointCloud(s,n);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!o.ok()||!n.ptr){let h=`DRACO decompression failed: ${o.error_msg()}`;throw new Error(h)}let a=this._getDracoLoaderData(n,i,r),c=this._getMeshData(n,a,r),l=Is(c.attributes),u=u2(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:n.num_points(),boundingBox:l},...c,schema:u}}finally{this.draco.destroy(s),n&&this.draco.destroy(n)}}_getDracoLoaderData(e,r,s){let i=this._getTopLevelMetadata(e),n=this._getDracoAttributes(e,s);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:i,attributes:n}}_getDracoAttributes(e,r){let s={};for(let i=0;ithis.decoder[o]).includes(i)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(e))return{quantization_bits:o.quantization_bits(),range:o.range(),min_values:new Float32Array([1,2,3]).map(a=>o.min_value(a))}}finally{this.draco.destroy(o)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:s=[]}=r,i=e.attribute_type();if(s.map(o=>this.decoder[o]).includes(i)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(e))return{quantization_bits:o.quantization_bits()}}finally{this.draco.destroy(o)}}return null}};function S7(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function v7(t){let e=t.size(),r=new Int32Array(e);for(let s=0;s({draco:r})):PT||=M7(t),await PT}async function M7(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await os(wT[Xt.FALLBACK_DECODER],"draco",t,Xt.FALLBACK_DECODER);break;case"wasm":default:[e,r]=await Promise.all([await os(wT[Xt.DECODER],"draco",t,Xt.DECODER),await os(wT[Xt.DECODER_WASM],"draco",t,Xt.DECODER_WASM)])}return e=e||globalThis.DracoDecoderModule,await R7(e,r)}function R7(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(s=>{t({...r,onModuleLoaded:i=>s({draco:i})})})}var Hg={...c2,parse:I7};async function I7(t,e){let{draco:r}=await d2(e),s=new xf(r);try{return s.parseSync(t,e?.draco)}finally{s.destroy()}}function p2(t){let e={};for(let r in t){let s=t[r];if(r!=="indices"){let i=MT(s);e[r]=i}}return e}function MT(t){let{buffer:e,size:r,count:s}=B7(t);return{value:e,size:r,byteOffset:0,count:s,type:Fg(r),componentType:Ca(e)}}function B7(t){let e=t,r=1,s=0;return t&&t.value&&(e=t.value,r=t.size||1),e&&(ArrayBuffer.isView(e)||(e=O7(e,Float32Array)),s=e.length/r),{buffer:e,size:r,count:s}}function O7(t,e,r=!1){return t?Array.isArray(t)?new e(t):r&&!(t instanceof e)?new e(t):t:null}var $i="KHR_draco_mesh_compression",F7=$i;function L7(t,e,r){let s=new Te(t);for(let i of g2(s))s.getObjectExtension(i,$i)}async function N7(t,e,r){if(!e?.gltf?.decompressMeshes)return;let s=new Te(t),i=[];for(let n of g2(s))s.getObjectExtension(n,$i)&&i.push(U7(s,n,e,r));await Promise.all(i),s.removeExtension($i)}function D7(t,e={}){let r=new Te(t);for(let s of r.json.meshes||[])k7(s,e),r.addRequiredExtension($i)}async function U7(t,e,r,s){let i=t.getObjectExtension(e,$i);if(!i)return;let n=t.getTypedArrayForBufferView(i.bufferView),o=cn(n.buffer,n.byteOffset),a={...r};delete a["3d-tiles"];let c=await Kt(o,Hg,a,s),l=p2(c.attributes);for(let[u,f]of Object.entries(l))if(u in e.attributes){let h=e.attributes[u],d=t.getAccessor(h);d?.min&&d?.max&&(f.min=d.min,f.max=d.max)}e.attributes=l,c.indices&&(e.indices=MT(c.indices)),t.removeObjectExtension(e,$i),V7(e)}function k7(t,e,r=4,s,i){if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let n=s.DracoWriter.encodeSync({attributes:t}),o=i?.parseSync?.({attributes:t}),a=s._addFauxAttributes(o.attributes),c=s.addBufferView(n);return{primitives:[{attributes:a,mode:r,extensions:{[$i]:{bufferView:c,attributes:a}}}]}}function V7(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*g2(t){for(let e of t.json.meshes||[])for(let r of e.primitives)yield r}var IT={};Ke(IT,{decode:()=>W7,name:()=>z7});var Wg="KHR_texture_transform",z7=Wg,Gg=new w,H7=new me,G7=new me;async function W7(t,e){if(!new Te(t).hasExtension(Wg)||!e.gltf?.loadBuffers)return;let i=t.json.materials||[];for(let n=0;no===s&&a===i)!==-1)){let o=J7(r);return s!==i&&(t.texCoord=i),e.push([s,i]),{originalTexCoord:s,texCoord:i,matrix:o}}return null}function q7(t,e,r){let{originalTexCoord:s,texCoord:i,matrix:n}=r,o=e.attributes[`TEXCOORD_${s}`];if(Number.isFinite(o)){let a=t.json.accessors?.[o];if(a&&a.bufferView){let c=t.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:u}=t.buffers[c.buffer],f=(u||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:d}=wa(a,c),p=Og[a.componentType],g=Bg[a.type],m=c.byteStride||p*g,_=new Float32Array(d);for(let y=0;yQ7,encode:()=>eY,name:()=>Z7});var no="KHR_lights_punctual",Z7=no;async function Q7(t){let e=new Te(t),{json:r}=e,s=e.getExtension(no);s&&(e.json.lights=s.lights,e.removeExtension(no));for(let i of r.nodes||[]){let n=e.getObjectExtension(i,no);n&&(i.light=n.light),e.removeObjectExtension(i,no)}}async function eY(t){let e=new Te(t),{json:r}=e;if(r.lights){let s=e.addExtension(no);nt(!s.lights),s.lights=r.lights,delete r.lights}if(e.json.lights){for(let s of e.json.lights){let i=s.node;e.addObjectExtension(i,no,s)}delete e.json.lights}}var OT={};Ke(OT,{decode:()=>rY,encode:()=>sY,name:()=>tY});var Af="KHR_materials_unlit",tY=Af;async function rY(t){let e=new Te(t),{json:r}=e;for(let s of r.materials||[])s.extensions&&s.extensions.KHR_materials_unlit&&(s.unlit=!0),e.removeObjectExtension(s,Af);e.removeExtension(Af)}function sY(t){let e=new Te(t),{json:r}=e;if(e.materials)for(let s of r.materials||[])s.unlit&&(delete s.unlit,e.addObjectExtension(s,Af,{}),e.addExtension(Af))}var FT={};Ke(FT,{decode:()=>nY,encode:()=>oY,name:()=>iY});var Tf="KHR_techniques_webgl",iY=Tf;async function nY(t){let e=new Te(t),{json:r}=e,s=e.getExtension(Tf);if(s){let i=aY(s,e);for(let n of r.materials||[]){let o=e.getObjectExtension(n,Tf);o&&(n.technique=Object.assign({},o,i[o.technique]),n.technique.values=cY(n.technique,e)),e.removeObjectExtension(n,Tf)}e.removeExtension(Tf)}}async function oY(t,e){}function aY(t,e){let{programs:r=[],shaders:s=[],techniques:i=[]}=t,n=new TextDecoder;return s.forEach(o=>{if(Number.isFinite(o.bufferView))o.code=n.decode(e.getTypedArrayForBufferView(o.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(o=>{o.fragmentShader=s[o.fragmentShader],o.vertexShader=s[o.vertexShader]}),i.forEach(o=>{o.program=r[o.program]}),i}function cY(t,e){let r=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(s=>{t.uniforms[s].value&&!(s in r)&&(r[s]=t.uniforms[s].value)}),Object.keys(r).forEach(s=>{typeof r[s]=="object"&&r[s].index!==void 0&&(r[s].texture=e.getTexture(r[s].index))}),r}var m2=[mT,dT,ET,ST,vT,RT,BT,OT,FT,IT,_T];function _2(t,e={},r){let s=m2.filter(i=>x2(i.name,e));for(let i of s)i.preprocess?.(t,e,r)}async function y2(t,e={},r){let s=m2.filter(i=>x2(i.name,e));for(let i of s)await i.decode?.(t,e,r)}function x2(t,e){let r=e?.gltf?.excludeExtensions||{};return!(t in r&&!r[t])}var LT="KHR_binary_glTF";function A2(t){let e=new Te(t),{json:r}=e;for(let s of r.images||[]){let i=e.getObjectExtension(s,LT);i&&Object.assign(s,i),e.removeObjectExtension(s,LT)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,e.removeExtension(LT)}var T2={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},uY={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},NT=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,r){this.json=e.json;let s=e.json;switch(s.asset&&s.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${s.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(s),this._convertTopLevelObjectsToArrays(s),A2(e),this._convertObjectIdsToArrayIndices(s),this._updateObjects(s),this._updateMaterial(s)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(let r in T2)this._convertTopLevelObjectToArray(e,r)}_convertTopLevelObjectToArray(e,r){let s=e[r];if(!(!s||Array.isArray(s))){e[r]=[];for(let i in s){let n=s[i];n.id=n.id||i;let o=e[r].length;e[r].push(n),this.idToIndexMap[r][i]=o}}}_convertObjectIdsToArrayIndices(e){for(let r in T2)this._convertIdsToIndices(e,r);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(let r of e.textures)this._convertTextureIds(r);for(let r of e.meshes)this._convertMeshIds(r);for(let r of e.nodes)this._convertNodeIds(r);for(let r of e.scenes)this._convertSceneIds(r)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(let r of e.primitives){let{attributes:s,indices:i,material:n}=r;for(let o in s)s[o]=this._convertIdToIndex(s[o],"accessor");i&&(r.indices=this._convertIdToIndex(i,"accessor")),n&&(r.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(r=>this._convertIdToIndex(r,"node"))),e.meshes&&(e.meshes=e.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(e,r){e[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),e[r]=[]);for(let s of e[r])for(let i in s){let n=s[i],o=this._convertIdToIndex(n,i);s[i]=o}}_convertIdToIndex(e,r){let s=uY[r];if(s in this.idToIndexMap){let i=this.idToIndexMap[s][e];if(!Number.isFinite(i))throw new Error(`gltf v1: failed to resolve ${r} with id ${e}`);return i}return e}_updateObjects(e){for(let r of this.json.buffers)delete r.type}_updateMaterial(e){for(let r of e.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let s=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,i=e.textures.findIndex(n=>n.id===s);i!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:i})}}};function b2(t,e={}){return new NT().normalize(t,e)}async function E2(t,e,r=0,s,i){return fY(t,e,r,s),b2(t,{normalize:s?.gltf?.normalize}),_2(t,s,i),s?.gltf?.loadBuffers&&t.json.buffers&&await hY(t,s,i),s?.gltf?.loadImages&&await dY(t,s,i),await y2(t,s,i),t}function fY(t,e,r,s){if(s.uri&&(t.baseUri=s.uri),e instanceof ArrayBuffer&&!i2(e,r,s)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=B_(e);else if(e instanceof ArrayBuffer){let o={};r=n2(o,e,r,s.glb),nt(o.type==="glTF",`Invalid GLB magic string ${o.type}`),t._glb=o,t.json=o.json}else nt(!1,"GLTF: must be ArrayBuffer or string");let i=t.json.buffers||[];if(t.buffers=new Array(i.length).fill(null),t._glb&&t._glb.header.hasBinChunk){let{binChunks:o}=t._glb;t.buffers[0]={arrayBuffer:o[0].arrayBuffer,byteOffset:o[0].byteOffset,byteLength:o[0].byteLength}}let n=t.json.images||[];t.images=new Array(n.length).fill({})}async function hY(t,e,r){let s=t.json.buffers||[];for(let i=0;ithis._resolveBufferView(i,n))),e.images&&(s.images=e.images.map((i,n)=>this._resolveImage(i,n))),e.samplers&&(s.samplers=e.samplers.map((i,n)=>this._resolveSampler(i,n))),e.textures&&(s.textures=e.textures.map((i,n)=>this._resolveTexture(i,n))),e.accessors&&(s.accessors=e.accessors.map((i,n)=>this._resolveAccessor(i,n))),e.materials&&(s.materials=e.materials.map((i,n)=>this._resolveMaterial(i,n))),e.meshes&&(s.meshes=e.meshes.map((i,n)=>this._resolveMesh(i,n))),e.nodes&&(s.nodes=e.nodes.map((i,n)=>this._resolveNode(i,n)),s.nodes=s.nodes.map((i,n)=>this._resolveNodeChildren(i))),e.skins&&(s.skins=e.skins.map((i,n)=>this._resolveSkin(i,n))),e.scenes&&(s.scenes=e.scenes.map((i,n)=>this._resolveScene(i,n))),typeof this.json.scene=="number"&&s.scenes&&(s.scene=s.scenes[this.json.scene]),s}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,r){if(typeof r=="object")return r;let s=e&&e[r];return s||console.warn(`glTF file error: Could not find ${e}[${r}]`),s}_resolveScene(e,r){return{...e,id:e.id||`scene-${r}`,nodes:(e.nodes||[]).map(s=>this.getNode(s))}}_resolveNode(e,r){let s={...e,id:e?.id||`node-${r}`};return e.mesh!==void 0&&(s.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(s.camera=this.getCamera(e.camera)),e.skin!==void 0&&(s.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(s.mesh=e.meshes.reduce((i,n)=>{let o=this.getMesh(n);return i.id=o.id,i.primitives=i.primitives.concat(o.primitives),i},{primitives:[]})),s}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(r=>this.getNode(r))),e}_resolveSkin(e,r){let s=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${r}`,inverseBindMatrices:s}}_resolveMesh(e,r){let s={...e,id:e.id||`mesh-${r}`,primitives:[]};return e.primitives&&(s.primitives=e.primitives.map(i=>{let n={...i,attributes:{},indices:void 0,material:void 0},o=i.attributes;for(let a in o)n.attributes[a]=this.getAccessor(o[a]);return i.indices!==void 0&&(n.indices=this.getAccessor(i.indices)),i.material!==void 0&&(n.material=this.getMaterial(i.material)),n})),s}_resolveMaterial(e,r){let s={...e,id:e.id||`material-${r}`};if(s.normalTexture&&(s.normalTexture={...s.normalTexture},s.normalTexture.texture=this.getTexture(s.normalTexture.index)),s.occlusionTexture&&(s.occlusionTexture={...s.occlusionTexture},s.occlusionTexture.texture=this.getTexture(s.occlusionTexture.index)),s.emissiveTexture&&(s.emissiveTexture={...s.emissiveTexture},s.emissiveTexture.texture=this.getTexture(s.emissiveTexture.index)),s.emissiveFactor||(s.emissiveFactor=s.emissiveTexture?[1,1,1]:[0,0,0]),s.pbrMetallicRoughness){s.pbrMetallicRoughness={...s.pbrMetallicRoughness};let i=s.pbrMetallicRoughness;i.baseColorTexture&&(i.baseColorTexture={...i.baseColorTexture},i.baseColorTexture.texture=this.getTexture(i.baseColorTexture.index)),i.metallicRoughnessTexture&&(i.metallicRoughnessTexture={...i.metallicRoughnessTexture},i.metallicRoughnessTexture.texture=this.getTexture(i.metallicRoughnessTexture.index))}return s}_resolveAccessor(e,r){let s=bY(e.componentType),i=EY(e.type),n=s*i,o={...e,id:e.id||`accessor-${r}`,bytesPerComponent:s,components:i,bytesPerElement:n,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(o.bufferView=this.getBufferView(e.bufferView)),o.bufferView){let a=o.bufferView.buffer,{ArrayType:c,byteLength:l}=wa(o,o.bufferView),u=(o.bufferView.byteOffset||0)+(o.byteOffset||0)+a.byteOffset,f=a.arrayBuffer.slice(u,u+l);o.bufferView.byteStride&&(f=this._getValueFromInterleavedBuffer(a,u,o.bufferView.byteStride,o.bytesPerElement,o.count)),o.value=new c(f)}return o}_getValueFromInterleavedBuffer(e,r,s,i,n){let o=new Uint8Array(n*i);for(let a=0;a{r.traverse(s=>{Object.values(s.model.uniforms).forEach(i=>{i.loaded===!1&&e.push(i)})})}),await SY(()=>e.some(r=>!r.loaded))}async function SY(t){for(;t();)await new Promise(e=>requestAnimationFrame(e))}var v2=`#version 300 es #define SHADER_NAME scenegraph-layer-vertex-shader in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; uniform float sizeScale; uniform float sizeMinPixels; uniform float sizeMaxPixels; uniform mat4 sceneModelMatrix; uniform bool composeModelMatrix; in vec3 positions; #ifdef HAS_UV in vec2 texCoords; #endif #ifdef MODULE_PBR #ifdef HAS_NORMALS in vec3 normals; #endif #endif out vec4 vColor; #ifndef MODULE_PBR #ifdef HAS_UV out vec2 vTEXCOORD_0; #endif #endif void main(void) { #if defined(HAS_UV) && !defined(MODULE_PBR) vTEXCOORD_0 = texCoords; geometry.uv = texCoords; #endif geometry.worldPosition = instancePositions; geometry.pickingColor = instancePickingColors; mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 normal = vec3(0.0, 0.0, 1.0); #ifdef MODULE_PBR #ifdef HAS_NORMALS normal = instanceModelMatrix * (sceneModelMatrix * vec4(normals, 0.0)).xyz; #endif #endif float originalSize = project_size_to_pixel(sizeScale); float clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels); vec3 pos = (instanceModelMatrix * (sceneModelMatrix * vec4(positions, 1.0)).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation; if(composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); geometry.normal = project_normal(normal); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position); } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position); geometry.normal = project_normal(normal); } DECKGL_FILTER_GL_POSITION(gl_Position, geometry); #ifdef MODULE_PBR pbr_vPosition = geometry.position.xyz; #ifdef HAS_NORMALS pbr_vNormal = geometry.normal; #endif #ifdef HAS_UV pbr_vUV = texCoords; #else pbr_vUV = vec2(0., 0.); #endif geometry.uv = pbr_vUV; #endif vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); } `;var C2=`#version 300 es #define SHADER_NAME scenegraph-layer-fragment-shader uniform float opacity; in vec4 vColor; out vec4 fragColor; #ifndef MODULE_PBR #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) in vec2 vTEXCOORD_0; uniform sampler2D u_BaseColorSampler; #endif #endif void main(void) { #ifdef MODULE_PBR fragColor = vColor * pbr_filterColor(vec4(0)); geometry.uv = pbr_vUV; #else #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) fragColor = vColor * texture(u_BaseColorSampler, vTEXCOORD_0); geometry.uv = vTEXCOORD_0; #else fragColor = vColor; #endif #endif fragColor.a *= opacity; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var w2=[255,255,255,255],vY={scenegraph:{type:"object",value:null,async:!0},getScene:t=>t&&t.scenes?typeof t.scene=="object"?t.scene:t.scenes[t.scene||0]:t,getAnimator:t=>t&&t.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:w2},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[Zs]},bf=class extends he{getShaders(){let e=[de,_e];return this.props._lighting==="pbr"&&e.push(An),super.getShaders({vs:v2,fs:C2,modules:e})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:w2,transition:!0},instanceModelMatrix:vg})}updateState(e){super.updateState(e);let{props:r,oldProps:s}=e;r.scenegraph!==s.scenegraph?this._updateScenegraph():r._animations!==s._animations&&this._applyAnimationsProp(this.state.animator,r._animations)}finalizeState(e){super.finalizeState(e),this.state.scenegraph?.destroy()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){let e=this.props,{device:r}=this.context,s=null;if(e.scenegraph instanceof yr)s={scenes:[e.scenegraph]};else if(e.scenegraph&&typeof e.scenegraph=="object"){let a=e.scenegraph,c=a.json?oo(a):a,l=hT(r,c,this._getModelOptions());s={gltf:c,...l},S2(l).then(()=>{this.setNeedsRedraw()}).catch(u=>{this.raiseError(u,"loading glTF")})}let i={layer:this,device:this.context.device},n=e.getScene(s,i),o=e.getAnimator(s,i);if(n instanceof tr){this.state.scenegraph?.destroy(),this._applyAnimationsProp(o,e._animations);let a=[];n.traverse(c=>{c instanceof ds&&a.push(c.model)}),this.setState({scenegraph:n,animator:o,models:a}),this.getAttributeManager().invalidateAll()}else n!==null&&k.warn("invalid scenegraph:",n)()}_applyAnimationsProp(e,r){if(!e||!r)return;let s=e.getAnimations();Object.keys(r).sort().forEach(i=>{let n=r[i];if(i==="*")s.forEach(o=>{Object.assign(o,n)});else if(Number.isFinite(Number(i))){let o=Number(i);o>=0&&oa===i);o?Object.assign(o,n):k.warn(`animation ${i} not found`)()}})}_getModelOptions(){let{_imageBasedLightingEnvironment:e}=this.props,r;return e&&(typeof e=="function"?r=e({gl:this.context.gl,layer:this}):r=e),{imageBasedLightingEnvironment:r,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(e.timeline.getTime()),this.setNeedsRedraw());let{viewport:r,renderPass:s}=this.context,{sizeScale:i,sizeMinPixels:n,sizeMaxPixels:o,opacity:a,coordinateSystem:c}=this.props,l=this.getNumInstances();this.state.scenegraph.traverse((u,{worldMatrix:f})=>{if(u instanceof ds){let{model:h}=u;h.setInstanceCount(l),h.setUniforms({sizeScale:i,opacity:a,sizeMinPixels:n,sizeMaxPixels:o,composeModelMatrix:Cg(r,c),sceneModelMatrix:f,u_Camera:h.uniforms.project_uCameraPosition}),h.draw(s)}})}};bf.defaultProps=vY;bf.layerName="ScenegraphLayer";var jg=bf;var P2=`#version 300 es #define SHADER_NAME simple-mesh-layer-vs uniform float sizeScale; uniform bool composeModelMatrix; uniform bool pickFeatureIds; in vec3 positions; in vec3 normals; in vec3 colors; in vec2 texCoords; in vec4 uvRegions; in vec3 featureIdsPickingColors; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; out vec2 vTexCoord; out vec3 cameraPosition; out vec3 normals_commonspace; out vec4 position_commonspace; out vec4 vColor; vec2 applyUVRegion(vec2 uv) { #ifdef HAS_UV_REGIONS return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy; #else return uv; #endif } void main(void) { vec2 uv = applyUVRegion(texCoords); geometry.uv = uv; if (pickFeatureIds) { geometry.pickingColor = featureIdsPickingColors; } else { geometry.pickingColor = instancePickingColors; } mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vTexCoord = uv; cameraPosition = project_uCameraPosition; vColor = vec4(colors * instanceColors.rgb, instanceColors.a); vec3 pos = (instanceModelMatrix * positions) * sizeScale; vec3 projectedPosition = project_position(positions); position_commonspace = vec4(projectedPosition, 1.0); gl_Position = project_common_position_to_clipspace(position_commonspace); geometry.position = position_commonspace; normals_commonspace = project_normal(instanceModelMatrix * normals); geometry.normal = normals_commonspace; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); #ifdef MODULE_PBR pbr_vPosition = geometry.position.xyz; #ifdef HAS_NORMALS pbr_vNormal = geometry.normal; #endif #ifdef HAS_UV pbr_vUV = uv; #else pbr_vUV = vec2(0., 0.); #endif geometry.uv = pbr_vUV; #endif DECKGL_FILTER_COLOR(vColor, geometry); } `;var M2=`#version 300 es #define SHADER_NAME simple-mesh-layer-fs precision highp float; uniform bool hasTexture; uniform sampler2D sampler; uniform bool flatShading; uniform float opacity; in vec2 vTexCoord; in vec3 cameraPosition; in vec3 normals_commonspace; in vec4 position_commonspace; in vec4 vColor; out vec4 fragColor; void main(void) { #ifdef MODULE_PBR fragColor = vColor * pbr_filterColor(vec4(0)); geometry.uv = pbr_vUV; fragColor.a *= opacity; #else geometry.uv = vTexCoord; vec3 normal; if (flatShading) { normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); } else { normal = normals_commonspace; } vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor; vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); fragColor = vec4(lightColor, color.a * opacity); #endif DECKGL_FILTER_COLOR(fragColor, geometry); } `;function CY(t){let e=t.positions||t.POSITION,r=e.value.length/e.size;t.COLOR_0||t.colors||(t.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var wY={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},Ef=class extends so{getShaders(){let e=super.getShaders();return e.modules.push(An),{...e,vs:P2,fs:M2}}initializeState(){let{featureIds:e}=this.props;super.initializeState();let r=this.getAttributeManager();e&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);let{props:r,oldProps:s}=e;r.pbrMaterial!==s.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(e){let{featureIds:r}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:Boolean(r)}),super.draw(e))}getModel(e){let{id:r,pbrMaterial:s}=this.props,i=this.parseMaterial(s,e);this.setState({parsedPBRMaterial:i});let n=this.getShaders();return CY(e.attributes),new J(this.context.device,{...this.getShaders(),id:r,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...n.defines,...i?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:i?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){let{model:r}=this.state;if(r){let{mesh:s}=this.props,i=this.parseMaterial(e,s);this.setState({parsedPBRMaterial:i}),r.setBindings(i.bindings),r.setUniforms(i.uniforms)}}parseMaterial(e,r){let s=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return mf(this.context.device,{unlit:s,...e},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){let r=this.props.featureIds,s=new Uint8ClampedArray(r.length*e.size),i=[];for(let n=0;nr.destroy()),this.setState({parsedPBRMaterial:null})}};Ef.layerName="MeshLayer";Ef.defaultProps=wY;var R2=Ef;var Qs=6356752314245179e-9,PY={radii:[6378137,6378137,Qs],radiiSquared:[6378137*6378137,6378137*6378137,Qs*Qs],oneOverRadii:[1/6378137,1/6378137,1/Qs],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(Qs*Qs)],maximumRadius:Math.max(6378137,6378137,Qs),centerToleranceSquared:.1};function Xg(t){return t}var aIe=new w;function MY(t,e=[],r=Xg){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function I2(t,e=[]){return MY(t,e,Se._cartographicRadians?Xg:vy)}function RY(t,e,r=Xg){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function B2(t,e){return RY(t,e,Se._cartographicRadians?Xg:Cy)}var O2=1e-14,IY=new w,F2={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},UT={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Sf={east:new w,north:new w,up:new w,west:new w,south:new w,down:new w},BY=new w,OY=new w,FY=new w;function kT(t,e,r,s,i,n){let o=F2[e]&&F2[e][r];ut(o&&(!s||s===o));let a,c,l,u=IY.copy(i);if(Ce(u.x,0,O2)&&Ce(u.y,0,O2)){let h=Math.sign(u.z);a=BY.fromArray(UT[e]),e!=="east"&&e!=="west"&&a.scale(h),c=OY.fromArray(UT[r]),r!=="east"&&r!=="west"&&c.scale(h),l=FY.fromArray(UT[s]),s!=="east"&&s!=="west"&&l.scale(h)}else{let{up:h,east:d,north:p}=Sf;d.set(-u.y,u.x,0).normalize(),t.geodeticSurfaceNormal(u,h),p.copy(h).cross(d);let{down:g,west:m,south:_}=Sf;g.copy(h).scale(-1),m.copy(d).scale(-1),_.copy(p).scale(-1),a=Sf[e],c=Sf[r],l=Sf[s]}return n[0]=a.x,n[1]=a.y,n[2]=a.z,n[3]=0,n[4]=c.x,n[5]=c.y,n[6]=c.z,n[7]=0,n[8]=l.x,n[9]=l.y,n[10]=l.z,n[11]=0,n[12]=u.x,n[13]=u.y,n[14]=u.z,n[15]=1,n}var Oa=new w,LY=new w,NY=new w;function L2(t,e,r=[]){let{oneOverRadii:s,oneOverRadiiSquared:i,centerToleranceSquared:n}=e;Oa.from(t);let o=Oa.x,a=Oa.y,c=Oa.z,l=s.x,u=s.y,f=s.z,h=o*o*l*l,d=a*a*u*u,p=c*c*f*f,g=h+d+p,m=Math.sqrt(1/g);if(!Number.isFinite(m))return;let _=LY;if(_.copy(t).scale(m),gdr.EPSILON12);return Oa.scale([M,v,T]).to(r)}var Yg=new w,N2=new w,kY=new w,Jr=new w,VY=new w,qg=new w,oe=class{constructor(e=0,r=0,s=0){this.centerToleranceSquared=dr.EPSILON1,ut(e>=0),ut(r>=0),ut(s>=0),this.radii=new w(e,r,s),this.radiiSquared=new w(e*e,r*r,s*s),this.radiiToTheFourth=new w(e*e*e*e,r*r*r*r,s*s*s*s),this.oneOverRadii=new w(e===0?0:1/e,r===0?0:1/r,s===0?0:1/s),this.oneOverRadiiSquared=new w(e===0?0:1/(e*e),r===0?0:1/(r*r),s===0?0:1/(s*s)),this.minimumRadius=Math.min(e,r,s),this.maximumRadius=Math.max(e,r,s),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let s=N2,i=kY,[,,n]=e;this.geodeticSurfaceNormalCartographic(e,s),i.copy(this.radiiSquared).scale(s);let o=Math.sqrt(s.dot(i));return i.scale(1/o),s.scale(n),i.add(s),i.to(r)}cartesianToCartographic(e,r=[0,0,0]){qg.from(e);let s=this.scaleToGeodeticSurface(qg,Jr);if(!s)return;let i=this.geodeticSurfaceNormal(s,N2),n=VY;n.copy(qg).subtract(s);let o=Math.atan2(i.y,i.x),a=Math.asin(i.z),c=Math.sign(We.dot(n,qg))*We.length(n);return B2([o,a,c],r)}eastNorthUpToFixedFrame(e,r=new q){return kT(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,s,i,n=new q){return kT(this,e,r,s,i,n)}geocentricSurfaceNormal(e,r=[0,0,0]){return Yg.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let s=I2(e),i=s[0],n=s[1],o=Math.cos(n);return Yg.set(o*Math.cos(i),o*Math.sin(i),Math.sin(n)).normalize(),Yg.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Yg.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return L2(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){Jr.from(e);let s=Jr.x,i=Jr.y,n=Jr.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(s*s*o.x+i*i*o.y+n*n*o.z);return Jr.multiplyScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return Jr.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return Jr.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,s=[0,0,0]){ut(Ce(this.radii.x,this.radii.y,dr.EPSILON15)),ut(this.radii.z>0),Jr.from(e);let i=Jr.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-r))return Jr.set(0,0,i).to(s)}};oe.WGS84=new oe(6378137,6378137,Qs);var Kg=class{item;previous;next;constructor(e,r,s){this.item=e,this.previous=r,this.next=s}};var $g=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new Kg(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let s=e.next;e.next=r,this.tail===e?this.tail=r:s.previous=r,r.next=s,r.previous=e,++this._length}};var Jg=class{_list;_sentinel;_trimTiles;constructor(){this._list=new $g,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,s){r._cacheNode||(r._cacheNode=this._list.add(r),s&&s(e,r))}unloadTile(e,r,s){let i=r._cacheNode;i&&(this._list.remove(i),r._cacheNode=null,s&&s(e,r))}unloadTiles(e,r){let s=this._trimTiles;this._trimTiles=!1;let i=this._list,n=e.maximumMemoryUsage*1024*1024,o=this._sentinel,a=i.head;for(;a!==o&&(e.gpuMemoryUsageInBytes>n||s);){let c=a.item;a=a.next,this.unloadTile(e,c,r)}}trim(){this._trimTiles=!0}};function D2(t,e){ne(t),ne(e);let{rtcCenter:r,gltfUpAxis:s}=e,{computedTransform:i,boundingVolume:{center:n}}=t,o=new q(i);switch(r&&o.translate(r),s){case"Z":break;case"Y":let f=new q().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let h=new q().rotateY(-Math.PI/2);o=o.multiplyRight(h);break;default:break}e.isQuantized&&o.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new w(n);e.cartesianModelMatrix=o,e.cartesianOrigin=a;let c=oe.WGS84.cartesianToCartographic(a,new w),u=oe.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=u.multiplyRight(o),e.cartographicOrigin=c,e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var U2=new w,VT=new w,zT=new st([new ht,new ht,new ht,new ht,new ht,new ht]);function V2(t,e){let{cameraDirection:r,cameraUp:s,height:i}=t,{metersPerUnit:n}=t.distanceScales,o=Zg(t,t.center),a=oe.WGS84.eastNorthUpToFixedFrame(o),c=t.unprojectPosition(t.cameraPosition),l=oe.WGS84.cartographicToCartesian(c,new w),u=new w(a.transformAsVector(new w(r).scale(n))).normalize(),f=new w(a.transformAsVector(new w(s).scale(n))).normalize();zY(t);let h=t.constructor,{longitude:d,latitude:p,width:g,bearing:m,zoom:_}=t,y=new h({longitude:d,latitude:p,height:i,width:g,bearing:m,zoom:_,pitch:0});return{camera:{position:l,direction:u,up:f},viewport:t,topDownViewport:y,height:i,cullingVolume:zT,frameNumber:e,sseDenominator:1.15}}function z2(t,e,r){if(r===0||t.length<=r)return[t,[]];let s=[],{longitude:i,latitude:n}=e.viewport;for(let[l,u]of t.entries()){let[f,h]=u.header.mbs,d=Math.abs(i-f),p=Math.abs(n-h),g=Math.sqrt(p*p+d*d);s.push([l,g])}let o=s.sort((l,u)=>l[1]-u[1]),a=[];for(let l=0;l0?o.normalize():o=new w(0,1,0);let a=o.clone().cross(n);for(let c of[o,a,n]){Qg.copy(c).scale(s);for(let l=0;l<2;l++)Ct.copy(r),Ct.add(Qg),Z2(e,Ct),Qg.negate()}return e}function J2(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Z2(t,e){oe.WGS84.cartesianToCartographic(e,Ct),t[0][0]=Math.min(t[0][0],Ct[0]),t[0][1]=Math.min(t[0][1],Ct[1]),t[0][2]=Math.min(t[0][2],Ct[2]),t[1][0]=Math.max(t[1][0],Ct[0]),t[1][1]=Math.max(t[1][1],Ct[1]),t[1][2]=Math.max(t[1][2],Ct[2])}var YIe=new w,qIe=new w,KIe=new q,$Ie=new w,JIe=new w,ZIe=new w;function JY(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function ZY(t,e){if(t.dynamicScreenSpaceError&&t.dynamicScreenSpaceErrorComputedDensity){let r=t.dynamicScreenSpaceErrorComputedDensity,s=t.dynamicScreenSpaceErrorFactor;return JY(e,r)*s}return 0}function Q2(t,e,r){let s=t.tileset,i=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,n=r?i:t.lodMetricValue;if(n===0)return 0;let o=Math.max(t._distanceToCamera,1e-7),{height:a,sseDenominator:c}=e,{viewDistanceScale:l}=s.options,u=n*a*(l||1)/(o*c);return u-=ZY(s,o),u}var WT=new w,e3=new w,Ji=new w,t3=new w,QY=new w,jT=new q,r3=new q;function s3(t,e){if(t.lodMetricValue===0||isNaN(t.lodMetricValue))return"DIG";let r=2*XT(t,e);return r<2?"OUT":!t.header.children||r<=t.lodMetricValue?"DRAW":t.header.children?"DIG":"OUT"}function XT(t,e){let{topDownViewport:r}=e,s=t.header.mbs[1],i=t.header.mbs[0],n=t.header.mbs[2],o=t.header.mbs[3],a=[...t.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);oe.WGS84.cartographicToCartesian(c,WT),e3.copy(WT).subtract(a).normalize(),oe.WGS84.eastNorthUpToFixedFrame(a,jT),r3.copy(jT).invert(),Ji.copy(WT).transform(r3);let l=Math.sqrt(Ji[0]*Ji[0]+Ji[1]*Ji[1]),u=l*l/Ji[2];t3.copy([Ji[0],Ji[1],u]);let h=t3.transform(jT).subtract(a).normalize(),p=e3.cross(h).normalize().scale(o).add(a),g=oe.WGS84.cartesianToCartographic(p),m=r.project([i,s,n]),_=r.project(g);return QY.copy(m).subtract(_).magnitude()}function i3(t){return{assetGltfUpAxis:t.asset&&t.asset.gltfUpAxis||"Y"}}var vf=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return ne(e=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){ne(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){ne(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var eq={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Es=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new vf;_emptyTraversalStack=new vf;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...eq,...e}}traverse(e,r,s){this.root=e,this.options={...this.options,...s},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let s=this._traversalStack;for(e._selectionDepth=1,s.push(e);s.length>0;){let n=s.pop(),o=!1;this.canTraverse(n,r)&&(this.updateChildTiles(n,r),o=this.updateAndPushChildren(n,r,s,n.hasRenderContent?n._selectionDepth+1:n._selectionDepth));let a=n.parent,c=Boolean(!a||a._shouldRefine),l=!o;n.hasRenderContent?n.refine===vt.ADD?(this.loadTile(n,r),this.selectTile(n,r)):n.refine===vt.REPLACE&&(this.loadTile(n,r),l&&this.selectTile(n,r)):(this.emptyTiles[n.id]=n,this.loadTile(n,r),l&&this.selectTile(n,r)),this.touchTile(n,r),n._shouldRefine=o&&c}let i=new Date().getTime();(this.traversalFinished(r)||i-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=i,this.options.onTraversalEnd(r))}updateChildTiles(e,r){let s=e.children;for(let i of s)this.updateTile(i,r)}updateAndPushChildren(e,r,s,i){let{loadSiblings:n,skipLevelOfDetail:o}=this.options,a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===vt.REPLACE&&e.hasRenderContent&&!o,l=!1,u=!0;for(let f of a)if(f._selectionDepth=i,f.isVisibleAndInRequestVolume?(s.find(f)&&s.delete(f),s.push(f),l=!0):(c||n)&&(this.loadTile(f,r),this.touchTile(f,r)),c){let h;if(f._inRequestVolume?f.hasRenderContent?h=f.contentAvailable:h=this.executeEmptyTraversal(f,r):h=!1,u=u&&h,!u)return!1}return l||(u=!1),u}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){this.shouldLoadTile(e)&&(e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r,s=!1,i=!1){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:!i&&!e.isVisibleAndInRequestVolume?!1:this.shouldRefine(e,r,s):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,r,s=!1){let i=e._screenSpaceError;return s&&(i=e.getScreenSpaceError(r,!0)),i>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let s=[];if(this.options.viewportTraversersMap)for(let i in this.options.viewportTraversersMap)this.options.viewportTraversersMap[i]===r.viewport.id&&s.push(i);else s.push(r.viewport.id);e.updateVisibility(r,s)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let s=!1;for(let i of e.children)i.updateVisibility(r),s=s||i.isVisibleAndInRequestVolume;return s}executeEmptyTraversal(e,r){let s=!0,i=this._emptyTraversalStack;for(i.push(e);i.length>0;){let n=i.pop(),o=!n.hasRenderContent&&this.canTraverse(n,r,!1,!1),a=!n.hasRenderContent&&n.children.length===0;if(!o&&!n.contentAvailable&&!a&&(s=!1),this.updateTile(n,r),n.isVisibleAndInRequestVolume||(this.loadTile(n,r),this.touchTile(n,r)),o){let c=n.children;for(let l of c)i.push(l)}}return s}};var n3=new w;function tq(t){return t!=null}var co=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Dt.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new q;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Es({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new q;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(e,r,s,i=""){this.header=r,this.tileset=e,this.id=i||r.id,this.url=r.url,this.parent=s,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Dt.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Dt.UNLOADED}get contentExpired(){return this.contentState===Dt.EXPIRED}get contentFailed(){return this.contentState===Dt.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=K2(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,r){switch(this.tileset.type){case dt.I3S:return XT(this,e);case dt.TILES3D:return Q2(this,e,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let e=this.tileset._traverser,{skipLevelOfDetail:r}=e.options,s=this.refine===vt.ADD||r;if(s&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Dt.UNLOADED)return-1;let i=this.parent,o=i&&(!s||this._screenSpaceError===0||i.hasTilesetContent)?i._screenSpaceError:this._screenSpaceError,a=e.root?e.root._screenSpaceError:0;return Math.max(a-o,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Dt.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Dt.UNLOADED,!1;try{let s=this.tileset.getTileUrl(this.contentUrl),i=this.tileset.loader,n={...this.tileset.loadOptions,[i.id]:{...this.tileset.loadOptions[i.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(i.id)}};return this.content=await $e(s,i,n),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Dt.READY,this._onContentLoaded(),!0}catch(s){throw this.contentState=Dt.FAILED,s}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Dt.UNLOADED,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let s=this.parent,i=s?s._visibilityPlaneMask:st.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let n=s?s.computedTransform:this.tileset.modelMatrix;this._updateTransform(n)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,i),this._visible=this._visibilityPlaneMask!==st.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}visibility(e,r){let{cullingVolume:s}=e,{boundingVolume:i}=this;return s.computeVisibilityWithPlaneMask(i,r)}contentVisibility(){return!0}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return n3.subVectors(r.center,e.position),e.direction.dot(n3)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(tq(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=Dt.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new q(e.transform):new q;let r=this.parent,s=this.tileset,i=r&&r.computedTransform?r.computedTransform.clone():s.modelMatrix.clone();this.computedTransform=new q(i).multiplyRight(this.transform);let n=r&&r._initialTransform?r._initialTransform.clone():new q;this._initialTransform=new q(n).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Dt.UNLOADED,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=st.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||vt.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=em(e.boundingVolume,this.computedTransform,this.boundingVolume);let r=e.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=em(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=em(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new q){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return i3(this.tileset.tileset)}}};var tm=class extends Es{compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let s=e.children.length>0;if(e.hasTilesetContent&&s){let o=e.children[0];this.updateTileVisibility(o,r),e._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let i=e.refine===vt.REPLACE,n=e._optimChildrenWithinParent===W2.USE_OPTIMIZATION;if(i&&n&&s&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:s}=e;return!s||s.hasTilesetContent||s.refine!==vt.ADD?!1:!this.shouldRefine(e,r,!0)}};var rm=class{frameNumberMap=new Map;register(e,r){let s=this.frameNumberMap.get(e)||new Map,i=s.get(r)||0;s.set(r,i+1),this.frameNumberMap.set(e,s)}deregister(e,r){let s=this.frameNumberMap.get(e);if(!s)return;let i=s.get(r)||1;s.set(r,i-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var YT={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},sm=class{_statusMap;pendingTilesRegister=new rm;constructor(){this._statusMap={}}add(e,r,s,i){if(!this._statusMap[r]){let{frameNumber:n,viewport:{id:o}}=i;this._statusMap[r]={request:e,callback:s,key:r,frameState:i,status:YT.REQUESTED},this.pendingTilesRegister.register(o,n),e().then(a=>{this._statusMap[r].status=YT.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,i)}).catch(a=>{this._statusMap[r].status=YT.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),s(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:s,viewport:{id:i}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(i,s);let{frameNumber:n,viewport:{id:o}}=r;this.pendingTilesRegister.register(o,n),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var im=class extends Es{_tileManager;constructor(e){super(e),this._tileManager=new sm}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=s3(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let s=e.header.children||[],i=e.children,n=e.tileset;for(let o of s){let a=`${o.id}-${r.viewport.id}`,c=i&&i.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(o.id,n);this._tileManager.find(a)?this._tileManager.update(a,r):(n.tileset.nodePages&&(l=()=>n.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(l,a,f=>this._onTileLoad(f,e,a),r))}}return!1}async _loadTile(e,r){let{loader:s}=r,i=r.getTileUrl(`${r.url}/nodes/${e}`),n={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await $e(i,s,n)}_onTileLoad(e,r,s){let i=new co(r.tileset,e,r,s);r.children.push(i);let n=this._tileManager.find(i.id).frameState;this.updateTile(i,n),this._frameNumber===n.frameNumber&&(this.traversalFinished(n)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,n)}};var rq={description:"",ellipsoid:oe.WGS84,modelMatrix:new q,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},nm="Tiles In Tileset(s)",qT="Tiles In Memory",o3="Tiles In View",a3="Tiles To Render",c3="Tiles Loaded",KT="Tiles Loading",l3="Tiles Unloaded",u3="Failed Tile Loads",f3="Points/Vertices",$T="Tile Memory Use",h3="Maximum Screen Space Error",Cf=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Jg;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(e,r){this.options={...rq,...r},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||$t.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new ui({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new Tt({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let s=e;return this.queryParams.length&&(s=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),s}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytesthis._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let s=[];for(let i of r){let n=i.id;this._needTraverse(n)?s.push(n):this.traverseCounter--}for(let i of r){let n=i.id;if(this.roots[n]||(this.roots[n]=this._initializeTileHeaders(this.tileset,null)),!s.includes(n))continue;let o=V2(i,this._frameNumber);this._traverser.traverse(this.roots[n],o,this.options)}}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let s=this.frameStateData[r],i=Object.values(this._traverser.selectedTiles),[n,o]=z2(i,e,this.options.maximumTilesSelected);s.selectedTiles=n;for(let a of o)a.unselect();s._requestedTiles=Object.values(this._traverser.requestedTiles),s._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let e in this.frameStateData){let r=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(r.selectedTiles),this._requestedTiles=this._requestedTiles.concat(r._requestedTiles),this._emptyTiles=this._emptyTiles.concat(r._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(let e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let s=new Set(e.map(o=>o.id)),i=new Set(r.map(o=>o.id)),n=e.filter(o=>!i.has(o.id)).length>0;return n=n||r.filter(o=>!s.has(o.id)).length>0,n}_loadTiles(){for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r))}_updateStats(){let e=0,r=0;for(let s of this.selectedTiles)s.contentAvailable&&s.content&&(e++,s.content.pointCount?r+=s.content.pointCount:r+=s.content.vertexCount);this.stats.get(o3).count=this.selectedTiles.length,this.stats.get(a3).count=e,this.stats.get(f3).count=r,this.stats.get(h3).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===dt.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===dt.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===dt.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let e=this.tileset.fullExtent;if(e){let{xmin:s,xmax:i,ymin:n,ymax:o,zmin:a,zmax:c}=e;this.cartographicCenter=new w(s+(i-s)/2,n+(o-n)/2,a+(c-a)/2),this.cartesianCenter=new w,oe.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=GT(e,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[s,i,n,o]=r;this.cartographicCenter=new w(s+(n-s)/2,i+(o-i)/2,0),this.cartesianCenter=new w,oe.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=G2(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new w,this.zoom=1}calculateViewPropsTiles3D(){let e=this.root,{center:r}=e.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new w,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new w,oe.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new w(0,0,-oe.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=H2(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(nm),this.stats.get(KT),this.stats.get(qT),this.stats.get(o3),this.stats.get(a3),this.stats.get(c3),this.stats.get(l3),this.stats.get(u3),this.stats.get(f3),this.stats.get($T,"memory"),this.stats.get(h3)}_initializeTileHeaders(e,r){let s=new co(this,e.root,r);if(r&&(r.children.push(s),s.depth=r.depth+1),this.type===dt.TILES3D){let i=[];for(i.push(s);i.length>0;){let n=i.pop();this.stats.get(nm).incrementCount();let o=n.header.children||[];for(let a of o){let c=new co(this,a,n);if(c.contentUrl?.includes("?session=")){let u=new URL(c.contentUrl).searchParams.get("session");u&&(this._queryParams.session=u)}n.children.push(c),c.depth=n.depth+1,i.push(c)}}}return s}_initializeTraverser(){let e;switch(this.type){case dt.TILES3D:e=tm;break;case dt.I3S:e=im;break;default:e=Es}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r;try{this._onStartTileLoading(),r=await e.loadContent()}catch(s){this._onTileLoadError(e,s instanceof Error?s:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}_onTileLoadError(e,r){this.stats.get(u3).incrementCount();let s=r.message||r.toString(),i=e.url;console.error(`A 3D tile failed to load: ${e.url} ${s}`),this.options.onTileError(e,s,i)}_onTileLoad(e,r){if(r){if(this.type===dt.I3S){let s=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(nm).reset(),this.stats.get(nm).addCount(s)}e&&e.content&&D2(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===dt.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===dt.TILES3D){let{extensionsRemoved:r=[]}=e.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(KT).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(KT).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(c3).incrementCount(),this.stats.get(qT).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get($T).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(qT).decrementCount(),this.stats.get(l3).incrementCount(),this.stats.get($T).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let s of r.children)e.push(s);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,s=[];for(s.push(r);s.length>0;){e=s.pop();for(let i of e.children)s.push(i);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){let r=new URLSearchParams(e.queryString),s=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...s}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}};var om="4.2.0-beta.2";var lo={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},K2e=Object.keys(lo);function JT(t,e,r){ne(t instanceof ArrayBuffer);let s=new TextDecoder("utf8"),i=new Uint8Array(t,e,r);return s.decode(i)}function d3(t,e=0){let r=new DataView(t);return`${String.fromCharCode(r.getUint8(e+0))}${String.fromCharCode(r.getUint8(e+1))}${String.fromCharCode(r.getUint8(e+2))}${String.fromCharCode(r.getUint8(e+3))}`}var sq={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ye={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},re={...sq,...Ye};var ZT={[Ye.DOUBLE]:Float64Array,[Ye.FLOAT]:Float32Array,[Ye.UNSIGNED_SHORT]:Uint16Array,[Ye.UNSIGNED_INT]:Uint32Array,[Ye.UNSIGNED_BYTE]:Uint8Array,[Ye.BYTE]:Int8Array,[Ye.SHORT]:Int16Array,[Ye.INT]:Int32Array},iq={DOUBLE:Ye.DOUBLE,FLOAT:Ye.FLOAT,UNSIGNED_SHORT:Ye.UNSIGNED_SHORT,UNSIGNED_INT:Ye.UNSIGNED_INT,UNSIGNED_BYTE:Ye.UNSIGNED_BYTE,BYTE:Ye.BYTE,SHORT:Ye.SHORT,INT:Ye.INT},QT="Failed to convert GL type",wt=class{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(let r in ZT)if(ZT[r]===e)return r;throw new Error(QT)}static fromName(e){let r=iq[e];if(!r)throw new Error(QT);return r}static getArrayType(e){switch(e){case Ye.UNSIGNED_SHORT_5_6_5:case Ye.UNSIGNED_SHORT_4_4_4_4:case Ye.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=ZT[e];if(!r)throw new Error(QT);return r}}static getByteSize(e){return wt.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(wt.getArrayType(e))}static createTypedArray(e,r,s=0,i){i===void 0&&(i=(r.byteLength-s)/wt.getByteSize(e));let n=wt.getArrayType(e);return new n(r,s,i)}};function p3(t,e){if(!t)throw new Error(`math.gl assertion failed. ${e}`)}function eb(t,e=[0,0,0]){let r=t>>11&31,s=t>>5&63,i=t&31;return e[0]=r<<3,e[1]=s<<2,e[2]=i<<3,e}var o3e=1/256;var a3e=new Br,c3e=new w,l3e=new Br,u3e=new Br,f3e=new Uint8Array(1);function g3(t,e=255){return fe(t,0,e)/e*2-1}function m3(t){return t<0?-1:1}function _3(t,e,r,s){if(p3(s),t<0||t>r||e<0||e>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(s.x=g3(t,r),s.y=g3(e,r),s.z=1-(Math.abs(s.x)+Math.abs(s.y)),s.z<0){let i=s.x;s.x=(1-Math.abs(s.y))*m3(i),s.y=(1-Math.abs(i))*m3(s.y)}return s.normalize()}function tb(t,e,r){return _3(t,e,255,r)}var ti=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,r){this.json=e,this.buffer=r}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,r=re.UNSIGNED_INT,s=1){let i=this.json[e];return i&&Number.isFinite(i.byteOffset)?this._getTypedArrayFromBinary(e,r,s,1,i.byteOffset):i}getPropertyArray(e,r,s){let i=this.json[e];return i&&Number.isFinite(i.byteOffset)?("componentType"in i&&(r=wt.fromName(i.componentType)),this._getTypedArrayFromBinary(e,r,s,this.featuresLength,i.byteOffset)):this._getTypedArrayFromArray(e,r,i)}getProperty(e,r,s,i,n){let o=this.json[e];if(!o)return o;let a=this.getPropertyArray(e,r,s);if(s===1)return a[i];for(let c=0;ct[e],VEC2:(t,e)=>[t[2*e+0],t[2*e+1]],VEC3:(t,e)=>[t[3*e+0],t[3*e+1],t[3*e+2]],VEC4:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT2:(t,e)=>[t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]],MAT3:(t,e)=>[t[9*e+0],t[9*e+1],t[9*e+2],t[9*e+3],t[9*e+4],t[9*e+5],t[9*e+6],t[9*e+7],t[9*e+8]],MAT4:(t,e)=>[t[16*e+0],t[16*e+1],t[16*e+2],t[16*e+3],t[16*e+4],t[16*e+5],t[16*e+6],t[16*e+7],t[16*e+8],t[16*e+9],t[16*e+10],t[16*e+11],t[16*e+12],t[16*e+13],t[16*e+14],t[16*e+15]]},aq={SCALAR:(t,e,r)=>{e[r]=t},VEC2:(t,e,r)=>{e[2*r+0]=t[0],e[2*r+1]=t[1]},VEC3:(t,e,r)=>{e[3*r+0]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2]},VEC4:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT2:(t,e,r)=>{e[4*r+0]=t[0],e[4*r+1]=t[1],e[4*r+2]=t[2],e[4*r+3]=t[3]},MAT3:(t,e,r)=>{e[9*r+0]=t[0],e[9*r+1]=t[1],e[9*r+2]=t[2],e[9*r+3]=t[3],e[9*r+4]=t[4],e[9*r+5]=t[5],e[9*r+6]=t[6],e[9*r+7]=t[7],e[9*r+8]=t[8],e[9*r+9]=t[9]},MAT4:(t,e,r)=>{e[16*r+0]=t[0],e[16*r+1]=t[1],e[16*r+2]=t[2],e[16*r+3]=t[3],e[16*r+4]=t[4],e[16*r+5]=t[5],e[16*r+6]=t[6],e[16*r+7]=t[7],e[16*r+8]=t[8],e[16*r+9]=t[9],e[16*r+10]=t[10],e[16*r+11]=t[11],e[16*r+12]=t[12],e[16*r+13]=t[13],e[16*r+14]=t[14],e[16*r+15]=t[15]}};function y3(t,e,r,s){let{componentType:i}=t;ne(t.componentType);let n=typeof i=="string"?wt.fromName(i):i,o=nq[t.type],a=oq[t.type],c=aq[t.type];return r+=t.byteOffset,{values:wt.createTypedArray(n,e,r,o*s),type:n,size:o,unpacker:a,packer:c}}var Ss=t=>t!==void 0;function x3(t,e,r){if(!e)return null;let s=t.getExtension("3DTILES_batch_table_hierarchy"),i=e.HIERARCHY;return i&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),e.extensions=e.extensions||{},e.extensions["3DTILES_batch_table_hierarchy"]=i,s=i),s?cq(s,r):null}function cq(t,e){let r,s,i,n=t.instancesLength,o=t.classes,a=t.classIds,c=t.parentCounts,l=t.parentIds,u=n;Ss(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,i=getBinaryAccessor(a),a=i.createArrayBufferView(e.buffer,e.byteOffset+a.byteOffset,n));let f;if(Ss(c))for(Ss(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,i=getBinaryAccessor(c),c=i.createArrayBufferView(e.buffer,e.byteOffset+c.byteOffset,n)),f=new Uint16Array(n),u=0,r=0;r0?lq(t,e,r):uq(t,e,r)}function lq(t,e,r){let s=t.classIds,i=t.parentCounts,n=t.parentIds,o=t.parentIndexes,a=s.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,u=scratchStack;for(u.length=0,u.push(e);u.length>0;){if(e=u.pop(),c[e]===l)continue;c[e]=l;let f=r(t,e);if(Ss(f))return f;let h=i[e],d=o[e];for(let p=0;pt,hq={HIERARCHY:!0,extensions:!0,extras:!0},uo=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,r,s,i={}){ne(s>=0),this.json=e||{},this.binary=r,this.featureCount=s,this._extensions=this.json?.extensions||{},this._properties={};for(let n in this.json)hq[n]||(this._properties[n]=this.json[n]);this._binaryProperties=this._initializeBinaryProperties(),i["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=x3(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,r){if(this._checkBatchId(e),ne(typeof r=="string",r),this._hierarchy){let s=La(this._hierarchy,e,(i,n)=>{let o=i.classIds[n];return i.classes[o].name===r});return Yt(s)}return!1}isExactClass(e,r){return ne(typeof r=="string",r),this.getExactClassName(e)===r}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){let r=this._hierarchy.classIds[e];return this._hierarchy.classes[r].name}}hasProperty(e,r){return this._checkBatchId(e),ne(typeof r=="string",r),Yt(this._properties[r])||this._hasPropertyInHierarchy(e,r)}getPropertyNames(e,r){this._checkBatchId(e),r=Yt(r)?r:[],r.length=0;let s=Object.keys(this._properties);return r.push(...s),this._hierarchy&&this._getPropertyNamesInHierarchy(e,r),r}getProperty(e,r){if(this._checkBatchId(e),ne(typeof r=="string",r),this._binaryProperties){let i=this._binaryProperties[r];if(Yt(i))return this._getBinaryProperty(i,e)}let s=this._properties[r];if(Yt(s))return am(s[e],!0);if(this._hierarchy){let i=this._getHierarchyProperty(e,r);if(Yt(i))return i}}setProperty(e,r,s){let i=this.featureCount;if(this._checkBatchId(e),ne(typeof r=="string",r),this._binaryProperties){let o=this._binaryProperties[r];if(o){this._setBinaryProperty(o,e,s);return}}if(this._hierarchy&&this._setHierarchyProperty(this,e,r,s))return;let n=this._properties[r];Yt(n)||(this._properties[r]=new Array(i),n=this._properties[r]),n[e]=am(s,!0)}_checkBatchId(e){if(!(e>=0&&e{let o=i.classIds[n],a=i.classes[o].instances;return Yt(a[r])});return Yt(s)}_getPropertyNamesInHierarchy(e,r){La(this._hierarchy,e,(s,i)=>{let n=s.classIds[i],o=s.classes[n].instances;for(let a in o)o.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(e,r){return La(this._hierarchy,e,(s,i)=>{let n=s.classIds[i],o=s.classes[n],a=s.classIndexes[i],c=o.instances[r];return Yt(c)?Yt(c.typedArray)?this._getBinaryProperty(c,a):am(c[a],!0):null})}_setHierarchyProperty(e,r,s,i){let n=La(this._hierarchy,r,(o,a)=>{let c=o.classIds[a],l=o.classes[c],u=o.classIndexes[a],f=l.instances[s];return Yt(f)?(ne(a===r,`Inherited property "${s}" is read-only.`),Yt(f.typedArray)?this._setBinaryProperty(f,u,i):f[u]=am(i,!0),!0):!1});return Yt(n)}};function Zi(t,e,r=0){let s=new DataView(e);if(t.magic=s.getUint32(r,!0),r+=4,t.version=s.getUint32(r,!0),r+=4,t.byteLength=s.getUint32(r,!0),r+=4,t.version!==1)throw new Error(`3D Tile Version ${t.version} not supported`);return r}var Na=4,T3="b3dm tile in legacy format.";function Da(t,e,r){let s=new DataView(e),i;t.header=t.header||{};let n=s.getUint32(r,!0);r+=Na;let o=s.getUint32(r,!0);r+=Na;let a=s.getUint32(r,!0);r+=Na;let c=s.getUint32(r,!0);return r+=Na,a>=570425344?(r-=Na*2,i=n,a=o,c=0,n=0,o=0,console.warn(T3)):c>=570425344&&(r-=Na,i=a,a=n,c=o,n=0,o=0,console.warn(T3)),t.header.featureTableJsonByteLength=n,t.header.featureTableBinaryByteLength=o,t.header.batchTableJsonByteLength=a,t.header.batchTableBinaryByteLength=c,t.header.batchLength=i,r}function Ua(t,e,r,s){return r=dq(t,e,r,s),r=pq(t,e,r,s),r}function dq(t,e,r,s){let{featureTableJsonByteLength:i,featureTableBinaryByteLength:n,batchLength:o}=t.header||{};if(t.featureTableJson={BATCH_LENGTH:o||0},i&&i>0){let a=JT(e,r,i);t.featureTableJson=JSON.parse(a)}return r+=i||0,t.featureTableBinary=new Uint8Array(e,r,n),r+=n||0,r}function pq(t,e,r,s){let{batchTableJsonByteLength:i,batchTableBinaryByteLength:n}=t.header||{};if(i&&i>0){let o=JT(e,r,i);t.batchTableJson=JSON.parse(o),r+=i,n&&n>0&&(t.batchTableBinary=new Uint8Array(e,r,n),t.batchTableBinary=new Uint8Array(t.batchTableBinary),r+=n)}return r}function rb(t,e,r){if(!e&&(!t||!t.batchIds||!r))return null;let{batchIds:s,isRGB565:i,pointCount:n=0}=t;if(s&&r){let o=new Uint8ClampedArray(n*3);for(let a=0;af*255);o[a*3]=u[0],o[a*3+1]=u[1],o[a*3+2]=u[2]}return{type:re.UNSIGNED_BYTE,value:o,size:3,normalized:!0}}if(e&&i){let o=new Uint8ClampedArray(n*3);for(let a=0;a12;){let a={shape:"tile3d"};t.tiles.push(a),r=await n(e,r,s,i,a)}return r}async function M3(t,e,r,s){if(t.rotateYtoZ=!0,t.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!s)return e.byteLength;let i=await Kt(e,Zs,r,s);t.gltf=oo(i),t.gpuMemoryUsageInBytes=_f(t.gltf)}else t.gltfArrayBuffer=e;return e.byteLength}async function sb(t,e=0,r,s,i={shape:"tile3d"}){switch(i.byteOffset=e,i.type=d3(t,e),i.type){case lo.COMPOSITE:return await P3(i,t,e,r,s,sb);case lo.BATCHED_3D_MODEL:return await C3(i,t,e,r,s);case lo.GLTF:return await M3(i,t,r,s);case lo.INSTANCED_3D_MODEL:return await w3(i,t,e,r,s);case lo.POINT_CLOUD:return await v3(i,t,e,r,s);default:throw new Error(`3DTileLoader: unknown type ${i.type}`)}}async function ib(t,e,r){if(new Uint32Array(t.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(t.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let n=R3(t.slice(8,16)),o=new Uint8Array(t,24,n),c=new TextDecoder("utf8").decode(o),l=JSON.parse(c),u=R3(t.slice(16,24)),f=new ArrayBuffer(0);if(u&&(f=t.slice(24+n)),await fm(l,l.tileAvailability,f,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await fm(l,h,f,r);else await fm(l,l.contentAvailability,f,r);return await fm(l,l.childSubtreeAvailability,f,r),l}async function fm(t,e,r,s){let i=Number.isFinite(e.bitstream)?e.bitstream:e.bufferView;if(typeof i!="number")return;let n=t.bufferViews[i],o=t.buffers[n.buffer];if(!s?.baseUrl)throw new Error("Url is not provided");if(!s.fetch)throw new Error("fetch is not provided");if(o.uri){let c=`${s?.baseUrl||""}/${o.uri}`,u=await(await s.fetch(c)).arrayBuffer();e.explicitBitstream=new Uint8Array(u,n.byteOffset,n.byteLength);return}let a=t.buffers.slice(0,n.buffer).reduce((c,l)=>c+l.byteLength,0);e.explicitBitstream=new Uint8Array(r.slice(a,a+o.byteLength),n.byteOffset,n.byteLength)}function R3(t){let e=new DataView(t),r=e.getUint32(0,!0),s=e.getUint32(4,!0);return r+2**32*s}var hm={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:om,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:ib,options:{}};var Cr=null;try{Cr=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Oe(t,e,r){this.low=t|0,this.high=e|0,this.unsigned=!!r}Oe.prototype.__isLong__;Object.defineProperty(Oe.prototype,"__isLong__",{value:!0});function Pt(t){return(t&&t.__isLong__)===!0}function I3(t){var e=Math.clz32(t&-t);return t?31-e:e}Oe.isLong=Pt;var B3={},O3={};function fo(t,e){var r,s,i;return e?(t>>>=0,(i=0<=t&&t<256)&&(s=O3[t],s)?s:(r=pe(t,0,!0),i&&(O3[t]=r),r)):(t|=0,(i=-128<=t&&t<128)&&(s=B3[t],s)?s:(r=pe(t,t<0?-1:0,!1),i&&(B3[t]=r),r))}Oe.fromInt=fo;function wr(t,e){if(isNaN(t))return e?ri:Zr;if(e){if(t<0)return ri;if(t>=D3)return V3}else{if(t<=-L3)return qt;if(t+1>=L3)return k3}return t<0?wr(-t,e).neg():pe(t%Va|0,t/Va|0,e)}Oe.fromNumber=wr;function pe(t,e,r){return new Oe(t,e,r)}Oe.fromBits=pe;var dm=Math.pow;function ob(t,e,r){if(t.length===0)throw Error("empty string");if(typeof e=="number"?(r=e,e=!1):e=!!e,t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e?ri:Zr;if(r=r||10,r<2||360)throw Error("interior hyphen");if(s===0)return ob(t.substring(1),e,r).neg();for(var i=wr(dm(r,8)),n=Zr,o=0;o>>0:this.low};G.toNumber=function(){return this.unsigned?(this.high>>>0)*Va+(this.low>>>0):this.high*Va+(this.low>>>0)};G.toString=function(e){if(e=e||10,e<2||36>>0,u=l.toString(e);if(o=c,o.isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}};G.getHighBits=function(){return this.high};G.getHighBitsUnsigned=function(){return this.high>>>0};G.getLowBits=function(){return this.low};G.getLowBitsUnsigned=function(){return this.low>>>0};G.getNumBitsAbs=function(){if(this.isNegative())return this.eq(qt)?64:this.neg().getNumBitsAbs();for(var e=this.high!=0?this.high:this.low,r=31;r>0&&!(e&1<=0};G.isOdd=function(){return(this.low&1)===1};G.isEven=function(){return(this.low&1)===0};G.equals=function(e){return Pt(e)||(e=Qr(e)),this.unsigned!==e.unsigned&&this.high>>>31===1&&e.high>>>31===1?!1:this.high===e.high&&this.low===e.low};G.eq=G.equals;G.notEquals=function(e){return!this.eq(e)};G.neq=G.notEquals;G.ne=G.notEquals;G.lessThan=function(e){return this.comp(e)<0};G.lt=G.lessThan;G.lessThanOrEqual=function(e){return this.comp(e)<=0};G.lte=G.lessThanOrEqual;G.le=G.lessThanOrEqual;G.greaterThan=function(e){return this.comp(e)>0};G.gt=G.greaterThan;G.greaterThanOrEqual=function(e){return this.comp(e)>=0};G.gte=G.greaterThanOrEqual;G.ge=G.greaterThanOrEqual;G.compare=function(e){if(Pt(e)||(e=Qr(e)),this.eq(e))return 0;var r=this.isNegative(),s=e.isNegative();return r&&!s?-1:!r&&s?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1};G.comp=G.compare;G.negate=function(){return!this.unsigned&&this.eq(qt)?qt:this.not().add(ka)};G.neg=G.negate;G.add=function(e){Pt(e)||(e=Qr(e));var r=this.high>>>16,s=this.high&65535,i=this.low>>>16,n=this.low&65535,o=e.high>>>16,a=e.high&65535,c=e.low>>>16,l=e.low&65535,u=0,f=0,h=0,d=0;return d+=n+l,h+=d>>>16,d&=65535,h+=i+c,f+=h>>>16,h&=65535,f+=s+a,u+=f>>>16,f&=65535,u+=r+o,u&=65535,pe(h<<16|d,u<<16|f,this.unsigned)};G.subtract=function(e){return Pt(e)||(e=Qr(e)),this.add(e.neg())};G.sub=G.subtract;G.multiply=function(e){if(this.isZero())return this;if(Pt(e)||(e=Qr(e)),Cr){var r=Cr.mul(this.low,this.high,e.low,e.high);return pe(r,Cr.get_high(),this.unsigned)}if(e.isZero())return this.unsigned?ri:Zr;if(this.eq(qt))return e.isOdd()?qt:Zr;if(e.eq(qt))return this.isOdd()?qt:Zr;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(N3)&&e.lt(N3))return wr(this.toNumber()*e.toNumber(),this.unsigned);var s=this.high>>>16,i=this.high&65535,n=this.low>>>16,o=this.low&65535,a=e.high>>>16,c=e.high&65535,l=e.low>>>16,u=e.low&65535,f=0,h=0,d=0,p=0;return p+=o*u,d+=p>>>16,p&=65535,d+=n*u,h+=d>>>16,d&=65535,d+=o*l,h+=d>>>16,d&=65535,h+=i*u,f+=h>>>16,h&=65535,h+=n*l,f+=h>>>16,h&=65535,h+=o*c,f+=h>>>16,h&=65535,f+=s*u+i*l+n*c+o*a,f&=65535,pe(d<<16|p,f<<16|h,this.unsigned)};G.mul=G.multiply;G.divide=function(e){if(Pt(e)||(e=Qr(e)),e.isZero())throw Error("division by zero");if(Cr){if(!this.unsigned&&this.high===-2147483648&&e.low===-1&&e.high===-1)return this;var r=(this.unsigned?Cr.div_u:Cr.div_s)(this.low,this.high,e.low,e.high);return pe(r,Cr.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ri:Zr;var s,i,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return ri;if(e.gt(this.shru(1)))return U3;n=ri}else{if(this.eq(qt)){if(e.eq(ka)||e.eq(nb))return qt;if(e.eq(qt))return ka;var o=this.shr(1);return s=o.div(e).shl(1),s.eq(Zr)?e.isNegative()?ka:nb:(i=this.sub(e.mul(s)),n=s.add(i.div(e)),n)}else if(e.eq(qt))return this.unsigned?ri:Zr;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=Zr}for(i=this;i.gte(e);){s=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(s)/Math.LN2),c=a<=48?1:dm(2,a-48),l=wr(s),u=l.mul(e);u.isNegative()||u.gt(i);)s-=c,l=wr(s,this.unsigned),u=l.mul(e);l.isZero()&&(l=ka),n=n.add(l),i=i.sub(u)}return n};G.div=G.divide;G.modulo=function(e){if(Pt(e)||(e=Qr(e)),Cr){var r=(this.unsigned?Cr.rem_u:Cr.rem_s)(this.low,this.high,e.low,e.high);return pe(r,Cr.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))};G.mod=G.modulo;G.rem=G.modulo;G.not=function(){return pe(~this.low,~this.high,this.unsigned)};G.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};G.clz=G.countLeadingZeros;G.countTrailingZeros=function(){return this.low?I3(this.low):I3(this.high)+32};G.ctz=G.countTrailingZeros;G.and=function(e){return Pt(e)||(e=Qr(e)),pe(this.low&e.low,this.high&e.high,this.unsigned)};G.or=function(e){return Pt(e)||(e=Qr(e)),pe(this.low|e.low,this.high|e.high,this.unsigned)};G.xor=function(e){return Pt(e)||(e=Qr(e)),pe(this.low^e.low,this.high^e.high,this.unsigned)};G.shiftLeft=function(e){return Pt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?pe(this.low<>>32-e,this.unsigned):pe(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):pe(this.high>>e-32,this.high>=0?0:-1,this.unsigned)};G.shr=G.shiftRight;G.shiftRightUnsigned=function(e){return Pt(e)&&(e=e.toInt()),(e&=63)===0?this:e<32?pe(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):e===32?pe(this.high,0,this.unsigned):pe(this.high>>>e-32,0,this.unsigned)};G.shru=G.shiftRightUnsigned;G.shr_u=G.shiftRightUnsigned;G.rotateLeft=function(e){var r;return Pt(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?pe(this.high,this.low,this.unsigned):e<32?(r=32-e,pe(this.low<>>r,this.high<>>r,this.unsigned)):(e-=32,r=32-e,pe(this.high<>>r,this.low<>>r,this.unsigned))};G.rotl=G.rotateLeft;G.rotateRight=function(e){var r;return Pt(e)&&(e=e.toInt()),(e&=63)===0?this:e===32?pe(this.high,this.low,this.unsigned):e<32?(r=32-e,pe(this.high<>>e,this.low<>>e,this.unsigned)):(e-=32,r=32-e,pe(this.low<>>e,this.high<>>e,this.unsigned))};G.rotr=G.rotateRight;G.toSigned=function(){return this.unsigned?pe(this.low,this.high,!1):this};G.toUnsigned=function(){return this.unsigned?this:pe(this.low,this.high,!0)};G.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()};G.toBytesLE=function(){var e=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,e&255,e>>>8&255,e>>>16&255,e>>>24]};G.toBytesBE=function(){var e=this.high,r=this.low;return[e>>>24,e>>>16&255,e>>>8&255,e&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Oe.fromBytes=function(e,r,s){return s?Oe.fromBytesLE(e,r):Oe.fromBytesBE(e,r)};Oe.fromBytesLE=function(e,r){return new Oe(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r)};Oe.fromBytesBE=function(e,r){return new Oe(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],r)};var za=Oe;var Mq=16;function wf(t){t==="X"&&(t="");let e=t.padEnd(Mq,"0");return za.fromString(e,!0,16)}function ab(t){if(t.isZero())return"X";let e=t.countTrailingZeros(),r=e%4;e=(e-r)/4;let s=e;e*=4;let n=t.shiftRightUnsigned(e).toString(16).replace(/0+$/,"");return Array(17-s-n.length).join("0")+n}function cb(t,e){let r=Rq(t).shiftRightUnsigned(2);return t.add(za.fromNumber(2*e+1-4).multiply(r))}function Rq(t){return t.and(t.not().add(1))}var Iq=3,Bq=30,Oq=2*Bq+1,z3=180/Math.PI;function G3(t){if(t.length===0)throw new Error(`Invalid Hilbert quad key ${t}`);let e=t.split("/"),r=parseInt(e[0],10),s=e[1],i=s.length,n=0,o=[0,0];for(let a=i-1;a>=0;a--){n=i-a;let c=s[a],l=0,u=0;c==="1"?u=1:c==="2"?(l=1,u=1):c==="3"&&(l=1);let f=Math.pow(2,n-1);Fq(f,o,l,u),o[0]+=f*l,o[1]+=f*u}if(r%2===1){let a=o[0];o[0]=o[1],o[1]=a}return{face:r,ij:o,level:n}}function W3(t){if(t.isZero())return"";let e=t.toString(2);for(;e.length=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function ub(t){return[H3(t[0]),H3(t[1])]}function fb(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function hb([t,e,r]){let s=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*z3,s*z3]}function Fq(t,e,r,s){if(s===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let i=e[0];e[0]=e[1],e[1]=i}}function j3(t){let e=lb(t.ij,t.level,[.5,.5]),r=ub(e),s=fb(t.face,r);return hb(s)}var Lq=100;function db(t){let{face:e,ij:r,level:s}=t,i=[[0,0],[0,1],[1,1],[1,0],[0,0]],n=Math.max(1,Math.ceil(Lq*Math.pow(2,-s))),o=new Float64Array(4*n*2+2),a=0,c=0;for(let l=0;l<4;l++){let u=i[l].slice(0),f=i[l+1],h=(f[0]-u[0])/n,d=(f[1]-u[1])/n;for(let p=0;p89.999&&(y[0]=c);let x=y[0]-c;y[0]+=x>180?-360:x<-180?360:0,o[a++]=y[0],o[a++]=y[1],c=y[0]}}return o[a++]=o[0],o[a++]=o[1],o}function Ha(t){let e=Nq(t);return G3(e)}function Nq(t){if(t.indexOf("/")>0)return t;let e=wf(t);return W3(e)}function pb(t){let e=Ha(t);return j3(e)}function Y3(t){let e;if(t.face===2||t.face===5){let r=null,s=0;for(let i=0;i<4;i++){let n=`${t.face}/${i}`,o=Ha(n),a=db(o);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,s),s+=a.length}e=X3(r)}else{let r=db(t);e=X3(r)}return e}function X3(t){if(t.length%2!==0)throw new Error("Invalid corners");let e=[],r=[];for(let s=0;ss-i),r.sort((s,i)=>s-i),{west:e[0],east:e[e.length-1],north:r[r.length-1],south:r[0]}}function gb(t,e){let r=e?.minimumHeight||0,s=e?.maximumHeight||0,i=Ha(t),n=Y3(i),o=n.west,a=n.south,c=n.east,l=n.north,u=[];return u.push(new w(o,l,r)),u.push(new w(c,l,r)),u.push(new w(c,a,r)),u.push(new w(o,a,r)),u.push(new w(o,l,s)),u.push(new w(c,l,s)),u.push(new w(c,a,s)),u.push(new w(o,a,s)),u}function pm(t){let e=t.token,r={minimumHeight:t.minimumHeight,maximumHeight:t.maximumHeight},s=gb(e,r),i=pb(e),n=i[0],o=i[1],a=oe.WGS84.cartographicToCartesian([n,o,r.maximumHeight]),c=new w(a[0],a[1],a[2]);s.push(c);let l=af(s);return[...l.center,...l.halfAxes]}var Dq=4,Uq=8,kq={QUADTREE:Dq,OCTREE:Uq};function Vq(t,e,r){if(t?.box){let s=wf(t.s2VolumeInfo.token),i=cb(s,e),n=ab(i),o={...t.s2VolumeInfo};switch(o.token=n,r){case"OCTREE":let l=t.s2VolumeInfo,u=l.maximumHeight-l.minimumHeight,f=u/2,h=l.minimumHeight+u/2;l.minimumHeight=h-f,l.maximumHeight=h+f;break;default:break}return{box:pm(o),s2VolumeInfo:o}}}async function _b(t){let{implicitOptions:e,parentData:r={mortonIndex:0,x:0,y:0,z:0},childIndex:s=0,s2VolumeBox:i,loaderOptions:n}=t,{subtree:o,level:a=0,globalData:c={level:0,mortonIndex:0,x:0,y:0,z:0}}=t,{subdivisionScheme:l,subtreeLevels:u,maximumLevel:f,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=e,g={children:[],lodMetricValue:0,contentUrl:""};if(!f)return T_.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${h} won't be loaded...`),g;let m=a+c.level;if(m>f)return g;let _=kq[l],y=Math.log2(_),x=s&1,S=s>>1&1,P=s>>2&1,B=(_**a-1)/(_-1),L=ho(r.mortonIndex,s,y),M=B+L,v=ho(r.x,x,1),T=ho(r.y,S,1),D=ho(r.z,P,1),V=!1;a>=u&&(V=mb(o.childSubtreeAvailability,L));let z=ho(c.x,v,a),W=ho(c.y,T,a),Z=ho(c.z,D,a);if(V){let be=`${p}/${d}`,Ee=gm(be,m,z,W,Z);o=await $e(Ee,hm,n),c={mortonIndex:L,x:v,y:T,z:D,level:a},L=0,M=0,v=0,T=0,D=0,a=0}if(!mb(o.tileAvailability,M))return g;mb(o.contentAvailability,M)&&(g.contentUrl=gm(h,m,z,W,Z));let Re=a+1,ge={mortonIndex:L,x:v,y:T,z:D};for(let be=0;be<_;be++){let Ee=Vq(i,be,l),xt=await _b({subtree:o,implicitOptions:e,loaderOptions:n,parentData:ge,childIndex:be,level:Re,globalData:{...c},s2VolumeBox:Ee});if(xt.contentUrl||xt.children.length){let dc=m+1,c_=zq(xt,dc,{childTileX:v,childTileY:T,childTileZ:D},e,i);g.children.push(c_)}}return g}function mb(t,e){let r;return Array.isArray(t)?(r=t[0],t.length>1&&T_.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=t,"constant"in r?Boolean(r.constant):r.explicitBitstream?Wq(e,r.explicitBitstream):!1}function zq(t,e,r,s,i){let{basePath:n,refine:o,getRefine:a,lodMetricType:c,getTileType:l,rootLodMetricValue:u,rootBoundingVolume:f}=s,h=t.contentUrl&&t.contentUrl.replace(`${n}/`,""),d=u/2**e,p=i?.box?{box:i.box}:f,g=Hq(e,p,r);return{children:t.children,contentUrl:t.contentUrl,content:{uri:h},id:t.contentUrl,refine:a(o),type:l(t),lodMetricType:c,lodMetricValue:d,geometricError:d,transform:t.transform,boundingVolume:g}}function Hq(t,e,r){if(e.region){let{childTileX:s,childTileY:i,childTileZ:n}=r,[o,a,c,l,u,f]=e.region,h=2**t,d=(c-o)/h,p=(l-a)/h,g=(f-u)/h,[m,_]=[o+d*s,o+d*(s+1)],[y,x]=[a+p*i,a+p*(i+1)],[S,P]=[u+g*n,u+g*(n+1)];return{region:[m,y,_,x,S,P]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}function ho(t,e,r){return(t<n[o])}function Gq(t){let e={};for(let r in t)e[`{${r}}`]=t[r];return e}function Wq(t,e){let r=Math.floor(t/8),s=t%8;return(e[r]>>s&1)===1}function xb(t,e=""){if(!e)return vr.EMPTY;let s=e.split("?")[0].split(".").pop();switch(s){case"pnts":return vr.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return vr.SCENEGRAPH;default:return s||vr.EMPTY}}function Ab(t){switch(t){case"REPLACE":case"replace":return vt.REPLACE;case"ADD":case"add":return vt.ADD;default:return t}}function yb(t,e){if(/^[a-z][0-9a-z+.-]*:/i.test(e)){let s=new URL(t,`${e}/`);return decodeURI(s.toString())}else if(t.startsWith("/"))return t;return $t.resolve(e,t)}function q3(t,e){if(!t)return null;let r;if(t.content){let i=t.content.uri||t.content?.url;typeof i<"u"&&(r=yb(i,e))}return{...t,id:r,contentUrl:r,lodMetricType:ei.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:xb(t,r),refine:Ab(t.refine)}}async function J3(t,e,r){let s=null,i=$3(t.root);i&&t.root?s=await K3(t.root,t,e,i,r):s=q3(t.root,e);let n=[];for(n.push(s);n.length>0;){let o=n.pop()||{},a=o.children||[],c=[];for(let l of a){let u=$3(l),f;u?f=await K3(l,t,e,u,r):f=q3(l,e),f&&(c.push(f),n.push(f))}o.children=c}return s}async function K3(t,e,r,s,i){let{subdivisionScheme:n,maximumLevel:o,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=s,u=gm(l,0,0,0,0),f=yb(u,r),h=await $e(f,hm,i),d=t.content?.uri,p=d?yb(d,r):"",g=e?.root?.refine,m=t.geometricError,_=t.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(_){let P={box:pm(_),s2VolumeInfo:_};t.boundingVolume=P}let y=t.boundingVolume,x={contentUrlTemplate:p,subtreesUriTemplate:l,subdivisionScheme:n,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:o,refine:g,basePath:r,lodMetricType:ei.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:y,getTileType:xb,getRefine:Ab};return await jq(t,r,h,x,i)}async function jq(t,e,r,s,i){if(!t)return null;let{children:n,contentUrl:o}=await _b({subtree:r,implicitOptions:s,loaderOptions:i}),a,c=null;return o&&(a=o,c={uri:o.replace(`${e}/`,"")}),{...t,id:a,contentUrl:a,lodMetricType:ei.GEOMETRIC_ERROR,lodMetricValue:t.geometricError,transformMatrix:t.transform,type:xb(t,a),refine:Ab(t.refine),content:c||t.content,children:n}}function $3(t){return t?.extensions?.["3DTILES_implicit_tiling"]||t?.implicitTiling}var mm={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:om,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:Xq,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function Xq(t,e={},r){let s=e["3d-tiles"]||{},i;return s.isTileset==="auto"?i=r?.url&&r.url.indexOf(".json")!==-1:i=s.isTileset,i?Yq(t,e,r):qq(t,e,r)}async function Yq(t,e,r){let s=JSON.parse(new TextDecoder().decode(t)),i=r?.url||"",n=Kq(i),o=await J3(s,n,e||{});return{...s,shape:"tileset3d",loader:mm,url:i,queryString:r?.queryString||"",basePath:n,root:o||s.root,type:dt.TILES3D,lodMetricType:ei.GEOMETRIC_ERROR,lodMetricValue:s.root?.geometricError||0}}async function qq(t,e,r){let s={content:{shape:"tile3d",featureIds:null}};return await sb(t,0,e,r,s.content),s.content}function Kq(t){return $t.dirname(t)}var Z3=[0],$q={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:mm,onTilesetLoad:{type:"function",value:t=>{}},onTileLoad:{type:"function",value:t=>{}},onTileUnload:{type:"function",value:t=>{}},onTileError:{type:"function",value:(t,e,r)=>{}},_getMeshColor:{type:"function",value:t=>[255,255,255]}},Pf=class extends Le{initializeState(){"onTileLoadFail"in this.props&&k.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:r,changeFlags:s}){if(e.data&&e.data!==r.data&&this._loadTileset(e.data),s.viewportChanged){let{activeViewports:i}=this.state;Object.keys(i).length&&(this._updateTileset(i),this.state.lastUpdatedViewports=i,this.state.activeViewports={})}if(s.propsChanged){let{layerMap:i}=this.state;for(let n in i)i[n].needsUpdate=!0}}activateViewport(e){let{activeViewports:r,lastUpdatedViewports:s}=this.state;this.internalState.viewport=e,r[e.id]=e;let i=s?.[e.id];(!i||!e.equals(i))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:r}){let s=r&&r.props.tile;return e.picked&&(e.object=s),e.sourceTile=s,e}filterSubLayer({layer:e,viewport:r}){let{tile:s}=e.props,{id:i}=r;return s.selected&&s.viewportIds.includes(i)}_updateAutoHighlight(e){let r=e.sourceTile,s=this.state.layerMap[r?.id];s&&s.layer&&s.layer.updateAutoHighlight(e)}async _loadTileset(e){let{loadOptions:r={}}=this.props,s=this.props.loader||this.props.loaders,i=Array.isArray(s)?s[0]:s,n={loadOptions:{...r}},o=e;if(i.preload){let l=await i.preload(e,r);l.url&&(o=l.url),l.headers&&(n.loadOptions.fetch={...n.loadOptions.fetch,headers:l.headers}),Object.assign(n,l)}let a=await $e(o,i,n.loadOptions),c=new Cf(a,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...n});this.setState({tileset3d:c,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(c)}_onTileLoad(e){let{lastUpdatedViewports:r}=this.state;this.props.onTileLoad(e),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;let{tileset3d:r}=this.state,{timeline:s}=this.context,i=Object.keys(e).length;!s||!i||!r||r.selectTiles(Object.values(e)).then(n=>{this.state.frameNumber!==n&&this.setState({frameNumber:n})})}_getSubLayer(e,r){if(!e.content)return null;switch(e.type){case vr.POINTCLOUD:return this._makePointCloudLayer(e,r);case vr.SCENEGRAPH:return this._make3DModelLayer(e);case vr.MESH:return this._makeSimpleMeshLayer(e,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,r){let{attributes:s,pointCount:i,constantRGBA:n,cartographicOrigin:o,modelMatrix:a}=e.content,{positions:c,normals:l,colors:u}=s;if(!c)return null;let f=r&&r.props.data||{header:{vertexCount:i},attributes:{POSITION:c,NORMAL:l,COLOR_0:u}},{pointSize:h,getPointColor:d}=this.props,p=this.getSubLayerClass("pointcloud",zp);return new p({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:f,coordinateSystem:X.METER_OFFSETS,coordinateOrigin:o,modelMatrix:a,getColor:n||d,_offset:0})}_make3DModelLayer(e){let{gltf:r,instances:s,cartographicOrigin:i,modelMatrix:n}=e.content,o=this.getSubLayerClass("scenegraph",jg);return new o({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:s||Z3,scenegraph:r,coordinateSystem:X.METER_OFFSETS,coordinateOrigin:i,modelMatrix:n,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(e,r){let s=e.content,{attributes:i,indices:n,modelMatrix:o,cartographicOrigin:a,coordinateSystem:c=X.METER_OFFSETS,material:l,featureIds:u}=s,{_getMeshColor:f}=this.props,h=r&&r.props.mesh||new se({topology:"triangle-list",attributes:Jq(i),indices:n}),d=this.getSubLayerClass("mesh",R2);return new d(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:Z3,getColor:f(e),pbrMaterial:l,modelMatrix:o,coordinateOrigin:a,coordinateSystem:c,featureIds:u,_offset:0})}renderLayers(){let{tileset3d:e,layerMap:r}=this.state;return e?e.tiles.map(s=>{let i=r[s.id]=r[s.id]||{tile:s},{layer:n}=i;return s.selected&&(n?i.needsUpdate&&(n=this._getSubLayer(s,n),i.needsUpdate=!1):n=this._getSubLayer(s)),i.layer=n,n}).filter(Boolean):null}};Pf.defaultProps=$q;Pf.layerName="Tile3DLayer";var Q3=Pf;function Jq(t){let e={};return e.positions={...t.positions,value:new Float32Array(t.positions.value)},t.normals&&(e.normals=t.normals),t.texCoords&&(e.texCoords=t.texCoords),t.colors&&(e.colors=t.colors),t.uvRegions&&(e.uvRegions=t.uvRegions),e}var Zq=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function Tb(t){return t>>1^-(t&1)}function Qq(t){let e=0,r={};for(let[s,i]of Zq){let n=i===8?t.getFloat64:t.getFloat32;r[s]=n.call(t,e,!0),e+=i}return{header:r,headerEndPosition:e}}function eK(t,e){let r=e,s=3,i=t.getUint32(r,!0),n=new Uint16Array(i*s);r+=Uint32Array.BYTES_PER_ELEMENT;let o=Uint16Array.BYTES_PER_ELEMENT,a=i*o,c=r,l=c+a,u=l+a,f=0,h=0,d=0;for(let p=0;p65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;s%o!==0&&(s+=o-s%o);let a=t.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=Mf(t.buffer,s,c,o);return s+=c*o,{triangleIndicesEndPosition:s,triangleIndices:l}}function rK(t,e,r){let s=r,i=3,o=e.length/i>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=t.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let c=Mf(t.buffer,s,a,o,!1);s+=a*o;let l=t.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let u=Mf(t.buffer,s,l,o,!1);s+=l*o;let f=t.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let h=Mf(t.buffer,s,f,o,!1);s+=f*o;let d=t.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let p=Mf(t.buffer,s,d,o,!1);return s+=d*o,{edgeIndicesEndPosition:s,westIndices:c,southIndices:u,eastIndices:h,northIndices:p}}function sK(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function iK(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function nK(t,e){let r={};if(t.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let s=e;for(;sMath.min(...i)-Math.min(...n)||Math.max(...i)-Math.max(...n));let r=[],s=0;for(;se[3*s+1]-e[3*i+1]),t.eastIndices.sort((s,i)=>e[3*i+1]-e[3*s+1]),t.southIndices.sort((s,i)=>e[3*i]-e[3*s]),t.northIndices.sort((s,i)=>e[3*s]-e[3*i]);let r=[];for(let s in t){let i=t[s];for(let n=0;n>=1)>1;){let h=n+a>>1,d=o+c>>1;i&1?(a=n,c=o,n=l,o=u):(n=a,o=c,a=l,c=u),l=h,u=d}let f=s*4;this.coords[f+0]=n,this.coords[f+1]=o,this.coords[f+2]=a,this.coords[f+3]=c}}createTile(e){return new Sb(e,this)}},Sb=class{constructor(e,r){let s=r.gridSize;if(e.length!==s*s)throw new Error(`Expected terrain data of length ${s*s} (${s} x ${s}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:s,gridSize:i}=this.martini,{terrain:n,errors:o}=this;for(let a=e-1;a>=0;a--){let c=a*4,l=s[c+0],u=s[c+1],f=s[c+2],h=s[c+3],d=l+f>>1,p=u+h>>1,g=d+p-u,m=p+l-d,_=(n[u*i+l]+n[h*i+f])/2,y=p*i+d,x=Math.abs(_-n[y]);if(o[y]=Math.max(o[y],x),a>1)*i+(l+g>>1),P=(h+m>>1)*i+(f+g>>1);o[y]=Math.max(o[y],o[S],o[P])}}}getMesh(e=0){let{gridSize:r,indices:s}=this.martini,{errors:i}=this,n=0,o=0,a=r-1;s.fill(0);function c(d,p,g,m,_,y){let x=d+g>>1,S=p+m>>1;Math.abs(d-_)+Math.abs(p-y)>1&&i[S*r+x]>e?(c(_,y,d,p,x,S),c(g,m,_,y,x,S)):(s[p*r+d]=s[p*r+d]||++n,s[m*r+g]=s[m*r+g]||++n,s[y*r+_]=s[y*r+_]||++n,o++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(n*2),u=new Uint32Array(o*3),f=0;function h(d,p,g,m,_,y){let x=d+g>>1,S=p+m>>1;if(Math.abs(d-_)+Math.abs(p-y)>1&&i[S*r+x]>e)h(_,y,d,p,x,S),h(g,m,_,y,x,S);else{let P=s[p*r+d]-1,B=s[m*r+g]-1,L=s[y*r+_]-1;l[2*P]=d,l[2*P+1]=p,l[2*B]=g,l[2*B+1]=m,l[2*L]=_,l[2*L+1]=y,u[f++]=P,u[f++]=B,u[f++]=L}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:u}}};var If=class{constructor(e,r,s=r){this.data=e,this.width=r,this.height=s,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let i=r-1,n=s-1,o=this._addPoint(0,0),a=this._addPoint(i,0),c=this._addPoint(0,n),l=this._addPoint(i,n),u=this._addTriangle(l,o,c,-1,-1,-1);this._addTriangle(o,l,a,u,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r=0&&le>=0&&ie>=0){Re=!0;let be=B*Z+L*le+M*ie,Ee=Math.abs(be-this.heightAt(ge,z));V+=Ee*Ee,Ee>v&&(v=Ee,T=ge,D=z)}else if(Re)break;Z+=_,le+=x,ie+=g}h+=y,d+=S,p+=m}(T===e&&D===r||T===s&&D===i||T===n&&D===o)&&(v=0),this._candidates[2*a]=T,this._candidates[2*a+1]=D,this._rms[a]=V,this._queuePush(a,v,V)}_step(){let e=this._queuePop(),r=e*3+0,s=e*3+1,i=e*3+2,n=this.triangles[r],o=this.triangles[s],a=this.triangles[i],c=this.coords[2*n],l=this.coords[2*n+1],u=this.coords[2*o],f=this.coords[2*o+1],h=this.coords[2*a],d=this.coords[2*a+1],p=this._candidates[2*e],g=this._candidates[2*e+1],m=this._addPoint(p,g);if(go(c,l,u,f,p,g)===0)this._handleCollinear(m,r);else if(go(u,f,h,d,p,g)===0)this._handleCollinear(m,s);else if(go(h,d,c,l,p,g)===0)this._handleCollinear(m,i);else{let _=this._halfedges[r],y=this._halfedges[s],x=this._halfedges[i],S=this._addTriangle(n,o,m,_,-1,-1,r),P=this._addTriangle(o,a,m,y,-1,S+1),B=this._addTriangle(a,n,m,x,S+2,P+1);this._legalize(S),this._legalize(P),this._legalize(B)}}_addPoint(e,r){let s=this.coords.length>>1;return this.coords.push(e,r),s}_addTriangle(e,r,s,i,n,o,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=s,this._halfedges[a+0]=i,this._halfedges[a+1]=n,this._halfedges[a+2]=o,i>=0&&(this._halfedges[i]=a+0),n>=0&&(this._halfedges[n]=a+1),o>=0&&(this._halfedges[o]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let s=e-e%3,i=r-r%3,n=s+(e+1)%3,o=s+(e+2)%3,a=i+(r+2)%3,c=i+(r+1)%3,l=this.triangles[o],u=this.triangles[e],f=this.triangles[n],h=this.triangles[a],d=this.coords;if(!fK(d[2*l],d[2*l+1],d[2*u],d[2*u+1],d[2*f],d[2*f+1],d[2*h],d[2*h+1]))return;let p=this._halfedges[n],g=this._halfedges[o],m=this._halfedges[a],_=this._halfedges[c];this._queueRemove(s/3),this._queueRemove(i/3);let y=this._addTriangle(l,h,f,-1,m,p,s),x=this._addTriangle(h,l,u,y,g,_,i);this._legalize(y+1),this._legalize(x+2)}_handleCollinear(e,r){let s=r-r%3,i=s+(r+1)%3,n=s+(r+2)%3,o=this.triangles[n],a=this.triangles[r],c=this.triangles[i],l=this._halfedges[i],u=this._halfedges[n],f=this._halfedges[r];if(f<0){let B=this._addTriangle(e,o,a,-1,u,-1,s),L=this._addTriangle(o,e,c,B,-1,l);this._legalize(B+1),this._legalize(L+2);return}let h=f-f%3,d=h+(f+2)%3,p=h+(f+1)%3,g=this.triangles[d],m=this._halfedges[d],_=this._halfedges[p];this._queueRemove(h/3);let y=this._addTriangle(o,a,e,u,-1,-1,s),x=this._addTriangle(a,g,e,_,-1,y+1,h),S=this._addTriangle(g,c,e,m,-1,x+1),P=this._addTriangle(c,o,e,l,y+2,S+1);this._legalize(y),this._legalize(x),this._legalize(S),this._legalize(P)}_queuePush(e,r,s){let i=this._queue.length;this._queueIndices[e]=i,this._queue.push(e),this._errors.push(r),this._rmsSum+=s,this._queueUp(i)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let i=this._pending.indexOf(e);if(i!==-1)this._pending[i]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let s=this._queue.length-1;s!==r&&(this._queueSwap(r,s),this._queueDown(r,s)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let s=this._queue[e],i=this._queue[r];this._queue[e]=i,this._queue[r]=s,this._queueIndices[s]=r,this._queueIndices[i]=e;let n=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=n}_queueUp(e){let r=e;for(;;){let s=r-1>>1;if(s===r||!this._queueLess(r,s))break;this._queueSwap(s,r),r=s}}_queueDown(e,r){let s=e;for(;;){let i=2*s+1;if(i>=r||i<0)break;let n=i+1,o=i;if(ne}};function go(t,e,r,s,i,n){return(r-i)*(e-n)-(s-n)*(t-i)}function fK(t,e,r,s,i,n,o,a){let c=t-o,l=e-a,u=r-o,f=s-a,h=i-o,d=n-a,p=c*c+l*l,g=u*u+f*f,m=h*h+d*d;return c*(f*m-g*d)-l*(u*m-g*h)+p*(u*d-f*h)<0}function rB(t,e){let{meshMaxError:r,bounds:s,elevationDecoder:i}=e,{data:n,width:o,height:a}=t,c,l;switch(e.tesselator){case"martini":c=ym(n,o,a,i,e.tesselator),l=eB(r,o,c);break;case"delatin":c=ym(n,o,a,i,e.tesselator),l=tB(r,o,a,c);break;default:o===a&&!(a&o-1)?(c=ym(n,o,a,i,"martini"),l=eB(r,o,c)):(c=ym(n,o,a,i,"delatin"),l=tB(r,o,a,c));break}let{vertices:u}=l,{triangles:f}=l,h=hK(u,c,o,a,s),d=Is(h);if(e.skirtHeight){let{attributes:p,triangles:g}=_m(h,f,e.skirtHeight);h=p,f=g}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:d},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:h}}function eB(t,e,r){let s=e+1,n=new Rf(s).createTile(r),{vertices:o,triangles:a}=n.getMesh(t);return{vertices:o,triangles:a}}function tB(t,e,r,s){let i=new If(s,e+1,r+1);i.run(t);let{coords:n,triangles:o}=i;return{vertices:n,triangles:o}}function ym(t,e,r,s,i){let{rScaler:n,bScaler:o,gScaler:a,offset:c}=s,l=new Float32Array((e+1)*(r+1));for(let u=0,f=0;fEb(t,e?.["quantized-mesh"]),parse:async(t,e)=>Eb(t,e?.["quantized-mesh"])};var iB=[1],gK={...ro.defaultProps,elevationData:qi,texture:{...qi,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[Am]};function nB(t){return Array.isArray(t)?t.join(";"):t||""}var Bf=class extends Le{updateState({props:e,oldProps:r}){let s=e.elevationData!==r.elevationData;if(s){let{elevationData:n}=e,o=n&&(Array.isArray(n)||n.includes("{x}")&&n.includes("{y}"));this.setState({isTiled:o})}let i=s||e.meshMaxError!==r.meshMaxError||e.elevationDecoder!==r.elevationDecoder||e.bounds!==r.bounds;if(!this.state.isTiled&&i){let n=this.loadTerrain(e);this.setState({terrain:n})}e.workerUrl&&k.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:e,bounds:r,elevationDecoder:s,meshMaxError:i,signal:n}){if(!e)return null;let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?i*2:0,...o?.terrain,bounds:r,meshMaxError:i,elevationDecoder:s}};let{fetch:a}=this.props;return a(e,{propName:"elevationData",layer:this,loadOptions:o,signal:n})}getTiledTerrainData(e){let{elevationData:r,fetch:s,texture:i,elevationDecoder:n,meshMaxError:o}=this.props,{viewport:a}=this.context,c=bs(r,e),l=i&&bs(i,e),{signal:u}=e,f=[0,0],h=[0,0];if(a.isGeospatial){let m=e.bbox;f=a.projectFlat([m.west,m.south]),h=a.projectFlat([m.east,m.north])}else{let m=e.bbox;f=[m.left,m.bottom],h=[m.right,m.top]}let d=[f[0],f[1],h[0],h[1]],p=this.loadTerrain({elevationData:c,bounds:d,elevationDecoder:n,meshMaxError:o,signal:u}),g=l?s(l,{propName:"texture",layer:this,loaders:[],signal:u}).catch(m=>null):Promise.resolve(null);return Promise.all([p,g])}renderSubLayers(e){let r=this.getSubLayerClass("mesh",so),{color:s,wireframe:i,material:n}=this.props,{data:o}=e;if(!o)return null;let[a,c]=o;return new r(e,{data:iB,mesh:a,texture:c,_instanced:!1,coordinateSystem:X.CARTESIAN,getPosition:l=>[0,0,0],getColor:s,wireframe:i,material:n})}onViewportLoad(e){if(!e)return;let{zRange:r}=this.state,s=e.map(o=>o.content).filter(Boolean).map(o=>o[0].header.boundingBox.map(c=>c[2]));if(s.length===0)return;let i=Math.min(...s.map(o=>o[0])),n=Math.max(...s.map(o=>o[1]));(!r||ir[1])&&this.setState({zRange:[i,n]})}renderLayers(){let{color:e,material:r,elevationData:s,texture:i,wireframe:n,meshMaxError:o,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:u,extent:f,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:g,maxCacheSize:m,maxCacheByteSize:_,refinementStrategy:y}=this.props;if(this.state.isTiled)return new ro(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:nB(s),texture:nB(i),meshMaxError:o,elevationDecoder:a}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:u,extent:f,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:g,maxCacheSize:m,maxCacheByteSize:_,refinementStrategy:y});if(!s)return null;let x=this.getSubLayerClass("mesh",so);return new x(this.getSubLayerProps({id:"mesh"}),{data:iB,mesh:this.state.terrain,texture:i,_instanced:!1,getPosition:S=>[0,0,0],getColor:e,material:r,wireframe:n})}};Bf.defaultProps=gK;Bf.layerName="TerrainLayer";var oB=Bf;var mK=` uniform bool brushing_enabled; uniform int brushing_target; uniform vec2 brushing_mousePos; uniform float brushing_radius; in vec2 brushingTargets; out float brushing_isVisible; bool brushing_isPointInRange(vec2 position) { if (!brushing_enabled) { return true; } vec2 source_commonspace = project_position(position); vec2 target_commonspace = project_position(brushing_mousePos); float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy); return distance <= brushing_radius; } bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) { return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos); } void brushing_setVisible(bool visible) { brushing_isVisible = float(visible); } `,_K=` uniform bool brushing_enabled; in float brushing_isVisible; `,yK={source:0,target:1,custom:2,source_target:3},xK={"vs:DECKGL_FILTER_GL_POSITION":` vec2 brushingTarget; vec2 brushingSource; if (brushing_target == 3) { brushingTarget = geometry.worldPositionAlt.xy; brushingSource = geometry.worldPosition.xy; } else if (brushing_target == 0) { brushingTarget = geometry.worldPosition.xy; } else if (brushing_target == 1) { brushingTarget = geometry.worldPositionAlt.xy; } else { brushingTarget = brushingTargets; } bool visible; if (brushing_target == 3) { visible = brushing_arePointsInRange(brushingSource, brushingTarget); } else { visible = brushing_isPointInRange(brushingTarget); } brushing_setVisible(visible); `,"fs:DECKGL_FILTER_COLOR":` if (brushing_enabled && brushing_isVisible < 0.5) { discard; } `},aB={name:"brushing",dependencies:[Qe],vs:mK,fs:_K,inject:xK,getUniforms:t=>{if(!t||!("viewport"in t))return{};let{brushingEnabled:e=!0,brushingRadius:r=1e4,brushingTarget:s="source",mousePosition:i,viewport:n}=t;return{brushing_enabled:Boolean(e&&i&&n.containsPixel(i)),brushing_radius:r,brushing_target:yK[s]||0,brushing_mousePos:i?n.unproject([i.x-n.x,i.y-n.y]):[0,0]}}};var AK={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},Of=class extends tt{getShaders(){return{modules:[aB]}}initializeState(e,r){let s=this.getAttributeManager();s&&s.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});let i=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=i,e.deck&&e.deck.eventManager.on({pointermove:i,pointerleave:i})}finalizeState(e,r){if(e.deck){let s=this.state.onMouseMove;e.deck.eventManager.off({pointermove:s,pointerleave:s})}}};Of.defaultProps=AK;Of.extensionName="BrushingExtension";var cB=Of;var lB=` uniform bool filter_useSoftMargin; uniform bool filter_enabled; uniform bool filter_transformSize; uniform ivec4 filter_categoryBitMask; #ifdef DATAFILTER_TYPE uniform DATAFILTER_TYPE filter_min; uniform DATAFILTER_TYPE filter_softMin; uniform DATAFILTER_TYPE filter_softMax; uniform DATAFILTER_TYPE filter_max; in DATAFILTER_TYPE filterValues; #ifdef DATAFILTER_DOUBLE in DATAFILTER_TYPE filterValues64Low; uniform DATAFILTER_TYPE filter_min64High; uniform DATAFILTER_TYPE filter_max64High; #endif #endif #ifdef DATACATEGORY_TYPE in DATACATEGORY_TYPE filterCategoryValues; #endif out float dataFilter_value; float dataFilter_reduceValue(float value) { return value; } float dataFilter_reduceValue(vec2 value) { return min(value.x, value.y); } float dataFilter_reduceValue(vec3 value) { return min(min(value.x, value.y), value.z); } float dataFilter_reduceValue(vec4 value) { return min(min(value.x, value.y), min(value.z, value.w)); } #ifdef DATAFILTER_TYPE void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) { if (filter_useSoftMargin) { DATAFILTER_TYPE leftInRange = mix( smoothstep(filter_min, filter_softMin, valueFromMin), step(filter_min, valueFromMin), step(filter_softMin, filter_min) ); DATAFILTER_TYPE rightInRange = mix( 1.0 - smoothstep(filter_softMax, filter_max, valueFromMax), step(valueFromMax, filter_max), step(filter_max, filter_softMax) ); dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange); } else { dataFilter_value = dataFilter_reduceValue( step(filter_min, valueFromMin) * step(valueFromMax, filter_max) ); } } #endif #ifdef DATACATEGORY_TYPE void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) { #if DATACATEGORY_CHANNELS == 1 int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)]; #elif DATACATEGORY_CHANNELS == 2 ivec2 dataFilter_masks = ivec2( filter_categoryBitMask[int(category.x / 32.0)], filter_categoryBitMask[int(category.y / 32.0) + 2] ); #elif DATACATEGORY_CHANNELS == 3 ivec3 dataFilter_masks = filter_categoryBitMask.xyz; #else ivec4 dataFilter_masks = filter_categoryBitMask; #endif DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) / pow(DATACATEGORY_TYPE(2.0), mod(category, 32.0)); dataFilter_bits = mod(floor(dataFilter_bits), 2.0); #if DATACATEGORY_CHANNELS == 1 if(dataFilter_bits == 0.0) dataFilter_value = 0.0; #else if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0; #endif } #endif `,uB=` uniform bool filter_transformColor; in float dataFilter_value; `;function fB(t){if(!t||!("extensions"in t))return{};let{filterRange:e=[-1,1],filterEnabled:r=!0,filterTransformSize:s=!0,filterTransformColor:i=!0}=t,n=t.filterSoftRange||e;return{...Number.isFinite(e[0])?{filter_min:e[0],filter_softMin:n[0],filter_softMax:n[1],filter_max:e[1]}:{filter_min:e.map(o=>o[0]),filter_softMin:n.map(o=>o[0]),filter_softMax:n.map(o=>o[1]),filter_max:e.map(o=>o[1])},filter_enabled:r,filter_useSoftMargin:Boolean(t.filterSoftRange),filter_transformSize:r&&s,filter_transformColor:r&&i}}function TK(t){if(!t||!("extensions"in t))return{};let e=fB(t);if(Number.isFinite(e.filter_min)){let r=Math.fround(e.filter_min);e.filter_min-=r,e.filter_softMin-=r,e.filter_min64High=r;let s=Math.fround(e.filter_max);e.filter_max-=s,e.filter_softMax-=s,e.filter_max64High=s}else{let r=e.filter_min.map(Math.fround);e.filter_min=e.filter_min.map((i,n)=>i-r[n]),e.filter_softMin=e.filter_softMin.map((i,n)=>i-r[n]),e.filter_min64High=r;let s=e.filter_max.map(Math.fround);e.filter_max=e.filter_max.map((i,n)=>i-s[n]),e.filter_softMax=e.filter_softMax.map((i,n)=>i-s[n]),e.filter_max64High=s}return e}var hB={"vs:#main-start":` dataFilter_value = 1.0; if (filter_enabled) { #ifdef DATAFILTER_TYPE #ifdef DATAFILTER_DOUBLE dataFilter_setValue( filterValues - filter_min64High + filterValues64Low, filterValues - filter_max64High + filterValues64Low ); #else dataFilter_setValue(filterValues, filterValues); #endif #endif #ifdef DATACATEGORY_TYPE dataFilter_setCategoryValue(filterCategoryValues); #endif } `,"vs:#main-end":` if (dataFilter_value == 0.0) { gl_Position = vec4(0.); } `,"vs:DECKGL_FILTER_SIZE":` if (filter_transformSize) { size = size * dataFilter_value; } `,"fs:DECKGL_FILTER_COLOR":` if (dataFilter_value == 0.0) discard; if (filter_transformColor) { color.a *= dataFilter_value; } `},dB={name:"data-filter",vs:lB,fs:uB,inject:hB,getUniforms:fB},pB={name:"data-filter-fp64",vs:lB,fs:uB,inject:hB,getUniforms:TK};var bK=`#version 300 es #define SHADER_NAME data-filter-vertex-shader #ifdef FLOAT_TARGET in float filterIndices; in float filterPrevIndices; #else in vec2 filterIndices; in vec2 filterPrevIndices; #endif out vec4 vColor; const float component = 1.0 / 255.0; void main() { #ifdef FLOAT_TARGET dataFilter_value *= float(filterIndices != filterPrevIndices); gl_Position = vec4(0.0, 0.0, 0.0, 1.0); vColor = vec4(0.0, 0.0, 0.0, 1.0); #else // Float texture is not supported: pack result into 4 channels x 256 px x 64px dataFilter_value *= float(filterIndices.x != filterPrevIndices.x); float col = filterIndices.x; float row = filterIndices.y * 4.0; float channel = floor(row); row = fract(row); vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0)); gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0); #endif gl_PointSize = 1.0; } `,EK=`#version 300 es #define SHADER_NAME data-filter-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main() { if (dataFilter_value < 0.5) { discard; } fragColor = vColor; } `,SK=["float32-renderable-webgl","texture-blend-float-webgl"];function gB(t){return SK.every(e=>t.features.has(e))}function mB(t,e){return e?t.createFramebuffer({width:1,height:1,colorAttachments:[t.createTexture({format:"rgba32float",type:5126,mipmaps:!1})]}):t.createFramebuffer({width:256,height:64,colorAttachments:[t.createTexture({format:"rgba8unorm",type:5126,mipmaps:!1})]})}function _B(t,e,r){return e.defines.NON_INSTANCED_MODEL=1,r&&(e.defines.FLOAT_TARGET=1),new J(t,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,drawMode:0,vs:bK,fs:EK,...e})}var yB={blend:!0,blendFunc:[1,1,1,1],blendEquation:[32774,32774],depthTest:!1};var CK={getFilterValue:{type:"accessor",value:0},getFilterCategory:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterCategories:[0],filterTransformSize:!0,filterTransformColor:!0},wK={categorySize:0,filterSize:1,fp64:!1,countItems:!1},xB={1:"float",2:"vec2",3:"vec3",4:"vec4"},Ff=class extends tt{constructor(e={}){super({...wK,...e})}getShaders(e){let{categorySize:r,filterSize:s,fp64:i}=e.opts,n={};return r&&(n.DATACATEGORY_TYPE=xB[r],n.DATACATEGORY_CHANNELS=r),s&&(n.DATAFILTER_TYPE=xB[s],n.DATAFILTER_DOUBLE=Boolean(i)),{modules:[i?pB:dB],defines:n}}initializeState(e,r){let s=this.getAttributeManager(),{categorySize:i,filterSize:n,fp64:o}=r.opts;s&&(n&&s.add({filterValues:{size:n,type:o?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),i&&s.add({filterCategoryValues:{size:i,stepMode:"dynamic",accessor:"getFilterCategory",transform:i===1?c=>r._getCategoryKey.call(this,c,0):c=>c.map((l,u)=>r._getCategoryKey.call(this,l,u))}}));let{device:a}=this.context;if(s&&r.opts.countItems){let c=gB(a);s.add({filterIndices:{size:c?1:2,vertexOffset:1,type:"unorm8",accessor:(f,{index:h})=>{let d=f&&f.__source?f.__source.index:h;return c?(d+1)%255:[(d+1)%255,Math.floor(d/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});let l=mB(a,c),u=_B(a,r.getShaders.call(this,r),c);this.setState({filterFBO:l,filterModel:u})}}updateState({props:e,oldProps:r,changeFlags:s},i){let n=this.getAttributeManager(),{categorySize:o}=i.opts;if(this.state.filterModel){let a=n.attributes.filterValues?.needsUpdate()||n.attributes.filterCategoryValues?.needsUpdate()||e.filterEnabled!==r.filterEnabled||e.filterRange!==r.filterRange||e.filterSoftRange!==r.filterSoftRange||e.filterCategories!==r.filterCategories;a&&this.setState({filterNeedsUpdate:a})}n?.attributes.filterCategoryValues&&((n.attributes.filterCategoryValues.needsUpdate()||!ve(e.filterCategories,r.filterCategories,2))&&this.setState({categoryBitMask:null}),s.dataChanged&&(this.setState({categoryMap:Array(o).fill(0).map(()=>({}))}),n.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(e,r){let s=this.state.filterFBO,i=this.state.filterModel,n=this.state.filterNeedsUpdate,{onFilteredItemsChange:o}=this.props;if(this.state.categoryBitMask||r._updateCategoryBitMask.call(this,e,r),e.uniforms.filter_categoryBitMask=this.state.categoryBitMask,n&&o&&i){let{attributes:{filterValues:a,filterCategoryValues:c,filterIndices:l}}=this.getAttributeManager();i.setVertexCount(this.getNumInstances()),this.context.device.clearWebGL({framebuffer:s,color:[0,0,0,0]}),i.updateModuleSettings(e.moduleParameters),i.setAttributes({...a?.getValue(),...c?.getValue(),...l?.getValue()}),i.setUniforms(e.uniforms),i.device.withParametersWebGL({framebuffer:s,...yB,viewport:[0,0,s.width,s.height]},()=>{i.draw(this.context.renderPass)});let u=i.device.readPixelsToArrayWebGL(s),f=0;for(let h=0;h 0.0) { if (dashAlignMode == 0.0) { offset = vDashOffset; } else { unitLength = vPathLength / round(vPathLength / unitLength); offset = solidLength / 2.0; } float unitOffset = mod(vPathPosition.y + offset, unitLength); if (gapLength > 0.0 && unitOffset > solidLength) { if (capType <= 0.5) { if (!(dashGapPickable && bool(picking.isActive))) { discard; } } else { float distToEnd = length(vec2( min(unitOffset - solidLength, unitLength - unitOffset), vPathPosition.x )); if (distToEnd > 1.0) { if (!(dashGapPickable && bool(picking.isActive))) { discard; } } } } } `}},SB={inject:{"vs:#decl":` in float instanceOffsets; `,"vs:DECKGL_FILTER_SIZE":` float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; size *= offsetWidth; `,"vs:#main-end":` float offsetWidth = abs(instanceOffsets * 2.0) + 1.0; float offsetDir = sign(instanceOffsets); vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir; vPathPosition.y *= offsetWidth; vPathLength *= offsetWidth; `,"fs:#main-start":` float isInside; isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0); if (isInside == 0.0) { discard; } `}};var OK={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},Lf=class extends tt{constructor({dash:e=!1,offset:r=!1,highPrecisionDash:s=!1}={}){super({dash:e||s,offset:r,highPrecisionDash:s})}isEnabled(e){return"pathTesselator"in e.state}getShaders(e){if(!e.isEnabled(this))return null;let r={};return e.opts.dash&&(r=ys(r,EB)),e.opts.offset&&(r=ys(r,SB)),r}initializeState(e,r){let s=this.getAttributeManager();!s||!r.isEnabled(this)||(r.opts.dash&&s.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},instanceDashOffsets:r.opts.highPrecisionDash?{size:1,accessor:"getPath",transform:r.getDashOffsets.bind(this)}:{size:1,update:i=>{i.constant=!0,i.value=[0]}}}),r.opts.offset&&s.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(e,r){if(!r.isEnabled(this))return;let s={};r.opts.dash&&(s.dashAlignMode=this.props.dashJustified?1:0,s.dashGapPickable=Boolean(this.props.dashGapPickable)),this.state.model?.setUniforms(s)}getDashOffsets(e){let r=[0],s=this.props.positionFormat==="XY"?2:3,i=Array.isArray(e[0]),n=i?e.length:e.length/s,o,a;for(let c=0;c0&&(r[c]=r[c-1]+We.dist(a,o)),a=o;return r[n-1]=0,r}};Lf.defaultProps=OK;Lf.extensionName="PathStyleExtension";var vB=Lf;var FK=` in vec4 fillPatternFrames; in float fillPatternScales; in vec2 fillPatternOffsets; uniform bool fill_patternEnabled; uniform vec2 fill_patternTextureSize; out vec2 fill_uv; out vec4 fill_patternBounds; out vec4 fill_patternPlacement; `,LK=` uniform bool fill_patternEnabled; uniform bool fill_patternMask; uniform sampler2D fill_patternTexture; uniform vec2 fill_uvCoordinateOrigin; uniform vec2 fill_uvCoordinateOrigin64Low; in vec4 fill_patternBounds; in vec4 fill_patternPlacement; in vec2 fill_uv; const float FILL_UV_SCALE = 512.0 / 40000000.0; `,NK={"vs:DECKGL_FILTER_GL_POSITION":` fill_uv = geometry.position.xy; `,"vs:DECKGL_FILTER_COLOR":` if (fill_patternEnabled) { fill_patternBounds = fillPatternFrames / vec4(fill_patternTextureSize, fill_patternTextureSize); fill_patternPlacement.xy = fillPatternOffsets; fill_patternPlacement.zw = fillPatternScales * fillPatternFrames.zw; } `,"fs:DECKGL_FILTER_COLOR":` if (fill_patternEnabled) { vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw; vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale; patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0); vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV; vec4 patternColor = texture(fill_patternTexture, texCoords); color.a *= patternColor.a; if (!fill_patternMask) { color.rgb = patternColor.rgb; } } `};function DK(t,e){if(!t)return{};if("fillPatternTexture"in t){let{fillPatternTexture:r}=t;return{fill_patternTexture:r,fill_patternTextureSize:[r.width,r.height]}}if("viewport"in t){let{fillPatternMask:r=!0,fillPatternEnabled:s=!0}=t,{project_uCommonOrigin:i}=e,n=[Dr(i[0]),Dr(i[1])];return{fill_uvCoordinateOrigin:i.slice(0,2),fill_uvCoordinateOrigin64Low:n,fill_patternMask:r,fill_patternEnabled:s}}return{}}var CB={name:"fill-pattern",vs:FK,fs:LK,inject:NK,dependencies:[Qe],getUniforms:DK};var UK={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:t=>t.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},Nf=class extends tt{constructor({pattern:e=!1}={}){super({pattern:e})}isEnabled(e){return e.getAttributeManager()!==null&&!("pathTesselator"in e.state)}getShaders(e){return e.isEnabled(this)?{modules:[e.opts.pattern&&CB].filter(Boolean)}:null}initializeState(e,r){if(!r.isEnabled(this))return;let s=this.getAttributeManager();r.opts.pattern&&s.add({fillPatternFrames:{size:4,stepMode:"dynamic",accessor:"getFillPattern",transform:r.getPatternFrame.bind(this)},fillPatternScales:{size:1,stepMode:"dynamic",accessor:"getFillPatternScale",defaultValue:1},fillPatternOffsets:{size:2,stepMode:"dynamic",accessor:"getFillPatternOffset"}}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState({props:e,oldProps:r},s){s.isEnabled(this)&&e.fillPatternMapping&&e.fillPatternMapping!==r.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(e,r){if(!r.isEnabled(this))return;let{fillPatternAtlas:s}=this.props;this.setModuleParameters({fillPatternTexture:s||this.state.emptyTexture})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(e){let{fillPatternMapping:r}=this.getCurrentLayer().props,s=r&&r[e];return s?[s.x,s.y,s.width,s.height]:[0,0,0,0]}};Nf.defaultProps=UK;Nf.extensionName="FillStyleExtension";var wB=Nf;var kK={clipBounds:[0,0,1,1],clipByInstance:void 0},PB=` uniform vec4 clip_bounds; bool clip_isInBounds(vec2 position) { return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3]; } `,VK={name:"clip-vs",vs:PB},zK={"vs:#decl":` out float clip_isVisible; `,"vs:DECKGL_FILTER_GL_POSITION":` clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy)); `,"fs:#decl":` in float clip_isVisible; `,"fs:DECKGL_FILTER_COLOR":` if (clip_isVisible < 0.5) discard; `},HK={name:"clip-fs",fs:PB},GK={"vs:#decl":` out vec2 clip_commonPosition; `,"vs:DECKGL_FILTER_GL_POSITION":` clip_commonPosition = geometry.position.xy; `,"fs:#decl":` in vec2 clip_commonPosition; `,"fs:DECKGL_FILTER_COLOR":` if (!clip_isInBounds(clip_commonPosition)) discard; `},Df=class extends tt{getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(e=Boolean(this.props.clipByInstance)),this.state.clipByInstance=e,e?{modules:[VK],inject:zK}:{modules:[HK],inject:GK}}draw({uniforms:e}){let{clipBounds:r}=this.props;if(this.state.clipByInstance)e.clip_bounds=r;else{let s=this.projectPosition([r[0],r[1],0]),i=this.projectPosition([r[2],r[3],0]);e.clip_bounds=[Math.min(s[0],i[0]),Math.min(s[1],i[1]),Math.max(s[0],i[0]),Math.max(s[1],i[1])]}}};Df.defaultProps=kK;Df.extensionName="ClipExtension";var Em=Df;var WK=` in float collisionPriorities; uniform sampler2D collision_texture; uniform bool collision_sort; uniform bool collision_enabled; vec2 collision_getCoords(vec4 position) { vec4 collision_clipspace = project_common_position_to_clipspace(position); return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0; } float collision_match(vec2 tex, vec3 pickingColor) { vec4 collision_pickingColor = texture(collision_texture, tex); float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0)); float e = 0.001; return step(delta, e); } float collision_isVisible(vec2 texCoords, vec3 pickingColor) { if (!collision_enabled) { return 1.0; } const int N = 2; float accumulator = 0.0; vec2 step = vec2(1.0 / project_uViewportSize); const float floatN = float(N); vec2 delta = -floatN * step; for(int i = -N; i <= N; i++) { delta.x = -step.x * floatN; for(int j = -N; j <= N; j++) { accumulator += collision_match(texCoords + delta, pickingColor); delta.x += step.x; } delta.y += step.y; } float W = 2.0 * floatN + 1.0; return pow(accumulator / (W * W), 2.2); } `,jK={"vs:#decl":` float collision_fade = 1.0; `,"vs:DECKGL_FILTER_GL_POSITION":` if (collision_sort) { float collisionPriority = collisionPriorities; position.z = -0.001 * collisionPriority * position.w; } if (collision_enabled) { vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0)); vec2 collision_texCoords = collision_getCoords(collision_common_position); collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0); if (collision_fade < 0.0001) { position = vec4(0.0, 0.0, 2.0, 1.0); } } `,"vs:DECKGL_FILTER_COLOR":` color.a *= collision_fade; `},XK=(t,e)=>{if(!t||!("dummyCollisionMap"in t))return{};let{collisionFBO:r,drawToCollisionMap:s,dummyCollisionMap:i}=t;return{collision_sort:Boolean(s),collision_texture:!s&&r?r.colorAttachments[0]:i}},MB={name:"collision",dependencies:[Qe],vs:WK,inject:jK,getUniforms:XK};var Uf=class extends _t{renderCollisionMap(e,r){let i=[0,0,0,0],n=[1,1,e.width-2*1,e.height-2*1];this.render({...r,clearColor:i,scissorRect:n,target:e,pass:"collision"})}getLayerParameters(e,r,s){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}getModuleParameters(){return{drawToCollisionMap:!0,picking:{isActive:1,isAttribute:!1},lightSources:{}}}};var vb=2,kf=class{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(e){this.context=e;let{device:r}=e;this.dummyCollisionMap=r.createTexture({width:1,height:1}),this.collisionFilterPass=new Uf(r,{id:"default-collision-filter"})}preRender({effects:e,layers:r,layerFilter:s,viewports:i,onViewportActive:n,views:o,isPicking:a,preRenderStats:c={}}){let{device:l}=this.context;if(a)return;let u=r.filter(({props:{visible:m,collisionEnabled:_}})=>m&&_);if(u.length===0){this.channels={};return}let f=e?.filter(m=>m.useInPicking&&c[m.id]),h=c["mask-effect"]?.didRender,d=this._groupByCollisionGroup(l,u),p=i[0],g=!this.lastViewport||!this.lastViewport.equals(p)||h;for(let m in d){let _=this.collisionFBOs[m],y=d[m],[x,S]=l.canvasContext.getPixelSize();_.resize({width:x/vb,height:S/vb}),this._render(y,{effects:f,layerFilter:s,onViewportActive:n,views:o,viewport:p,viewportChanged:g})}}_render(e,{effects:r,layerFilter:s,onViewportActive:i,views:n,viewport:o,viewportChanged:a}){let{collisionGroup:c}=e,l=this.channels[c];if(!l)return;let u=a||e===l||!ve(l.layers,e.layers,1)||e.layerBounds.some((f,h)=>!Ce(f,l.layerBounds[h]))||e.allLayersLoaded!==l.allLayersLoaded||e.layers.some(f=>f.props.transitions);if(this.channels[c]=e,u){this.lastViewport=o;let f=this.collisionFBOs[c];this.collisionFilterPass.renderCollisionMap(f,{pass:"collision-filter",isPicking:!0,layers:e.layers,effects:r,layerFilter:s,viewports:o?[o]:[],onViewportActive:i,views:n,moduleParameters:{dummyCollisionMap:this.dummyCollisionMap,devicePixelRatio:f.device.canvasContext.getDevicePixelRatio()/vb}})}}_groupByCollisionGroup(e,r){let s={};for(let i of r){let{collisionGroup:n}=i.props,o=s[n];o||(o={collisionGroup:n,layers:[],layerBounds:[],allLayersLoaded:!0},s[n]=o),o.layers.push(i),o.layerBounds.push(i.getBounds()),i.isLoaded||(o.allLayersLoaded=!1)}for(let i of Object.keys(s))this.collisionFBOs[i]||this.createFBO(e,i),this.channels[i]||(this.channels[i]=s[i]);for(let i of Object.keys(this.collisionFBOs))s[i]||this.destroyFBO(i);return s}getModuleParameters(e){let{collisionGroup:r}=e.props,{collisionFBOs:s,dummyCollisionMap:i}=this;return{collisionFBO:s[r],dummyCollisionMap:i}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(let e of Object.keys(this.collisionFBOs))this.destroyFBO(e);this.collisionFBOs={},this.lastViewport=void 0}createFBO(e,r){let{width:s,height:i}=e.gl.canvas,n=e.createTexture({format:"rgba8unorm",width:s,height:i,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),o=e.createTexture({format:"depth16unorm",width:s,height:i,mipmaps:!1,dataFormat:6402,type:5125});this.collisionFBOs[r]=e.createFramebuffer({id:`collision-${r}`,width:s,height:i,colorAttachments:[n],depthStencilAttachment:o})}destroyFBO(e){let r=this.collisionFBOs[e];r.colorAttachments[0]?.destroy(),r.depthStencilAttachment?.destroy(),r.destroy(),delete this.collisionFBOs[e]}};var YK={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},Vf=class extends tt{getShaders(){return{modules:[MB]}}draw({uniforms:e,context:r,moduleParameters:s}){let{collisionEnabled:i}=this.props,{collisionFBO:n,drawToCollisionMap:o}=s,a=i&&Boolean(n);e.collision_enabled=a,o&&(this.props=this.clone(this.props.collisionTestProps).props)}initializeState(e,r){if(this.getAttributeManager()===null)return;this.context.deck?._addDefaultEffect(new kf),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}};Vf.defaultProps=YK;Vf.extensionName="CollisionFilterExtension";var RB=Vf;var qK=` uniform vec4 mask_bounds; uniform bool mask_maskByInstance; vec2 mask_getCoords(vec4 position) { return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy); } `,KK=` uniform sampler2D mask_texture; uniform int mask_channel; uniform bool mask_enabled; uniform bool mask_inverted; bool mask_isInBounds(vec2 texCoords) { if (!mask_enabled) { return true; } vec4 maskColor = texture(mask_texture, texCoords); float maskValue = 1.0; if (mask_channel == 0) { maskValue = maskColor.r; } else if (mask_channel == 1) { maskValue = maskColor.g; } else if (mask_channel == 2) { maskValue = maskColor.b; } else if (mask_channel == 3) { maskValue = maskColor.a; } if (mask_inverted) { return maskValue >= 0.5; } else { return maskValue < 0.5; } } `,$K={"vs:#decl":` out vec2 mask_texCoords; `,"vs:#main-end":` vec4 mask_common_position; if (mask_maskByInstance) { mask_common_position = project_position(vec4(geometry.worldPosition, 1.0)); } else { mask_common_position = geometry.position; } mask_texCoords = mask_getCoords(mask_common_position); `,"fs:#decl":` in vec2 mask_texCoords; `,"fs:#main-start":` if (mask_enabled) { bool mask = mask_isInBounds(mask_texCoords); fragColor = texture(mask_texture, mask_texCoords); if (!mask) discard; } `},JK=t=>t&&"maskMap"in t?{mask_texture:t.maskMap}:{},IB={name:"mask",dependencies:[Qe],vs:qK,fs:KK,inject:$K,getUniforms:JK};var ZK={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"},zf=class extends _t{constructor(e,r){super(e,r);let{mapSize:s=2048}=r;this.maskMap=e.createTexture({format:"rgba8unorm",width:s,height:s,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=e.createFramebuffer({id:"maskmap",width:s,height:s,colorAttachments:[this.maskMap]})}render(e){let r=2**e.channel,s=[255,255,255,255];super.render({...e,clearColor:s,colorMask:r,target:this.fbo,pass:"mask"})}getLayerParameters(e,r,s){return{...e.props.parameters,blend:!0,depthTest:!1,...ZK}}shouldDrawLayer(e){return e.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}};function Ga(t,e){let r=[1/0,1/0,-1/0,-1/0];for(let s of t){let i=s.getBounds();if(i){let n=s.projectPosition(i[0],{viewport:e,autoOffset:!1}),o=s.projectPosition(i[1],{viewport:e,autoOffset:!1});r[0]=Math.min(r[0],n[0]),r[1]=Math.min(r[1],n[1]),r[2]=Math.max(r[2],o[0]),r[3]=Math.max(r[3],o[1])}}return Number.isFinite(r[0])?r:null}var QK=2048;function Wa(t){let{bounds:e,viewport:r,border:s=0}=t,{isGeospatial:i}=r;if(e[2]<=e[0]||e[3]<=e[1])return null;let n=r.unprojectPosition([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),{width:o,height:a,zoom:c}=t;if(c===void 0){o=o-s*2,a=a-s*2;let l=Math.min(o/(e[2]-e[0]),a/(e[3]-e[1]));c=Math.min(Math.log2(l),20)}else if(!o||!a){let l=2**c;o=Math.round(Math.abs(e[2]-e[0])*l),a=Math.round(Math.abs(e[3]-e[1])*l);let u=QK-s*2;if(o>u||a>u){let f=u/Math.max(o,a);o=Math.round(o*f),a=Math.round(a*f),c+=Math.log2(f)}}return i?new Et({id:r.id,x:s,y:s,width:o,height:a,longitude:n[0],latitude:n[1],zoom:c,orthographic:!0}):new js({id:r.id,x:s,y:s,width:o,height:a,target:n,zoom:c,flipY:!1})}function e$(t,e){let r;if(e&&e.length===2){let[n,o]=e,a=t.getBounds({z:n}),c=t.getBounds({z:o});r=[Math.min(a[0],c[0]),Math.min(a[1],c[1]),Math.max(a[2],c[2]),Math.max(a[3],c[3])]}else r=t.getBounds();let s=t.projectPosition(r.slice(0,2)),i=t.projectPosition(r.slice(2,4));return[s[0],s[1],i[0],i[1]]}function ja(t,e,r){if(!t)return[0,0,1,1];let s=e$(e,r),i=t$(s);return t[2]-t[0]<=i[2]-i[0]&&t[3]-t[1]<=i[3]-i[1]?t:[Math.max(t[0],i[0]),Math.max(t[1],i[1]),Math.min(t[2],i[2]),Math.min(t[3],i[3])]}function t$(t){let e=t[2]-t[0],r=t[3]-t[1],s=(t[0]+t[2])/2,i=(t[1]+t[3])/2;return[s-e,i-r,s+e,i+r]}var Hf=class{constructor(){this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.channels=[],this.masks=null}setup({device:e}){this.dummyMaskMap=e.createTexture({width:1,height:1}),this.maskPass=new zf(e,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:e,layerFilter:r,viewports:s,onViewportActive:i,views:n,isPicking:o}){let a=!1;if(o)return{didRender:a};let c=e.filter(h=>h.props.visible&&h.props.operation.includes("mask"));if(c.length===0)return this.masks=null,this.channels.length=0,{didRender:a};this.masks={};let l=this._sortMaskChannels(c),u=s[0],f=!this.lastViewport||!this.lastViewport.equals(u);if(u.resolution!==void 0)return k.warn("MaskExtension is not supported in GlobeView")(),{didRender:a};for(let h in l){let d=this._renderChannel(l[h],{layerFilter:r,onViewportActive:i,views:n,viewport:u,viewportChanged:f});a||(a=d)}return{didRender:a}}_renderChannel(e,{layerFilter:r,onViewportActive:s,views:i,viewport:n,viewportChanged:o}){let a=!1,c=this.channels[e.index];if(!c)return a;let l=e===c||e.layers.length!==c.layers.length||e.layers.some((u,f)=>u!==c.layers[f]||u.props.transitions)||e.layerBounds.some((u,f)=>u!==c.layerBounds[f]);if(e.bounds=c.bounds,e.maskBounds=c.maskBounds,this.channels[e.index]=e,l||o){this.lastViewport=n;let u=Ga(e.layers,n);if(e.bounds=u&&ja(u,n),l||!Ce(e.bounds,c.bounds)){let{maskPass:f,maskMap:h}=this,d=u&&Wa({bounds:e.bounds,viewport:n,width:h.width,height:h.height,border:1});e.maskBounds=d?d.getBounds():[0,0,1,1],f.render({pass:"mask",channel:e.index,layers:e.layers,layerFilter:r,viewports:d?[d]:[],onViewportActive:s,views:i,moduleParameters:{devicePixelRatio:1}}),a=!0}}return this.masks[e.id]={index:e.index,bounds:e.maskBounds,coordinateOrigin:e.coordinateOrigin,coordinateSystem:e.coordinateSystem},a}_sortMaskChannels(e){let r={},s=0;for(let i of e){let{id:n}=i.root,o=r[n];if(!o){if(++s>4){k.warn("Too many mask layers. The max supported is 4")();continue}o={id:n,index:this.channels.findIndex(a=>a?.id===n),layers:[],layerBounds:[],coordinateOrigin:i.root.props.coordinateOrigin,coordinateSystem:i.root.props.coordinateSystem},r[n]=o}o.layers.push(i),o.layerBounds.push(i.getBounds())}for(let i=0;i<4;i++){let n=this.channels[i];(!n||!(n.id in r))&&(this.channels[i]=null)}for(let i in r){let n=r[i];n.index<0&&(n.index=this.channels.findIndex(o=>!o),this.channels[n.index]=n)}return r}getModuleParameters(){return{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}}cleanup(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0}};var r$={maskId:"",maskByInstance:void 0,maskInverted:!1},Gf=class extends tt{initializeState(){this.context.deck?._addDefaultEffect(new Hf)}getShaders(){let e="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(e=Boolean(this.props.maskByInstance)),this.state.maskByInstance=e,{modules:[IB]}}draw({uniforms:e,context:r,moduleParameters:s}){e.mask_maskByInstance=this.state.maskByInstance;let{maskId:i,maskInverted:n}=this.props,{maskChannels:o}=s,{viewport:a}=r;if(o&&o[i]){let{index:c,bounds:l,coordinateOrigin:u}=o[i],{coordinateSystem:f}=o[i];e.mask_enabled=!0,e.mask_channel=c,e.mask_inverted=n,f===X.DEFAULT&&(f=a.isGeospatial?X.LNGLAT:X.CARTESIAN);let h={modelMatrix:null,fromCoordinateOrigin:u,fromCoordinateSystem:f},d=this.projectPosition([l[0],l[1],0],h),p=this.projectPosition([l[2],l[3],0],h);e.mask_bounds=[d[0],d[1],p[0],p[1]]}else i&&k.warn(`Could not find a mask layer with id: ${i}`)(),e.mask_enabled=!1}};Gf.defaultProps=r$;Gf.extensionName="MaskExtension";var BB=Gf;var vs={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},OB=Object.keys(vs).map(t=>`const float TERRAIN_MODE_${t} = ${vs[t]}.0;`).join(` `),Wf={name:"terrain",dependencies:[Qe],inject:{"vs:#decl":` uniform float terrain_mode; uniform sampler2D terrain_map; uniform vec4 terrain_bounds; out vec3 commonPos; `+OB,"vs:#main-start":` if (terrain_mode == TERRAIN_MODE_SKIP) { gl_Position = vec4(0.0); return; } `,"vs:DECKGL_FILTER_GL_POSITION":` commonPos = geometry.position.xyz; if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) { vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw; position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0); commonPos.z += project_uCommonOrigin.z; } if (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) { vec3 anchor = geometry.worldPosition; anchor.z = 0.0; vec3 anchorCommon = project_position(anchor); vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw; if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) { float terrainZ = texture(terrain_map, texCoords).r; geometry.position.z += terrainZ; position = project_common_position_to_clipspace(geometry.position); } } `,"fs:#decl":` uniform float terrain_mode; uniform sampler2D terrain_map; uniform vec4 terrain_bounds; in vec3 commonPos; `+OB,"fs:#main-start":` if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) { fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0); return; } `,"fs:DECKGL_FILTER_COLOR":` if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) { vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw; vec4 pixel = texture(terrain_map, texCoords); if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) { color = pixel; } else { color = pixel + color * (1.0 - pixel.a); } return; } `},getUniforms:(t={},e)=>{if("dummyHeightMap"in t){let{drawToTerrainHeightMap:r,heightMap:s,heightMapBounds:i,dummyHeightMap:n,terrainCover:o,useTerrainHeightMap:a,terrainSkipRender:c}=t,{project_uCommonOrigin:l}=e,u=c?vs.SKIP:vs.NONE,f=n,h=null;if(r)u=vs.WRITE_HEIGHT_MAP,h=i;else if(a&&s)u=vs.USE_HEIGHT_MAP,f=s,h=i;else if(o){let d=t.picking?.isActive;f=(d?o.getPickingFramebuffer():o.getRenderFramebuffer())?.colorAttachments[0].texture,d&&(u=vs.SKIP),f?(u=u===vs.SKIP?vs.USE_COVER_ONLY:vs.USE_COVER,h=o.bounds):f=n}return{terrain_mode:u,terrain_map:f,terrain_bounds:h?[h[0]-l[0],h[1]-l[1],h[2]-h[0],h[3]-h[1]]:[0,0,0,0]}}return null}};function jf(t,e){return t.createFramebuffer({id:e.id,colorAttachments:[t.createTexture({id:e.id,...e.float&&{format:"rgba32float",type:5126},mipmaps:!1,sampler:e.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var Sm=class{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=FB(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:r,layers:s,layerNeedsRedraw:i}){e&&(this.targetLayer=e);let n=r?this._updateViewport(r):!1,o=s?this._updateLayers(s):!1;if(i){for(let a of this.layers)if(i[a]){o=!0;break}}return o||n}_updateLayers(e){let r=!1;if(e=this.tile?s$(this.tile,e):e,e.length!==this.layers.length)r=!0;else for(let s=0;ss.id)),r}_updateViewport(e){let r=this.targetLayer,s=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){s=!0,this.targetBounds=this.tile.boundingBox;let n=e.projectPosition(this.targetBounds[0]),o=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[n[0],n[1],o[0],o[1]]}}else this.targetBounds!==r.getBounds()&&(s=!0,this.targetBounds=r.getBounds(),this.targetBoundsCommon=Ga([r],e));if(!this.targetBoundsCommon)return!1;let i=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let n=this.renderViewport?.zoom;s=s||i!==n;let o=ja(this.targetBoundsCommon,e),a=this.bounds;s=s||!a||o.some((c,l)=>c!==a[l]),this.bounds=o}return s&&(this.renderViewport=Wa({bounds:this.bounds,zoom:i,viewport:e})),s}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=jf(this.targetLayer.context.device,{id:this.id})),this.fbo)}getPickingFramebuffer(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=jf(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:r})=>this.layers.includes(r))}delete(){let{fbo:e,pickingFbo:r}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),r&&(r.colorAttachments[0].destroy(),r.destroy())}};function s$(t,e){return e.filter(r=>{let s=FB(r);return s?i$(t.boundingBox,s.boundingBox):!0})}function FB(t){for(;t;){let{tile:e}=t.props;if(e)return e;t=t.parent}return null}function i$(t,e){return t&&e?t[0][0]n!==this.layers[o]||n.props.transitions||n.getBounds()!==this.layersBounds[o]);s&&(this.layers=e,this.layersBounds=e.map(n=>n.getBounds()),this.layersBoundsCommon=Ga(e,r));let i=!this.lastViewport||!r.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(s||i){let n=ja(this.layersBoundsCommon,r);if(n[2]<=n[0]||n[3]<=n[1])return this.renderViewport=null,!1;this.bounds=n,this.lastViewport=r;let o=r.scale,a=(n[2]-n[0])*o,c=(n[3]-n[1])*o;return this.renderViewport=a>0||c>0?Wa({bounds:[r.center[0]-1,r.center[1]-1,r.center[0]+1,r.center[1]+1],zoom:r.zoom,width:Math.min(a,LB),height:Math.min(c,LB),viewport:r}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var wm=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:r}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new vm(e,{id:"terrain"}),this.terrainPickingPass=new Cm(e,{id:"terrain-picking"}),Xf.isSupported(e)?this.heightMap=new Xf(e):k.warn("Terrain offset mode is not supported by this browser")(),r._addDefaultShaderModule(Wf)}preRender(e){if(e.pickZ){this.isDrapingEnabled=!1;return}let{viewports:r}=e,s=e.pass.startsWith("picking");this.isPicking=s,this.isDrapingEnabled=!0;let i=r[0],n=(s?this.terrainPickingPass:this.terrainPass).getRenderableLayers(i,e),o=n.filter(c=>c.props.operation.includes("terrain"));if(o.length===0)return;s||n.filter(l=>l.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(o,i,e);let a=n.filter(c=>c.state.terrainDrawMode==="drape");this._updateTerrainCovers(o,a,i,e)}getModuleParameters(e){let{terrainDrawMode:r}=e.state;return{heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(e.id):null,useTerrainHeightMap:r==="offset",terrainSkipRender:r==="drape"||!e.props.operation.includes("draw")}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(let r of this.terrainCovers.values())r.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(Wf)}_updateHeightMap(e,r,s){!this.heightMap||!this.heightMap.shouldUpdate({layers:e,viewport:r})||this.terrainPass.renderHeightMap(this.heightMap,{...s,layers:e,moduleParameters:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,devicePixelRatio:1,drawToTerrainHeightMap:!0}})}_updateTerrainCovers(e,r,s,i){let n={};for(let o of r)o.state.terrainCoverNeedsRedraw&&(n[o.id]=!0,o.state.terrainCoverNeedsRedraw=!1);for(let o of this.terrainCovers.values())o.isDirty=o.isDirty||o.shouldUpdate({layerNeedsRedraw:n});for(let o of e)this._updateTerrainCover(o,r,s,i);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,r,s,i){let n=this.isPicking?this.terrainPickingPass:this.terrainPass,o=this.terrainCovers.get(e.id);o||(o=new Sm(e),this.terrainCovers.set(e.id,o));try{let a=o.shouldUpdate({targetLayer:e,viewport:s,layers:r});(this.isPicking||o.isDirty||a)&&(n.renderTerrainCover(o,{...i,layers:r,moduleParameters:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1,devicePixelRatio:1}}),this.isPicking||(o.isDirty=!1))}catch(a){e.raiseError(a,`Error rendering terrain cover ${o.id}`)}}_pruneTerrainCovers(){let e=[];for(let[r,s]of this.terrainCovers)s.isActive||e.push(r);for(let r of e)this.terrainCovers.delete(r)}};var o$={terrainDrawMode:void 0},Yf=class extends tt{getShaders(){return{modules:[Wf]}}initializeState(){this.context.deck?._addDefaultEffect(new wm)}updateState(e){let{props:r,oldProps:s}=e;if(this.state.terrainDrawMode&&r.terrainDrawMode===s.terrainDrawMode&&r.extruded===s.extruded)return;let{terrainDrawMode:i}=r;if(!i){let n=this.props.extruded,o=this.getAttributeManager()?.attributes,a=o&&"instancePositions"in o;i=n||a?"offset":"drape"}this.setState({terrainDrawMode:i})}onNeedsRedraw(){let e=this.state;e.terrainDrawMode==="drape"&&(e.terrainCoverNeedsRedraw=!0)}};Yf.defaultProps=o$;Yf.extensionName="TerrainExtension";var NB=Yf;function Pb(t,e,r){let s=a$(t),i=Object.keys(s).filter(n=>s[n]!==Array);return c$(t,{propArrayTypes:s,...e},{numericPropKeys:r&&r.numericPropKeys||i,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function a$(t){let e={};for(let r of t)if(r.properties)for(let s in r.properties){let i=r.properties[s];e[s]=p$(i,e[s])}return e}function c$(t,e,r){let{pointPositionsCount:s,pointFeaturesCount:i,linePositionsCount:n,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:f,propArrayTypes:h,coordLength:d}=e,{numericPropKeys:p=[],PositionDataType:g=Float32Array,triangulate:m=!0}=r,_=t[0]&&"id"in t[0],y=t.length>65535?Uint32Array:Uint16Array,x={type:"Point",positions:new g(s*d),globalFeatureIds:new y(s),featureIds:i>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},S={type:"LineString",pathIndices:n>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new g(n*d),globalFeatureIds:new y(n),featureIds:a>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},P={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new g(c*d),globalFeatureIds:new y(c),featureIds:f>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};m&&(P.triangles=[]);for(let L of[x,S,P])for(let M of p){let v=h[M];L.numericProps[M]=new v(L.positions.length/d)}S.pathIndices[o]=n,P.polygonIndices[l]=c,P.primitivePolygonIndices[u]=c;let B={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let L of t){let M=L.geometry,v=L.properties||{};switch(M.type){case"Point":l$(M,x,B,d,v),x.properties.push(wb(v,p)),_&&x.fields.push({id:L.id}),B.pointFeature++;break;case"LineString":u$(M,S,B,d,v),S.properties.push(wb(v,p)),_&&S.fields.push({id:L.id}),B.lineFeature++;break;case"Polygon":f$(M,P,B,d,v),P.properties.push(wb(v,p)),_&&P.fields.push({id:L.id}),B.polygonFeature++;break;default:throw new Error("Invalid geometry type")}B.feature++}return d$(x,S,P,d)}function l$(t,e,r,s,i){e.positions.set(t.data,r.pointPosition*s);let n=t.data.length/s;Mb(e,i,r.pointPosition,n),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+n),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+n),r.pointPosition+=n}function u$(t,e,r,s,i){e.positions.set(t.data,r.linePosition*s);let n=t.data.length/s;Mb(e,i,r.linePosition,n),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+n),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+n);for(let o=0,a=t.indices.length;o(h-l)/n),f=dA(c,u,n,e);for(let h=0,d=f.length;hc>=e&&c<=r),n=t.primitivePolygonIndices.value.filter(c=>c>=e&&c<=r);if(!(i.length>2)){let c=[];for(let l=0;la>=e&&a<=r);if(!(i.length>2))return{type:"LineString",coordinates:Mm(s,i[0],i[1])};let o=[];for(let a=0;a1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Mm(t,e,r){e=e||0,r=r||t.value.length/t.size;let s=[];for(let i=e;i>3}if(i--,s===1||s===2)n+=e.readSVarint(),o+=e.readSVarint(),s===1&&(c&&a.push(c),c=[]),c&&c.push([n,o]);else if(s===7)c&&c.push(c[0].slice());else throw new Error(`unknown command ${s}`)}return c&&a.push(c),a}bbox(){let e=this._pbf;e.pos=this._geometry;let r=e.readVarint()+e.pos,s=1,i=0,n=0,o=0,a=1/0,c=-1/0,l=1/0,u=-1/0;for(;e.pos>3}if(i--,s===1||s===2)n+=e.readSVarint(),o+=e.readSVarint(),nc&&(c=n),ou&&(u=o);else if(s!==7)throw new Error(`unknown command ${s}`)}return[a,l,c,u]}_toGeoJSON(e){let r=this.loadGeometry(),s=qa.types[this.type],i,n;switch(this.type){case 1:let a=[];for(i=0;i=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let r=this._pbf.readVarint()+this._pbf.pos;return new qa(this._pbf,r,this.extent,this._keys,this._values)}};function z$(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(H$(r)))}function H$(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos>3;e=s===1?t.readString():s===2?t.readFloat():s===3?t.readDouble():s===4?t.readVarint64():s===5?t.readVarint():s===6?t.readSVarint():s===7?t.readBoolean():null}return e}var Fm=class{layers;constructor(e,r){this.layers=e.readFields(G$,{},r)}};function G$(t,e,r){if(t===3&&r){let s=new Om(r,r.readVarint()+r.pos);s.length&&e&&(e[s.name]=s)}}function KB(t){let e=t.indices.length,r="Polygon";if(e<=1)return{type:r,data:t.data,areas:[[Di(t.data)]],indices:[t.indices]};let s=[],i=[],n=[],o=[],a,c=0;for(let l,u=0,f;u>3),Lm--,mo===1||mo===2)Ob+=e.readSVarint(),Fb+=e.readSVarint(),mo===1&&r.push(qf),s.push(Ob,Fb),qf+=2;else if(mo===7){if(qf>0){let i=r[r.length-1];s.push(s[i],s[i+1]),qf+=2}}else throw new Error(`unknown command ${mo}`);return{data:s,indices:r}}_toBinaryCoordinates(e){let r=this.loadGeometry(),s;e(r.data,this);let i=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=r.indices.length,s={type:"Point",...r};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=r.indices.length,this._geometryInfo.linePositionsCount+=r.data.length/i,s={type:"LineString",...r};break;case 3:s=KB(r),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=s.indices.length;for(let o of s.indices)this._geometryInfo.polygonRingsCount+=o.length;this._geometryInfo.polygonPositionsCount+=s.data.length/i;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let n={type:"Feature",geometry:s,properties:this.properties};return this.id!==null&&(n.id=this.id),n}toBinaryCoordinates(e){if(typeof e=="function")return this._toBinaryCoordinates(e);let{x:r,y:s,z:i}=e,n=this.extent*Math.pow(2,i),o=this.extent*r,a=this.extent*s;return this._toBinaryCoordinates(c=>$B(c,o,a,n))}};var Dm=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(e,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(j$,this,r),this.length=this._features.length}feature(e,r){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];let s=this._pbf.readVarint()+this._pbf.pos;return new Nm(this._pbf,s,this.extent,this._keys,this._values,r)}};function j$(t,e,r){e&&r&&(t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(X$(r)))}function X$(t){let e=null,r=t.readVarint()+t.pos;for(;t.pos>3;e=s===1?t.readString():s===2?t.readFloat():s===3?t.readDouble():s===4?t.readVarint64():s===5?t.readVarint():s===6?t.readSVarint():s===7?t.readBoolean():null}return e}var Um=class{layers;constructor(e,r){this.layers=e.readFields(Y$,{},r)}};function Y$(t,e,r){if(t===3&&r){let s=new Dm(r,r.readVarint()+r.pos);s.length&&e&&(e[s.name]=s)}}function Db(t,e){let r=K$(e),s=e?.gis?.format||e?.mvt?.shape||e?.shape;switch(s){case"columnar-table":return{shape:"columnar-table",data:Lb(t,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:QB(t,r)};case"geojson":return QB(t,r);case"binary-geometry":return Lb(t,r);case"binary":return Lb(t,r);default:throw new Error(s||"undefined shape")}}function Lb(t,e){let[r,s]=q$(t,e),i=Pb(r,s);return i.byteLength=t.byteLength,i}function q$(t,e){let r=[],s={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength<=0)return[r,s];let i=new Um(new Nb.default(t));return(e&&Array.isArray(e.layers)?e.layers:Object.keys(i.layers)).forEach(o=>{let a=i.layers[o];if(a)for(let c=0;c{let o=s.layers[n];if(o)for(let a=0;aDb(t,e),parseSync:Db,binary:!0};var rJ={Point:eO,MultiPoint:sJ,LineString:tO,MultiLineString:iJ,Polygon:rO,MultiPolygon:nJ};function eO([t,e],[r,s],i){let n=it(r[0],s[0],t),o=it(r[1],s[1],e);return i.unprojectFlat([n,o])}function Ub(t,e,r){return t.map(s=>eO(s,e,r))}function sJ(t,e,r){return Ub(t,e,r)}function tO(t,e,r){return Ub(t,e,r)}function iJ(t,e,r){return t.map(s=>tO(s,e,r))}function rO(t,e,r){return t.map(s=>Ub(s,e,r))}function nJ(t,e,r){return t.map(s=>rO(s,e,r))}function sO(t,e,r){let s=r.projectFlat([e.west,e.north]),i=r.projectFlat([e.east,e.south]),n=[s,i];return{...t,coordinates:rJ[t.type](t.coordinates,n,r)}}var oJ=["points","lines","polygons"];function kb(t,e,r,s){for(let i of oJ){let n=t[i]&&aJ(t[i],e,r,s);if(n>=0)return n}return-1}function aJ(t,e,r,s){let i=t.featureIds.value;if(!i.length)return-1;let n=0,o=i[i.length-1]+1;if(s){let c=cJ(t,s);if(c)n=c[0],o=c[1]+1;else return-1}let a=-1;if(e in t.numericProps){let c=t.numericProps[e].value.findIndex((l,u)=>l===r&&i[u]>=n&&i[u]=0?t.globalFeatureIds.value[c]:-1}else e?a=iO(t.properties,c=>c[e]===r,n,o):t.fields&&(a=iO(t.fields,c=>c.id===r,n,o));return a>=0?lJ(t,a):-1}function cJ(t,e){if(!t.__layers){let r={},{properties:s}=t;for(let i=0;is&&(e.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(i)||r.maxzoom{let h=zb(f,n)===u,d=c||nO(f)===s;return h&&d}):a&&i?kb(a,n,u,c?"":s):-1}_pickObjects(e){let{deck:r,viewport:s}=this.context,i=s.width,n=s.height,o=s.x,a=s.y,c=[this.id];return r.pickObjects({x:o,y:a,width:i,height:n,layerIds:c,maxObjects:e})}getRenderedFeatures(e=null){let r=this._pickObjects(e),s=new Set,i=[];for(let n of r){let o=zb(n.object,this.props.uniqueIdProperty);o===void 0?i.push(n.object):s.has(o)||(s.add(o),i.push(n.object))}return i}_setWGS84PropertyForTiles(){let e="dataInWGS84";this.state.tileset.selectedTiles.forEach(s=>{s.hasOwnProperty(e)||Object.defineProperty(s,e,{get:()=>{if(!s.content)return null;if(this.state.binary&&Array.isArray(s.content)&&!s.content.length)return[];let{bbox:i}=s;if(s._contentWGS84===void 0&&QA(i)){let n=this.state.binary?Rm(s.content):s.content;s._contentWGS84=n.map(o=>aO(o,i,this.context.viewport))}return s._contentWGS84}})})}};Kf.layerName="MVTLayer";Kf.defaultProps=uJ;var cO=Kf;function zb(t,e){if(t.properties&&e)return t.properties[e];if("id"in t)return t.id}function nO(t){return t.properties?.layerName||null}function oO(t){return t!=null&&t!==""}function aO(t,e,r){let s={...t,geometry:{type:t.geometry.type}};return Object.defineProperty(s.geometry,"coordinates",{get:()=>sO(t.geometry,e,r).coordinates}),s}var lO="0123456789bcdefghjkmnpqrstuvwxyz",uO={};for(let t=0;t=0;f--){let h=a>>f&1;e?(o=(i+n)/2,h===1?n=o:i=o):(o=(r+s)/2,h===1?s=o:r=o),e=!e}}return[s,n,r,i]}function fO(t){let[e,r,s,i]=gJ(t);return[i,s,i,e,r,e,r,s,i,s]}var mJ={getGeohash:{type:"accessor",value:t=>t.geohash}},$f=class extends As{indexToBounds(){let{data:e,getGeohash:r}=this.props;return{data:e,_normalize:!1,positionFormat:"XY",getPolygon:(s,i)=>fO(r(s,i))}}};$f.layerName="GeohashLayer";$f.defaultProps=mJ;var hO=$f;var Hb={};Ke(Hb,{Buffer:()=>Q,BufferTransform:()=>_r,CubeGeometry:()=>Ds,Device:()=>Zt,Framebuffer:()=>us,Geometry:()=>se,GroupNode:()=>tr,Model:()=>J,ModelNode:()=>ds,ScenegraphNode:()=>yr,SphereGeometry:()=>El,Texture:()=>xe,TextureTransform:()=>hs,attachDevice:()=>bJ,createDevice:()=>EJ,enforceWebGL2:()=>SJ,getAvailableDevices:()=>xJ,getSupportedDevices:()=>AJ,registerDevices:()=>yJ,setDefaultDeviceProps:()=>TJ,stats:()=>_J});var{stats:_J,registerDevices:yJ,getAvailableDevices:xJ,getSupportedDevices:AJ,setDefaultDeviceProps:TJ,attachDevice:bJ,createDevice:EJ,enforceWebGL2:SJ}=Vt;var Gb={};Ke(Gb,{fetchFile:()=>vo,load:()=>$e,parse:()=>fi,registerLoaders:()=>Lc});var Vm=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let r=this.props,s={...this.props,...e};if(this.props=s,!this.map)return;this._update(r,s)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:r,container:s}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:s,maxZoom:24,...e.mapOptions,...dO(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(s,"offsetWidth",{get:()=>this.width}),Object.defineProperty(s,"clientWidth",{get:()=>this.width}),Object.defineProperty(s,"offsetHeight",{get:()=>this.height}),Object.defineProperty(s,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let i=e.width!==r.width||e.height!==r.height;i&&(this.width=r.width,this.height=r.height,this.map.resize());let n=e.viewState,o=r.viewState,a=o.latitude!==n.latitude||o.longitude!==n.longitude||o.zoom!==n.zoom||o.pitch!==n.pitch||o.bearing!==n.bearing;return a&&this.map.jumpTo(dO(o)),i||a}};function dO(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var pO={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function vJ(t){let{container:e=document.body}=t;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let s=document.createElement("div");e.appendChild(s),Object.assign(s.style,pO);let i=document.createElement("canvas");return e.appendChild(i),Object.assign(i.style,pO),{container:e,mapCanvas:s,deckCanvas:i}}var Jf=class extends jr{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:s}=vJ(e),i=e.viewState||e.initialViewState,n=Number.isFinite(i&&i.latitude),{map:o=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:s,...e}),o&&o.Map?this._map=n&&new Vm({...e,width:0,height:0,viewState:i,container:r,mapLib:o}):this._map=o}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,r){if(this._map){let s=this.getViewports()[0];s&&this._map.setProps({width:s.width,height:s.height,viewState:s})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,Hb);Object.assign(globalThis.loaders,Gb);var Me={SUM:1,MEAN:2,MIN:3,MAX:4};function gO(t,e){return t+e}function CJ(t,e){return e>t?e:t}function wJ(t,e){return eIJ(i,e);case Me.SUM:return i=>MJ(i,e);case Me.MEAN:return i=>PJ(i,e);case Me.MAX:return i=>RJ(i,e);default:return null}}function BJ(t,e={}){return Number.isFinite(t)?t:r=>(e.index=r.index,t(r.source,e))}function mO(t,e={}){return r=>(e.indices=r.map(s=>s.index),t(r.map(s=>s.source),e))}var _O={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},Qi=3402823466e29,Wb=[32775,32774],jb=[32776,32774],yO=[32776,32775],Xb={[Me.SUM]:32774,[Me.MEAN]:32774,[Me.MIN]:Wb,[Me.MAX]:jb};var xO={size:1,operation:Me.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},AO=4;var TO=`#version 300 es #define SHADER_NAME gpu-aggregation-to-grid-vs in vec3 positions; in vec3 positions64Low; in vec3 weights; uniform vec2 cellSize; uniform vec2 gridSize; uniform bool projectPoints; uniform vec2 translation; uniform vec3 scaling; out vec3 vWeights; vec2 project_to_pixel(vec4 pos) { vec4 result; pos.xy = pos.xy/pos.w; result = pos + vec4(translation, 0., 0.); result.xy = scaling.z > 0. ? result.xy * scaling.xy : result.xy; return result.xy; } void main(void) { vWeights = weights; vec4 windowPos = vec4(positions, 1.); if (projectPoints) { windowPos = project_position_to_clipspace(positions, positions64Low, vec3(0)); } vec2 pos = project_to_pixel(windowPos); vec2 pixelXY64[2]; pixelXY64[0] = vec2(pos.x, 0.); pixelXY64[1] = vec2(pos.y, 0.); vec2 gridXY64[2]; gridXY64[0] = div_fp64(pixelXY64[0], vec2(cellSize.x, 0)); gridXY64[1] = div_fp64(pixelXY64[1], vec2(cellSize.y, 0)); float x = floor(gridXY64[0].x); float y = floor(gridXY64[1].x); pos = vec2(x, y); pos = (pos * (2., 2.) / (gridSize)) - (1., 1.); vec2 offset = 1.0 / gridSize; pos = pos + offset; gl_Position = vec4(pos, 0.0, 1.0); gl_PointSize = 1.0; } `;var bO=`#version 300 es #define SHADER_NAME gpu-aggregation-to-grid-fs precision highp float; in vec3 vWeights; out vec4 fragColor; void main(void) { fragColor = vec4(vWeights, 1.0); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var EO=`#version 300 es #define SHADER_NAME gpu-aggregation-all-vs-64 in vec2 position; uniform ivec2 gridSize; out vec2 vTextureCoord; void main(void) { vec2 pos = vec2(-1.0, -1.0); vec2 offset = 1.0 / vec2(gridSize); pos = pos + offset; gl_Position = vec4(pos, 0.0, 1.0); int yIndex = gl_InstanceID / gridSize[0]; int xIndex = gl_InstanceID - (yIndex * gridSize[0]); vec2 yIndexFP64 = vec2(float(yIndex), 0.); vec2 xIndexFP64 = vec2(float(xIndex), 0.); vec2 gridSizeYFP64 = vec2(gridSize[1], 0.); vec2 gridSizeXFP64 = vec2(gridSize[0], 0.); vec2 texCoordXFP64 = div_fp64(yIndexFP64, gridSizeYFP64); vec2 texCoordYFP64 = div_fp64(xIndexFP64, gridSizeXFP64); vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x); gl_PointSize = 1.0; } `;var SO=`#version 300 es #define SHADER_NAME gpu-aggregation-all-fs precision highp float; in vec2 vTextureCoord; uniform sampler2D uSampler; uniform bool combineMaxMin; out vec4 fragColor; void main(void) { vec4 textureColor = texture(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); if (textureColor.a == 0.) { discard; } fragColor.rgb = textureColor.rgb; fragColor.a = combineMaxMin ? textureColor.r : textureColor.a; } `;var vO=`#version 300 es #define SHADER_NAME gpu-aggregation-transform-mean-vs in vec4 aggregationValues; out vec4 meanValues; void main() { bool isCellValid = bool(aggregationValues.w > 0.); meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0); meanValues.w = aggregationValues.w; gl_PointSize = 1.0; } `;var OJ={minFilter:"nearest",magFilter:"nearest"};function $a(t,e){let{width:r=1,height:s=1,data:i=null,parameters:n=OJ}=e;return t.createTexture({data:i,format:"rgba32float",mipmaps:!1,sampler:n,width:r,height:s})}function Zf(t,e){let{id:r,width:s=1,height:i=1,texture:n}=e;return t.createFramebuffer({id:r,width:s,height:i,colorAttachments:[n]})}var FJ=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],CO={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},LJ=["float32-renderable-webgl","texture-blend-float-webgl"],ot=class{static getAggregationData({aggregationData:e,maxData:r,minData:s,maxMinData:i,pixelIndex:n}){let o=n*AO,a={};return e&&(a.cellCount=e[o+3],a.cellWeight=e[o]),i?(a.maxCellWieght=i[0],a.minCellWeight=i[3]):(r&&(a.maxCellWieght=r[0],a.totalCount=r[3]),s&&(a.minCellWeight=s[0],a.totalCount=s[3])),a}static getCellData({countsData:e,size:r=1}){let s=e.length/4,i=new Float32Array(s*r),n=new Uint32Array(s);for(let o=0;oe.features.has(r))}constructor(e,r={}){this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},shaderOptions:{},modelDirty:!1,resources:{},results:{}},this.id=r.id||"gpu-grid-aggregator",this.device=e;let s=["float32-renderable-webgl"];this._hasGPUSupport=s.every(i=>e.features.has(i)),this._hasGPUSupport&&this._setupModels()}delete(){let{gridAggregationModel:e,allAggregationModel:r,meanTransform:s}=this,{textures:i,framebuffers:n,maxMinFramebuffers:o,minFramebuffers:a,maxFramebuffers:c,meanTextures:l,resources:u}=this.state;e?.destroy(),r?.destroy(),s?.destroy(),DJ([n,i,o,a,c,l,u])}run(e={}){this.setState({results:{}});let r=this._normalizeAggregationParams(e);return this._runAggregation(r)}getData(e){let r={},s=this.state.results;s[e].aggregationData||(s[e].aggregationData=s[e].aggregationBuffer.getData()),r.aggregationData=s[e].aggregationData;for(let i in CO){let n=CO[i];(s[e][i]||s[e][n])&&(s[e][i]=s[e][i]||s[e][n].getData(),r[i]=s[e][i])}return r}updateShaders(e={}){this.setState({shaderOptions:e,modelDirty:!0})}_normalizeAggregationParams(e){let r={..._O,...e},{weights:s}=r;return s&&(r.weights=NJ(s)),r}setState(e){Object.assign(this.state,e)}_getAggregateData(e){let r={},{textures:s,framebuffers:i,maxMinFramebuffers:n,minFramebuffers:o,maxFramebuffers:a,resources:c}=this.state,{weights:l}=e;for(let u in l){r[u]={};let{needMin:f,needMax:h,combineMaxMin:d}=l[u];r[u].aggregationTexture=s[u],r[u].aggregationBuffer=this.device.readPixelsToBufferWebGL(i[u],{target:l[u].aggregationBuffer,sourceType:5126}),f&&h&&d?(r[u].maxMinBuffer=this.device.readPixelsToBufferWebGL(n[u],{target:l[u].maxMinBuffer,sourceType:5126}),r[u].maxMinTexture=c[`${u}-maxMinTexture`]):(f&&(r[u].minBuffer=this.device.readPixelsToBufferWebGL(o[u],{target:l[u].minBuffer,sourceType:5126}),r[u].minTexture=c[`${u}-minTexture`]),h&&(r[u].maxBuffer=this.device.readPixelsToBufferWebGL(a[u],{target:l[u].maxBuffer,sourceType:5126}),r[u].maxTexture=c[`${u}-maxTexture`]))}return this._trackGPUResultBuffers(r,l),r}_renderAggregateData(e){let{cellSize:r,projectPoints:s,attributes:i,moduleSettings:n,numCol:o,numRow:a,weights:c,translation:l,scaling:u}=e,{maxMinFramebuffers:f,minFramebuffers:h,maxFramebuffers:d}=this.state,p=[o,a],g={blend:!0,depthTest:!1,blendFunc:[1,1]},m={cellSize:r,gridSize:p,projectPoints:s,translation:l,scaling:u};for(let _ in c){let{needMin:y,needMax:x}=c[_],S=y&&x&&c[_].combineMaxMin;this._renderToWeightsTexture({id:_,parameters:g,moduleSettings:n,uniforms:m,gridSize:p,attributes:i,weights:c}),S?this._renderToMaxMinTexture({id:_,parameters:{...g,blendEquation:yO},gridSize:p,minOrMaxFb:f[_],clearParams:{clearColor:[0,0,0,Qi]},combineMaxMin:S}):(y&&this._renderToMaxMinTexture({id:_,parameters:{...g,blendEquation:Wb},gridSize:p,minOrMaxFb:h[_],clearParams:{clearColor:[Qi,Qi,Qi,0]},combineMaxMin:S}),x&&this._renderToMaxMinTexture({id:_,parameters:{...g,blendEquation:jb},gridSize:p,minOrMaxFb:d[_],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:S}))}}_renderToMaxMinTexture(e){let{id:r,gridSize:s,minOrMaxFb:i,combineMaxMin:n,clearParams:o={}}=e,{framebuffers:a}=this.state,{allAggregationModel:c}=this;this.device.withParametersWebGL({...o,framebuffer:i,viewport:[0,0,s[0],s[1]]},()=>{this.device.clearWebGL({color:!0}),c.setUniforms({gridSize:s,combineMaxMin:n}),c.setBindings({uSampler:a[r].texture}),c.draw()})}_renderToWeightsTexture(e){let{id:r,parameters:s,moduleSettings:i,uniforms:n,gridSize:o,weights:a}=e,{framebuffers:c,equations:l,weightAttributes:u}=this.state,{gridAggregationModel:f}=this,{operation:h}=a[r],d=h===Me.MIN?[Qi,Qi,Qi,0]:[0,0,0,0];if(this.device.withParametersWebGL({framebuffer:c[r],viewport:[0,0,o[0],o[1]],clearColor:d},()=>{this.device.clearWebGL({color:!0});let p={weights:u[r]};f.draw({parameters:{...s,blendEquation:l[r]},moduleSettings:i,uniforms:n,attributes:p})}),h===Me.MEAN){let{meanTextures:p,textures:g}=this.state,m={_sourceTextures:{aggregationValues:p[r]},_targetTexture:g[r],elementCount:g[r].width*g[r].height};this.meanTransform?this.meanTransform.update(m):this.meanTransform=VJ(this.device,m),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),c[r].attach({[36064]:g[r]})}}_runAggregation(e){this._updateModels(e),this._setupFramebuffers(e),this._renderAggregateData(e);let r=this._getAggregateData(e);return this.setState({results:r}),r}_setupFramebuffers(e){let{textures:r,framebuffers:s,maxMinFramebuffers:i,minFramebuffers:n,maxFramebuffers:o,meanTextures:a,equations:c}=this.state,{weights:l}=e,{numCol:u,numRow:f}=e,h={width:u,height:f};for(let d in l){let{needMin:p,needMax:g,combineMaxMin:m,operation:_}=l[d];r[d]=l[d].aggregationTexture||r[d]||$a(this.device,{id:`${d}-texture`,width:u,height:f}),r[d].resize(h);let y=r[d];_===Me.MEAN&&(a[d]=a[d]||$a(this.device,{id:`${d}-mean-texture`,width:u,height:f}),a[d].resize(h),y=a[d]),s[d]?s[d].attach({[36064]:y}):s[d]=Zf(this.device,{id:`${d}-fb`,width:u,height:f,texture:y}),s[d].resize(h),c[d]=Xb[_]||Xb[Me.SUM],(p||g)&&(p&&g&&m?i[d]||(y=l[d].maxMinTexture||this._getMinMaxTexture(`${d}-maxMinTexture`),i[d]=Zf(this.device,{id:`${d}-maxMinFb`,texture:y})):(p&&(n[d]||(y=l[d].minTexture||this._getMinMaxTexture(`${d}-minTexture`),n[d]=Zf(this.device,{id:`${d}-minFb`,texture:y}))),g&&(o[d]||(y=l[d].maxTexture||this._getMinMaxTexture(`${d}-maxTexture`),o[d]=Zf(this.device,{id:`${d}-maxFb`,texture:y})))))}}_getMinMaxTexture(e){let{resources:r}=this.state;return r[e]||(r[e]=$a(this.device,{id:"resourceName"})),r[e]}_setupModels({numCol:e=0,numRow:r=0}={}){let{shaderOptions:s}=this.state;if(this.gridAggregationModel?.destroy(),this.gridAggregationModel=UJ(this.device,s),!this.allAggregationModel){let i=e*r;this.allAggregationModel=kJ(this.device,i)}}_setupWeightAttributes(e){let{weightAttributes:r}=this.state,{weights:s}=e;for(let i in s)r[i]=e.attributes[i]}_trackGPUResultBuffers(e,r){let{resources:s}=this.state;for(let i in e)if(e[i]){for(let n of FJ)if(e[i][n]&&r[i][n]!==e[i][n]){let o=`gpu-result-${i}-${n}`;s[o]&&s[o].delete(),s[o]=e[i][n]}}}_updateModels(e){let{vertexCount:r,attributes:s,numCol:i,numRow:n}=e,{modelDirty:o}=this.state;o&&(this._setupModels(e),this.setState({modelDirty:!1})),this._setupWeightAttributes(e),this.gridAggregationModel.setVertexCount(r),this.gridAggregationModel.setAttributes(s),this.allAggregationModel.setInstanceCount(i*n)}};function NJ(t){let e={};for(let r in t)e[r]={...xO,...t[r]};return e}function DJ(t){t=Array.isArray(t)?t:[t],t.forEach(e=>{for(let r in e)e[r].delete()})}function UJ(t,e){let r=ys({vs:TO,fs:bO,modules:[Ls,de]},e);return new J(t,{id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:Ko(),...r})}function kJ(t,e){return new J(t,{id:"All-Aggregation-Model",vs:EO,fs:SO,modules:[Ls],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:e,attributes:{position:[0,0]}})}function VJ(t,e){return new hs(t,{vs:vO,_targetTextureVarying:"meanValues",...e})}var Pr=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function en(t,e=!1,r=Float32Array){let s;if(Number.isFinite(t[0]))s=new r(t);else{s=new r(t.length*4);let i=0;for(let n=0;n= domain.x && value <= domain.y) { float domainRange = domain.y - domain.x; if (domainRange <= 0.) { outColor = colorRange[0]; } else { float rangeCount = float(RANGE_COUNT); float rangeStep = domainRange / rangeCount; float idx = floor((value - domain.x) / rangeStep); idx = clamp(idx, 0., rangeCount - 1.); int intIdx = int(idx); outColor = colorRange[intIdx]; } } outColor = outColor / 255.; return outColor; } void main(void) { vSampleCount = instanceCounts.a; float weight = instanceCounts.r; float maxWeight = texture(maxTexture, vec2(0.5)).r; float step = weight / maxWeight; vec4 minMaxColor = mix(minColor, maxColor, step) / 255.; vec2 domain = colorDomain; float domainMaxValid = float(colorDomain.y != 0.); domain.y = mix(maxWeight, colorDomain.y, domainMaxValid); vec4 rangeColor = quantizeScale(domain, colorRange, weight); float rangeMinMax = float(shouldUseMinMax); vec4 color = mix(rangeColor, minMaxColor, rangeMinMax); vColor = vec4(color.rgb, color.a * opacity); picking_setPickingColor(instancePickingColors); gl_Position = vec4(instancePositions + positions * cellScale, 1.); } `;var PO=`#version 300 es #define SHADER_NAME screen-grid-layer-fragment-shader precision highp float; in vec4 vColor; in float vSampleCount; out vec4 fragColor; void main(void) { if (vSampleCount <= 0.0) { discard; } fragColor = vColor; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var zJ=[0,0,0,0],HJ=[0,255,0,255],GJ=["minColor","maxColor","colorRange","colorDomain"],WJ={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:Pr},Qf=class extends he{getShaders(){return{vs:wO,fs:PO,modules:[_e]}}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e);let{oldProps:r,props:s,changeFlags:i}=e,n=this.getAttributeManager();s.numInstances!==r.numInstances?n.invalidateAll():r.cellSizePixels!==s.cellSizePixels&&n.invalidate("instancePositions"),this._updateUniforms(r,s,i)}draw({uniforms:e}){let{parameters:r,maxTexture:s}=this.props,i=this.props.minColor||zJ,n=this.props.maxColor||HJ,o=this.props.colorDomain||[1,0],a=this.state.model;a.setUniforms(e),a.setBindings({maxTexture:s}),a.setUniforms({minColor:i,maxColor:n,colorDomain:o}),a.setParameters({depthWriteEnabled:!1,...r}),a.draw(this.context.renderPass)}calculateInstancePositions(e,{numInstances:r}){let{width:s,height:i}=this.context.viewport,{cellSizePixels:n}=this.props,o=Math.ceil(s/n),{value:a,size:c}=e;for(let l=0;le[n]!==r[n])&&i.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),e.colorRange!==r.colorRange&&i.setUniforms({colorRange:en(r.colorRange)}),e.cellMarginPixels!==r.cellMarginPixels||e.cellSizePixels!==r.cellSizePixels||s.viewportChanged){let{width:n,height:o}=this.context.viewport,{cellSizePixels:a,cellMarginPixels:c}=this.props,l=a>c?c:0,u=new Float32Array([(a-l)/n*2,-(a-l)/o*2,1]);i.setUniforms({cellScale:u})}}};Qf.layerName="ScreenGridCellLayer";Qf.defaultProps=WJ;var Yb=Qf;function MO(t,e){let r={};for(let s in t)e.includes(s)||(r[s]=t[s]);return r}var zm=class extends Le{initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:MO(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:r}=e;if(r.extensionsChanged){let s=this.getShaders({});s&&s.defines&&(s.defines.NON_INSTANCED_MODEL=1),this.updateShaders(s)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:r,device:s}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:r,picking:{isActive:0},devicePixelRatio:s.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,r={}){let{props:s,oldProps:i,changeFlags:n}=e,{compareAll:o=!1,dimension:a}=r,{ignoreProps:c}=this.state,{props:l,accessors:u=[]}=a,{updateTriggersChanged:f}=n;if(n.dataChanged)return!0;if(f){if(f.all)return!0;for(let h of u)if(f[h])return!0}if(o)return n.extensionsChanged?!0:ha({oldProps:i,newProps:s,ignoreProps:c,propTypes:this.constructor._propTypes});for(let h of l)if(s[h]!==i[h])return!0;return!1}isAttributeChanged(e){let{changedAttributes:r}=this.state;return e?r&&r[e]!==void 0:!jJ(r)}_getAttributeManager(){return new Xr(this.context.device,{id:this.props.id,stats:this.context.stats})}};zm.layerName="AggregationLayer";var Cs=zm;function jJ(t){let e=!0;for(let r in t){e=!1;break}return e}function Hm(t,e,r){let s=r;return s.domain=()=>t,s.range=()=>e,s}function RO(t,e){return Hm(t,e,s=>QJ(t,e,s))}function XJ(t,e){return Hm(t,e,s=>eZ(t,e,s))}function YJ(t,e){let r=t.sort(IO),s=0,i=Math.max(1,e.length),n=new Array(i-1);for(;++s$J(n,e,a);return o.thresholds=()=>n,Hm(t,e,o)}function IO(t,e){return t-e}function qJ(t,e){let r=t.length;if(e<=0||r<2)return t[0];if(e>=1)return t[r-1];let s=(r-1)*e,i=Math.floor(s),n=t[i],o=t[i+1];return n+(o-n)*(s-i)}function KJ(t,e){let r=0,s=t.length;for(;r>>1;IO(t[i],e)>0?s=i:r=i+1}return r}function $J(t,e,r){return e[KJ(t,r)]}function JJ(t,e,r,s){let i=`${s}`,n=e.get(i);return n===void 0&&(n=t.push(s),e.set(i,n)),r[(n-1)%r.length]}function ZJ(t,e){let r=new Map,s=[];for(let n of t){let o=`${n}`;r.has(o)||r.set(o,s.push(n))}return Hm(t,e,n=>JJ(s,r,e,n))}function QJ(t,e,r){let s=t[1]-t[0];if(s<=0)return k.warn("quantizeScale: invalid domain, returning range[0]")(),e[0];let i=s/e.length,n=Math.floor((r-t[0])/i),o=Math.max(Math.min(n,e.length-1),0);return e[o]}function eZ(t,e,r){return(r-t[0])/(t[1]-t[0])*(e[1]-e[0])+e[0]}function BO(t){return t!=null}function tZ(t){let e=[];return t.forEach(r=>{!e.includes(r)&&BO(r)&&e.push(r)}),e}function OO(t,e){return(typeof e=="function"?t.map(e):t).filter(BO)}function FO(t,e){return OO(t,e)}function LO(t,e){return tZ(OO(t,e))}function NO(t,e,r){return Math.max(e,Math.min(r,t))}function DO(t){switch(t){case"quantize":return RO;case"linear":return XJ;case"quantile":return YJ;case"ordinal":return ZJ;default:return RO}}var kO=t=>t.length,rZ=3402823466e29,VO=t=>t.points,zO=t=>t.index,UO=(t,e)=>te?1:t>=e?0:NaN,sZ={getValue:kO,getPoints:VO,getIndex:zO,filterData:null},ii=class{constructor(e=[],r=sZ){this.aggregatedBins=this.getAggregatedBins(e,r),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(e,r){let{getValue:s=kO,getPoints:i=VO,getIndex:n=zO,filterData:o}=r,a=typeof o=="function",c=e.length,l=[],u=0;for(let f=0;fNO(a,0,100)),n=Math.ceil(s/100*(r-1)),o=Math.floor(i/100*(r-1));return[n,o]}getBinMap(){let e={};for(let r of this.aggregatedBins)e[r.i]=r;return e}_updateMinMaxValues(){let e=0,r=0,s=rZ,i=0;for(let n of this.aggregatedBins)e=e>n.counts?e:n.counts,r=r>n.value?r:n.value,s=sUO(i.value,n.value))),!this.sortedBins.length)return[];let r=0,s=this.sortedBins.length-1;if(Array.isArray(e)){let i=this._percentileToIndex(e);r=i[0],s=i[1]}return[this.sortedBins[r].value,this.sortedBins[s].value]}getValueDomainByScale(e,[r=0,s=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((n,o)=>UO(n.value,o.value))),!this.sortedBins.length)return[];let i=this._percentileToIndex([r,s]);return this._getScaleDomain(e,i)}_getScaleDomain(e,[r,s]){let i=this.sortedBins;switch(e){case"quantize":case"linear":return[i[r].value,i[s].value];case"quantile":return FO(i.slice(r,s+1),n=>n.value);case"ordinal":return LO(i,n=>n.value);default:return[i[r].value,i[s].value]}}};var GO=6378e3;function Gm(t){return Number.isFinite(t)?t:0}function Wm(t,e){let r=t.positions.value,s=1/0,i=-1/0,n=1/0,o=-1/0,a,c;for(let u=0;ui?a:i,n=co?c:o;return{xMin:Gm(n),xMax:Gm(o),yMin:Gm(s),yMax:Gm(i)}}function iZ(t,e,r,s){let{width:i,height:n}=s,o=r===X.CARTESIAN?[-i/2,-n/2]:[-180,-90];k.assert(r===X.CARTESIAN||r===X.LNGLAT||r===X.DEFAULT);let{xMin:a,yMin:c}=t;return[-1*(HO(a-o[0],e.xOffset)+o[0]),-1*(HO(c-o[1],e.yOffset)+o[1])]}function HO(t,e){let r=t<0?-1:1,s=r<0?Math.abs(t)+e:Math.abs(t);return s=Math.floor(s/e)*e,s*r}function qb(t,e,r=!0){if(!r)return{xOffset:e,yOffset:e};let{yMin:s,yMax:i}=t,n=(s+i)/2;return nZ(e,n)}function jm(t,e,r,s){let i=qb(t,e,s!==X.CARTESIAN),n=iZ(t,i,s,r),{xMin:o,yMin:a,xMax:c,yMax:l}=t,u=c-o+i.xOffset,f=l-a+i.yOffset,h=Math.ceil(u/i.xOffset),d=Math.ceil(f/i.yOffset);return{gridOffset:i,translation:n,width:u,height:f,numCol:h,numRow:d}}function nZ(t,e){let r=oZ(t),s=aZ(e,t);return{yOffset:r,xOffset:s}}function oZ(t){return t/GO*(180/Math.PI)}function aZ(t,e){return e/GO*(180/Math.PI)/Math.cos(t*Math.PI/180)}function Ja(t,e){let r=cZ(t,e),s=lZ(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:s}}function cZ(t,e){let{data:r=[],cellSize:s}=t,{attributes:i,viewport:n,projectPoints:o,numInstances:a}=e,c=i.positions.value,{size:l}=i.positions.getAccessor(),u=e.boundingBox||uZ(i.positions,a),f=e.posOffset||[180,90],h=e.gridOffset||qb(u,s);if(h.xOffset<=0||h.yOffset<=0)return{gridHash:{},gridOffset:h,offsets:[0,0]};let{width:d,height:p}=n,g=Math.ceil(d/h.xOffset),m=Math.ceil(p/h.yOffset),_={},{iterable:y,objectInfo:x}=ze(r),S=new Array(3);for(let P of y){x.index++,S[0]=c[x.index*l],S[1]=c[x.index*l+1],S[2]=l>=3?c[x.index*l+2]:0;let[B,L]=o?n.project(S):S;if(Number.isFinite(B)&&Number.isFinite(L)){let M=Math.floor((L+f[1])/h.yOffset),v=Math.floor((B+f[0])/h.xOffset);if(!o||v>=0&&v=0&&Mn?c:n,o=la?l:a);return{xMin:o,xMax:a,yMin:i,yMax:n}}var Xm=class extends Cs{initializeAggregationLayer({dimensions:e}){super.initializeAggregationLayer(e),this.setState({layerData:{},gpuGridAggregator:new ot(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:Ja})}updateState(e){super.updateState(e),this.updateAggregationState(e);let{aggregationDataDirty:r,aggregationWeightsDirty:s,gpuAggregation:i}=this.state;if(this.getNumInstances()<=0)return;let n=!1;(r||i&&s)&&(this._updateAggregation(e),n=!0),!i&&(r||s)&&(this._updateWeightBins(),this._uploadAggregationResults(),n=!0),this.setState({aggregationDirty:n})}finalizeState(e){let{count:r}=this.state.weights;r&&r.aggregationBuffer&&r.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(e)}updateShaders(e){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(e)}updateAggregationState(e){k.assert(!1)}allocateResources(e,r){if(this.state.numRow!==e||this.state.numCol!==r){let s=r*e*4*4,{weights:i}=this.state;for(let n in i){let o=i[n];o.aggregationBuffer&&o.aggregationBuffer.delete(),o.aggregationBuffer=this.context.device.createBuffer({byteLength:s,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:e,maxMinData:r,maxData:s,minData:i}){let{count:n}=this.state.weights;n&&(n.aggregationData=e,n.maxMinData=r,n.maxData=s,n.minData=i)}_updateAggregation(e){let{cpuGridAggregator:r,gpuGridAggregator:s,gridOffset:i,posOffset:n,translation:o=[0,0],scaling:a=[0,0,0],boundingBox:c,projectPoints:l,gpuAggregation:u,numCol:f,numRow:h}=this.state,{props:d}=e,{viewport:p}=this.context,g=this.getAttributes(),m=this.getNumInstances();if(u){let{weights:_}=this.state;s.run({weights:_,cellSize:[i.xOffset,i.yOffset],numCol:f,numRow:h,translation:o,scaling:a,vertexCount:m,projectPoints:l,attributes:g,moduleSettings:this.getModuleSettings()})}else{let _=r(d,{gridOffset:i,projectPoints:l,attributes:g,viewport:p,posOffset:n,boundingBox:c});this.setState({layerData:_})}}_updateWeightBins(){let{getValue:e}=this.state,r=new ii(this.state.layerData.data||[],{getValue:e});this.setState({sortedBins:r})}_uploadAggregationResults(){let{numCol:e,numRow:r}=this.state,{data:s}=this.state.layerData,{aggregatedBins:i,minValue:n,maxValue:o,totalCount:a}=this.state.sortedBins,c=4,l=e*r*c,u=new Float32Array(l).fill(0);for(let p of i){let{lonIdx:g,latIdx:m}=s[p.i],{value:_,counts:y}=p,x=(g+m*e)*c;u[x]=_,u[x+c-1]=y}let f=new Float32Array([o,0,0,n]),h=new Float32Array([o,0,0,a]),d=new Float32Array([n,0,0,a]);this.updateResults({aggregationData:u,maxMinData:f,maxData:h,minData:d})}};Xm.layerName="GridAggregationLayer";var Za=Xm;var fZ={...Yb.defaultProps,getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},WO="positions",hZ={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},eh=class extends Za{initializeState(){super.initializeAggregationLayer({dimensions:hZ,getCellSize:s=>s.cellSizePixels});let e={count:{size:1,operation:Me.SUM,needMax:!0,maxTexture:$a(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:e,subLayerData:{attributes:{}},maxTexture:e.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[WO]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return this.state.supported&&e.somethingChanged}updateState(e){super.updateState(e)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:e,numRow:r,numCol:s,weights:i}=this.state,{updateTriggers:n}=this.props,{aggregationBuffer:o}=i.count,a=this.getSubLayerClass("cells",Yb);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:n}),{data:{attributes:{instanceCounts:o}},maxTexture:e,numInstances:r*s})}finalizeState(e){super.finalizeState(e);let{aggregationBuffer:r,maxBuffer:s,maxTexture:i}=this.state;r?.delete(),s?.delete(),i?.delete()}getPickingInfo({info:e}){let{index:r}=e;if(r>=0){let{gpuGridAggregator:s,gpuAggregation:i,weights:n}=this.state,o=i?s.getData("count"):n.count;e.object=ot.getAggregationData({pixelIndex:r,...o})}return e}updateResults({aggregationData:e,maxData:r}){let{count:s}=this.state.weights;s.aggregationData=e,s.aggregationBuffer.write(e),s.maxData=r,s.maxTexture.setImageData({data:r})}updateAggregationState(e){let r=e.props.cellSizePixels,s=e.oldProps.cellSizePixels!==r,{viewportChanged:i}=e.changeFlags,n=e.props.gpuAggregation;this.state.gpuAggregation!==e.props.gpuAggregation&&n&&!ot.isSupported(this.context.device)&&(k.warn("GPU Grid Aggregation not supported, falling back to CPU")(),n=!1);let o=n!==this.state.gpuAggregation;this.setState({gpuAggregation:n});let a=this.isAttributeChanged(WO),{dimensions:c}=this.state,{data:l,weights:u}=c,f=a||o||i||this.isAggregationDirty(e,{compareAll:n,dimension:l}),h=this.isAggregationDirty(e,{dimension:u});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:h});let{viewport:d}=this.context;if(i||s){let{width:p,height:g}=d,m=Math.ceil(p/r),_=Math.ceil(g/r);this.allocateResources(_,m),this.setState({scaling:[p/2,-g/2,1],gridOffset:{xOffset:r,yOffset:r},width:p,height:g,numCol:m,numRow:_})}h&&this._updateAccessors(e),(f||h)&&this._resetResults()}_updateAccessors(e){let{getWeight:r,aggregation:s,data:i}=e.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=Me[s]),this.setState({getValue:Ka(s,r,{data:i})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}};eh.layerName="ScreenGridLayer";eh.defaultProps=fZ;var jO=eh;function XO(){}var YO=["getBins","getDomain","getScaleFunc"],qO=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],dZ=t=>t.cellSize,ni=class{constructor(e){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=e.getCellSize||dZ,this._getAggregator=e.getAggregator,this._addDimension(e.dimensions||qO)}static defaultDimensions(){return qO}updateState(e,r){let{oldProps:s,props:i,changeFlags:n}=e;this.updateGetValueFuncs(s,i,n);let o=this.needsReProjectPoints(s,i,n),a=!1;return n.dataChanged||o?(this.getAggregatedData(i,r),a=!0):((this.getDimensionChanges(s,i,n)||[]).forEach(l=>typeof l=="function"&&l()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(e){this.state={...this.state,...e}}setDimensionState(e,r){this.setState({dimensions:{...this.state.dimensions,[e]:{...this.state.dimensions[e],...r}}})}normalizeResult(e={}){return e.hexagons?{data:e.hexagons,...e}:e.layerData?{data:e.layerData,...e}:e}getAggregatedData(e,r){let i=this._getAggregator(e)(e,r);this.setState({layerData:this.normalizeResult(i)}),this.changeFlags={layerData:!0},this.getSortedBins(e)}updateGetValueFuncs(e,r,s){for(let i in this.dimensionUpdaters){let{value:n,weight:o,aggregation:a}=this.dimensionUpdaters[i].getBins.triggers,c=r[n.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[i].getBins,e,r,s)&&(c?c=mO(c,{data:r.data}):c=Ka(r[a.prop],r[o.prop],{data:r.data})),c&&this.setDimensionState(i,{getValue:c})}}needsReProjectPoints(e,r,s){return this._getCellSize(e)!==this._getCellSize(r)||this._getAggregator(e)!==this._getAggregator(r)||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getPosition)}addDimension(e){this._addDimension(e)}_addDimension(e=[]){e.forEach(r=>{let{key:s}=r;this.dimensionUpdaters[s]=this.getDimensionUpdaters(r),this.state.dimensions[s]={getValue:null,domain:null,sortedBins:null,scaleFunc:XO}})}getDimensionUpdaters({key:e,accessor:r,pickingInfo:s,getBins:i,getDomain:n,getScaleFunc:o,nullValue:a}){return{key:e,accessor:r,pickingInfo:s,getBins:{updater:this.getDimensionSortedBins.bind(this),...i},getDomain:{updater:this.getDimensionValueDomain.bind(this),...n},getScaleFunc:{updater:this.getDimensionScale.bind(this),...o},attributeAccessor:this.getSubLayerDimensionAttribute(e,a)}}needUpdateDimensionStep(e,r,s,i){return Object.values(e.triggers).some(n=>n.updateTrigger?i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged[n.updateTrigger]):r[n.prop]!==s[n.prop])}getDimensionChanges(e,r,s){let i=[];for(let n in this.dimensionUpdaters){let o=YO.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[n][a],e,r,s));o&&i.push(this.dimensionUpdaters[n][o].updater.bind(this,r,this.dimensionUpdaters[n]))}return i.length?i:null}getUpdateTriggers(e){let r=e.updateTriggers||{},s={};for(let i in this.dimensionUpdaters){let{accessor:n}=this.dimensionUpdaters[i];s[n]={},YO.forEach(o=>{Object.values(this.dimensionUpdaters[i][o].triggers).forEach(({prop:a,updateTrigger:c})=>{if(c){let l=r[c];typeof l=="object"&&!Array.isArray(l)?Object.assign(s[n],l):l!==void 0&&(s[n][a]=l)}else s[n][a]=e[a]})})}return s}getSortedBins(e){for(let r in this.dimensionUpdaters)this.getDimensionSortedBins(e,this.dimensionUpdaters[r])}getDimensionSortedBins(e,r){let{key:s}=r,{getValue:i}=this.state.dimensions[s],n=new ii(this.state.layerData.data||[],{getValue:i,filterData:e._filterData});this.setDimensionState(s,{sortedBins:n}),this.getDimensionValueDomain(e,r)}getDimensionValueDomain(e,r){let{getDomain:s,key:i}=r,{triggers:{lowerPercentile:n,upperPercentile:o,scaleType:a}}=s,c=this.state.dimensions[i].sortedBins.getValueDomainByScale(e[a.prop],[e[n.prop],e[o.prop]]);this.setDimensionState(i,{valueDomain:c}),this.getDimensionScale(e,r)}getDimensionScale(e,r){let{key:s,getScaleFunc:i,getDomain:n}=r,{domain:o,range:a}=i.triggers,{scaleType:c}=n.triggers,{onSet:l}=i,u=e[a.prop],f=e[o.prop]||this.state.dimensions[s].valueDomain,d=DO(c&&e[c.prop])(f,u);typeof l=="object"&&typeof e[l.props]=="function"&&e[l.props](d.domain()),this.setDimensionState(s,{scaleFunc:d})}getSubLayerDimensionAttribute(e,r){return s=>{let{sortedBins:i,scaleFunc:n}=this.state.dimensions[e],o=i.binMap[s.index];if(o&&o.counts===0)return r;let a=o&&o.value,c=n.domain();return a>=c[0]&&a<=c[c.length-1]?n(a):r}}getSubLayerAccessors(e){let r={};for(let s in this.dimensionUpdaters){let{accessor:i}=this.dimensionUpdaters[s];r[i]=this.getSubLayerDimensionAttribute(e,s)}return r}getPickingInfo({info:e}){let r=e.picked&&e.index>-1,s=null;if(r){let i=this.state.layerData.data[e.index],n={};for(let o in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[o],{sortedBins:c}=this.state.dimensions[o],l=c.binMap[i.index]&&c.binMap[i.index].value;n[a]=l}s=Object.assign(n,i,{points:i.filteredPoints||i.points})}return e.picked=Boolean(s),e.object=s,e}getAccessor(e){return this.dimensionUpdaters.hasOwnProperty(e)?this.dimensionUpdaters[e].attributeAccessor:XO}};function KO(){}var pZ={colorDomain:null,colorRange:Pr,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:KO,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:KO,gridAggregator:Ja,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},th=class extends Cs{initializeState(){let e=new ni({getAggregator:s=>s.gridAggregator,getCellSize:s=>s.cellSize});this.state={cpuAggregator:e,aggregatorState:e.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){super.updateState(e),this.setState({aggregatorState:this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,cellSize:s,coverage:i,material:n,transitions:o}=this.props,{cpuAggregator:a}=this.state,c=this.getSubLayerClass("grid-cell",Kp),l=this._getSublayerUpdateTriggers();return new c({cellSize:s,coverage:i,material:n,elevationScale:e,extruded:r,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:o&&{getFillColor:o.getColorValue||o.getColorWeight,getElevation:o.getElevationValue||o.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:l}),{data:a.state.layerData.data})}};th.layerName="CPUGridLayer";th.defaultProps=pZ;var rh=th;var Qa=Math.PI/3,gZ=[0,Qa,2*Qa,3*Qa,4*Qa,5*Qa];function mZ(t){return t[0]}function _Z(t){return t[1]}function Kb(){var t=0,e=0,r=1,s=1,i=mZ,n=_Z,o,a,c;function l(f){var h={},d=[],p,g=f.length;for(p=0;p1){var B=_-S,L=S+(_v*v+T*T&&(S=L+(x&1?1:-1)/2,x=M)}var D=S+"-"+x,V=h[D];V?V.push(m):(d.push(V=h[D]=[m]),V.x=(S+(x&1)/2)*a,V.y=x*c)}return d}function u(f){var h=0,d=0;return gZ.map(function(p){var g=Math.sin(p)*f,m=-Math.cos(p)*f,_=g-h,y=m-d;return h=g,d=m,[_,y]})}return l.hexagon=function(f){return"m"+u(f==null?o:+f).join("l")+"z"},l.centers=function(){for(var f=[],h=Math.round(e/c),d=Math.round(t/a),p=h*c;pg.screenCoord[0]).y(g=>g.screenCoord[1])(c).map((g,m)=>({position:i.unprojectFlat([g.x,g.y]),points:g,index:m})),radiusCommon:a}}function yZ(t,e){let{attributes:r}=e,s=r.positions.value,{size:i}=r.positions.getAccessor(),n=1/0,o=1/0,a=-1/0,c=-1/0,l;for(l=0;lt.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},sh=class extends Cs{initializeState(){let e=new ni({getAggregator:s=>s.hexagonAggregator,getCellSize:s=>s.radius});this.state={cpuAggregator:e,aggregatorState:e.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){if(super.updateState(e),e.changeFlags.propsOrDataChanged){let r=this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==r.layerData){let{hexagonVertices:s}=r.layerData||{};this.setState({vertices:s&&this.convertLatLngToMeterOffset(s)})}this.setState({aggregatorState:r})}}convertLatLngToMeterOffset(e){let{viewport:r}=this.context;if(Array.isArray(e)&&e.length===6){let s=e[0],i=e[3],n=[(s[0]+i[0])/2,(s[1]+i[1])/2],o=r.projectFlat(n),{metersPerUnit:a}=r.getDistanceScales(n);return e.map(l=>{let u=r.projectFlat(l);return[(u[0]-o[0])*a[0],(u[1]-o[1])*a[1]]})}return k.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,coverage:s,material:i,transitions:n}=this.props,{aggregatorState:o,vertices:a}=this.state,c=this.getSubLayerClass("hexagon-cell",ki),l=this._getSublayerUpdateTriggers(),u=a?{vertices:a,radius:1}:{radius:o.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new c({...u,diskResolution:6,elevationScale:e,extruded:r,coverage:s,material:i,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:n&&{getFillColor:n.getColorValue||n.getColorWeight,getElevation:n.getElevationValue||n.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:l}),{data:o.layerData.data})}};sh.layerName="HexagonLayer";sh.defaultProps=AZ;var ZO=sh;var K=.16666666666666666,F={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},ec=[F.W,F.SW,F.S],tc=[F.S,F.SE,F.E],rc=[F.E,F.NE,F.N],sc=[F.NW,F.W,F.N],ic=[[-.5,K],[-.5,-K],[-K,-.5],[K,-.5]],nc=[[-K,-.5],[K,-.5],[.5,-K],[.5,K]],oc=[[.5,-K],[.5,K],[K,.5],[-K,.5]],ac=[[-.5,K],[-.5,-K],[K,.5],[-K,.5]],QO=[F.W,F.SW,F.SE,F.E],eF=[F.S,F.SE,F.NE,F.N],tF=[F.NW,F.W,F.E,F.NE],rF=[F.NW,F.SW,F.S,F.N],sF=[[-.5,K],[-.5,-K],[.5,-K],[.5,K]],iF=[[-K,-.5],[K,-.5],[K,.5],[-K,.5]],TZ=[F.NW,F.SW,F.SE,F.NE],nF=[F.NW,F.SW,F.SE,F.E,F.N],oF=[F.W,F.SW,F.SE,F.NE,F.N],aF=[F.NW,F.W,F.S,F.SE,F.NE],cF=[F.NW,F.SW,F.S,F.E,F.NE],lF=[F.NW,F.W,[.5,-K],[.5,K],F.N],uF=[[-K,-.5],[K,-.5],F.E,F.NE,F.N],fF=[[-.5,K],[-.5,-K],F.S,F.SE,F.E],hF=[F.W,F.SW,F.S,[K,.5],[-K,.5]],dF=[F.NW,F.W,[-K,-.5],[K,-.5],F.N],pF=[[-.5,K],[-.5,-K],F.E,F.NE,F.N],gF=[F.S,F.SE,F.E,[K,.5],[-K,.5]],mF=[F.W,F.SW,F.S,[.5,-K],[.5,K]],_F=[F.W,F.SW,F.SE,F.E,[K,.5],[-K,.5]],yF=[[-.5,K],[-.5,-K],F.S,F.SE,F.NE,F.N],xF=[F.NW,F.W,[-K,-.5],[K,-.5],F.E,F.NE],AF=[F.NW,F.SW,F.S,[.5,-K],[.5,K],F.N],cc=[F.W,F.SW,F.S,F.E,F.NE,F.N],lc=[F.NW,F.W,F.S,F.SE,F.E,F.N],Ym=[[-.5,K],[-.5,-K],[-K,-.5],[K,-.5],F.E,F.NE,F.N],qm=[F.W,F.SW,F.S,[.5,-K],[.5,K],[K,.5],[-K,.5]],Km=[F.NW,F.W,[-K,-.5],[K,-.5],[.5,-K],[.5,K],F.N],$m=[[-.5,K],[-.5,-K],F.S,F.SE,F.E,[K,.5],[-K,.5]],TF=[[-.5,K],[-.5,-K],[-K,-.5],[K,-.5],[.5,-K],[.5,K],[K,.5],[-K,.5]],bF={0:[],1:[[F.W,F.S]],2:[[F.S,F.E]],3:[[F.W,F.E]],4:[[F.N,F.E]],5:{0:[[F.W,F.S],[F.N,F.E]],1:[[F.W,F.N],[F.S,F.E]]},6:[[F.N,F.S]],7:[[F.W,F.N]],8:[[F.W,F.N]],9:[[F.N,F.S]],10:{0:[[F.W,F.N],[F.S,F.E]],1:[[F.W,F.S],[F.N,F.E]]},11:[[F.N,F.E]],12:[[F.W,F.E]],13:[[F.S,F.E]],14:[[F.W,F.S]],15:[]};function j(t){return parseInt(t,4)}var EF={[j("0000")]:[],[j("2222")]:[],[j("2221")]:[ec],[j("2212")]:[tc],[j("2122")]:[rc],[j("1222")]:[sc],[j("0001")]:[ec],[j("0010")]:[tc],[j("0100")]:[rc],[j("1000")]:[sc],[j("2220")]:[ic],[j("2202")]:[nc],[j("2022")]:[oc],[j("0222")]:[ac],[j("0002")]:[ic],[j("0020")]:[nc],[j("0200")]:[oc],[j("2000")]:[ac],[j("0011")]:[QO],[j("0110")]:[eF],[j("1100")]:[tF],[j("1001")]:[rF],[j("2211")]:[QO],[j("2112")]:[eF],[j("1122")]:[tF],[j("1221")]:[rF],[j("2200")]:[sF],[j("2002")]:[iF],[j("0022")]:[sF],[j("0220")]:[iF],[j("1111")]:[TZ],[j("1211")]:[nF],[j("2111")]:[oF],[j("1112")]:[aF],[j("1121")]:[cF],[j("1011")]:[nF],[j("0111")]:[oF],[j("1110")]:[aF],[j("1101")]:[cF],[j("1200")]:[lF],[j("0120")]:[uF],[j("0012")]:[fF],[j("2001")]:[hF],[j("1022")]:[lF],[j("2102")]:[uF],[j("2210")]:[fF],[j("0221")]:[hF],[j("1002")]:[dF],[j("2100")]:[pF],[j("0210")]:[gF],[j("0021")]:[mF],[j("1220")]:[dF],[j("0122")]:[pF],[j("2012")]:[gF],[j("2201")]:[mF],[j("0211")]:[_F],[j("2110")]:[yF],[j("1102")]:[xF],[j("1021")]:[AF],[j("2011")]:[_F],[j("0112")]:[yF],[j("1120")]:[xF],[j("1201")]:[AF],[j("2101")]:[cc],[j("0121")]:[cc],[j("1012")]:[lc],[j("1210")]:[lc],[j("0101")]:{0:[ec,rc],1:[cc],2:[cc]},[j("1010")]:{0:[sc,tc],1:[lc],2:[lc]},[j("2121")]:{0:[cc],1:[cc],2:[ec,rc]},[j("1212")]:{0:[lc],1:[lc],2:[sc,tc]},[j("2120")]:{0:[Ym],1:[Ym],2:[ic,rc]},[j("2021")]:{0:[qm],1:[qm],2:[ec,oc]},[j("1202")]:{0:[Km],1:[Km],2:[sc,nc]},[j("0212")]:{0:[$m],1:[$m],2:[tc,ac]},[j("0102")]:{0:[ic,rc],1:[Ym],2:[Ym]},[j("0201")]:{0:[ec,oc],1:[qm],2:[qm]},[j("1020")]:{0:[sc,nc],1:[Km],2:[Km]},[j("2010")]:{0:[tc,ac],1:[$m],2:[$m]},[j("2020")]:{0:[ac,nc],1:[TF],2:[ic,oc]},[j("0202")]:{0:[oc,ic],1:[TF],2:[ac,nc]}};var _o={ISO_LINES:1,ISO_BANDS:2},bZ={zIndex:0,zOffset:.005};function ih(t,e){return Array.isArray(e)?t=e?1:0}function SF(t){let{cellWeights:e,x:r,y:s,width:i,height:n}=t,o=t.threshold;t.thresholdValue&&(k.deprecated("thresholdValue","threshold")(),o=t.thresholdValue);let a=r<0,c=r>=i-1,l=s<0,u=s>=n-1,f=a||c||l||u,h={},d={};a||u?d.top=0:(h.top=e[(s+1)*i+r],d.top=ih(h.top,o)),c||u?d.topRight=0:(h.topRight=e[(s+1)*i+r+1],d.topRight=ih(h.topRight,o)),c||l?d.right=0:(h.right=e[s*i+r+1],d.right=ih(h.right,o)),a||l?d.current=0:(h.current=e[s*i+r],d.current=ih(h.current,o));let{top:p,topRight:g,right:m,current:_}=d,y=-1;Number.isFinite(o)&&(y=p<<3|g<<2|m<<1|_),Array.isArray(o)&&(y=p<<6|g<<4|m<<2|_);let x=0;return f||(x=ih((h.top+h.topRight+h.right+h.current)/4,o)),{code:y,meanCode:x}}function $b(t){let{gridOrigin:e,cellSize:r,x:s,y:i,code:n,meanCode:o,type:a=_o.ISO_LINES}=t,c={...bZ,...t.thresholdData},l=a===_o.ISO_BANDS?EF[n]:bF[n];Array.isArray(l)||(l=l[o]);let u=c.zIndex*c.zOffset,f=(s+1)*r[0],h=(i+1)*r[1],d=e[0]+f,p=e[1]+h;if(a===_o.ISO_BANDS){let m=[];return l.forEach(_=>{let y=[];_.forEach(x=>{let S=d+x[0]*r[0],P=p+x[1]*r[1];y.push([S,P,u])}),m.push(y)}),m}let g=[];return l.forEach(m=>{m.forEach(_=>{let y=d+_[0]*r[0],x=p+_[1]*r[1];g.push([y,x,u])})}),g}function vF({thresholdData:t,cellWeights:e,gridSize:r,gridOrigin:s,cellSize:i}){let n=[],o=[],a=r[0],c=r[1],l=0,u=0;for(let f of t){let{contour:h}=f,{threshold:d}=h;for(let p=-1;pt.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:SZ}],optional:!0,compare:3},zOffset:.005},wF="positions",CZ={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},nh=class extends Za{initializeState(){super.initializeAggregationLayer({dimensions:CZ}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:Me.SUM}}}),this.getAttributeManager().add({[wF]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(e){super.updateState(e);let r=!1,{oldProps:s,props:i}=e,{aggregationDirty:n}=this.state;(s.contours!==i.contours||s.zOffset!==i.zOffset)&&(r=!0,this._updateThresholdData(e.props)),this.getNumInstances()>0&&(n||r)&&this._generateContours()}renderLayers(){let{contourSegments:e,contourPolygons:r}=this.state.contourData,s=this.getSubLayerClass("lines",Vp),i=this.getSubLayerClass("bands",Hi),n=e&&e.length>0&&new s(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:a=>a.start,getTargetPosition:a=>a.end,getColor:a=>a.contour.color||CF,getWidth:a=>a.contour.strokeWidth||EZ}),o=r&&r.length>0&&new i(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||CF});return[n,o]}updateAggregationState(e){let{props:r,oldProps:s}=e,{cellSize:i,coordinateSystem:n}=r,{viewport:o}=this.context,a=s.cellSize!==i,c=r.gpuAggregation;this.state.gpuAggregation!==r.gpuAggregation&&c&&!ot.isSupported(this.context.device)&&(k.warn("GPU Grid Aggregation not supported, falling back to CPU")(),c=!1);let l=c!==this.state.gpuAggregation;this.setState({gpuAggregation:c});let{dimensions:u}=this.state,f=this.isAttributeChanged(wF),{data:h,weights:d}=u,{boundingBox:p}=this.state;if(f&&(p=Wm(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:p})),f||a){let{gridOffset:_,translation:y,width:x,height:S,numCol:P,numRow:B}=jm(p,i,o,n);this.allocateResources(B,P),this.setState({gridOffset:_,boundingBox:p,translation:y,posOffset:y.slice(),gridOrigin:[-1*y[0],-1*y[1]],width:x,height:S,numCol:P,numRow:B})}let g=f||l||this.isAggregationDirty(e,{dimension:h,compareAll:c}),m=this.isAggregationDirty(e,{dimension:d});m&&this._updateAccessors(e),(g||m)&&this._resetResults(),this.setState({aggregationDataDirty:g,aggregationWeightsDirty:m})}_updateAccessors(e){let{getWeight:r,aggregation:s,data:i}=e.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=Me[s]),this.setState({getValue:Ka(s,r,{data:i})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}_generateContours(){let{numCol:e,numRow:r,gridOrigin:s,gridOffset:i,thresholdData:n}=this.state,{count:o}=this.state.weights,{aggregationData:a}=o;a||(a=o.aggregationBuffer.readSyncWebGL(),o.aggregationData=a);let{cellWeights:c}=ot.getCellData({countsData:a}),l=vF({thresholdData:n,cellWeights:c,gridSize:[e,r],gridOrigin:s,cellSize:[i.xOffset,i.yOffset]});this.setState({contourData:l})}_updateThresholdData(e){let{contours:r,zOffset:s}=e,i=r.length,n=new Array(i);for(let o=0;o= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) { float domainRange = domain.y - domain.x; if (domainRange <= 0.) { outColor = colorRange[0]; } else { float rangeCount = float(RANGE_COUNT); float rangeStep = domainRange / rangeCount; float idx = floor((value - domain.x) / rangeStep); idx = clamp(idx, 0., rangeCount - 1.); int intIdx = int(idx); outColor = colorRange[intIdx]; } } return outColor; } float linearScale(vec2 domain, vec2 range, float value) { if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) { return ((value - domain.x) / (domain.y - domain.x)) * (range.y - range.x) + range.x; } return -1.; } void main(void) { vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r); vec4 color = quantizeScale(clrDomain, colorRange, colors.r); float elevation = 0.0; if (extruded) { vec2 elvDomain = elevationDomainValid ? elevationDomain : vec2(elevationData.maxMinCount.a, elevationData.maxMinCount.r); elevation = linearScale(elvDomain, elevationRange, elevations.r); elevation = elevation * (positions.z + 1.0) / 2.0 * elevationScale; } float shouldRender = float(color.r > 0.0 && elevations.r >= 0.0); float dotRadius = cellSize / 2. * coverage * shouldRender; int yIndex = (gl_InstanceID / gridSize[0]); int xIndex = gl_InstanceID - (yIndex * gridSize[0]); vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(float(xIndex), 0.)); instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0])); vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(float(yIndex), 0.)); instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1])); vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation); vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0); geometry.worldPosition = centroidPosition; vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.); picking_setPickingColor(instancePickingColors); gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position); vec3 normals_commonspace = project_normal(normals); if (extruded) { vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, normals_commonspace); vColor = vec4(lightColor, color.a * opacity) / 255.; } else { vColor = vec4(color.rgb, color.a * opacity) / 255.; } } `;var RF=`#version 300 es #define SHADER_NAME gpu-grid-cell-layer-fragment-shader precision highp float; in vec4 vColor; out vec4 fragColor; void main(void) { fragColor = vColor; fragColor = picking_filterColor(fragColor); } `;var Jb=0,Zb=1,wZ={colorDomain:null,colorRange:Pr,elevationDomain:null,elevationRange:[0,1e3],elevationScale:{type:"number",min:0,value:1},gridSize:{type:"array",value:[1,1]},gridOrigin:{type:"array",value:[0,0]},gridOffset:{type:"array",value:[0,0]},cellSize:{type:"number",min:0,max:1e3,value:1e3},offset:{type:"array",value:[1,1]},coverage:{type:"number",min:0,max:1,value:1},extruded:!0,material:!0},oh=class extends he{getShaders(){return super.getShaders({vs:MF,fs:RF,modules:[de,pr,_e,Ls]})}initializeState(){this.getAttributeManager().addInstanced({colors:{size:4,noAlloc:!0},elevations:{size:4,noAlloc:!0}});let r=this._getModel();this._setupUniformBuffer(r),this.setState({model:r})}_getModel(){return new J(this.context.device,{...this.getShaders(),id:this.props.id,geometry:new Ds,isInstanced:!0})}draw({uniforms:e}){let{cellSize:r,offset:s,extruded:i,elevationScale:n,coverage:o,gridSize:a,gridOrigin:c,gridOffset:l,elevationRange:u,colorMaxMinBuffer:f,elevationMaxMinBuffer:h}=this.props,d=this.state.model,p=[Dr(c[0]),Dr(c[1])],g=[Dr(l[0]),Dr(l[1])],m=this.getDomainUniforms(),_=en(this.props.colorRange);this.bindUniformBuffers(f,h),d.setUniforms(e),d.setUniforms(m),d.setUniforms({cellSize:r,offset:s,extruded:i,elevationScale:n,coverage:o,gridSize:a,gridOrigin:c,gridOriginLow:p,gridOffset:l,gridOffsetLow:g,colorRange:_,elevationRange:u}),d.draw(this.context.renderPass),this.unbindUniformBuffers(f,h)}bindUniformBuffers(e,r){e.bind({target:35345,index:Jb}),r.bind({target:35345,index:Zb})}unbindUniformBuffers(e,r){e.unbind({target:35345,index:Jb}),r.unbind({target:35345,index:Zb})}getDomainUniforms(){let{colorDomain:e,elevationDomain:r}=this.props,s={};return e!==null?(s.colorDomainValid=!0,s.colorDomain=e):s.colorDomainValid=!1,r!==null?(s.elevationDomainValid=!0,s.elevationDomain=r):s.elevationDomainValid=!1,s}_setupUniformBuffer(e){let r=e.pipeline.handle,s=this.context.gl,i=s.getUniformBlockIndex(r,"ColorData"),n=s.getUniformBlockIndex(r,"ElevationData");s.uniformBlockBinding(r,i,Jb),s.uniformBlockBinding(r,n,Zb)}};oh.layerName="GPUGridCellLayer";oh.defaultProps=wZ;var IF=oh;var PZ={colorDomain:null,colorRange:Pr,getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",elevationDomain:null,elevationRange:[0,1e3],getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},cellSize:{type:"number",min:1,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},extruded:!1,material:!0},MZ={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},BF="positions",ah=class extends Za{initializeState({device:e}){let r=ot.isSupported(e);r||k.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),super.initializeAggregationLayer({dimensions:MZ}),this.setState({gpuAggregation:!1,projectPoints:!1,isSupported:r,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"}),this.getAttributeManager().add({[BF]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},color:{size:3,accessor:"getColorWeight"},elevation:{size:3,accessor:"getElevationWeight"}})}updateState(e){if(this.state.isSupported===!1)return;super.updateState(e);let{aggregationDirty:r}=this.state;r&&this.setState({gridHash:null})}getHashKeyForIndex(e){let{numRow:r,numCol:s,boundingBox:i,gridOffset:n}=this.state,o=[s,r],a=[i.xMin,i.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(e/o[0]),u=e-l*o[0],f=Math.floor((l*c[1]+a[1]+90+c[1]/2)/c[1]),h=Math.floor((u*c[0]+a[0]+180+c[0]/2)/c[0]);return`${f}-${h}`}getPositionForIndex(e){let{numRow:r,numCol:s,boundingBox:i,gridOffset:n}=this.state,o=[s,r],a=[i.xMin,i.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(e/o[0]),u=e-l*o[0],f=l*c[1]+a[1];return[u*c[0]+a[0],f]}getPickingInfo({info:e,mode:r}){let{index:s}=e,i=null;if(s>=0){let n=this.state.gpuGridAggregator,o=this.getPositionForIndex(s),a=ot.getAggregationData({pixelIndex:s,...n.getData("color")}),c=ot.getAggregationData({pixelIndex:s,...n.getData("elevation")});if(i={colorValue:a.cellWeight,elevationValue:c.cellWeight,count:a.cellCount||c.cellCount,position:o,totalCount:a.totalCount||c.totalCount},r!=="hover"){let{props:l}=this,{gridHash:u}=this.state;if(!u){let{gridOffset:d,translation:p,boundingBox:g}=this.state,{viewport:m}=this.context,_=this.getAttributes();u=Ja(l,{gridOffset:d,attributes:_,viewport:m,translation:p,boundingBox:g}).gridHash,this.setState({gridHash:u})}let f=this.getHashKeyForIndex(s),h=u[f];Object.assign(i,h)}}return e.picked=Boolean(i),e.object=i,e}renderLayers(){if(!this.state.isSupported)return null;let{elevationScale:e,extruded:r,cellSize:s,coverage:i,material:n,elevationRange:o,colorDomain:a,elevationDomain:c}=this.props,{weights:l,numRow:u,numCol:f,gridOrigin:h,gridOffset:d}=this.state,{color:p,elevation:g}=l,m=en(this.props.colorRange),_=this.getSubLayerClass("gpu-grid-cell",IF);return new _({gridSize:[f,u],gridOrigin:h,gridOffset:[d.xOffset,d.yOffset],colorRange:m,elevationRange:o,colorDomain:a,elevationDomain:c,cellSize:s,coverage:i,material:n,elevationScale:e,extruded:r},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:p.aggregationBuffer,elevations:g.aggregationBuffer}},colorMaxMinBuffer:p.maxMinBuffer,elevationMaxMinBuffer:g.maxMinBuffer,numInstances:f*u})}finalizeState(e){let{color:r,elevation:s}=this.state.weights;[r,s].forEach(i=>{let{aggregationBuffer:n,maxMinBuffer:o}=i;o?.destroy(),n?.destroy()}),super.finalizeState(e)}updateAggregationState(e){let{props:r,oldProps:s}=e,{cellSize:i,coordinateSystem:n}=r,{viewport:o}=this.context,a=s.cellSize!==i,{dimensions:c}=this.state,l=this.isAttributeChanged(BF),u=l||this.isAttributeChanged(),{boundingBox:f}=this.state;if(l&&(f=Wm(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:f})),l||a){let{gridOffset:d,translation:p,width:g,height:m,numCol:_,numRow:y}=jm(f,i,o,n);this.allocateResources(y,_),this.setState({gridOffset:d,translation:p,gridOrigin:[-1*p[0],-1*p[1]],width:g,height:m,numCol:_,numRow:y})}let h=u||this.isAggregationDirty(e,{dimension:c.data,compareAll:!0});h&&this._updateAccessors(e),this.setState({aggregationDataDirty:h})}_updateAccessors(e){let{colorAggregation:r,elevationAggregation:s}=e.props,{color:i,elevation:n}=this.state.weights;i.operation=Me[r],n.operation=Me[s]}};ah.layerName="GPUGridLayer";ah.defaultProps=PZ;var ch=ah;var RZ={...ch.defaultProps,...rh.defaultProps,gpuAggregation:!1},lh=class extends Le{initializeState(){this.state={useGPUAggregation:!1}}updateState({props:e}){this.setState({useGPUAggregation:!1})}renderLayers(){let{data:e,updateTriggers:r}=this.props,s=this.state.useGPUAggregation?"GPU":"CPU",i=this.state.useGPUAggregation?this.getSubLayerClass("GPU",ch):this.getSubLayerClass("CPU",rh);return new i(this.props,this.getSubLayerProps({id:s,updateTriggers:r}),{data:e})}canUseGPUAggregation(e){let{gpuAggregation:r,lowerPercentile:s,upperPercentile:i,getColorValue:n,getElevationValue:o,colorScaleType:a}=e;return!(!r||!ot.isSupported(this.context.device)||s!==0||i!==100||n!==null||o!==null||a==="quantile"||a==="ordinal")}};lh.layerName="GridLayer";lh.defaultProps=RZ;var OF=lh;function LF(t){let e=t.map(a=>a[0]),r=t.map(a=>a[1]),s=Math.min.apply(null,e),i=Math.max.apply(null,e),n=Math.min.apply(null,r),o=Math.max.apply(null,r);return[s,n,i,o]}function NF(t,e){return e[0]>=t[0]&&e[2]<=t[2]&&e[1]>=t[1]&&e[3]<=t[3]}var FF=new Float32Array(12);function Qb(t,e=2){let r=0;for(let s of t)for(let i=0;i 0.) { maxValue = colorDomain[1]; minValue = colorDomain[0]; } vIntensityMax = intensity / maxValue; vIntensityMin = intensity / minValue; } `;var VF=`#version 300 es #define SHADER_NAME triangle-layer-fragment-shader precision highp float; uniform float opacity; uniform sampler2D weightsTexture; uniform sampler2D colorTexture; uniform float aggregationMode; in vec2 vTexCoords; in float vIntensityMin; in float vIntensityMax; out vec4 fragColor; vec4 getLinearColor(float value) { float factor = clamp(value * vIntensityMax, 0., 1.); vec4 color = texture(colorTexture, vec2(factor, 0.5)); color.a *= min(value * vIntensityMin, 1.0); return color; } void main(void) { vec4 weights = texture(weightsTexture, vTexCoords); float weight = weights.r; if (aggregationMode > 0.5) { weight /= max(1.0, weights.a); } if (weight <= 0.) { discard; } vec4 linearColor = getLinearColor(weight); linearColor.a *= opacity; fragColor = linearColor; } `;var Jm=class extends he{getShaders(){return{vs:kF,fs:VF,modules:[de]}}initializeState({device:e}){this.setState({model:this._getModel(e)})}_getModel(e){let{vertexCount:r,data:s,weightsTexture:i,maxTexture:n,colorTexture:o}=this.props;return new J(e,{...this.getShaders(),id:this.props.id,bindings:{weightsTexture:i,maxTexture:n,colorTexture:o},attributes:s.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-fan-webgl",vertexCount:r})}draw({uniforms:e}){let{model:r}=this.state,{intensity:s,threshold:i,aggregationMode:n,colorDomain:o}=this.props;r.setUniforms({...e,intensity:s,threshold:i,aggregationMode:n,colorDomain:o}),r.draw(this.context.renderPass)}};Jm.layerName="TriangleLayer";var zF=Jm;var eE=`#version 300 es in vec3 positions; in vec3 positions64Low; in float weights; out vec4 weightsTexture; uniform float radiusPixels; uniform float textureWidth; uniform vec4 commonBounds; uniform float weightsScale; void main() { weightsTexture = vec4(weights * weightsScale, 0., 0., 1.); float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x); gl_PointSize = radiusTexels * 2.; vec3 commonPosition = project_position(positions, positions64Low); gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ; gl_Position.xy = (gl_Position.xy * 2.) - (1.); gl_Position.w = 1.0; } `;var tE=`#version 300 es in vec4 weightsTexture; out vec4 fragColor; float gaussianKDE(float u){ return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666); } void main() { float dist = length(gl_PointCoord - vec2(0.5, 0.5)); if (dist > 0.5) { discard; } fragColor = weightsTexture * gaussianKDE(2. * dist); DECKGL_FILTER_COLOR(fragColor, geometry); } `;var HF=`#version 300 es uniform sampler2D inTexture; uniform float textureSize; out vec4 outTexture; void main() { int yIndex = gl_VertexID / int(textureSize); int xIndex = gl_VertexID - (yIndex * int(textureSize)); vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize; outTexture = texture(inTexture, uv); gl_Position = vec4(0.0, 0.0, 0.0, 1.0); gl_PointSize = 1.0; } `;var GF=`#version 300 es in vec4 outTexture; out vec4 fragColor; void main() { fragColor = outTexture; fragColor.g = outTexture.r / max(1.0, outTexture.a); } `;var IZ=2,rE={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},WF=[0,0],BZ={SUM:0,MEAN:1},OZ={getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:Pr,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},FZ=["float32-renderable-webgl","texture-blend-float-webgl"],LZ={data:{props:["radiusPixels"]}},uh=class extends Cs{initializeState(){super.initializeAggregationLayer(LZ),this.setState({colorDomain:WF}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:r,oldProps:s}=e,i=this._getChangeFlags(e);(i.dataChanged||i.viewportChanged)&&(i.boundsChanged=this._updateBounds(i.dataChanged),this._updateTextureRenderingBounds()),i.dataChanged||i.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):i.viewportZoomChanged&&this._debouncedUpdateWeightmap(),r.colorRange!==s.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:r,triTexCoordBuffer:s,maxWeightsTexture:i,colorTexture:n,colorDomain:o}=this.state,{updateTriggers:a,intensity:c,threshold:l,aggregation:u}=this.props,f=this.getSubLayerClass("triangle",zF);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:X.DEFAULT,data:{attributes:{positions:r,texCoords:s}},vertexCount:4,maxTexture:i,colorTexture:n,aggregationMode:BZ[u]||0,weightsTexture:e,intensity:c,threshold:l,colorDomain:o})}finalizeState(e){super.finalizeState(e);let{weightsTransform:r,weightsTexture:s,maxWeightTransform:i,maxWeightsTexture:n,triPositionBuffer:o,triTexCoordBuffer:a,colorTexture:c,updateTimer:l}=this.state;r?.destroy(),s?.destroy(),i?.destroy(),n?.destroy(),o?.destroy(),a?.destroy(),c?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new Xr(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let r={},{dimensions:s}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:s.data})&&"aggregation is dirty",r.viewportChanged=e.changeFlags.viewportChanged;let{zoom:i}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==i)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:e,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...rE,width:e,height:e,format:r}),maxWeightsTexture:this.context.device.createTexture({...rE,width:1,height:1,format:r})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:r}=this.props,s=Math.min(r,e.limits.maxTextureDimension2D),i=FZ.every(a=>e.features.has(a)),n=i?"rgba32float":"rgba8unorm",o=i?1:1/255;this.setState({textureSize:s,format:n,weightsScale:o}),i||k.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:r}=this.state,{weightsTexture:s}=this.state,i=this.getAttributeManager();r?.destroy(),r=new hs(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:i.getBufferLayouts(),vertexCount:1,targetTexture:s,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...e}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:r,weightsTexture:s,maxWeightsTexture:i}=this.state,n=this.getShaders({vs:eE,fs:tE});this._createWeightsTransform(n);let o=this.getShaders({vs:HF,fs:GF}),a=new hs(e,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:s},uniforms:{textureSize:r},targetTexture:i,...o,vertexCount:r*r,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:s,maxWeightsTexture:i,maxWeightTransform:a,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:eE,fs:tE,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:r}=this.context,s=[r.unproject([0,0]),r.unproject([r.width,0]),r.unproject([r.width,r.height]),r.unproject([0,r.height])].map(a=>a.map(Math.fround)),i=LF(s),n={visibleWorldBounds:i,viewportCorners:s},o=!1;if(e||!this.state.worldBounds||!NF(this.state.worldBounds,i)){let a=this._worldToCommonBounds(i),c=this._commonToWorldBounds(a);this.props.coordinateSystem===X.LNGLAT&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let l=this._worldToCommonBounds(c);n.worldBounds=c,n.normalizedCommonBounds=l,o=!0}return this.setState(n),o}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:r,normalizedCommonBounds:s,viewportCorners:i}=this.state,{viewport:n}=this.context;e.write(Qb(i,3));let o=i.map(a=>UF(n.projectPosition(a),s));r.write(Qb(o,2))}_updateColorTexture(e){let{colorRange:r}=e.props,{colorTexture:s}=this.state,i=en(r,!1,Uint8Array);s&&s?.width===r.length?s.setSubImageData({data:i}):(s?.destroy(),s=this.context.device.createTexture({...rE,data:i,width:r.length,height:1})),this.setState({colorTexture:s})}_updateWeightmap(){let{radiusPixels:e,colorDomain:r,aggregation:s}=this.props,{worldBounds:i,textureSize:n,weightsScale:o}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let c=this._worldToCommonBounds(i,{useLayerCoordinateSystem:!0});if(r&&s==="SUM"){let{viewport:d}=this.context,p=d.distanceScales.metersPerUnit[2]*(c[2]-c[0])/n;this.state.colorDomain=r.map(g=>g*p*o)}else this.state.colorDomain=r||WF;let u=this.getAttributeManager().getAttributes(),f=this.getModuleSettings(),h={radiusPixels:e,commonBounds:c,textureWidth:n,weightsScale:o};this._setModelAttributes(a.model,u),a.model.setVertexCount(this.getNumInstances()),a.model.setUniforms(h),a.model.updateModuleSettings(f),a.run({parameters:{viewport:[0,0,n,n]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:r}=this.state,{debounceTimeout:s}=this.props;e?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),s)),this.setState({updateTimer:r})}_worldToCommonBounds(e,r={}){let{useLayerCoordinateSystem:s=!1}=r,[i,n,o,a]=e,{viewport:c}=this.context,{textureSize:l}=this.state,{coordinateSystem:u}=this.props,f=s&&(u===X.LNGLAT_OFFSETS||u===X.METER_OFFSETS),h=f?c.projectPosition(this.props.coordinateOrigin):[0,0],d=l*IZ/c.scale,p,g;return s&&!f?(p=this.projectPosition([i,n,0]),g=this.projectPosition([o,a,0])):(p=c.projectPosition([i,n,0]),g=c.projectPosition([o,a,0])),DF([p[0]-h[0],p[1]-h[1],g[0]-h[0],g[1]-h[1]],d,d)}_commonToWorldBounds(e){let[r,s,i,n]=e,{viewport:o}=this.context,a=o.unprojectPosition([r,s]),c=o.unprojectPosition([i,n]);return a.slice(0,2).concat(c.slice(0,2))}};uh.layerName="HeatmapLayer";uh.defaultProps=OZ;var jF=uh;var sE=85.05113;function nE(t,e,r,s){if(r){if(r.userData._googleMap===t)return r;Zm(r)}let i={click:null,rightclick:null,dblclick:null,mousemove:null,mouseout:null},n=new jr({...s,useDevicePixels:s.interleaved?!0:s.useDevicePixels,style:s.interleaved?null:{pointerEvents:"none"},parent:NZ(e,s.style),views:new Ri({repeat:!0}),initialViewState:{longitude:0,latitude:0,zoom:1},controller:!1});for(let o in i)i[o]=t.addListener(o,a=>UZ(n,o,a));return n.userData._googleMap=t,n.userData._eventListeners=i,n}function NZ(t,e){let r=document.createElement("div");return r.style.position="absolute",Object.assign(r.style,e),"getPanes"in t?t.getPanes()?.overlayLayer.appendChild(r):t.getMap()?.getDiv().appendChild(r),r}function Zm(t){let{_eventListeners:e}=t.userData;for(let r in e)e[r]&&e[r].remove();t.finalize()}function XF(t,e){let{width:r,height:s}=YF(t),i=e.getProjection(),n=t.getBounds();if(!n)return{width:r,height:s,left:0,top:0};let o=n.getNorthEast(),a=n.getSouthWest(),c=i.fromLatLngToDivPixel(o),l=i.fromLatLngToDivPixel(a),u=iE(i,r/2,s/2),f=new google.maps.LatLng(0,u[0]),h=i.fromLatLngToContainerPixel(f),d=i.fromLatLngToDivPixel(f);if(!c||!l||!d||!h)return{width:r,height:s,left:0,top:0};let p=Math.round(d.x-h.x),g=d.y-h.y,m=iE(i,r/2,0),_=iE(i,r/2,s),y=u[1],x=u[0];if(Math.abs(y)>sE){y=y>0?sE:-sE;let v=new google.maps.LatLng(y,x),T=i.fromLatLngToContainerPixel(v);g+=T.y-s/2}g=Math.round(g);let P=180*new Br(m).sub(_).verticalAngle()/Math.PI;P<0&&(P+=360);let B=t.getHeading()||0,L=t.getZoom()-1,M;if(P===0)M=s?(l.y-c.y)/s:1;else if(P===B){let v=new Br([c.x,c.y]).sub([l.x,l.y]).len(),T=new Br([r,-s]).len();M=T?v/T:1}return L+=Math.log2(M||1),{width:r,height:s,left:p,top:g,zoom:L,bearing:P,pitch:t.getTilt(),latitude:y,longitude:x}}function oE(t,e){let{width:r,height:s}=YF(t),{center:i,heading:n,tilt:o,zoom:a}=e.getCameraParams(),c=25,l=s?r/s:1,u=.75,f=3e14,h=new q().perspective({fovy:c*Math.PI/180,aspect:l,near:u,far:f}),d=.5*h[5];return{width:r,height:s,viewState:{altitude:d,bearing:n,latitude:i.lat(),longitude:i.lng(),pitch:o,projectionMatrix:h,repeat:!0,zoom:a-1}}}function YF(t){let e=t.getDiv().firstChild;return{width:e.offsetWidth,height:e.offsetHeight}}function iE(t,e,r){let s=new google.maps.Point(e,r),i=t.fromContainerPixelToLatLng(s);return[i.lng(),i.lat()]}function DZ(t,e){if(t.pixel)return t.pixel;let r=e.getViewports()[0].project([t.latLng.lng(),t.latLng.lat()]);return{x:r[0],y:r[1]}}function UZ(t,e,r){if(!t.isInitialized)return;let s={type:e,offsetCenter:DZ(r,t),srcEvent:r};switch(e){case"click":case"rightclick":s.type="click",s.tapCount=1,t._onPointerDown(s),t._onEvent(s);break;case"dblclick":s.type="click",s.tapCount=2,t._onEvent(s);break;case"mousemove":s.type="pointermove",t._onPointerMove(s);break;case"mouseout":s.type="pointerleave",t._onPointerMove(s);break;default:return}}var kZ=()=>!1,VZ={depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],blendEquation:32774};function qF(){}var zZ={interleaved:!0},fh=class{constructor(e){this.props={},this._map=null,this._deck=null,this._overlay=null,this.setProps({...zZ,...e})}setMap(e){if(e===this._map)return;let{VECTOR:r,UNINITIALIZED:s}=google.maps.RenderingType;this._map&&(!e&&this._map.getRenderingType()===r&&this.props.interleaved&&this._overlay.requestRedraw(),this._overlay?.setMap(null),this._map=null),e&&(this._map=e,e.getRenderingType()!==s?this._createOverlay(e):e.addListener("renderingtype_changed",()=>{this._createOverlay(e)}))}setProps(e){if(Object.assign(this.props,e),this._deck){let r=this._deck.getCanvas();if(e.style&&r?.parentElement){let s=r.parentElement.style;Object.assign(s,e.style),e.style=null}this._deck.setProps(e)}}pickObject(e){return this._deck&&this._deck.pickObject(e)}pickMultipleObjects(e){return this._deck&&this._deck.pickMultipleObjects(e)}pickObjects(e){return this._deck&&this._deck.pickObjects(e)}finalize(){this.setMap(null),this._deck&&(Zm(this._deck),this._deck=null)}_createOverlay(e){let{interleaved:r}=this.props,{VECTOR:s,UNINITIALIZED:i}=google.maps.RenderingType,n=e.getRenderingType();if(n===i)return;let a=n===s&&google.maps.WebGLOverlayView?google.maps.WebGLOverlayView:google.maps.OverlayView,c=new a;c instanceof google.maps.WebGLOverlayView?(r?(c.onAdd=qF,c.onContextRestored=this._onContextRestored.bind(this),c.onDraw=this._onDrawVectorInterleaved.bind(this)):(c.onAdd=this._onAdd.bind(this),c.onContextRestored=qF,c.onDraw=this._onDrawVectorOverlay.bind(this)),c.onContextLost=this._onContextLost.bind(this)):(c.onAdd=this._onAdd.bind(this),c.draw=this._onDrawRaster.bind(this)),c.onRemove=this._onRemove.bind(this),this._overlay=c,this._overlay.setMap(e)}_onAdd(){this._deck=nE(this._map,this._overlay,this._deck,this.props)}_onContextRestored({gl:e}){if(!this._map||!this._overlay)return;let r=()=>{this._overlay&&this._overlay.requestRedraw()},s=nE(this._map,this._overlay,this._deck,{gl:e,_customRender:r,...this.props});this._deck=s;let i=s.animationLoop;i._renderFrame=()=>{let n=e.getParameter(34964);s.device.withParametersWebGL({},()=>{i.props.onRender(i.animationProps)}),e.bindBuffer(34962,n)}}_onContextLost(){this._deck&&(Zm(this._deck),this._deck=null)}_onRemove(){this._deck?.setProps({layerFilter:kZ})}_onDrawRaster(){if(!this._deck||!this._map)return;let e=this._deck,{width:r,height:s,left:i,top:n,...o}=XF(this._map,this._overlay),c=e.getCanvas()?.parentElement||e.props.parent;if(c){let u=c.style;u.left=`${i}px`,u.top=`${n}px`}let l=1e4;e.setProps({width:r,height:s,viewState:{altitude:l,...o}}),e.redraw()}_onDrawVectorInterleaved({gl:e,transformer:r}){if(!this._deck||!this._map)return;let s=this._deck;if(s.setProps({...oE(this._map,r),width:null,height:null}),s.isInitialized){let i=s.device,n=i.getParametersWebGL(36006);s.setProps({_framebuffer:n}),i.getCanvasContext().resize(),s.needsRedraw({clearRedrawFlags:!0}),i.setParametersWebGL({viewport:[0,0,e.canvas.width,e.canvas.height],scissor:[0,0,e.canvas.width,e.canvas.height],stencilFunc:[519,0,255,519,0,255]}),i.withParametersWebGL(VZ,()=>{s._drawLayers("google-vector",{clearCanvas:!1})})}}_onDrawVectorOverlay({transformer:e}){if(!this._deck||!this._map)return;let r=this._deck;r.setProps({...oE(this._map,e)}),r.redraw()}};var aE=512,HZ=Math.PI/180;function Qm({map:t,gl:e,deck:r}){if(t.__deck)return t.__deck;let s=r?.props._customRender,i=r?.props.onLoad,n=lE({...r?.props,_customRender:()=>{t.triggerRepaint(),s?.("")}}),o;return(!r||r.props.gl===e)&&(Object.assign(n,{gl:e,width:null,height:null,touchAction:"unset",viewState:uc(t)}),r?.isInitialized?KF(r,t):n.onLoad=()=>{i?.(),KF(o,t)}),r?(o=r,r.setProps(n),r.userData.isExternal=!0):(o=new jr(n),t.on("remove",()=>{cE(t)})),o.userData.mapboxLayers=new Set,t.__deck=o,t.on("render",()=>{o.isInitialized&&WZ(o,t)}),o}function KF(t,e){let r=()=>{t.isInitialized?jZ(t,e):e.off("move",r)};e.on("move",r)}function cE(t){t.__deck?.finalize(),t.__deck=null}function lE(t){return{...t,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...t.parameters},views:t.views||[new Ri({id:"mapbox"})]}}function $F(t,e){t.userData.mapboxLayers.add(e),uE(t)}function JF(t,e){t.userData.mapboxLayers.delete(e),uE(t)}function ZF(t,e){uE(t)}function QF(t,e,r){let{currentViewport:s}=t.userData,i=!1;s||(s=eL(t,e,!0),t.userData.currentViewport=s,i=!0),t.isInitialized&&t._drawLayers("mapbox-repaint",{viewports:[s],layerFilter:({layer:n})=>r.id===n.id||n.props.operation.includes("terrain"),clearStack:i,clearCanvas:!1})}function uc(t){let{lng:e,lat:r}=t.getCenter(),s={longitude:(e+540)%360-180,latitude:r,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return t.getTerrain?.()&&GZ(t,s),s}function GZ(t,e){if(t.getFreeCameraOptions){let{position:r}=t.getFreeCameraOptions();if(!r||r.z===void 0)return;let s=t.transform.height,{longitude:i,latitude:n,pitch:o}=e,a=r.x*aE,c=(1-r.y)*aE,l=r.z*aE,u=je([i,n]),f=a-u[0],h=c-u[1],d=Math.sqrt(f*f+h*h),p=o*HZ,g=1.5*s,m=p<.001?g*Math.cos(p)/l:g*Math.sin(p)/d;e.zoom=Math.log2(m);let _=g*Math.cos(p)/m,y=l-_;e.position=[0,0,y/bn(n)]}else typeof t.transform.elevation=="number"&&(e.position=[0,0,t.transform.elevation])}function eL(t,e,r=!0){return new Et({id:"mapbox",x:0,y:0,width:t.width,height:t.height,...uc(e),nearZMultiplier:r?.02:.1,nearZ:e.transform._nearZ/e.transform.height,farZ:e.transform._farZ/e.transform.height})}function WZ(t,e){let{mapboxLayers:r,isExternal:s}=t.userData;if(s){let i=Array.from(r,u=>u.id),o=Bt(t.props.layers,Boolean).some(u=>u&&!i.includes(u.id)),a=t.getViewports(),c=a.findIndex(u=>u.id==="mapbox"),l=a.length>1||c<0;(o||l)&&(c>=0&&(a=a.slice(),a[c]=eL(t,e,!1)),t._drawLayers("mapbox-repaint",{viewports:a,layerFilter:u=>(!t.props.layerFilter||t.props.layerFilter(u))&&(u.viewport.id!=="mapbox"||!i.includes(u.layer.id)),clearCanvas:!1}))}t.userData.currentViewport=null}function jZ(t,e){t.setProps({viewState:uc(e)}),t.needsRedraw({clearRedrawFlags:!0})}function uE(t){if(t.userData.isExternal)return;let e=[];t.userData.mapboxLayers.forEach(r=>{let s=r.props.type,i=new s(r.props);e.push(i)}),t.setProps({layers:e})}var hh=class{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.map=null,this.deck=null,this.props=e}onAdd(e,r){this.map=e,this.deck=Qm({map:e,gl:r,deck:this.props.deck}),$F(this.deck,this)}onRemove(){this.deck&&JF(this.deck,this)}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&ZF(this.deck,this)}render(){QF(this.deck,this.map,this)}};var fE="__UNDEFINED__";function dh(t,e,r,s){if(!t||!e||!t.style||!t.style._loaded)return;let i=Bt(s,Boolean);if(r!==s){let a=Bt(r,Boolean),c=new Set(a.map(l=>l.id));for(let l of i)c.delete(l.id);for(let l of c)t.getLayer(l)&&t.removeLayer(l)}for(let a of i){let c=t.getLayer(a.id);c?(c.implementation||c).setProps(a.props):t.addLayer(new hh({id:a.id,deck:e}),a.props.beforeId)}let n=t.style._order,o={};for(let a of i){let{beforeId:c}=a.props;(!c||!n.includes(c))&&(c=fE),o[c]=o[c]||[],o[c].push(a.id)}for(let a in o){let c=o[a],l=a===fE?n.length:n.indexOf(a),u=a===fE?void 0:a;for(let f=c.length-1;f>=0;f--){let h=c[f],d=n.indexOf(h);d!==l-1&&(t.moveLayer(h,u),d>l&&l++),l--,u=h}}}var ph=class{constructor(e){this._handleStyleChange=()=>{dh(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:i,clientHeight:n}=this._map.getContainer();Object.assign(this._container.style,{width:`${i}px`,height:`${n}px`})}},this._updateViewState=()=>{let i=this._deck;i&&(i.setProps({viewState:uc(this._map)}),i.isInitialized&&i.redraw())},this._handleMouseEvent=i=>{let n=this._deck;if(!n||!n.isInitialized)return;let o={type:i.type,offsetCenter:i.point,srcEvent:i},a=this._lastMouseDownPoint;switch(!i.point&&a&&(o.deltaX=i.originalEvent.clientX-a.clientX,o.deltaY=i.originalEvent.clientY-a.clientY,o.offsetCenter={x:a.x+o.deltaX,y:a.y+o.deltaY}),o.type){case"mousedown":n._onPointerDown(o),this._lastMouseDownPoint={...i.point,clientX:i.originalEvent.clientX,clientY:i.originalEvent.clientY};break;case"dragstart":o.type="panstart",n._onEvent(o);break;case"drag":o.type="panmove",n._onEvent(o);break;case"dragend":o.type="panend",n._onEvent(o);break;case"click":o.tapCount=1,n._onEvent(o);break;case"dblclick":o.type="click",o.tapCount=2,n._onEvent(o);break;case"mousemove":o.type="pointermove",n._onPointerMove(o);break;case"mouseout":o.type="pointerleave",n._onPointerMove(o);break;default:return}};let{interleaved:r=!1,...s}=e;this._interleaved=r,this._props=s}setProps(e){this._interleaved&&e.layers&&dh(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,e),this._deck&&this._deck.setProps(this._interleaved?lE(this._props):this._props)}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new jr({...this._props,parent:r,viewState:uc(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(e){let r=e.painter.context.gl;return r instanceof WebGLRenderingContext&&k.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=Qm({map:e,gl:r,deck:new jr({...this._props,gl:r})}),e.on("styledata",this._handleStyleChange),dh(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),dh(e,this._deck,this._props.layers,[]),cE(e)}getDefaultPosition(){return"top-left"}pickObject(e){return Ae(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return Ae(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return Ae(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}};var i_,Ie,oL,XZ,yo,tL,aL,hE,YZ,gh={},cL=[],qZ=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pE=Array.isArray;function tn(t,e){for(var r in e)t[r]=e[r];return t}function lL(t){var e=t.parentNode;e&&e.removeChild(t)}function KZ(t,e,r){var s,i,n,o={};for(n in e)n=="key"?s=e[n]:n=="ref"?i=e[n]:o[n]=e[n];if(arguments.length>2&&(o.children=arguments.length>3?i_.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(n in t.defaultProps)o[n]===void 0&&(o[n]=t.defaultProps[n]);return t_(t,o,s,i,null)}function t_(t,e,r,s,i){var n={type:t,props:e,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:i??++oL,__i:-1,__u:0};return i==null&&Ie.vnode!=null&&Ie.vnode(n),n}function fc(t){return t.children}function r_(t,e){this.props=t,this.context=e}function xo(t,e){if(e==null)return t.__?xo(t.__,t.__i+1):null;for(var r;ee&&yo.sort(hE));s_.__r=0}function fL(t,e,r,s,i,n,o,a,c,l,u){var f,h,d,p,g,m=s&&s.__k||cL,_=e.length;for(r.__d=c,$Z(r,e,m),c=r.__d,f=0;f<_;f++)(d=r.__k[f])!=null&&typeof d!="boolean"&&typeof d!="function"&&(h=d.__i===-1?gh:m[d.__i]||gh,d.__i=f,gE(t,d,h,i,n,o,a,c,l,u),p=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&mE(h.ref,null,d),u.push(d.ref,d.__c||p,d)),g==null&&p!=null&&(g=p),65536&d.__u||h.__k===d.__k?(p||h.__e!=c||(c=xo(h)),c=hL(d,c,t)):typeof d.type=="function"&&d.__d!==void 0?c=d.__d:p&&(c=p.nextSibling),d.__d=void 0,d.__u&=-196609);r.__d=c,r.__e=g}function $Z(t,e,r){var s,i,n,o,a,c=e.length,l=r.length,u=l,f=0;for(t.__k=[],s=0;s0?t_(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)!=null?(i.__=t,i.__b=t.__b+1,a=JZ(i,r,o,u),i.__i=a,n=null,a!==-1&&(u--,(n=r[a])&&(n.__u|=131072)),n==null||n.__v===null?(a==-1&&f--,typeof i.type!="function"&&(i.__u|=65536)):a!==o&&(a===o+1?f++:a>o?u>c-o?f+=a-o:f--:a(c!=null&&!(131072&c.__u)?1:0))for(;o>=0||a=0){if((c=e[o])&&!(131072&c.__u)&&i==c.key&&n===c.type)return o;o--}if(a{let{className:e,label:r,onClick:s}=t;return He("div",{className:"deck-widget-button",children:He("button",{className:`deck-widget-icon-button ${e}`,type:"button",onClick:s,title:r,children:He("div",{className:"deck-widget-icon"})})})},gL=t=>{let{children:e,orientation:r}=t;return He("div",{className:`deck-widget-button-group ${r}`,children:e})},_E=t=>{let{className:e,label:r,onClick:s}=t;return He("button",{className:`deck-widget-icon-button ${e}`,type:"button",onClick:s,title:r,children:He("div",{className:"deck-widget-icon"})})};var n_=class{constructor(e){this.id="fullscreen",this.placement="top-left",this.fullscreen=!1,this.id=e.id||"fullscreen",this.placement=e.placement||"top-left",e.enterLabel=e.enterLabel||"Enter Fullscreen",e.exitLabel=e.exitLabel||"Exit Fullscreen",e.style=e.style||{},this.props=e}onAdd({deck:e}){let{style:r,className:s}=this.props,i=document.createElement("div");return i.classList.add("deck-widget","deck-widget-fullscreen"),s&&i.classList.add(s),r&&Object.entries(r).map(([n,o])=>i.style.setProperty(n,o)),this.deck=e,this.element=i,this.update(),document.addEventListener("fullscreenchange",this.onFullscreenChange.bind(this)),i}onRemove(){this.deck=void 0,this.element=void 0,document.removeEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}update(){let{enterLabel:e,exitLabel:r}=this.props,s=this.element;if(!s)return;let i=He(pL,{onClick:this.handleClick.bind(this),label:this.fullscreen?r:e,className:this.fullscreen?"deck-widget-fullscreen-exit":"deck-widget-fullscreen-enter"});hc(i,s)}setProps(e){let r=this.props,s=this.element;s&&(r.className!==e.className&&(r.className&&s.classList.remove(r.className),e.className&&s.classList.add(e.className)),ve(r.style,e.style,1)||(r.style&&Object.entries(r.style).map(([i])=>s.style.removeProperty(i)),e.style&&Object.entries(e.style).map(([i,n])=>s.style.setProperty(i,n)))),Object.assign(this.props,e)}getContainer(){return this.props.container||this.deck?.getCanvas()?.parentElement}onFullscreenChange(){let e=this.fullscreen,r=document.fullscreenElement===this.getContainer();e!==r&&(this.fullscreen=!this.fullscreen),this.update()}async handleClick(){this.fullscreen?await this.exitFullscreen():await this.requestFullscreen(),this.update()}async requestFullscreen(){let e=this.getContainer();e?.requestFullscreen?await e.requestFullscreen({navigationUI:"hide"}):this.togglePseudoFullscreen()}async exitFullscreen(){document.exitFullscreen?await document.exitFullscreen():this.togglePseudoFullscreen()}togglePseudoFullscreen(){this.getContainer()?.classList.toggle("deck-pseudo-fullscreen")}};var o_=class{constructor(e){this.id="compass",this.placement="top-left",this.viewId=null,this.viewports={},this.id=e.id||"compass",this.viewId=e.viewId||null,this.placement=e.placement||"top-left",e.transitionDuration=e.transitionDuration||200,e.label=e.label||"Compass",e.style=e.style||{},this.props=e}setProps(e){Object.assign(this.props,e)}onViewportChange(e){this.viewports[e.id]=e,this.update()}onAdd({deck:e}){let{style:r,className:s}=this.props,i=document.createElement("div");return i.classList.add("deck-widget","deck-widget-compass"),s&&i.classList.add(s),r&&Object.entries(r).map(([n,o])=>i.style.setProperty(n,o)),this.deck=e,this.element=i,this.update(),i}getRotation(e){return e instanceof Et?[-e.bearing,e.pitch]:e instanceof Yr?[0,Math.max(-80,Math.min(80,e.latitude))]:[0,0]}update(){let e=this.viewId||Object.values(this.viewports)[0]?.id||"default-view",r=this.viewports[e],[s,i]=this.getRotation(r),n=this.element;if(!n)return;let o=He("div",{className:"deck-widget-button",style:{perspective:100},children:He("button",{type:"button",onClick:()=>{for(let a of Object.values(this.viewports))this.handleCompassReset(a)},label:this.props.label,style:{transform:`rotateX(${i}deg)`},children:He("svg",{fill:"none",width:"100%",height:"100%",viewBox:"0 0 26 26",children:He("g",{transform:`rotate(${s},13,13)`,children:[He("path",{d:"M10 13.0001L12.9999 5L15.9997 13.0001H10Z",fill:"var(--icon-compass-north-color, #F05C44)"}),He("path",{d:"M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",fill:"var(--icon-compass-south-color, #C2C2CC)"})]})})})});hc(o,n)}onRemove(){this.deck=void 0,this.element=void 0}handleCompassReset(e){let r=this.viewId||e.id||"default-view";if(e instanceof Et){let s={...e,bearing:0,...this.getRotation(e)[0]===0?{pitch:0}:{},transitionDuration:this.props.transitionDuration,transitionInterpolator:new Xs};this.deck._onViewStateChange({viewId:r,viewState:s,interactionState:{}})}}};var a_=class{constructor(e){this.id="zoom",this.placement="top-left",this.orientation="vertical",this.viewId=null,this.viewports={},this.id=e.id||"zoom",this.viewId=e.viewId||null,this.placement=e.placement||"top-left",this.orientation=e.orientation||"vertical",e.transitionDuration=e.transitionDuration||200,e.zoomInLabel=e.zoomInLabel||"Zoom In",e.zoomOutLabel=e.zoomOutLabel||"Zoom Out",e.style=e.style||{},this.props=e}onAdd({deck:e}){let{style:r,className:s}=this.props,i=document.createElement("div");i.classList.add("deck-widget","deck-widget-zoom"),s&&i.classList.add(s),r&&Object.entries(r).map(([o,a])=>i.style.setProperty(o,a));let n=He(gL,{orientation:this.orientation,children:[He(_E,{onClick:()=>this.handleZoomIn(),label:this.props.zoomInLabel,className:"deck-widget-zoom-in"}),He(_E,{onClick:()=>this.handleZoomOut(),label:this.props.zoomOutLabel,className:"deck-widget-zoom-out"})]});return hc(n,i),this.deck=e,this.element=i,i}onRemove(){this.deck=void 0,this.element=void 0}setProps(e){Object.assign(this.props,e)}onViewportChange(e){this.viewports[e.id]=e}handleZoom(e,r){let s=this.viewId||e?.id||"default-view",i={...e,zoom:r,transitionDuration:this.props.transitionDuration,transitionInterpolator:new Xs};this.deck._onViewStateChange({viewId:s,viewState:i,interactionState:{}})}handleZoomIn(){for(let e of Object.values(this.viewports))this.handleZoom(e,e.zoom+1)}handleZoomOut(){for(let e of Object.values(this.viewports))this.handleZoom(e,e.zoom-1)}};var tQ={"--button-background":"#fff","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"unset","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--button-backdrop-filter":"unset","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--icon-compass-north-color":"#F05C44","--icon-compass-south-color":"#C2C2CC"},rQ={"--button-background":"rgba(18, 18, 20, 1)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"unset","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25)","--button-backdrop-filter":"unset","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--icon-compass-north-color":"#F05C44","--icon-compass-south-color":"#C2C2CC"},sQ={"--button-background":"rgba(255, 255, 255, 0.6)","--button-stroke":"rgba(255, 255, 255, 0.3)","--button-inner-stroke":"1px solid rgba(255, 255, 255, 0.6)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(97, 97, 102, 1)","--button-icon-hover":"rgba(24, 24, 26, 1)","--icon-compass-north-color":"#F05C44","--icon-compass-south-color":"#C2C2CC"},iQ={"--button-background":"rgba(18, 18, 20, 0.75)","--button-stroke":"rgba(18, 18, 20, 0.30)","--button-inner-stroke":"1px solid rgba(18, 18, 20, 0.75)","--button-shadow":"0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset","--button-backdrop-filter":"blur(4px)","--button-icon-idle":"rgba(158, 157, 168, 1)","--button-icon-hover":"rgba(215, 214, 229, 1)","--icon-compass-north-color":"#F05C44","--icon-compass-south-color":"#C2C2CC"};var mh=ss(ff(),1);va._checkH3Lib=()=>{let t='include the tag before the deck.gl script tag. https://deck.gl/docs/api-reference/geo-layers/h3-hexagon-layer';if(mh){if(mh.polyfill&&!mh.polygonToCells)throw new Error(`Incompatible h3-js version. ${t}`)}else throw new Error(`To use H3 functionality, ${t}`)};return $L(nQ);})(); return __exports__; });