File: C:/Users/fred/anaconda3/Lib/site-packages/panel/dist/bundled/deckglplot/
[email protected]/dist.min.js
(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 UN=Object.create;var Rc=Object.defineProperty;var kN=Object.getOwnPropertyDescriptor;var VN=Object.getOwnPropertyNames;var zN=Object.getPrototypeOf,HN=Object.prototype.hasOwnProperty;var GN=(e,t,r)=>t in e?Rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var c1=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),$t=(e,t)=>{for(var r in t)Rc(e,r,{get:t[r],enumerable:!0})},l1=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of VN(t))!HN.call(e,s)&&s!==r&&Rc(e,s,{get:()=>t[s],enumerable:!(i=kN(t,s))||i.enumerable});return e};var li=(e,t,r)=>(r=e!=null?UN(zN(e)):{},l1(t||!e||!e.__esModule?Rc(r,"default",{value:e,enumerable:!0}):r,e)),WN=e=>l1(Rc({},"__esModule",{value:!0}),e);var Y=(e,t,r)=>(GN(e,typeof t!="symbol"?t+"":t,r),r);var Jw=le((U_t,ip)=>{(function(e,t,r,i){"use strict";var s=["","webkit","Moz","MS","ms","o"],n=t.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!==i)for(N=0;N<A.length;)b.call(C,A[N],N,A),N++;else for(N in A)A.hasOwnProperty(N)&&b.call(C,A[N],N,A)}function d(A,b,C){var N="DEPRECATED METHOD: "+b+`
`+C+` AT
`;return function(){var H=new Error("get-stack-trace"),$=H&&H.stack?H.stack.replace(/^[^\(]+?[\n$]/gm,"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",at=e.console&&(e.console.warn||e.console.log);return at&&at.call(e.console,N,$),A.apply(this,arguments)}}var p;typeof Object.assign!="function"?p=function(b){if(b===i||b===null)throw new TypeError("Cannot convert undefined or null to object");for(var C=Object(b),N=1;N<arguments.length;N++){var H=arguments[N];if(H!==i&&H!==null)for(var $ in H)H.hasOwnProperty($)&&(C[$]=H[$])}return C}:p=Object.assign;var g=d(function(b,C,N){for(var H=Object.keys(C),$=0;$<H.length;)(!N||N&&b[H[$]]===i)&&(b[H[$]]=C[H[$]]),$++;return b},"extend","Use `assign`."),m=d(function(b,C){return g(b,C,!0)},"merge","Use `assign`.");function _(A,b,C){var N=b.prototype,H;H=A.prototype=Object.create(N),H.constructor=A,H._super=N,C&&p(H,C)}function y(A,b){return function(){return A.apply(b,arguments)}}function x(A,b){return typeof A==o?A.apply(b&&b[0]||i,b):A}function E(A,b){return A===i?b:A}function P(A,b,C){h(v(b),function(N){A.addEventListener(N,C,!1)})}function B(A,b,C){h(v(b),function(N){A.removeEventListener(N,C,!1)})}function F(A,b){for(;A;){if(A==b)return!0;A=A.parentNode}return!1}function M(A,b){return A.indexOf(b)>-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;N<A.length;){if(C&&A[N][C]==b||!C&&A[N]===b)return N;N++}return-1}function L(A){return Array.prototype.slice.call(A,0)}function V(A,b,C){for(var N=[],H=[],$=0;$<A.length;){var at=b?A[$][b]:A[$];T(H,at)<0&&N.push(A[$]),H[$]=at,$++}return C&&(b?N=N.sort(function(ge,Ie){return ge[b]>Ie[b]}):N=N.sort()),N}function z(A,b){for(var C,N,H=b[0].toUpperCase()+b.slice(1),$=0;$<s.length;){if(C=s[$],N=C?C+H:b,N in A)return N;$++}return i}var W=1;function Z(){return W++}function ut(A){var b=A.ownerDocument||A;return b.defaultView||b.parentWindow||e}var st=/mobile|tablet|ip(ad|hone|od)|android/i,Rt="ontouchstart"in e,gt=z(e,"PointerEvent")!==i,bt=Rt&&st.test(navigator.userAgent),Et="touch",Te="pen",bc="mouse",HE="kinect",v_=25,Re=1,ln=2,Kt=4,ke=8,rh=1,Ec=2,Sc=4,vc=8,Cc=16,oi=Ec|Sc,un=vc|Cc,GE=oi|un,WE=["x","y"],ih=["clientX","clientY"];function or(A,b){var C=this;this.manager=A,this.callback=b,this.element=A.element,this.target=A.options.inputTarget,this.domHandler=function(N){x(A.options.enable,[A])&&C.handler(N)},this.init()}or.prototype={handler:function(){},init:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(ut(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&B(this.element,this.evEl,this.domHandler),this.evTarget&&B(this.target,this.evTarget,this.domHandler),this.evWin&&B(ut(this.element),this.evWin,this.domHandler)}};function fN(A){var b,C=A.options.inputClass;return C?b=C:gt?b=w_:bt?b=oh:Rt?b=P_:b=nh,new b(A,hN)}function hN(A,b,C){var N=C.pointers.length,H=C.changedPointers.length,$=b&Re&&N-H===0,at=b&(Kt|ke)&&N-H===0;C.isFirst=!!$,C.isFinal=!!at,$&&(A.session={}),C.eventType=b,dN(A,C),A.emit("hammer.input",C),A.recognize(C),A.session.prevInput=C}function dN(A,b){var C=A.session,N=b.pointers,H=N.length;C.firstInput||(C.firstInput=jE(b)),H>1&&!C.firstMultiple?C.firstMultiple=jE(b):H===1&&(C.firstMultiple=!1);var $=C.firstInput,at=C.firstMultiple,ce=at?at.center:$.center,ge=b.center=XE(N);b.timeStamp=l(),b.deltaTime=b.timeStamp-$.timeStamp,b.angle=C_(ce,ge),b.distance=sh(ce,ge),pN(C,b),b.offsetDirection=qE(b.deltaX,b.deltaY);var Ie=YE(b.deltaTime,b.deltaX,b.deltaY);b.overallVelocityX=Ie.x,b.overallVelocityY=Ie.y,b.overallVelocity=c(Ie.x)>c(Ie.y)?Ie.x:Ie.y,b.scale=at?_N(at.pointers,N):1,b.rotation=at?mN(at.pointers,N):0,b.maxPointers=C.prevInput?b.pointers.length>C.prevInput.maxPointers?b.pointers.length:C.prevInput.maxPointers:b.pointers.length,gN(C,b);var ci=A.element;F(b.srcEvent.target,ci)&&(ci=b.srcEvent.target),b.target=ci}function pN(A,b){var C=b.center,N=A.offsetDelta||{},H=A.prevDelta||{},$=A.prevInput||{};(b.eventType===Re||$.eventType===Kt)&&(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 gN(A,b){var C=A.lastInterval||b,N=b.timeStamp-C.timeStamp,H,$,at,ce;if(b.eventType!=ke&&(N>v_||C.velocity===i)){var ge=b.deltaX-C.deltaX,Ie=b.deltaY-C.deltaY,ci=YE(N,ge,Ie);$=ci.x,at=ci.y,H=c(ci.x)>c(ci.y)?ci.x:ci.y,ce=qE(ge,Ie),A.lastInterval=b}else H=C.velocity,$=C.velocityX,at=C.velocityY,ce=C.direction;b.velocity=H,b.velocityX=$,b.velocityY=at,b.direction=ce}function jE(A){for(var b=[],C=0;C<A.pointers.length;)b[C]={clientX:a(A.pointers[C].clientX),clientY:a(A.pointers[C].clientY)},C++;return{timeStamp:l(),pointers:b,center:XE(b),deltaX:A.deltaX,deltaY:A.deltaY}}function XE(A){var b=A.length;if(b===1)return{x:a(A[0].clientX),y:a(A[0].clientY)};for(var C=0,N=0,H=0;H<b;)C+=A[H].clientX,N+=A[H].clientY,H++;return{x:a(C/b),y:a(N/b)}}function YE(A,b,C){return{x:b/A||0,y:C/A||0}}function qE(A,b){return A===b?rh:c(A)>=c(b)?A<0?Ec:Sc:b<0?vc:Cc}function sh(A,b,C){C||(C=WE);var N=b[C[0]]-A[C[0]],H=b[C[1]]-A[C[1]];return Math.sqrt(N*N+H*H)}function C_(A,b,C){C||(C=WE);var N=b[C[0]]-A[C[0]],H=b[C[1]]-A[C[1]];return Math.atan2(H,N)*180/Math.PI}function mN(A,b){return C_(b[1],b[0],ih)+C_(A[1],A[0],ih)}function _N(A,b){return sh(b[0],b[1],ih)/sh(A[0],A[1],ih)}var yN={mousedown:Re,mousemove:ln,mouseup:Kt},xN="mousedown",AN="mousemove mouseup";function nh(){this.evEl=xN,this.evWin=AN,this.pressed=!1,or.apply(this,arguments)}_(nh,or,{handler:function(b){var C=yN[b.type];C&Re&&b.button===0&&(this.pressed=!0),C&ln&&b.which!==1&&(C=Kt),this.pressed&&(C&Kt&&(this.pressed=!1),this.callback(this.manager,C,{pointers:[b],changedPointers:[b],pointerType:bc,srcEvent:b}))}});var TN={pointerdown:Re,pointermove:ln,pointerup:Kt,pointercancel:ke,pointerout:ke},bN={2:Et,3:Te,4:bc,5:HE},KE="pointerdown",$E="pointermove pointerup pointercancel";e.MSPointerEvent&&!e.PointerEvent&&(KE="MSPointerDown",$E="MSPointerMove MSPointerUp MSPointerCancel");function w_(){this.evEl=KE,this.evWin=$E,or.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}_(w_,or,{handler:function(b){var C=this.store,N=!1,H=b.type.toLowerCase().replace("ms",""),$=TN[H],at=bN[b.pointerType]||b.pointerType,ce=at==Et,ge=T(C,b.pointerId,"pointerId");$&Re&&(b.button===0||ce)?ge<0&&(C.push(b),ge=C.length-1):$&(Kt|ke)&&(N=!0),!(ge<0)&&(C[ge]=b,this.callback(this.manager,$,{pointers:C,changedPointers:[b],pointerType:at,srcEvent:b}),N&&C.splice(ge,1))}});var EN={touchstart:Re,touchmove:ln,touchend:Kt,touchcancel:ke},SN="touchstart",vN="touchstart touchmove touchend touchcancel";function JE(){this.evTarget=SN,this.evWin=vN,this.started=!1,or.apply(this,arguments)}_(JE,or,{handler:function(b){var C=EN[b.type];if(C===Re&&(this.started=!0),!!this.started){var N=CN.call(this,b,C);C&(Kt|ke)&&N[0].length-N[1].length===0&&(this.started=!1),this.callback(this.manager,C,{pointers:N[0],changedPointers:N[1],pointerType:Et,srcEvent:b})}}});function CN(A,b){var C=L(A.touches),N=L(A.changedTouches);return b&(Kt|ke)&&(C=V(C.concat(N),"identifier",!0)),[C,N]}var wN={touchstart:Re,touchmove:ln,touchend:Kt,touchcancel:ke},PN="touchstart touchmove touchend touchcancel";function oh(){this.evTarget=PN,this.targetIds={},or.apply(this,arguments)}_(oh,or,{handler:function(b){var C=wN[b.type],N=MN.call(this,b,C);N&&this.callback(this.manager,C,{pointers:N[0],changedPointers:N[1],pointerType:Et,srcEvent:b})}});function MN(A,b){var C=L(A.touches),N=this.targetIds;if(b&(Re|ln)&&C.length===1)return N[C[0].identifier]=!0,[C,C];var H,$,at=L(A.changedTouches),ce=[],ge=this.target;if($=C.filter(function(Ie){return F(Ie.target,ge)}),b===Re)for(H=0;H<$.length;)N[$[H].identifier]=!0,H++;for(H=0;H<at.length;)N[at[H].identifier]&&ce.push(at[H]),b&(Kt|ke)&&delete N[at[H].identifier],H++;if(ce.length)return[V($.concat(ce),"identifier",!0),ce]}var RN=2500,ZE=25;function P_(){or.apply(this,arguments);var A=y(this.handler,this);this.touch=new oh(this.manager,A),this.mouse=new nh(this.manager,A),this.primaryTouch=null,this.lastTouches=[]}_(P_,or,{handler:function(b,C,N){var H=N.pointerType==Et,$=N.pointerType==bc;if(!($&&N.sourceCapabilities&&N.sourceCapabilities.firesTouchEvents)){if(H)IN.call(this,C,N);else if($&&BN.call(this,N))return;this.callback(b,C,N)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function IN(A,b){A&Re?(this.primaryTouch=b.changedPointers[0].identifier,QE.call(this,b)):A&(Kt|ke)&&QE.call(this,b)}function QE(A){var b=A.changedPointers[0];if(b.identifier===this.primaryTouch){var C={x:b.clientX,y:b.clientY};this.lastTouches.push(C);var N=this.lastTouches,H=function(){var $=N.indexOf(C);$>-1&&N.splice($,1)};setTimeout(H,RN)}}function BN(A){for(var b=A.srcEvent.clientX,C=A.srcEvent.clientY,N=0;N<this.lastTouches.length;N++){var H=this.lastTouches[N],$=Math.abs(b-H.x),at=Math.abs(C-H.y);if($<=ZE&&at<=ZE)return!0}return!1}var t1=z(n.style,"touchAction"),e1=t1!==i,r1="compute",i1="auto",M_="manipulation",fn="none",wc="pan-x",Pc="pan-y",ah=FN();function R_(A,b){this.manager=A,this.set(b)}R_.prototype={set:function(A){A==r1&&(A=this.compute()),e1&&this.manager.element.style&&ah[A]&&(this.manager.element.style[t1]=A),this.actions=A.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var A=[];return h(this.manager.recognizers,function(b){x(b.options.enable,[b])&&(A=A.concat(b.getTouchAction()))}),ON(A.join(" "))},preventDefaults:function(A){var b=A.srcEvent,C=A.offsetDirection;if(this.manager.session.prevented){b.preventDefault();return}var N=this.actions,H=M(N,fn)&&!ah[fn],$=M(N,Pc)&&!ah[Pc],at=M(N,wc)&&!ah[wc];if(H){var ce=A.pointers.length===1,ge=A.distance<2,Ie=A.deltaTime<250;if(ce&&ge&&Ie)return}if(!(at&&$)&&(H||$&&C&oi||at&&C&un))return this.preventSrc(b)},preventSrc:function(A){this.manager.session.prevented=!0,A.preventDefault()}};function ON(A){if(M(A,fn))return fn;var b=M(A,wc),C=M(A,Pc);return b&&C?fn:b||C?b?wc:Pc:M(A,M_)?M_:i1}function FN(){if(!e1)return!1;var A={},b=e.CSS&&e.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(C){A[C]=b?e.CSS.supports("touch-action",C):!0}),A}var ch=1,ar=2,Fo=4,ms=8,Fi=ms,Mc=16,ai=32;function Ni(A){this.options=p({},this.defaults,A||{}),this.id=Z(),this.manager=null,this.options.enable=E(this.options.enable,!0),this.state=ch,this.simultaneous={},this.requireFail=[]}Ni.prototype={defaults:{},set:function(A){return p(this.options,A),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(A){if(f(A,"recognizeWith",this))return this;var b=this.simultaneous;return A=lh(A,this),b[A.id]||(b[A.id]=A,A.recognizeWith(this)),this},dropRecognizeWith:function(A){return f(A,"dropRecognizeWith",this)?this:(A=lh(A,this),delete this.simultaneous[A.id],this)},requireFailure:function(A){if(f(A,"requireFailure",this))return this;var b=this.requireFail;return A=lh(A,this),T(b,A)===-1&&(b.push(A),A.requireFailure(this)),this},dropRequireFailure:function(A){if(f(A,"dropRequireFailure",this))return this;A=lh(A,this);var b=T(this.requireFail,A);return b>-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<ms&&N(b.options.event+s1(C)),N(b.options.event),A.additionalEvent&&N(A.additionalEvent),C>=ms&&N(b.options.event+s1(C))},tryEmit:function(A){if(this.canEmit())return this.emit(A);this.state=ai},canEmit:function(){for(var A=0;A<this.requireFail.length;){if(!(this.requireFail[A].state&(ai|ch)))return!1;A++}return!0},recognize:function(A){var b=p({},A);if(!x(this.options.enable,[this,b])){this.reset(),this.state=ai;return}this.state&(Fi|Mc|ai)&&(this.state=ch),this.state=this.process(b),this.state&(ar|Fo|ms|Mc)&&this.tryEmit(b)},process:function(A){},getTouchAction:function(){},reset:function(){}};function s1(A){return A&Mc?"cancel":A&ms?"end":A&Fo?"move":A&ar?"start":""}function n1(A){return A==Cc?"down":A==vc?"up":A==Ec?"left":A==Sc?"right":""}function lh(A,b){var C=b.manager;return C?C.get(A):A}function Br(){Ni.apply(this,arguments)}_(Br,Ni,{defaults:{pointers:1},attrTest:function(A){var b=this.options.pointers;return b===0||A.pointers.length===b},process:function(A){var b=this.state,C=A.eventType,N=b&(ar|Fo),H=this.attrTest(A);return N&&(C&ke||!H)?b|Mc:N||H?C&Kt?b|ms:b&ar?b|Fo:ar:ai}});function uh(){Br.apply(this,arguments),this.pX=null,this.pY=null}_(uh,Br,{defaults:{event:"pan",threshold:10,pointers:1,direction:GE},getTouchAction:function(){var A=this.options.direction,b=[];return A&oi&&b.push(Pc),A&un&&b.push(wc),b},directionTest:function(A){var b=this.options,C=!0,N=A.distance,H=A.direction,$=A.deltaX,at=A.deltaY;return H&b.direction||(b.direction&oi?(H=$===0?rh:$<0?Ec:Sc,C=$!=this.pX,N=Math.abs(A.deltaX)):(H=at===0?rh:at<0?vc:Cc,C=at!=this.pY,N=Math.abs(A.deltaY))),A.direction=H,C&&N>b.threshold&&H&b.direction},attrTest:function(A){return Br.prototype.attrTest.call(this,A)&&(this.state&ar||!(this.state&ar)&&this.directionTest(A))},emit:function(A){this.pX=A.deltaX,this.pY=A.deltaY;var b=n1(A.direction);b&&(A.additionalEvent=this.options.event+b),this._super.emit.call(this,A)}});function I_(){Br.apply(this,arguments)}_(I_,Br,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[fn]},attrTest:function(A){return this._super.attrTest.call(this,A)&&(Math.abs(A.scale-1)>this.options.threshold||this.state&ar)},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 B_(){Ni.apply(this,arguments),this._timer=null,this._input=null}_(B_,Ni,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[i1]},process:function(A){var b=this.options,C=A.pointers.length===b.pointers,N=A.distance<b.threshold,H=A.deltaTime>b.time;if(this._input=A,!N||!C||A.eventType&(Kt|ke)&&!H)this.reset();else if(A.eventType&Re)this.reset(),this._timer=u(function(){this.state=Fi,this.tryEmit()},b.time,this);else if(A.eventType&Kt)return Fi;return ai},reset:function(){clearTimeout(this._timer)},emit:function(A){this.state===Fi&&(A&&A.eventType&Kt?this.manager.emit(this.options.event+"up",A):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function O_(){Br.apply(this,arguments)}_(O_,Br,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[fn]},attrTest:function(A){return this._super.attrTest.call(this,A)&&(Math.abs(A.rotation)>this.options.threshold||this.state&ar)}});function F_(){Br.apply(this,arguments)}_(F_,Br,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:oi|un,pointers:1},getTouchAction:function(){return uh.prototype.getTouchAction.call(this)},attrTest:function(A){var b=this.options.direction,C;return b&(oi|un)?C=A.overallVelocity:b&oi?C=A.overallVelocityX:b&un&&(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&Kt},emit:function(A){var b=n1(A.offsetDirection);b&&this.manager.emit(this.options.event+b,A),this.manager.emit(this.options.event,A)}});function fh(){Ni.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}_(fh,Ni,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[M_]},process:function(A){var b=this.options,C=A.pointers.length===b.pointers,N=A.distance<b.threshold,H=A.deltaTime<b.time;if(this.reset(),A.eventType&Re&&this.count===0)return this.failTimeout();if(N&&H&&C){if(A.eventType!=Kt)return this.failTimeout();var $=this.pTime?A.timeStamp-this.pTime<b.interval:!0,at=!this.pCenter||sh(this.pCenter,A.center)<b.posThreshold;this.pTime=A.timeStamp,this.pCenter=A.center,!at||!$?this.count=1:this.count+=1,this._input=A;var ce=this.count%b.taps;if(ce===0)return this.hasRequireFailures()?(this._timer=u(function(){this.state=Fi,this.tryEmit()},b.interval,this),ar):Fi}return ai},failTimeout:function(){return this._timer=u(function(){this.state=ai},this.options.interval,this),ai},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Fi&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function Li(A,b){return b=b||{},b.recognizers=E(b.recognizers,Li.defaults.preset),new N_(A,b)}Li.VERSION="2.0.7",Li.defaults={domEvents:!1,touchAction:r1,enable:!0,inputTarget:null,inputClass:null,preset:[[O_,{enable:!1}],[I_,{enable:!1},["rotate"]],[F_,{direction:oi}],[uh,{direction:oi},["swipe"]],[fh],[fh,{event:"doubletap",taps:2},["tap"]],[B_]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var NN=1,o1=2;function N_(A,b){this.options=p({},Li.defaults,b||{}),this.options.inputTarget=this.options.inputTarget||A,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=A,this.input=fN(this),this.touchAction=new R_(this,this.options.touchAction),a1(this,!0),h(this.options.recognizers,function(C){var N=this.add(new C[0](C[1]));C[2]&&N.recognizeWith(C[2]),C[3]&&N.requireFailure(C[3])},this)}N_.prototype={set:function(A){return p(this.options,A),A.touchAction&&this.touchAction.update(),A.inputTarget&&(this.input.destroy(),this.input.target=A.inputTarget,this.input.init()),this},stop:function(A){this.session.stopped=A?o1:NN},recognize:function(A){var b=this.session;if(!b.stopped){this.touchAction.preventDefaults(A);var C,N=this.recognizers,H=b.curRecognizer;(!H||H&&H.state&Fi)&&(H=b.curRecognizer=null);for(var $=0;$<N.length;)C=N[$],b.stopped!==o1&&(!H||C==H||C.canRecognizeWith(H))?C.recognize(A):C.reset(),!H&&C.state&(ar|Fo|ms)&&(H=b.curRecognizer=C),$++}},get:function(A){if(A instanceof Ni)return A;for(var b=this.recognizers,C=0;C<b.length;C++)if(b[C].options.event==A)return b[C];return null},add:function(A){if(f(A,"add",this))return this;var b=this.get(A.options.event);return b&&this.remove(b),this.recognizers.push(A),A.manager=this,this.touchAction.update(),A},remove:function(A){if(f(A,"remove",this))return this;if(A=this.get(A),A){var b=this.recognizers,C=T(b,A);C!==-1&&(b.splice(C,1),this.touchAction.update())}return this},on:function(A,b){if(A!==i&&b!==i){var C=this.handlers;return h(v(A),function(N){C[N]=C[N]||[],C[N].push(b)}),this}},off:function(A,b){if(A!==i){var C=this.handlers;return h(v(A),function(N){b?C[N]&&C[N].splice(T(C[N],b),1):delete C[N]}),this}},emit:function(A,b){this.options.domEvents&&LN(A,b);var C=this.handlers[A]&&this.handlers[A].slice();if(!(!C||!C.length)){b.type=A,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var N=0;N<C.length;)C[N](b),N++}},destroy:function(){this.element&&a1(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function a1(A,b){var C=A.element;if(C.style){var N;h(A.options.cssProps,function(H,$){N=z(C.style,$),b?(A.oldCssProps[N]=C.style[N],C.style[N]=H):C.style[N]=A.oldCssProps[N]||""}),b||(A.oldCssProps={})}}function LN(A,b){var C=t.createEvent("Event");C.initEvent(A,!0,!0),C.gesture=b,b.target.dispatchEvent(C)}p(Li,{INPUT_START:Re,INPUT_MOVE:ln,INPUT_END:Kt,INPUT_CANCEL:ke,STATE_POSSIBLE:ch,STATE_BEGAN:ar,STATE_CHANGED:Fo,STATE_ENDED:ms,STATE_RECOGNIZED:Fi,STATE_CANCELLED:Mc,STATE_FAILED:ai,DIRECTION_NONE:rh,DIRECTION_LEFT:Ec,DIRECTION_RIGHT:Sc,DIRECTION_UP:vc,DIRECTION_DOWN:Cc,DIRECTION_HORIZONTAL:oi,DIRECTION_VERTICAL:un,DIRECTION_ALL:GE,Manager:N_,Input:or,TouchAction:R_,TouchInput:oh,MouseInput:nh,PointerEventInput:w_,TouchMouseInput:P_,SingleTouchInput:JE,Recognizer:Ni,AttrRecognizer:Br,Tap:fh,Pan:uh,Swipe:F_,Pinch:I_,Rotate:O_,Press:B_,on:P,off:B,each:h,merge:m,extend:g,assign:p,inherit:_,bindFn:y,prefixed:z});var DN=typeof e<"u"?e:typeof self<"u"?self:{};DN.Hammer=Li,i==="function"&&define.amd?define(function(){return Li}):typeof ip<"u"&&ip.exports?ip.exports=Li:e[r]=Li})(window,document,"Hammer")});var BM=le(($Et,HA)=>{"use strict";HA.exports=kp;HA.exports.default=kp;function kp(e,t,r){r=r||2;var i=t&&t.length,s=i?t[0]*r:e.length,n=MM(e,0,s,r,!0),o=[];if(!n||n.next===n.prev)return o;var a,c,l,u,f,h,d;if(i&&(n=m9(e,t,n,r)),e.length>80*r){a=l=e[0],c=u=e[1];for(var p=r;p<s;p+=r)f=e[p],h=e[p+1],f<a&&(a=f),h<c&&(c=h),f>l&&(l=f),h>u&&(u=h);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return Ou(n,o,r,a,c,d,0),o}function MM(e,t,r,i,s){var n,o;if(s===zA(e,t,r,i)>0)for(n=t;n<r;n+=i)o=PM(n,e[n],e[n+1],o);else for(n=r-i;n>=t;n-=i)o=PM(n,e[n],e[n+1],o);return o&&Vp(o,o.next)&&(Nu(o),o=o.next),o}function oo(e,t){if(!e)return e;t||(t=e);var r=e,i;do if(i=!1,!r.steiner&&(Vp(r,r.next)||Ut(r.prev,r,r.next)===0)){if(Nu(r),r=t=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==t);return t}function Ou(e,t,r,i,s,n,o){if(e){!o&&n&&T9(e,i,s,n);for(var a=e,c,l;e.prev!==e.next;){if(c=e.prev,l=e.next,n?d9(e,i,s,n):h9(e)){t.push(c.i/r|0),t.push(e.i/r|0),t.push(l.i/r|0),Nu(e),e=l.next,a=l.next;continue}if(e=l,e===a){o?o===1?(e=p9(oo(e),t,r),Ou(e,t,r,i,s,n,2)):o===2&&g9(e,t,r,i,s,n):Ou(oo(e),t,r,i,s,n,1);break}}}}function h9(e){var t=e.prev,r=e,i=e.next;if(Ut(t,r,i)>=0)return!1;for(var s=t.x,n=r.x,o=i.x,a=t.y,c=r.y,l=i.y,u=s<n?s<o?s:o:n<o?n:o,f=a<c?a<l?a:l:c<l?c:l,h=s>n?s>o?s:o:n>o?n:o,d=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&wa(s,a,n,c,o,l,p.x,p.y)&&Ut(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function d9(e,t,r,i){var s=e.prev,n=e,o=e.next;if(Ut(s,n,o)>=0)return!1;for(var a=s.x,c=n.x,l=o.x,u=s.y,f=n.y,h=o.y,d=a<c?a<l?a:l:c<l?c:l,p=u<f?u<h?u:h:f<h?f:h,g=a>c?a>l?a:l:c>l?c:l,m=u>f?u>h?u:h:f>h?f:h,_=kA(d,p,t,r,i),y=kA(g,m,t,r,i),x=e.prevZ,E=e.nextZ;x&&x.z>=_&&E&&E.z<=y;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==s&&x!==o&&wa(a,u,c,f,l,h,x.x,x.y)&&Ut(x.prev,x,x.next)>=0||(x=x.prevZ,E.x>=d&&E.x<=g&&E.y>=p&&E.y<=m&&E!==s&&E!==o&&wa(a,u,c,f,l,h,E.x,E.y)&&Ut(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;x&&x.z>=_;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==s&&x!==o&&wa(a,u,c,f,l,h,x.x,x.y)&&Ut(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;E&&E.z<=y;){if(E.x>=d&&E.x<=g&&E.y>=p&&E.y<=m&&E!==s&&E!==o&&wa(a,u,c,f,l,h,E.x,E.y)&&Ut(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function p9(e,t,r){var i=e;do{var s=i.prev,n=i.next.next;!Vp(s,n)&&RM(s,i,i.next,n)&&Fu(s,n)&&Fu(n,s)&&(t.push(s.i/r|0),t.push(i.i/r|0),t.push(n.i/r|0),Nu(i),Nu(i.next),i=e=n),i=i.next}while(i!==e);return oo(i)}function g9(e,t,r,i,s,n){var o=e;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&S9(o,a)){var c=IM(o,a);o=oo(o,o.next),c=oo(c,c.next),Ou(o,t,r,i,s,n,0),Ou(c,t,r,i,s,n,0);return}a=a.next}o=o.next}while(o!==e)}function m9(e,t,r,i){var s=[],n,o,a,c,l;for(n=0,o=t.length;n<o;n++)a=t[n]*i,c=n<o-1?t[n+1]*i:e.length,l=MM(e,a,c,i,!1),l===l.next&&(l.steiner=!0),s.push(E9(l));for(s.sort(_9),n=0;n<s.length;n++)r=y9(s[n],r);return r}function _9(e,t){return e.x-t.x}function y9(e,t){var r=x9(e,t);if(!r)return t;var i=IM(r,e);return oo(i,i.next),oo(r,r.next)}function x9(e,t){var r=t,i=e.x,s=e.y,n=-1/0,o;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>n&&(n=a,o=r.x<r.next.x?r:r.next,a===i))return o}r=r.next}while(r!==t);if(!o)return null;var c=o,l=o.x,u=o.y,f=1/0,h;r=o;do i>=r.x&&r.x>=l&&i!==r.x&&wa(s<u?i:n,s,l,u,s<u?n:i,s,r.x,r.y)&&(h=Math.abs(s-r.y)/(i-r.x),Fu(r,e)&&(h<f||h===f&&(r.x>o.x||r.x===o.x&&A9(o,r)))&&(o=r,f=h)),r=r.next;while(r!==c);return o}function A9(e,t){return Ut(e.prev,e,t.prev)<0&&Ut(t.next,e,e.next)<0}function T9(e,t,r,i){var s=e;do s.z===0&&(s.z=kA(s.x,s.y,t,r,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,b9(s)}function b9(e){var t,r,i,s,n,o,a,c,l=1;do{for(r=e,e=null,n=null,o=0;r;){for(o++,i=r,a=0,t=0;t<l&&(a++,i=i.nextZ,!!i);t++);for(c=l;a>0||c>0&&i;)a!==0&&(c===0||!i||r.z<=i.z)?(s=r,r=r.nextZ,a--):(s=i,i=i.nextZ,c--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;r=i}n.nextZ=null,l*=2}while(o>1);return e}function kA(e,t,r,i,s){return e=(e-r)*s|0,t=(t-i)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function E9(e){var t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function wa(e,t,r,i,s,n,o,a){return(s-o)*(t-a)>=(e-o)*(n-a)&&(e-o)*(i-a)>=(r-o)*(t-a)&&(r-o)*(n-a)>=(s-o)*(i-a)}function S9(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!v9(e,t)&&(Fu(e,t)&&Fu(t,e)&&C9(e,t)&&(Ut(e.prev,e,t.prev)||Ut(e,t.prev,t))||Vp(e,t)&&Ut(e.prev,e,e.next)>0&&Ut(t.prev,t,t.next)>0)}function Ut(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Vp(e,t){return e.x===t.x&&e.y===t.y}function RM(e,t,r,i){var s=Up(Ut(e,t,r)),n=Up(Ut(e,t,i)),o=Up(Ut(r,i,e)),a=Up(Ut(r,i,t));return!!(s!==n&&o!==a||s===0&&Dp(e,r,t)||n===0&&Dp(e,i,t)||o===0&&Dp(r,e,i)||a===0&&Dp(r,t,i))}function Dp(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Up(e){return e>0?1:e<0?-1:0}function v9(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&RM(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function Fu(e,t){return Ut(e.prev,e,e.next)<0?Ut(e,t,e.next)>=0&&Ut(e,e.prev,t)>=0:Ut(e,t,e.prev)<0||Ut(e,e.next,t)<0}function C9(e,t){var r=e,i=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do r.y>n!=r.next.y>n&&r.next.y!==r.y&&s<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==e);return i}function IM(e,t){var r=new VA(e.i,e.x,e.y),i=new VA(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,r.next=s,s.prev=r,i.next=r,r.prev=i,n.next=i,i.prev=n,i}function PM(e,t,r,i){var s=new VA(e,t,r);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Nu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function VA(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}kp.deviation=function(e,t,r,i){var s=t&&t.length,n=s?t[0]*r:e.length,o=Math.abs(zA(e,0,n,r));if(s)for(var a=0,c=t.length;a<c;a++){var l=t[a]*r,u=a<c-1?t[a+1]*r:e.length;o-=Math.abs(zA(e,l,u,r))}var f=0;for(a=0;a<i.length;a+=3){var h=i[a]*r,d=i[a+1]*r,p=i[a+2]*r;f+=Math.abs((e[h]-e[p])*(e[d+1]-e[h+1])-(e[h]-e[d])*(e[p+1]-e[h+1]))}return o===0&&f===0?0:Math.abs((f-o)/o)};function zA(e,t,r,i){for(var s=0,n=t,o=r-i;n<r;n+=i)s+=(e[o]-e[n])*(e[n+1]+e[o+1]),o=n;return s}kp.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},i=0,s=0;s<e.length;s++){for(var n=0;n<e[s].length;n++)for(var o=0;o<t;o++)r.vertices.push(e[s][n][o]);s>0&&(i+=e[s-1].length,r.holes.push(i))}return r}});var sg=le(rs=>{"use strict";var _R=":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",tG=_R+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",yR="["+_R+"]["+tG+"]*",eG=new RegExp("^"+yR+"$"),rG=function(e,t){let r=[],i=t.exec(e);for(;i;){let s=[];s.startIndex=t.lastIndex-i[0].length;let n=i.length;for(let o=0;o<n;o++)s.push(i[o]);r.push(s),i=t.exec(e)}return r},iG=function(e){let t=eG.exec(e);return!(t===null||typeof t>"u")};rs.isExist=function(e){return typeof e<"u"};rs.isEmptyObject=function(e){return Object.keys(e).length===0};rs.merge=function(e,t,r){if(t){let i=Object.keys(t),s=i.length;for(let n=0;n<s;n++)r==="strict"?e[i[n]]=[t[i[n]]]:e[i[n]]=t[i[n]]}};rs.getValue=function(e){return rs.isExist(e)?e:""};rs.isName=iG;rs.getAllMatches=rG;rs.nameRegexp=yR});var qA=le(ER=>{"use strict";var YA=sg(),sG={allowBooleanAttributes:!1,unpairedTags:[]};ER.validate=function(e,t){t=Object.assign({},sG,t);let r=[],i=!1,s=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let n=0;n<e.length;n++)if(e[n]==="<"&&e[n+1]==="?"){if(n+=2,n=AR(e,n),n.err)return n}else if(e[n]==="<"){let o=n;if(n++,e[n]==="!"){n=TR(e,n);continue}else{let a=!1;e[n]==="/"&&(a=!0,n++);let c="";for(;n<e.length&&e[n]!==">"&&e[n]!==" "&&e[n]!==" "&&e[n]!==`
`&&e[n]!=="\r";n++)c+=e[n];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),n--),!hG(c)){let f;return c.trim().length===0?f="Invalid space after '<'.":f="Tag '"+c+"' is an invalid name.",re("InvalidTag",f,Xe(e,n))}let l=aG(e,n);if(l===!1)return re("InvalidAttr","Attributes for '"+c+"' have open quote.",Xe(e,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=bR(u,t);if(h===!0)i=!0;else return re(h.err.code,h.err.msg,Xe(e,f+h.err.line))}else if(a)if(l.tagClosed){if(u.trim().length>0)return re("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",Xe(e,o));{let f=r.pop();if(c!==f.tagName){let h=Xe(e,f.tagStartPos);return re("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+c+"'.",Xe(e,o))}r.length==0&&(s=!0)}}else return re("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",Xe(e,n));else{let f=bR(u,t);if(f!==!0)return re(f.err.code,f.err.msg,Xe(e,n-u.length+f.err.line));if(s===!0)return re("InvalidXml","Multiple possible root nodes found.",Xe(e,n));t.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:o}),i=!0}for(n++;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="!"){n++,n=TR(e,n);continue}else if(e[n+1]==="?"){if(n=AR(e,++n),n.err)return n}else break;else if(e[n]==="&"){let f=uG(e,n);if(f==-1)return re("InvalidChar","char '&' is not expected.",Xe(e,n));n=f}else if(s===!0&&!xR(e[n]))return re("InvalidXml","Extra text at the end",Xe(e,n));e[n]==="<"&&n--}}else{if(xR(e[n]))continue;return re("InvalidChar","char '"+e[n]+"' is not expected.",Xe(e,n))}if(i){if(r.length==1)return re("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Xe(e,r[0].tagStartPos));if(r.length>0)return re("InvalidXml","Invalid '"+JSON.stringify(r.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return re("InvalidXml","Start tag expected.",1);return!0};function xR(e){return e===" "||e===" "||e===`
`||e==="\r"}function AR(e,t){let r=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let i=e.substr(r,t-r);if(t>5&&i==="xml")return re("InvalidXml","XML declaration allowed only at the start of the document.",Xe(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function TR(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let r=1;for(t+=8;t<e.length;t++)if(e[t]==="<")r++;else if(e[t]===">"&&(r--,r===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var nG='"',oG="'";function aG(e,t){let r="",i="",s=!1;for(;t<e.length;t++){if(e[t]===nG||e[t]===oG)i===""?i=e[t]:i!==e[t]||(i="");else if(e[t]===">"&&i===""){s=!0;break}r+=e[t]}return i!==""?!1:{value:r,index:t,tagClosed:s}}var cG=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function bR(e,t){let r=YA.getAllMatches(e,cG),i={};for(let s=0;s<r.length;s++){if(r[s][1].length===0)return re("InvalidAttr","Attribute '"+r[s][2]+"' has no space in starting.",Hu(r[s]));if(r[s][3]!==void 0&&r[s][4]===void 0)return re("InvalidAttr","Attribute '"+r[s][2]+"' is without value.",Hu(r[s]));if(r[s][3]===void 0&&!t.allowBooleanAttributes)return re("InvalidAttr","boolean attribute '"+r[s][2]+"' is not allowed.",Hu(r[s]));let n=r[s][2];if(!fG(n))return re("InvalidAttr","Attribute '"+n+"' is an invalid name.",Hu(r[s]));if(!i.hasOwnProperty(n))i[n]=1;else return re("InvalidAttr","Attribute '"+n+"' is repeated.",Hu(r[s]))}return!0}function lG(e,t){let r=/\d/;for(e[t]==="x"&&(t++,r=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(r))break}return-1}function uG(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,lG(e,t);let r=0;for(;t<e.length;t++,r++)if(!(e[t].match(/\w/)&&r<20)){if(e[t]===";")break;return-1}return t}function re(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function fG(e){return YA.isName(e)}function hG(e){return YA.isName(e)}function Xe(e,t){let r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function Hu(e){return e.startIndex+e[1].length}});var vR=le(KA=>{var SR={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(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e}},dG=function(e){return Object.assign({},SR,e)};KA.buildOptions=dG;KA.defaultOptions=SR});var wR=le((BSt,CR)=>{"use strict";var $A=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,r){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:r})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,[":@"]:t[":@"]}):this.child.push({[t.tagname]:t.child})}};CR.exports=$A});var MR=le((OSt,PR)=>{var pG=sg();function gG(e,t){let r={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let i=1,s=!1,n=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!n){if(s&&yG(e,t))t+=7,[entityName,val,t]=mG(e,t+1),val.indexOf("&")===-1&&(r[bG(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(s&&xG(e,t))t+=8;else if(s&&AG(e,t))t+=8;else if(s&&TG(e,t))t+=9;else if(_G)n=!0;else throw new Error("Invalid DOCTYPE");i++,o=""}else if(e[t]===">"){if(n?e[t-1]==="-"&&e[t-2]==="-"&&(n=!1,i--):i--,i===0)break}else e[t]==="["?s=!0:o+=e[t];if(i!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:r,i:t}}function mG(e,t){let r="";for(;t<e.length&&e[t]!=="'"&&e[t]!=='"';t++)r+=e[t];if(r=r.trim(),r.indexOf(" ")!==-1)throw new Error("External entites are not supported");let i=e[t++],s="";for(;t<e.length&&e[t]!==i;t++)s+=e[t];return[r,s,t]}function _G(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function yG(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="N"&&e[t+4]==="T"&&e[t+5]==="I"&&e[t+6]==="T"&&e[t+7]==="Y"}function xG(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="L"&&e[t+4]==="E"&&e[t+5]==="M"&&e[t+6]==="E"&&e[t+7]==="N"&&e[t+8]==="T"}function AG(e,t){return e[t+1]==="!"&&e[t+2]==="A"&&e[t+3]==="T"&&e[t+4]==="T"&&e[t+5]==="L"&&e[t+6]==="I"&&e[t+7]==="S"&&e[t+8]==="T"}function TG(e,t){return e[t+1]==="!"&&e[t+2]==="N"&&e[t+3]==="O"&&e[t+4]==="T"&&e[t+5]==="A"&&e[t+6]==="T"&&e[t+7]==="I"&&e[t+8]==="O"&&e[t+9]==="N"}function bG(e){if(pG.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}PR.exports=gG});var IR=le((FSt,RR)=>{var EG=/^[-+]?0x[a-fA-F0-9]+$/,SG=/^([\-\+])?(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 vG={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function CG(e,t={}){if(t=Object.assign({},vG,t),!e||typeof e!="string")return e;let r=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(r))return e;if(t.hex&&EG.test(r))return Number.parseInt(r,16);{let i=SG.exec(r);if(i){let s=i[1],n=i[2],o=wG(i[3]),a=i[4]||i[6];if(!t.leadingZeros&&n.length>0&&s&&r[2]!==".")return e;if(!t.leadingZeros&&n.length>0&&!s&&r[1]!==".")return e;{let c=Number(r),l=""+c;return l.search(/[eE]/)!==-1||a?t.eNotation?c:e:r.indexOf(".")!==-1?l==="0"&&o===""||l===o||s&&l==="-"+o?c:e:n?o===l||s+o===l?c:e:r===l||r===s+l?c:e}}else return e}}function wG(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substr(0,e.length-1))),e}RR.exports=CG});var FR=le((NSt,OR)=>{"use strict";var BR=sg(),Gu=wR(),PG=MR(),MG=IR(),JA=class{constructor(t){this.options=t,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,i)=>String.fromCharCode(Number.parseInt(i,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(r,i)=>String.fromCharCode(Number.parseInt(i,16))}},this.addExternalEntities=RG,this.parseXml=NG,this.parseTextData=IG,this.resolveNameSpace=BG,this.buildAttributesMap=FG,this.isItStopNode=kG,this.replaceEntitiesValue=DG,this.readStopNodeData=zG,this.saveTextToParentTag=UG,this.addChild=LG}};function RG(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let i=t[r];this.lastEntities[i]={regex:new RegExp("&"+i+";","g"),val:e[i]}}}function IG(e,t,r,i,s,n,o){if(e!==void 0&&(this.options.trimValues&&!i&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e));let a=this.options.tagValueProcessor(t,e,r,s,n);return a==null?e:typeof a!=typeof e||a!==e?a:this.options.trimValues?QA(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?QA(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function BG(e){if(this.options.removeNSPrefix){let t=e.split(":"),r=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=r+t[1])}return e}var OG=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function FG(e,t,r){if(!this.options.ignoreAttributes&&typeof e=="string"){let i=BR.getAllMatches(e,OG),s=i.length,n={};for(let o=0;o<s;o++){let a=this.resolveNameSpace(i[o][1]),c=i[o][4],l=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),c!==void 0){this.options.trimValues&&(c=c.trim()),c=this.replaceEntitiesValue(c);let u=this.options.attributeValueProcessor(a,c,t);u==null?n[l]=c:typeof u!=typeof c||u!==c?n[l]=u:n[l]=QA(c,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[l]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){let o={};return o[this.options.attributesGroupName]=n,o}return n}}var NG=function(e){e=e.replace(/\r\n?/g,`
`);let t=new Gu("!xml"),r=t,i="",s="";for(let n=0;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="/"){let a=fo(e,">",n,"Closing Tag is not closed."),c=e.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&&(i=this.saveTextToParentTag(i,r,s));let l=s.substring(s.lastIndexOf(".")+1);if(c&&this.options.unpairedTags.indexOf(c)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${c}>`);let u=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(u=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=s.lastIndexOf("."),s=s.substring(0,u),r=this.tagsNodeStack.pop(),i="",n=a}else if(e[n+1]==="?"){let a=ZA(e,n,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,s),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){let c=new Gu(a.tagName);c.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(c[":@"]=this.buildAttributesMap(a.tagExp,s,a.tagName)),this.addChild(r,c,s)}n=a.closeIndex+1}else if(e.substr(n+1,3)==="!--"){let a=fo(e,"-->",n+4,"Comment is not closed.");if(this.options.commentPropName){let c=e.substring(n+4,a-2);i=this.saveTextToParentTag(i,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:c}])}n=a}else if(e.substr(n+1,2)==="!D"){let a=PG(e,n);this.docTypeEntities=a.entities,n=a.i}else if(e.substr(n+1,2)==="!["){let a=fo(e,"]]>",n,"CDATA is not closed.")-2,c=e.substring(n+9,a);i=this.saveTextToParentTag(i,r,s);let l=this.parseTextData(c,r.tagname,s,!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=ZA(e,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&&i&&r.tagname!=="!xml"&&(i=this.saveTextToParentTag(i,r,s,!1));let d=r;if(d&&this.options.unpairedTags.indexOf(d.tagname)!==-1&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),c!==t.tagname&&(s+=s?"."+c:c),this.isItStopNode(this.options.stopNodes,s,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(e,l,h+1);if(!m)throw new Error(`Unexpected end of ${l}`);n=m.i,p=m.tagContent}let g=new Gu(c);c!==u&&f&&(g[":@"]=this.buildAttributesMap(u,s,c)),p&&(p=this.parseTextData(p,c,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),g.add(this.options.textNodeName,p),this.addChild(r,g,s)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){c[c.length-1]==="/"?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),u=c):u=u.substr(0,u.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));let p=new Gu(c);c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,s,c)),this.addChild(r,p,s),s=s.substr(0,s.lastIndexOf("."))}else{let p=new Gu(c);this.tagsNodeStack.push(r),c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,s,c)),this.addChild(r,p,s),r=p}i="",n=h}}else i+=e[n];return t.child};function LG(e,t,r){let i=this.options.updateTag(t.tagname,r,t[":@"]);i===!1||(typeof i=="string"&&(t.tagname=i),e.addChild(t))}var DG=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let r=this.docTypeEntities[t];e=e.replace(r.regx,r.val)}for(let t in this.lastEntities){let r=this.lastEntities[t];e=e.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let r=this.htmlEntities[t];e=e.replace(r.regex,r.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function UG(e,t,r,i){return e&&(i===void 0&&(i=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,r,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,i),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function kG(e,t,r){let i="*."+r;for(let s in e){let n=e[s];if(i===n||t===n)return!0}return!1}function VG(e,t,r=">"){let i,s="";for(let n=t;n<e.length;n++){let o=e[n];if(i)o===i&&(i="");else if(o==='"'||o==="'")i=o;else if(o===r[0])if(r[1]){if(e[n+1]===r[1])return{data:s,index:n}}else return{data:s,index:n};else o===" "&&(o=" ");s+=o}}function fo(e,t,r,i){let s=e.indexOf(t,r);if(s===-1)throw new Error(i);return s+t.length-1}function ZA(e,t,r,i=">"){let s=VG(e,t+1,i);if(!s)return;let n=s.data,o=s.index,a=n.search(/\s/),c=n,l=!0;a!==-1&&(c=n.substring(0,a),n=n.substring(a+1).trimStart());let u=c;if(r){let f=c.indexOf(":");f!==-1&&(c=c.substr(f+1),l=c!==s.data.substr(f+1))}return{tagName:c,tagExp:n,closeIndex:o,attrExpPresent:l,rawTagName:u}}function zG(e,t,r){let i=r,s=1;for(;r<e.length;r++)if(e[r]==="<")if(e[r+1]==="/"){let n=fo(e,">",r,`${t} is not closed`);if(e.substring(r+2,n).trim()===t&&(s--,s===0))return{tagContent:e.substring(i,r),i:n};r=n}else if(e[r+1]==="?")r=fo(e,"?>",r+1,"StopNode is not closed.");else if(e.substr(r+1,3)==="!--")r=fo(e,"-->",r+3,"StopNode is not closed.");else if(e.substr(r+1,2)==="![")r=fo(e,"]]>",r,"StopNode is not closed.")-2;else{let n=ZA(e,r,">");n&&((n&&n.tagName)===t&&n.tagExp[n.tagExp.length-1]!=="/"&&s++,r=n.closeIndex)}}function QA(e,t,r){if(t&&typeof e=="string"){let i=e.trim();return i==="true"?!0:i==="false"?!1:MG(e,r)}else return BR.isExist(e)?e:""}OR.exports=JA});var DR=le(LR=>{"use strict";function HG(e,t){return NR(e,t)}function NR(e,t,r){let i,s={};for(let n=0;n<e.length;n++){let o=e[n],a=GG(o),c="";if(r===void 0?c=a:c=r+"."+a,a===t.textNodeName)i===void 0?i=o[a]:i+=""+o[a];else{if(a===void 0)continue;if(o[a]){let l=NR(o[a],t,c),u=jG(l,t);o[":@"]?WG(l,o[":@"],c,t):Object.keys(l).length===1&&l[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?l=l[t.textNodeName]:Object.keys(l).length===0&&(t.alwaysCreateTextNode?l[t.textNodeName]="":l=""),s[a]!==void 0&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(l)):t.isArray(a,c,u)?s[a]=[l]:s[a]=l}}}return typeof i=="string"?i.length>0&&(s[t.textNodeName]=i):i!==void 0&&(s[t.textNodeName]=i),s}function GG(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let i=t[r];if(i!==":@")return i}}function WG(e,t,r,i){if(t){let s=Object.keys(t),n=s.length;for(let o=0;o<n;o++){let a=s[o];i.isArray(a,r+"."+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function jG(e,t){let{textNodeName:r}=t,i=Object.keys(e).length;return!!(i===0||i===1&&(e[r]||typeof e[r]=="boolean"||e[r]===0))}LR.prettify=HG});var kR=le((DSt,UR)=>{var{buildOptions:XG}=vR(),YG=FR(),{prettify:qG}=DR(),KG=qA(),tT=class{constructor(t){this.externalEntities={},this.options=XG(t)}parse(t,r){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let n=KG.validate(t,r);if(n!==!0)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let i=new YG(this.options);i.addExternalEntities(this.externalEntities);let s=i.parseXml(t);return this.options.preserveOrder||s===void 0?s:qG(s,this.options)}addEntity(t,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.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[t]=r}};UR.exports=tT});var WR=le((USt,GR)=>{var $G=`
`;function JG(e,t){let r="";return t.format&&t.indentBy.length>0&&(r=$G),zR(e,t,"",r)}function zR(e,t,r,i){let s="",n=!1;for(let o=0;o<e.length;o++){let a=e[o],c=ZG(a);if(c===void 0)continue;let l="";if(r.length===0?l=c:l=`${r}.${c}`,c===t.textNodeName){let p=a[c];QG(l,t)||(p=t.tagValueProcessor(c,p),p=HR(p,t)),n&&(s+=i),s+=p,n=!1;continue}else if(c===t.cdataPropName){n&&(s+=i),s+=`<![CDATA[${a[c][0][t.textNodeName]}]]>`,n=!1;continue}else if(c===t.commentPropName){s+=i+`<!--${a[c][0][t.textNodeName]}-->`,n=!0;continue}else if(c[0]==="?"){let p=VR(a[":@"],t),g=c==="?xml"?"":i,m=a[c][0][t.textNodeName];m=m.length!==0?" "+m:"",s+=g+`<${c}${m}${p}?>`,n=!0;continue}let u=i;u!==""&&(u+=t.indentBy);let f=VR(a[":@"],t),h=i+`<${c}${f}`,d=zR(a[c],t,l,u);t.unpairedTags.indexOf(c)!==-1?t.suppressUnpairedNode?s+=h+">":s+=h+"/>":(!d||d.length===0)&&t.suppressEmptyNode?s+=h+"/>":d&&d.endsWith(">")?s+=h+`>${d}${i}</${c}>`:(s+=h+">",d&&i!==""&&(d.includes("/>")||d.includes("</"))?s+=i+t.indentBy+d+i:s+=d,s+=`</${c}>`),n=!0}return s}function ZG(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let i=t[r];if(e.hasOwnProperty(i)&&i!==":@")return i}}function VR(e,t){let r="";if(e&&!t.ignoreAttributes)for(let i in e){if(!e.hasOwnProperty(i))continue;let s=t.attributeValueProcessor(i,e[i]);s=HR(s,t),s===!0&&t.suppressBooleanAttributes?r+=` ${i.substr(t.attributeNamePrefix.length)}`:r+=` ${i.substr(t.attributeNamePrefix.length)}="${s}"`}return r}function QG(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let r=e.substr(e.lastIndexOf(".")+1);for(let i in t.stopNodes)if(t.stopNodes[i]===e||t.stopNodes[i]==="*."+r)return!0;return!1}function HR(e,t){if(e&&e.length>0&&t.processEntities)for(let r=0;r<t.entities.length;r++){let i=t.entities[r];e=e.replace(i.regex,i.val)}return e}GR.exports=JG});var XR=le((kSt,jR)=>{"use strict";var tW=WR(),eW={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},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 Ks(e){this.options=Object.assign({},eW,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=sW),this.processTextOrObjNode=rW,this.options.format?(this.indentate=iW,this.tagEndChar=`>
`,this.newLine=`
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}Ks.prototype.build=function(e){return this.options.preserveOrder?tW(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};Ks.prototype.j2x=function(e,t){let r="",i="";for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s))if(typeof e[s]>"u")this.isAttribute(s)&&(i+="");else if(e[s]===null)this.isAttribute(s)?i+="":s[0]==="?"?i+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:i+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(e[s]instanceof Date)i+=this.buildTextValNode(e[s],s,"",t);else if(typeof e[s]!="object"){let n=this.isAttribute(s);if(n)r+=this.buildAttrPairStr(n,""+e[s]);else if(s===this.options.textNodeName){let o=this.options.tagValueProcessor(s,""+e[s]);i+=this.replaceEntitiesValue(o)}else i+=this.buildTextValNode(e[s],s,"",t)}else if(Array.isArray(e[s])){let n=e[s].length,o="";for(let a=0;a<n;a++){let c=e[s][a];typeof c>"u"||(c===null?s[0]==="?"?i+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:i+=this.indentate(t)+"<"+s+"/"+this.tagEndChar:typeof c=="object"?this.options.oneListGroup?o+=this.j2x(c,t+1).val:o+=this.processTextOrObjNode(c,s,t):o+=this.buildTextValNode(c,s,"",t))}this.options.oneListGroup&&(o=this.buildObjectNode(o,s,"",t)),i+=o}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName){let n=Object.keys(e[s]),o=n.length;for(let a=0;a<o;a++)r+=this.buildAttrPairStr(n[a],""+e[s][n[a]])}else i+=this.processTextOrObjNode(e[s],s,t);return{attrStr:r,val:i}};Ks.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t==="true"?" "+e:" "+e+'="'+t+'"'};function rW(e,t,r){let i=this.j2x(e,r+1);return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,i.attrStr,r):this.buildObjectNode(i.val,t,i.attrStr,r)}Ks.prototype.buildObjectNode=function(e,t,r,i){if(e==="")return t[0]==="?"?this.indentate(i)+"<"+t+r+"?"+this.tagEndChar:this.indentate(i)+"<"+t+r+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,n="";return t[0]==="?"&&(n="?",s=""),(r||r==="")&&e.indexOf("<")===-1?this.indentate(i)+"<"+t+r+n+">"+e+s:this.options.commentPropName!==!1&&t===this.options.commentPropName&&n.length===0?this.indentate(i)+`<!--${e}-->`+this.newLine:this.indentate(i)+"<"+t+r+n+this.tagEndChar+e+this.indentate(i)+s}};Ks.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};Ks.prototype.buildTextValNode=function(e,t,r,i){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(i)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(i)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(i)+"<"+t+r+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(t,e);return s=this.replaceEntitiesValue(s),s===""?this.indentate(i)+"<"+t+r+this.closeTag(t)+this.tagEndChar:this.indentate(i)+"<"+t+r+">"+s+"</"+t+this.tagEndChar}};Ks.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let r=this.options.entities[t];e=e.replace(r.regex,r.val)}return e};function iW(e){return this.options.indentBy.repeat(e)}function sW(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}jR.exports=Ks});var qR=le((VSt,YR)=>{"use strict";var nW=qA(),oW=kR(),aW=XR();YR.exports={XMLParser:oW,XMLValidator:nW,XMLBuilder:aW}});var uT=le((nI,qu)=>{(function(e,t){typeof define=="function"&&define.amd?define([],t):typeof c1=="function"&&typeof qu=="object"&&qu&&qu.exports?qu.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(nI,function(){"use strict";function e(v,T,L){this.low=v|0,this.high=T|0,this.unsigned=!!L}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function t(v){return(v&&v.__isLong__)===!0}e.isLong=t;var r={},i={};function s(v,T){var L,V,z;return T?(v>>>=0,(z=0<=v&&v<256)&&(V=i[v],V)?V:(L=o(v,(v|0)<0?-1:0,!0),z&&(i[v]=L),L)):(v|=0,(z=-128<=v&&v<128)&&(V=r[v],V)?V:(L=o(v,v<0?-1:0,!1),z&&(r[v]=L),L))}e.fromInt=s;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 F;if(v+1>=p)return P}return v<0?n(-v,T).neg():o(v%h|0,v/h|0,T)}e.fromNumber=n;function o(v,T,L){return new e(v,T,L)}e.fromBits=o;var a=Math.pow;function c(v,T,L){if(v.length===0)throw Error("empty string");if(v==="NaN"||v==="Infinity"||v==="+Infinity"||v==="-Infinity")return m;if(typeof T=="number"?(L=T,T=!1):T=!!T,L=L||10,L<2||36<L)throw RangeError("radix");var V;if((V=v.indexOf("-"))>0)throw Error("interior hyphen");if(V===0)return c(v.substring(1),T,L).neg();for(var z=n(a(L,8)),W=m,Z=0;Z<v.length;Z+=8){var ut=Math.min(8,v.length-Z),st=parseInt(v.substring(Z,Z+ut),L);if(ut<8){var Rt=n(a(L,ut));W=W.mul(Rt).add(n(st))}else W=W.mul(z),W=W.add(n(st))}return W.unsigned=T,W}e.fromString=c;function l(v){return v instanceof e?v:typeof v=="number"?n(v):typeof v=="string"?c(v):o(v.low,v.high,v.unsigned)}e.fromValue=l;var u=1<<16,f=1<<24,h=u*u,d=h*h,p=d/2,g=s(f),m=s(0);e.ZERO=m;var _=s(0,!0);e.UZERO=_;var y=s(1);e.ONE=y;var x=s(1,!0);e.UONE=x;var E=s(-1);e.NEG_ONE=E;var P=o(-1,2147483647,!1);e.MAX_VALUE=P;var B=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=B;var F=o(0,-2147483648,!1);e.MIN_VALUE=F;var M=e.prototype;return M.toInt=function(){return this.unsigned?this.low>>>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<T)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(F)){var L=n(T),V=this.div(L),z=V.mul(L).sub(this);return V.toString(T)+z.toInt().toString(T)}else return"-"+this.neg().toString(T);for(var W=n(a(T,6),this.unsigned),Z=this,ut="";;){var st=Z.div(W),Rt=Z.sub(st.mul(W)).toInt()>>>0,gt=Rt.toString(T);if(Z=st,Z.isZero())return gt+ut;for(;gt.length<6;)gt="0"+gt;ut=""+gt+ut}},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(F)?64:this.neg().getNumBitsAbs();for(var T=this.high!=0?this.high:this.low,L=31;L>0&&!(T&1<<L);L--);return this.high!=0?L+33:L+1},M.isZero=function(){return this.high===0&&this.low===0},M.isNegative=function(){return!this.unsigned&&this.high<0},M.isPositive=function(){return this.unsigned||this.high>=0},M.isOdd=function(){return(this.low&1)===1},M.isEven=function(){return(this.low&1)===0},M.equals=function(T){return t(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(t(T)||(T=l(T)),this.eq(T))return 0;var L=this.isNegative(),V=T.isNegative();return L&&!V?-1:!L&&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(F)?F:this.not().add(y)},M.neg=M.negate,M.add=function(T){t(T)||(T=l(T));var L=this.high>>>16,V=this.high&65535,z=this.low>>>16,W=this.low&65535,Z=T.high>>>16,ut=T.high&65535,st=T.low>>>16,Rt=T.low&65535,gt=0,bt=0,Et=0,Te=0;return Te+=W+Rt,Et+=Te>>>16,Te&=65535,Et+=z+st,bt+=Et>>>16,Et&=65535,bt+=V+ut,gt+=bt>>>16,bt&=65535,gt+=L+Z,gt&=65535,o(Et<<16|Te,gt<<16|bt,this.unsigned)},M.subtract=function(T){return t(T)||(T=l(T)),this.add(T.neg())},M.sub=M.subtract,M.multiply=function(T){if(this.isZero()||(t(T)||(T=l(T)),T.isZero()))return m;if(this.eq(F))return T.isOdd()?F:m;if(T.eq(F))return this.isOdd()?F: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 L=this.high>>>16,V=this.high&65535,z=this.low>>>16,W=this.low&65535,Z=T.high>>>16,ut=T.high&65535,st=T.low>>>16,Rt=T.low&65535,gt=0,bt=0,Et=0,Te=0;return Te+=W*Rt,Et+=Te>>>16,Te&=65535,Et+=z*Rt,bt+=Et>>>16,Et&=65535,Et+=W*st,bt+=Et>>>16,Et&=65535,bt+=V*Rt,gt+=bt>>>16,bt&=65535,bt+=z*st,gt+=bt>>>16,bt&=65535,bt+=W*ut,gt+=bt>>>16,bt&=65535,gt+=L*Rt+V*st+z*ut+W*Z,gt&=65535,o(Et<<16|Te,gt<<16|bt,this.unsigned)},M.mul=M.multiply,M.divide=function(T){if(t(T)||(T=l(T)),T.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?_:m;var L,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(F)){if(T.eq(y)||T.eq(E))return F;if(T.eq(F))return y;var W=this.shr(1);return L=W.div(T).shl(1),L.eq(m)?T.isNegative()?y:E:(V=this.sub(T.mul(L)),z=L.add(V.div(T)),z)}else if(T.eq(F))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);){L=Math.max(1,Math.floor(V.toNumber()/T.toNumber()));for(var Z=Math.ceil(Math.log(L)/Math.LN2),ut=Z<=48?1:a(2,Z-48),st=n(L),Rt=st.mul(T);Rt.isNegative()||Rt.gt(V);)L-=ut,st=n(L,this.unsigned),Rt=st.mul(T);st.isZero()&&(st=y),z=z.add(st),V=V.sub(Rt)}return z},M.div=M.divide,M.modulo=function(T){return t(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 t(T)||(T=l(T)),o(this.low&T.low,this.high&T.high,this.unsigned)},M.or=function(T){return t(T)||(T=l(T)),o(this.low|T.low,this.high|T.high,this.unsigned)},M.xor=function(T){return t(T)||(T=l(T)),o(this.low^T.low,this.high^T.high,this.unsigned)},M.shiftLeft=function(T){return t(T)&&(T=T.toInt()),(T&=63)===0?this:T<32?o(this.low<<T,this.high<<T|this.low>>>32-T,this.unsigned):o(0,this.low<<T-32,this.unsigned)},M.shl=M.shiftLeft,M.shiftRight=function(T){return t(T)&&(T=T.toInt()),(T&=63)===0?this:T<32?o(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(t(T)&&(T=T.toInt()),T&=63,T===0)return this;var L=this.high;if(T<32){var V=this.low;return o(V>>>T|L<<32-T,L>>>T,this.unsigned)}else return T===32?o(L,0,this.unsigned):o(L>>>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]},e})});var ef=le((Hwt,FI)=>{FI.exports=globalThis.h3||{}});var WB=le(Zb=>{Zb.read=function(e,t,r,i,s){var n,o,a=s*8-i-1,c=(1<<a)-1,l=c>>1,u=-7,f=r?s-1:0,h=r?-1:1,d=e[t+f];for(f+=h,n=d&(1<<-u)-1,d>>=-u,u+=a;u>0;n=n*256+e[t+f],f+=h,u-=8);for(o=n&(1<<-u)-1,n>>=-u,u+=i;u>0;o=o*256+e[t+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,i),n=n-l}return(d?-1:1)*o*Math.pow(2,n-i)};Zb.write=function(e,t,r,i,s,n){var o,a,c,l=n*8-s-1,u=(1<<l)-1,f=u>>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:n-1,p=i?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?t+=h/c:t+=h*Math.pow(2,1-f),t*c>=2&&(o++,c/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(t*c-1)*Math.pow(2,s),o=o+f):(a=t*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;e[r+d]=a&255,d+=p,a/=256,s-=8);for(o=o<<s|a,l+=s;l>0;e[r+d]=o&255,d+=p,o/=256,l-=8);e[r+d-p]|=g*128}});var $B=le((xLt,KB)=>{"use strict";KB.exports=yt;var Vm=WB();function yt(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}yt.Varint=0;yt.Fixed64=1;yt.Bytes=2;yt.Fixed32=5;var Qb=(1<<16)*(1<<16),jB=1/Qb,_$=12,qB=typeof TextDecoder>"u"?null:new TextDecoder("utf8");yt.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),s=i>>3,n=this.pos;this.type=i&7,e(s,t,this),this.pos===n&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=zm(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=YB(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=zm(this.buf,this.pos)+zm(this.buf,this.pos+4)*Qb;return this.pos+=8,e},readSFixed64:function(){var e=zm(this.buf,this.pos)+YB(this.buf,this.pos+4)*Qb;return this.pos+=8,e},readFloat:function(){var e=Vm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Vm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,r,i;return i=t[this.pos++],r=i&127,i<128||(i=t[this.pos++],r|=(i&127)<<7,i<128)||(i=t[this.pos++],r|=(i&127)<<14,i<128)||(i=t[this.pos++],r|=(i&127)<<21,i<128)?r:(i=t[this.pos],r|=(i&15)<<28,y$(r,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=_$&&qB?B$(this.buf,t,e):I$(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==yt.Bytes)return e.push(this.readVarint(t));var r=hs(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==yt.Bytes)return e.push(this.readSVarint());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==yt.Bytes)return e.push(this.readBoolean());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==yt.Bytes)return e.push(this.readFloat());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==yt.Bytes)return e.push(this.readDouble());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==yt.Bytes)return e.push(this.readFixed32());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==yt.Bytes)return e.push(this.readSFixed32());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==yt.Bytes)return e.push(this.readFixed64());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==yt.Bytes)return e.push(this.readSFixed64());var t=hs(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===yt.Varint)for(;this.buf[this.pos++]>127;);else if(t===yt.Bytes)this.pos=this.readVarint()+this.pos;else if(t===yt.Fixed32)this.pos+=4;else if(t===yt.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var r=new Uint8Array(t);r.set(this.buf),this.buf=r,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),rc(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),rc(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),rc(this.buf,e&-1,this.pos),rc(this.buf,Math.floor(e*jB),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),rc(this.buf,e&-1,this.pos),rc(this.buf,Math.floor(e*jB),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){x$(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=O$(this.buf,e,this.pos);var r=this.pos-t;r>=128&&XB(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),Vm.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Vm.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var r=0;r<t;r++)this.buf[this.pos++]=e[r]},writeRawMessage:function(e,t){this.pos++;var r=this.pos;e(t,this);var i=this.pos-r;i>=128&&XB(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,r){this.writeTag(e,yt.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,b$,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,E$,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,C$,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,S$,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,v$,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,w$,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,P$,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,M$,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,R$,t)},writeBytesField:function(e,t){this.writeTag(e,yt.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,yt.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,yt.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,yt.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,yt.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,yt.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,yt.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,yt.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,yt.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,yt.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function y$(e,t,r){var i=r.buf,s,n;if(n=i[r.pos++],s=(n&112)>>4,n<128||(n=i[r.pos++],s|=(n&127)<<3,n<128)||(n=i[r.pos++],s|=(n&127)<<10,n<128)||(n=i[r.pos++],s|=(n&127)<<17,n<128)||(n=i[r.pos++],s|=(n&127)<<24,n<128)||(n=i[r.pos++],s|=(n&1)<<31,n<128))return ec(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function hs(e){return e.type===yt.Bytes?e.readVarint()+e.pos:e.pos+1}function ec(e,t,r){return r?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function x$(e,t){var r,i;if(e>=0?(r=e%4294967296|0,i=e/4294967296|0):(r=~(-e%4294967296),i=~(-e/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),A$(r,i,t),T$(i,t)}function A$(e,t,r){r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos]=e&127}function T$(e,t){var r=(e&7)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function XB(e,t,r){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));r.realloc(i);for(var s=r.pos-1;s>=e;s--)r.buf[s+i]=r.buf[s]}function b$(e,t){for(var r=0;r<e.length;r++)t.writeVarint(e[r])}function E$(e,t){for(var r=0;r<e.length;r++)t.writeSVarint(e[r])}function S$(e,t){for(var r=0;r<e.length;r++)t.writeFloat(e[r])}function v$(e,t){for(var r=0;r<e.length;r++)t.writeDouble(e[r])}function C$(e,t){for(var r=0;r<e.length;r++)t.writeBoolean(e[r])}function w$(e,t){for(var r=0;r<e.length;r++)t.writeFixed32(e[r])}function P$(e,t){for(var r=0;r<e.length;r++)t.writeSFixed32(e[r])}function M$(e,t){for(var r=0;r<e.length;r++)t.writeFixed64(e[r])}function R$(e,t){for(var r=0;r<e.length;r++)t.writeSFixed64(e[r])}function zm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function rc(e,t,r){e[r]=t,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function YB(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function I$(e,t,r){for(var i="",s=t;s<r;){var n=e[s],o=null,a=n>239?4:n>223?3:n>191?2:1;if(s+a>r)break;var c,l,u;a===1?n<128&&(o=n):a===2?(c=e[s+1],(c&192)===128&&(o=(n&31)<<6|c&63,o<=127&&(o=null))):a===3?(c=e[s+1],l=e[s+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=e[s+1],l=e[s+2],u=e[s+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,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),s+=a}return i}function B$(e,t,r){return qB.decode(e.subarray(t,r))}function O$(e,t,r){for(var i=0,s,n;i<t.length;i++){if(s=t.charCodeAt(i),s>55295&&s<57344)if(n)if(s<56320){e[r++]=239,e[r++]=191,e[r++]=189,n=s;continue}else s=n-55296<<10|s-56320|65536,n=null;else{s>56319||i+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):n=s;continue}else n&&(e[r++]=239,e[r++]=191,e[r++]=189,n=null);s<128?e[r++]=s:(s<2048?e[r++]=s>>6|192:(s<65536?e[r++]=s>>12|224:(e[r++]=s>>18|240,e[r++]=s>>12&63|128),e[r++]=s>>6&63|128),e[r++]=s&63|128)}return r}});var tQ={};$t(tQ,{AGGREGATION_OPERATION:()=>Mt,AmbientLight:()=>ca,ArcLayer:()=>Zn,Attribute:()=>Ji,AttributeManager:()=>qr,BitmapLayer:()=>Qn,BrushingExtension:()=>bf,COORDINATE_SYSTEM:()=>X,CPUGridLayer:()=>on,ClipExtension:()=>Mo,CollisionFilterExtension:()=>Mf,ColumnLayer:()=>$r,CompassWidget:()=>E_,CompositeLayer:()=>It,ContourLayer:()=>jf,Controller:()=>Ne,DarkGlassTheme:()=>QZ,DarkTheme:()=>JZ,DataFilterExtension:()=>Ef,Deck:()=>We,DeckGL:()=>Vf,DeckRenderer:()=>Dn,DirectionalLight:()=>Gi,FillStyleExtension:()=>Cf,FirstPersonController:()=>qn,FirstPersonView:()=>gu,FirstPersonViewport:()=>Xn,FlyToInterpolator:()=>Qi,Fp64Extension:()=>Sf,FullscreenWidget:()=>b_,GPUGridLayer:()=>an,GeoJsonLayer:()=>Ci,GeohashLayer:()=>kf,GoogleMapsOverlay:()=>$f,GreatCircleLayer:()=>Yu,GridCellLayer:()=>no,GridLayer:()=>Yf,H3ClusterLayer:()=>sf,H3HexagonLayer:()=>ns,HeatmapLayer:()=>Kf,HexagonLayer:()=>Gf,IconLayer:()=>es,Layer:()=>lt,LayerExtension:()=>Lt,LayerManager:()=>Fn,LightGlassTheme:()=>ZZ,LightTheme:()=>$Z,LightingEffect:()=>Ds,LineLayer:()=>to,LinearInterpolator:()=>Ae,MVTLayer:()=>Uf,MapController:()=>Ln,MapView:()=>Gr,MapboxOverlay:()=>Qf,MaskExtension:()=>Bf,OPERATION:()=>TC,OrbitController:()=>Kn,OrbitView:()=>_u,OrbitViewport:()=>jn,OrthographicController:()=>$n,OrthographicView:()=>yu,OrthographicViewport:()=>Zi,PathLayer:()=>Jr,PathStyleExtension:()=>vf,PointCloudLayer:()=>eo,PointLight:()=>fa,PolygonLayer:()=>Qr,PostProcessEffect:()=>Ol,QuadkeyLayer:()=>$u,S2Layer:()=>Ku,ScatterplotLayer:()=>ro,ScenegraphLayer:()=>Ao,ScreenGridLayer:()=>Hf,SimpleMeshLayer:()=>Ri,SolidPolygonLayer:()=>Zr,TRANSITION_EVENTS:()=>Dl,TerrainLayer:()=>Tf,Tesselator:()=>ts,TextLayer:()=>uo,Tile3DLayer:()=>_f,TileLayer:()=>Mi,TransitionInterpolator:()=>qi,TripsLayer:()=>tf,UNIT:()=>Ft,VERSION:()=>Ph,View:()=>Fe,Viewport:()=>xe,WebMercatorViewport:()=>ne,ZoomWidget:()=>S_,_AggregationLayer:()=>nr,_BinSorter:()=>ds,_CPUAggregator:()=>gs,_CameraLight:()=>vl,_Component:()=>Gn,_ComponentState:()=>Wn,_GPUGridAggregator:()=>ae,_GeoCellLayer:()=>ir,_GlobeController:()=>Jn,_GlobeView:()=>xu,_GlobeViewport:()=>Kr,_LayersPass:()=>ye,_MultiIconLayer:()=>ao,_PickLayersPass:()=>Vr,_SunLight:()=>Cl,_TerrainExtension:()=>Lf,_TextBackgroundLayer:()=>lo,_Tile2DHeader:()=>go,_Tileset2D:()=>mo,_WMSLayer:()=>og,_compareProps:()=>Ea,_count:()=>pp,_deepEqual:()=>vt,_fillArray:()=>Od,_flatten:()=>Oe,_getURLFromTemplate:()=>Pi,_memoize:()=>He,_mergeShaders:()=>Si,_registerLoggers:()=>wh,assert:()=>At,createIterable:()=>Ht,fp64LowPart:()=>kr,getShaderAssembler:()=>aa,gouraudLighting:()=>_r,log:()=>k,phongLighting:()=>Ns,picking:()=>_t,project:()=>te,project32:()=>dt,project64:()=>Cm,shadow:()=>oa});async function $e(e,t,r,i){return i._parse(e,t,r,i)}function nt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var ui={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},jN=ui.self||ui.window||ui.global||{},XN=ui.window||ui.self||ui.global||{},YN=ui.global||ui.self||ui.window||{},qN=ui.document||{};var Di=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var u1=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),KN=u1&&parseFloat(u1[1])||0;var hh=globalThis,$N=globalThis.document||{},dh=globalThis.process||{},JN=globalThis.console,f1=globalThis.navigator||{};function ph(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return Boolean(r&&r.indexOf("Electron")>=0)}function be(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||ph()}function L_(e){return!e&&!be()?"Node":ph(e)?"Electron":(e||f1.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var D_="4.0.7";function QN(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var gh=class{constructor(t,r,i="sessionStorage"){this.storage=QN(i),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){let r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}};function h1(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function d1(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}var mh;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(mh||(mh={}));var tL=10;function p1(e){return typeof e!="string"?e:(e=e.toUpperCase(),mh[e]||mh.WHITE)}function g1(e,t,r){return!be&&typeof e=="string"&&(t&&(e=`\x1B[${p1(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${p1(r)+tL}m${e}\x1B[49m`)),e}function m1(e,t=["constructor"]){let r=Object.getPrototypeOf(e),i=Object.getOwnPropertyNames(r),s=e;for(let n of i){let o=s[n];typeof o=="function"&&(t.find(a=>n===a)||(s[n]=o.bind(e)))}}function Ic(e,t){if(!e)throw new Error(t||"Assertion failed")}function hn(){let e;if(be()&&hh.performance)e=hh?.performance?.now?.();else if("hrtime"in dh){let t=dh?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var No={debug:be()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},eL={enabled:!0,level:0};function Lo(){}var _1={},y1={once:!0},Ve=class{constructor({id:t}={id:""}){this.VERSION=D_,this._startTs=hn(),this._deltaTs=hn(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new gh(`__probe-${this.id}__`,eL),this.timeStamp(`${this.id} started`),m1(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((hn()-this._startTs).toPrecision(10))}getDelta(){return Number((hn()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,r){this._storage.setConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t){return this._getLogFunction(0,t,No.warn,arguments,y1)}error(t){return this._getLogFunction(0,t,No.error,arguments)}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r){return this._getLogFunction(t,r,No.log,arguments,{time:!0,once:!0})}log(t,r){return this._getLogFunction(t,r,No.debug,arguments)}info(t,r){return this._getLogFunction(t,r,console.info,arguments)}once(t,r){return this._getLogFunction(t,r,No.debug||No.info,arguments,y1)}table(t,r,i){return r?this._getLogFunction(t,r,console.table||Lo,i&&[i],{tag:iL(r)}):Lo}time(t,r){return this._getLogFunction(t,r,console.time?console.time:console.info)}timeEnd(t,r){return this._getLogFunction(t,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,r){return this._getLogFunction(t,r,console.timeStamp||Lo)}group(t,r,i={collapsed:!1}){let s=x1({logLevel:t,message:r,opts:i}),{collapsed:n}=i;return s.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(t,r,i={}){return this.group(t,r,Object.assign({},i,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||Lo)}withGroup(t,r,i){this.group(t,r)();try{i()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=A1(t)}_getLogFunction(t,r,i,s,n){if(this._shouldLog(t)){n=x1({logLevel:t,message:r,args:s,opts:n}),i=i||n.method,Ic(i),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=hn();let o=n.tag||n.message;if(n.once&&o)if(!_1[o])_1[o]=hn();else return Lo;return r=rL(this.id,n.message,n),i.bind(console,r,...n.args)}return Lo}};Ve.VERSION=D_;function A1(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Ic(Number.isFinite(t)&&t>=0),t}function x1(e){let{logLevel:t,message:r}=e;e.logLevel=A1(t);let i=e.args?Array.from(e.args):[];for(;i.length&&i.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&i.unshift(r),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let s=typeof e.message;return Ic(s==="string"||s==="object"),Object.assign(e,{args:i},e.opts)}function rL(e,t,r){if(typeof t=="string"){let i=r.time?d1(h1(r.total)):"";t=r.time?`${e}: ${i} ${t}`:`${e}: ${t}`,t=g1(t,r.color,r.background)}return t}function iL(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var U_=new Ve({id:"@probe.gl/log"});function Bc(e,t){return T1(e||{},t)}function T1(e,t,r=0){if(r>3)return t;let i={...e};for(let[s,n]of Object.entries(t))n&&typeof n=="object"&&!Array.isArray(n)?i[s]=T1(i[s]||{},t[s],r+1):i[s]=t[s];return i}function k_(e){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,e)}function V_(e){return globalThis.loaders?.modules?.[e]||null}var b1="latest";function sL(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.0-beta.2"),globalThis._loadersgl_.version}var Oc=sL();function me(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}var fi={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},HQ=fi.self||fi.window||fi.global||{},GQ=fi.window||fi.self||fi.global||{},WQ=fi.global||fi.self||fi.window||{},jQ=fi.document||{};var ue=typeof process!="object"||String(process)!=="[object process]"||process.browser,Fc=typeof importScripts=="function",S1=typeof window<"u"&&typeof window.orientation<"u",E1=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),XQ=E1&&parseFloat(E1[1])||0;var Nc=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(t,r){this.name=t,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(t,r){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:r})}done(t){me(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){me(this.isRunning),this.isRunning=!1,this._reject(t)}};var Do=class{terminate(){}};var z_=new Map;function v1(e){me(e.source&&!e.url||!e.source&&e.url);let t=z_.get(e.source||e.url);return t||(e.url&&(t=nL(e.url),z_.set(e.url,t)),e.source&&(t=C1(e.source),z_.set(e.source,t))),me(t),t}function nL(e){if(!e.startsWith("http"))return e;let t=oL(e);return C1(t)}function C1(e){let t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function oL(e){return`try {
importScripts('${e}');
} catch (error) {
console.error(error);
throw error;
}`}function H_(e,t=!0,r){let i=r||new Set;if(e){if(w1(e))i.add(e);else if(w1(e.buffer))i.add(e.buffer);else if(!ArrayBuffer.isView(e)){if(t&&typeof e=="object")for(let s in e)H_(e[s],t,i)}}return r===void 0?Array.from(i):[]}function w1(e){return e?e instanceof ArrayBuffer||typeof MessagePort<"u"&&e instanceof MessagePort||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas:!1}var G_=()=>{},_s=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&ue||typeof Do<"u"&&!ue}constructor(t){let{name:r,source:i,url:s}=t;me(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=G_,this.onError=n=>console.log(n),this.worker=ue?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=G_,this.onError=G_,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,r){r=r||H_(t),this.worker.postMessage(t,r)}_getErrorFromErrorEvent(t){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,t.message&&(r+=`${t.message} in `),t.lineno&&(r+=`:${t.lineno}:${t.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=v1({source:this.source,url:this.url});let t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},t.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},t.onmessageerror=r=>console.error(r),t}_createNodeWorker(){let t;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;t=new Do(i,{eval:!1})}else if(this.source)t=new Do(this.source,{eval:!0});else throw new Error("no worker");return t.on("message",r=>{this.onMessage(r)}),t.on("error",r=>{this.onError(r)}),t.on("exit",r=>{}),t}};var Lc=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return _s.isSupported()}constructor(t){this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},t.name!==void 0&&(this.name=t.name),t.maxConcurrency!==void 0&&(this.maxConcurrency=t.maxConcurrency),t.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=t.maxMobileConcurrency),t.reuseWorkers!==void 0&&(this.reuseWorkers=t.reuseWorkers),t.onDebug!==void 0&&(this.onDebug=t.onDebug)}async startJob(t,r=(s,n,o)=>s.done(o),i=(s,n)=>s.error(n)){let s=new Promise(n=>(this.jobQueue.push({name:t,onMessage:r,onError:i,onStart:n}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let t=this._getAvailableWorker();if(!t)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:t,backlog:this.jobQueue.length});let i=new Nc(r.name,t);t.onMessage=s=>r.onMessage(i,s.type,s.payload),t.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!ue||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let t=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new _s({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return S1?this.maxMobileConcurrency:this.maxConcurrency}};var aL={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},dn=class{props;workerPools=new Map;static isSupported(){return _s.isSupported()}static getWorkerFarm(t={}){return dn._workerFarm=dn._workerFarm||new dn({}),dn._workerFarm.setProps(t),dn._workerFarm}constructor(t){this.props={...aL},this.setProps(t),this.workerPools=new Map}destroy(){for(let t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(t){let{name:r,source:i,url:s}=t,n=this.workerPools.get(r);return n||(n=new Lc({name:r,source:i,url:s}),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}}},ys=dn;Y(ys,"_workerFarm");function W_(e,t={}){let r=t[e.id]||{},i=ue?`${e.id}-worker.js`:`${e.id}-worker-node.js`,s=r.workerUrl;if(!s&&e.id==="compression"&&(s=t.workerUrl),t._workerType==="test"&&(ue?s=`modules/${e.module}/dist/${i}`:s=`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!s){let n=e.version;n==="latest"&&(n=b1);let o=n?`@${n}`:"";s=`https://unpkg.com/@loaders.gl/${e.module}${o}/dist/${i}`}return me(s),s}function j_(e,t=Oc){me(e,"no worker provided");let r=e.version;return!(!t||!r)}var X_={};async function hi(e,t=null,r={},i=null){return t&&(e=P1(e,t,r,i)),X_[e]=X_[e]||cL(e),await X_[e]}function P1(e,t,r={},i=null){if(!r.useLocalLibraries&&e.startsWith("http"))return e;i=i||e;let s=r.modules||{};return s[i]?s[i]:ue?r.CDN?(me(r.CDN.startsWith("http")),`${r.CDN}/${t}@${Oc}/dist/libs/${i}`):Fc?`../src/libs/${i}`:`modules/${t}/src/libs/${i}`:`modules/${t}/dist/libs/${i}`}async function cL(e){if(e.endsWith("wasm"))return await uL(e);if(!ue)try{let{requireFromFile:r}=globalThis.loaders||{};return await r?.(e)}catch(r){return console.error(r),null}if(Fc)return importScripts(e);let t=await fL(e);return lL(t,e)}function lL(e,t){if(!ue){let{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(Fc)return eval.call(globalThis,e),null;let r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch{r.text=e}return document.body.appendChild(r),null}async function uL(e){let{readFileAsArrayBuffer:t}=globalThis.loaders||{};return ue||!t||e.startsWith("http")?await(await fetch(e)).arrayBuffer():await t(e)}async function fL(e){let{readFileAsText:t}=globalThis.loaders||{};return ue||!t||e.startsWith("http")?await(await fetch(e)).text():await t(e)}function Y_(e,t){return!ys.isSupported()||!ue&&!t?._nodeWorkers?!1:e.worker&&t?.worker}async function q_(e,t,r,i,s){let n=e.id,o=W_(e,r),c=ys.getWorkerFarm(r).getWorkerPool({name:n,url:o});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",hL.bind(null,s));return l.postMessage("process",{input:t,options:r,context:i}),await(await l.result).result}async function hL(e,t,r,i){switch(r){case"done":t.done(i);break;case"error":t.error(new Error(i.error));break;case"process":let{id:s,input:n,options:o}=i;try{let a=await e(n,o);t.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function R1(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?M1(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?M1(e,0,t):""}function M1(e,t,r){if(e.byteLength<=t+r)return"";let i=new DataView(e),s="";for(let n=0;n<r;n++)s+=String.fromCharCode(i.getUint8(t+n));return s}function K_(e){try{return JSON.parse(e)}catch{throw new Error(`Failed to parse JSON from data starting with "${R1(e)}"`)}}function $_(e,t,r){if(r=r||e.byteLength,e.byteLength<r||t.byteLength<r)return!1;let i=new Uint8Array(e),s=new Uint8Array(t);for(let n=0;n<i.length;++n)if(i[n]!==s[n])return!1;return!0}function J_(...e){return I1(e)}function I1(e){let t=e.map(n=>n instanceof ArrayBuffer?new Uint8Array(n):n),r=t.reduce((n,o)=>n+o.byteLength,0),i=new Uint8Array(r),s=0;for(let n of t)i.set(n,s),s+=n.byteLength;return i.buffer}function Dc(...e){let t=e,r=t&&t.length>1&&t[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let i=t.reduce((o,a)=>o+a.length,0),s=new r(i),n=0;for(let o of t)s.set(o,n),n+=o.length;return s}function pn(e,t,r){let i=r!==void 0?new Uint8Array(e).subarray(t,t+r):new Uint8Array(e).subarray(t);return new Uint8Array(i).buffer}function xs(e,t){return nt(e>=0),nt(t>0),e+(t-1)&~(t-1)}function Z_(e,t,r){let i;if(e instanceof ArrayBuffer)i=new Uint8Array(e);else{let s=e.byteOffset,n=e.byteLength;i=new Uint8Array(e.buffer||e.arrayBuffer,s,n)}return t.set(i,r),r+xs(i.byteLength,4)}async function Q_(e){let t=[];for await(let r of e)t.push(r);return J_(...t)}function Uc(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var gn=class{constructor(t,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=t,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(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Uc(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Uc()-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 Ee=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let r of Object.values(this.stats))t(r)}getTable(){let t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){let{name:r,type:i}=t,s=this.stats[r];return s||(t instanceof gn?s=t:s=new gn(r,i),this.stats[r]=s),s}};var dL="Queued Requests",pL="Active Requests",gL="Cancelled Requests",mL="Queued Requests Ever",_L="Active Requests Ever",yL={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},As=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...yL,...t},this.stats=new Ee({id:this.props.id}),this.stats.get(dL),this.stats.get(pL),this.stats.get(gL),this.stats.get(mL),this.stats.get(_L)}scheduleRequest(t,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let i={handle:t,priority:0,getPriority:r},s=new Promise(n=>(i.resolve=n,i));return this.requestQueue.push(i),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){let{handle:r,resolve:i}=t,s=!1,n=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({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 t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let r=0;r<t;++r){let i=this.requestQueue.shift();i&&this._issueRequest(i)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let i=t[r];this._updateRequest(i)||(t.splice(r,1),this.requestMap.delete(i.handle),r--)}t.sort((r,i)=>r.priority-i.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var xL="",B1={};function t0(e){for(let t in B1)if(e.startsWith(t)){let r=B1[t];e=e.replace(t,r)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${xL}${e}`),e}function O1(e){return e&&typeof e=="object"&&e.isBuffer}function _h(e){if(O1(e))return e;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if(typeof e=="string"){let t=e;return new TextEncoder().encode(t).buffer}if(e&&typeof e=="object"&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}var Je={};$t(Je,{dirname:()=>TL,filename:()=>AL,join:()=>bL,resolve:()=>EL});function F1(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function AL(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function TL(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function bL(...e){let t="/";return e=e.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${t}`),"")),i!==e.length-1&&(r=r.replace(new RegExp(`${t}$`),"")),r)),e.join(t)}function EL(...e){let t=[];for(let n=0;n<e.length;n++)t[n]=e[n];let r="",i=!1,s;for(let n=t.length-1;n>=-1&&!i;n--){let o;n>=0?o=t[n]:(s===void 0&&(s=F1()),o=s),o.length!==0&&(r=`${o}/${r}`,i=o.charCodeAt(0)===kc)}return r=SL(r,!i),i?`/${r}`:r.length>0?r:"."}var kc=47,e0=46;function SL(e,t){let r="",i=-1,s=0,n,o=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===kc)break;n=kc}if(n===kc){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(r.length<2||!o||r.charCodeAt(r.length-1)!==e0||r.charCodeAt(r.length-2)!==e0){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==kc;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,s=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,s=0,o=!1;continue}}t&&(r.length>0?r+="/..":r="..",o=!0)}else{let c=e.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,o=!1}i=a,s=0}else n===e0&&s!==-1?++s:s=-1}return r}var yh=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=vL(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let r=this._needsRefresh;return t&&(this._needsRefresh=!1),r}};function vL(e){let t=e?.fetch;if(t&&typeof t=="function")return(i,s)=>t(i,s);let r=e?.fetch;return r&&typeof r!="function"?i=>fetch(i,r):i=>fetch(i)}var cr=class extends yh{};Y(cr,"type","template"),Y(cr,"testURL",t=>!1);var CL=e=>typeof e=="boolean",Vc=e=>typeof e=="function",mn=e=>e!==null&&typeof e=="object",r0=e=>mn(e)&&e.constructor==={}.constructor;var N1=e=>Boolean(e)&&typeof e[Symbol.iterator]=="function",L1=e=>e&&typeof e[Symbol.asyncIterator]=="function";var lr=e=>typeof Response<"u"&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json;var ur=e=>typeof Blob<"u"&&e instanceof Blob,D1=e=>e&&typeof e=="object"&&e.isBuffer;var wL=e=>typeof ReadableStream<"u"&&e instanceof ReadableStream||mn(e)&&Vc(e.tee)&&Vc(e.cancel)&&Vc(e.getReader);var PL=e=>mn(e)&&Vc(e.read)&&Vc(e.pipe)&&CL(e.readable),xh=e=>wL(e)||PL(e);var Ah=class extends Error{constructor(t,r){super(t),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var ML=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,RL=/^([-\w.]+\/[-\w.+]+)/;function i0(e,t){return e.toLowerCase()===t.toLowerCase()}function U1(e){let t=RL.exec(e);return t?t[1]:e}function s0(e){let t=ML.exec(e);return t?t[1]:""}var k1=/\?.*/;function V1(e){let t=e.match(k1);return t&&t[0]}function Uo(e){return e.replace(k1,"")}function z1(e){if(e.length<50)return e;let t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}function _n(e){return lr(e)?e.url:ur(e)?e.name||"":typeof e=="string"?e:""}function zc(e){if(lr(e)){let t=e,r=t.headers.get("content-type")||"",i=Uo(t.url);return U1(r)||s0(i)}return ur(e)?e.type||"":typeof e=="string"?s0(e):""}function H1(e){return lr(e)?e.headers["content-length"]||-1:ur(e)?e.size:typeof e=="string"?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}async function Th(e){if(lr(e))return e;let t={},r=H1(e);r>=0&&(t["content-length"]=String(r));let i=_n(e),s=zc(e);s&&(t["content-type"]=s);let n=await BL(e);n&&(t["x-first-bytes"]=n),typeof e=="string"&&(e=new TextEncoder().encode(e));let o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:i}),o}async function G1(e){if(!e.ok)throw await IL(e)}async function IL(e){let t=z1(e.url),r=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:e.statusText,url:e.url,response:e};try{let s=e.headers.get("Content-Type");i.reason=s?.includes("application/json")?await e.json():e.text()}catch{}return new Ah(r,i)}async function BL(e){if(typeof e=="string")return`data:,${e.slice(0,5)}`;if(e instanceof Blob){let r=e.slice(0,5);return await new Promise(i=>{let s=new FileReader;s.onload=n=>i(n?.target?.result),s.readAsDataURL(r)})}if(e instanceof ArrayBuffer){let r=e.slice(0,5);return`data:base64,${OL(r)}`}return null}function OL(e){let t="",r=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)t+=String.fromCharCode(r[i]);return btoa(t)}function FL(e){return!NL(e)&&!LL(e)}function NL(e){return e.startsWith("http:")||e.startsWith("https:")}function LL(e){return e.startsWith("data:")}async function ko(e,t){if(typeof e=="string"){let r=t0(e);return FL(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,t):await fetch(r,t)}return await Th(e)}var n0=new Ve({id:"loaders.gl"}),bh=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Eh=class{console;constructor(){this.console=console}log(...t){return this.console.log.bind(this.console,...t)}info(...t){return this.console.info.bind(this.console,...t)}warn(...t){return this.console.warn.bind(this.console,...t)}error(...t){return this.console.error.bind(this.console,...t)}};var o0={fetch:null,mimeType:void 0,nothrow:!1,log:new Eh,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Di,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},W1={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 a0(){globalThis.loaders=globalThis.loaders||{};let{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function c0(){let e=a0();return e.globalOptions=e.globalOptions||{...o0},e.globalOptions}function Y1(e,t,r,i){return r=r||[],r=Array.isArray(r)?r:[r],DL(e,r),kL(t,e,i)}function DL(e,t){j1(e,null,o0,W1,t);for(let r of t){let i=e&&e[r.id]||{},s=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};j1(i,r.id,s,n,t)}}function j1(e,t,r,i,s){let n=t||"Top level",o=t?`${t}.`:"";for(let a in e){let c=!t&&mn(e[a]),l=a==="baseUri"&&!t,u=a==="workerUrl"&&t;if(!(a in r)&&!l&&!u){if(a in i)n0.warn(`${n} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c){let f=UL(a,s);n0.warn(`${n} loader option '${o}${a}' not recognized. ${f}`)()}}}}function UL(e,t){let r=e.toLowerCase(),i="";for(let s of t)for(let n in s.options){if(e===n)return`Did you mean '${s.id}.${n}'?`;let o=n.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(i=i||`Did you mean '${s.id}.${n}'?`)}return i}function kL(e,t,r){let s={...e.options||{}};return VL(s,r),s.log===null&&(s.log=new bh),X1(s,c0()),X1(s,t),s}function X1(e,t){for(let r in t)if(r in t){let i=t[r];r0(i)&&r0(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function VL(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}function Hc(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions)):!1}function Gc(e){nt(e,"null loader"),nt(Hc(e),"invalid loader");let t;return Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}var q1=()=>{let e=a0();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function Wc(e){let t=q1();e=Array.isArray(e)?e:[e];for(let r of e){let i=Gc(r);t.find(s=>i===s)||t.unshift(i)}}function K1(){return q1()}var $1=new Ve({id:"loaders.gl"});var zL=/\.([^.]+)$/;async function Q1(e,t=[],r,i){if(!tS(e))return null;let s=J1(e,t,{...r,nothrow:!0},i);if(s)return s;if(ur(e)&&(e=await e.slice(0,10).arrayBuffer(),s=J1(e,t,r,i)),!s&&!r?.nothrow)throw new Error(eS(e));return s}function J1(e,t=[],r,i){if(!tS(e))return null;if(t&&!Array.isArray(t))return Gc(t);let s=[];t&&(s=s.concat(t)),r?.ignoreRegisteredLoaders||s.push(...K1()),WL(s);let n=HL(e,s,r,i);if(!n&&!r?.nothrow)throw new Error(eS(e));return n}function HL(e,t,r,i){let s=_n(e),n=zc(e),o=Uo(s)||i?.url,a=null,c="";return r?.mimeType&&(a=l0(t,r?.mimeType),c=`match forced by supplied MIME type ${r?.mimeType}`),a=a||jL(t,o),c=c||(a?`matched url ${o}`:""),a=a||l0(t,n),c=c||(a?`matched MIME type ${n}`:""),a=a||YL(t,e),c=c||(a?`matched initial data ${rS(e)}`:""),r?.fallbackMimeType&&(a=a||l0(t,r?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&$1.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function tS(e){return!(e instanceof Response&&e.status===204)}function eS(e){let t=_n(e),r=zc(e),i="No valid loader found (";i+=t?`${Je.filename(t)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let s=e?rS(e):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function WL(e){for(let t of e)Gc(t)}function jL(e,t){let r=t&&zL.exec(t),i=r&&r[1];return i?XL(e,i):null}function XL(e,t){t=t.toLowerCase();for(let r of e)for(let i of r.extensions)if(i.toLowerCase()===t)return r;return null}function l0(e,t){for(let r of e)if(r.mimeTypes?.some(i=>i0(t,i))||i0(t,`application/x.${r.id}`))return r;return null}function YL(e,t){if(!t)return null;for(let r of e)if(typeof t=="string"){if(qL(t,r))return r}else if(ArrayBuffer.isView(t)){if(Z1(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer&&Z1(t,0,r))return r;return null}function qL(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(i=>e.startsWith(i))}function Z1(e,t,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(s=>KL(e,t,r,s))}function KL(e,t,r,i){if(i instanceof ArrayBuffer)return $_(i,e,i.byteLength);switch(typeof i){case"function":return i(e);case"string":let s=u0(e,t,i.length);return i===s;default:return!1}}function rS(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?u0(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?u0(e,0,t):""}function u0(e,t,r){if(e.byteLength<t+r)return"";let i=new DataView(e),s="";for(let n=0;n<r;n++)s+=String.fromCharCode(i.getUint8(t+n));return s}function*iS(e,t){let r=t?.chunkSize||262144,i=0,s=new TextEncoder;for(;i<e.length;){let n=Math.min(e.length-i,r),o=e.slice(i,i+n);i+=n,yield s.encode(o)}}function*sS(e,t={}){let{chunkSize:r=262144}=t,i=0;for(;i<e.byteLength;){let s=Math.min(e.byteLength-i,r),n=new ArrayBuffer(s),o=new Uint8Array(e,i,s);new Uint8Array(n).set(o),i+=s,yield n}}async function*nS(e,t){let r=t?.chunkSize||1048576,i=0;for(;i<e.size;){let s=i+r,n=await e.slice(i,s).arrayBuffer();i=s,yield n}}function f0(e,t){return Di?$L(e,t):JL(e,t)}async function*$L(e,t){let r=e.getReader(),i;try{for(;;){let s=i||r.read();t?._streamReadAhead&&(i=r.read());let{done:n,value:o}=await s;if(n)return;yield _h(o)}}catch{r.releaseLock()}}async function*JL(e,t){for await(let r of e)yield _h(r)}function oS(e,t){if(typeof e=="string")return iS(e,t);if(e instanceof ArrayBuffer)return sS(e,t);if(ur(e))return nS(e,t);if(xh(e))return f0(e,t);if(lr(e))return f0(e.body,t);throw new Error("makeIterator")}var aS="Cannot convert supplied data type";function ZL(e,t,r){if(t.text&&typeof e=="string")return e;if(D1(e)&&(e=e.buffer),e instanceof ArrayBuffer){let i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer,s=e.byteLength||e.length;return(e.byteOffset!==0||s!==i.byteLength)&&(i=i.slice(e.byteOffset,e.byteOffset+s)),i}throw new Error(aS)}async function cS(e,t,r){let i=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if(typeof e=="string"||i)return ZL(e,t,r);if(ur(e)&&(e=await Th(e)),lr(e)){let s=e;return await G1(s),t.binary?await s.arrayBuffer():await s.text()}if(xh(e)&&(e=oS(e,r)),N1(e)||L1(e))return Q_(e);throw new Error(aS)}function Sh(e,t){let r=c0(),i=e||r;return typeof i.fetch=="function"?i.fetch:mn(i.fetch)?s=>ko(s,i.fetch):t?.fetch?t?.fetch:ko}function lS(e,t,r){if(r)return r;let i={fetch:Sh(t,e),...e};if(i.url){let s=Uo(i.url);i.baseUrl=s,i.queryString=V1(i.url),i.filename=Je.filename(s),i.baseUrl=Je.dirname(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function uS(e,t){if(e&&!Array.isArray(e))return e;let r;if(e&&(r=Array.isArray(e)?e:[e]),t&&t.loaders){let i=Array.isArray(t.loaders)?t.loaders:[t.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function Ts(e,t,r,i){t&&!Array.isArray(t)&&!Hc(t)&&(i=void 0,r=t,t=void 0),e=await e,r=r||{};let s=_n(e),o=uS(t,i),a=await Q1(e,o,r);return a?(r=Y1(r,a,o,s),i=lS({url:s,_parse:Ts,loaders:o},r,i||null),await QL(a,e,r,i)):null}async function QL(e,t,r,i){if(j_(e),r=Bc(e.options,r),lr(t)){let n=t,{ok:o,redirected:a,status:c,statusText:l,type:u,url:f}=n,h=Object.fromEntries(n.headers.entries());i.response={headers:h,ok:o,redirected:a,status:c,statusText:l,type:u,url:f}}t=await cS(t,e,r);let s=e;if(s.parseTextSync&&typeof t=="string")return s.parseTextSync(t,r,i);if(Y_(e,r))return await q_(e,t,r,i,Ts);if(s.parseText&&typeof t=="string")return await s.parseText(t,r,i);if(s.parse)return await s.parse(t,r,i);throw me(!s.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}function fS(e){switch(e.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 Ui(e){let t=1/0,r=1/0,i=1/0,s=-1/0,n=-1/0,o=-1/0,a=e.POSITION?e.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let u=a[l],f=a[l+1],h=a[l+2];t=u<t?u:t,r=f<r?f:r,i=h<i?h:i,s=u>s?u:s,n=f>n?f:n,o=h>o?h:o}return[[t,r,i],[s,n,o]]}function h0(e,t,r){let i=fS(t.value),s=r||hS(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:i}]},nullable:!1,metadata:s}}function hS(e){let t={};return"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10)),"byteStride"in e&&(t.byteStride=e.byteStride.toString(10)),"normalized"in e&&(t.normalized=e.normalized.toString()),t}async function Jt(e,t,r,i){let s,n;!Array.isArray(t)&&!Hc(t)?(s=[],n=t,i=void 0):(s=t,n=r);let o=Sh(n),a=e;return typeof e=="string"&&(a=await o(e)),ur(e)&&(a=await o(e)),Array.isArray(s)?await Ts(a,s,n):await Ts(a,s,n)}var dS="4.2.0-beta.2";var tD=globalThis.loaders?.parseImageNode,d0=typeof Image<"u",p0=typeof ImageBitmap<"u",eD=Boolean(tD),g0=Di?!0:eD;function pS(e){switch(e){case"auto":return p0||d0||g0;case"imagebitmap":return p0;case"image":return d0;case"data":return g0;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function gS(){if(p0)return"imagebitmap";if(d0)return"image";if(g0)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function mS(e){let t=rD(e);if(!t)throw new Error("Not an image");return t}function jc(e){switch(mS(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)throw new Error("getImageData");return t.width=e.width,t.height=e.height,r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function rD(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var iD=/^data:image\/svg\+xml/,sD=/\.svg((\?|#).*)?$/;function vh(e){return e&&(iD.test(e)||sD.test(e))}function _S(e,t){if(vh(t)){let i=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return m0(e,t)}function m0(e,t){if(vh(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ch(e,t,r){let i=_S(e,r),s=self.URL||self.webkitURL,n=typeof i!="string"&&s.createObjectURL(i);try{return await nD(n||i,t)}finally{n&&s.revokeObjectURL(n)}}async function nD(e,t){let r=new Image;return r.src=e,t.image&&t.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,s)=>{try{r.onload=()=>i(r),r.onerror=n=>{let o=n instanceof Error?n.message:"error";s(new Error(o))}}catch(n){s(n)}})}var oD={},yS=!0;async function xS(e,t,r){let i;vh(r)?i=await Ch(e,t,r):i=m0(e,r);let s=t&&t.imagebitmap;return await aD(i,s)}async function aD(e,t=null){if((cD(t)||!yS)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(r){console.warn(r),yS=!1}return await createImageBitmap(e)}function cD(e){for(let t in e||oD)return!1;return!0}function AS(e){return!hD(e,"ftyp",4)||!(e[8]&96)?null:lD(e)}function lD(e){switch(uD(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function uD(e,t,r){return String.fromCharCode(...e.slice(t,r))}function fD(e){return[...e].map(t=>t.charCodeAt(0))}function hD(e,t,r=0){let i=fD(t);for(let s=0;s<i.length;++s)if(i[s]!==e[s+r])return!1;return!0}var di=!1,Xc=!0;function yn(e){let t=Yc(e);return pD(t)||_D(t)||gD(t)||mD(t)||dD(t)}function dD(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),r=AS(t);return r?{mimeType:r.mimeType,width:0,height:0}:null}function pD(e){let t=Yc(e);return t.byteLength>=24&&t.getUint32(0,di)===2303741511?{mimeType:"image/png",width:t.getUint32(16,di),height:t.getUint32(20,di)}:null}function gD(e){let t=Yc(e);return t.byteLength>=10&&t.getUint32(0,di)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,Xc),height:t.getUint16(8,Xc)}:null}function mD(e){let t=Yc(e);return t.byteLength>=14&&t.getUint16(0,di)===16973&&t.getUint32(2,Xc)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Xc),height:t.getUint32(22,Xc)}:null}function _D(e){let t=Yc(e);if(!(t.byteLength>=3&&t.getUint16(0,di)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:s}=yD(),n=2;for(;n+9<t.byteLength;){let o=t.getUint16(n,di);if(s.has(o))return{mimeType:"image/jpeg",height:t.getUint16(n+5,di),width:t.getUint16(n+7,di)};if(!i.has(o))return null;n+=2,n+=t.getUint16(n,di)}return null}function yD(){let e=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)e.add(r);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Yc(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function TS(e,t){let{mimeType:r}=yn(e)||{},i=globalThis.loaders?.parseImageNode;return nt(i),await i(e,r)}async function bS(e,t,r){t=t||{};let s=(t.image||{}).type||"auto",{url:n}=r||{},o=xD(s),a;switch(o){case"imagebitmap":a=await xS(e,t,n);break;case"image":a=await Ch(e,t,n);break;case"data":a=await TS(e,t);break;default:nt(!1)}return s==="data"&&(a=jc(a)),a}function xD(e){switch(e){case"auto":case"data":return gS();default:return pS(e),e}}var AD=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],TD=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],bD={image:{type:"auto",decode:!0}},pi={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:dS,mimeTypes:TD,extensions:AD,parse:bS,tests:[e=>Boolean(yn(new DataView(e)))],options:bD};var _0={};function y0(e){if(_0[e]===void 0){let t=Di?SD(e):ED(e);_0[e]=t}return _0[e]}function ED(e){let t=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||t,i=globalThis.loaders?.parseImageNode;return Boolean(i)&&r.includes(e)}function SD(e){switch(e){case"image/avif":case"image/webp":return vD(e);default:return!0}}function vD(e){try{return document.createElement("canvas").toDataURL(e).indexOf(`data:${e}`)===0}catch{return!1}}var CD=new Ve({id:"deck"}),k=CD;var x0={};function wh(e){x0=e}function kt(e,t,r,i){k.level>0&&x0[e]&&x0[e].call(null,t,r,i)}function wD(e){let t=e[0],r=e[e.length-1];return t==="{"&&r==="}"||t==="["&&r==="]"}var ES={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:wD,parseTextSync:JSON.parse};function PD(){let e="9.0.20",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(k.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:k,_registerLoggers:wh},Wc([ES,[pi,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}var Ph=PD();function gi(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var A0={number:{type:"number",validate(e,t){return Number.isFinite(e)&&typeof t=="object"&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:"array",validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function vS(e){let t={};for(let[r,i]of Object.entries(e))t[r]=MD(i);return t}function CS(e,t,r){let i={};for(let[s,n]of Object.entries(t))e&&s in e&&!n.private?(n.validate&&gi(n.validate(e[s],n),`${r}: invalid ${s}`),i[s]=e[s]):i[s]=n.value;return i}function MD(e){let t=SS(e);if(t!=="object")return{value:e,...A0[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...A0[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=SS(e.value),{...e,...A0[t],type:t}):{type:"object",value:null};throw new Error("props")}function SS(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var wS=`#ifdef MODULE_LOGDEPTH
logdepth_adjustPosition(gl_Position);
#endif
`,PS=`#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 RD={vertex:wS,fragment:PS},MS=/void\s+main\s*\([^)]*\)\s*\{\n?/,RS=/}\n?[^{}]*$/,T0=[],qc="__LUMA_INJECT_DECLARATIONS__";function IS(e){let t={vertex:{},fragment:{}};for(let r in e){let i=e[r],s=ID(r);typeof i=="string"&&(i={order:0,injection:i}),t[s][r]=i}return t}function ID(e){let t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function Kc(e,t,r,i=!1){let s=t==="vertex";for(let n in r){let o=r[n];o.sort((c,l)=>c.order-l.order),T0.length=o.length;for(let c=0,l=o.length;c<l;++c)T0[c]=o[c].injection;let a=`${T0.join(`
`)}
`;switch(n){case"vs:#decl":s&&(e=e.replace(qc,a));break;case"vs:#main-start":s&&(e=e.replace(MS,c=>c+a));break;case"vs:#main-end":s&&(e=e.replace(RS,c=>a+c));break;case"fs:#decl":s||(e=e.replace(qc,a));break;case"fs:#main-start":s||(e=e.replace(MS,c=>c+a));break;case"fs:#main-end":s||(e=e.replace(RS,c=>a+c));break;default:e=e.replace(n,c=>c+a)}}return e=e.replace(qc,""),i&&(e=e.replace(/\}\s*$/,n=>n+RD[t])),e}var BD=1,Ze=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(t){return t.map(r=>{if(r instanceof Ze)return r;gi(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-${BD++}`);let i=new Ze(r);return i.dependencies=Ze.instantiateModules(r.dependencies||[]),i})}constructor(t){let{name:r,vs:i,fs:s,dependencies:n=[],uniformTypes:o={},uniformPropTypes:a={},getUniforms:c,deprecations:l=[],defines:u={},inject:f={}}=t;gi(typeof r=="string"),this.name=r,this.vs=i,this.fs=s,this.getModuleUniforms=c,this.dependencies=Ze.instantiateModules(n),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=u,this.injections=IS(f),this.uniformTypes=o,a&&(this.uniforms=vS(a))}getModuleSource(t){let r;switch(t){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:gi(!1)}let i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------
#define MODULE_${i}
${r}
`}getUniforms(t,r){return this.getModuleUniforms?this.getModuleUniforms(t,r):CS(t,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(t,r){this.deprecations.forEach(i=>{i.regex?.test(t)&&(i.deprecated?r.deprecated(i.old,i.new)():r.removed(i.old,i.new)())})}_parseDeprecationDefinitions(t){return t.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),t}_defaultGetUniforms(t={}){let r={},i=this.uniforms;for(let s in i){let n=i[s];s in t&&!n.private?(n.validate&&gi(n.validate(t[s],n),`${this.name}: invalid ${s}`),r[s]=t[s]):r[s]=n.value}return r}};function b0(e){if(e.source&&e.platformInfo.type==="webgpu")return{...e,vs:void 0,fs:void 0};if(!e.vs)throw new Error("no vertex shader");let t=BS(e.platformInfo,e.vs),r;return e.fs&&(r=BS(e.platformInfo,e.fs)),{...e,vs:t,fs:r}}function BS(e,t){if(typeof t=="string")return t;switch(e.type){case"webgpu":if(t?.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(t?.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}}function xn(e){let t=Ze.instantiateModules(e);return OD(t)}function OD(e){let t={},r={};return OS({modules:e,level:0,moduleMap:t,moduleDepth:r}),Object.keys(r).sort((i,s)=>r[s]-r[i]).map(i=>t[i])}function OS(e){let{modules:t,level:r,moduleMap:i,moduleDepth:s}=e;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let n of t)i[n.name]=n,(s[n.name]===void 0||s[n.name]<r)&&(s[n.name]=r);for(let n of t)n.dependencies&&OS({modules:n.dependencies,level:r+1,moduleMap:i,moduleDepth:s})}function FS(e){switch(e?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`;case"nvidia":return`#define NVIDIA_GPU
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
`;case"intel":return`#define INTEL_GPU
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`;case"amd":return`#define AMD_GPU
`;default:return`#define DEFAULT_GPU
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
`}}function LS(e,t){if(Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return e=NS(e,FD),e;case"fragment":return e=NS(e,ND),e;default:throw new Error(t)}}var DS=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],FD=[...DS,[E0("attribute"),"in $1"],[E0("varying"),"out $1"]],ND=[...DS,[E0("varying"),"in $1"]];function NS(e,t){for(let[r,i]of t)e=e.replace(r,i);return e}function E0(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function S0(e,t){let r="";for(let i in e){let s=e[i];if(r+=`void ${s.signature} {
`,s.header&&(r+=` ${s.header}`),t[i]){let n=t[i];n.sort((o,a)=>o.order-a.order);for(let o of n)r+=` ${o.injection}
`}s.footer&&(r+=` ${s.footer}`),r+=`}
`}return r}function v0(e){let t={vertex:{},fragment:{}};for(let r of e){let i,s;typeof r!="string"?(i=r,s=i.hook):(i={},s=r),s=s.trim();let[n,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(i,{signature:o});switch(n){case"vs":t.vertex[a]=c;break;case"fs":t.fragment[a]=c;break;default:throw new Error(n)}}return t}function US(e,t){return{name:LD(e,t),language:"glsl",version:DD(e)}}function LD(e,t="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return i?i[1]:t}function DD(e){let t=100,r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(t=i)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}var VS=`
${qc}
`,UD=`precision highp float;
`;function zS(e){let t=xn(e.modules||[]);return{source:C0(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:w0(t)}}function HS(e){let t=xn(e.modules||[]);return{vs:C0(e.platformInfo,{...e,source:e.vs,stage:"vertex",modules:t}),fs:C0(e.platformInfo,{...e,source:e.fs,stage:"fragment",modules:t}),getUniforms:w0(t)}}function GS(e){let{vs:t,fs:r}=e,i=xn(e.modules||[]);return{vs:kS(e.platformInfo,{...e,source:t,stage:"vertex",modules:i}),fs:kS(e.platformInfo,{...e,source:r,stage:"fragment",modules:i}),getUniforms:w0(i)}}function C0(e,t){let{source:r,stage:i,modules:s,hookFunctions:n=[],inject:o={},log:a}=t;gi(typeof r=="string","shader source must be a string");let c=r,l="",u=v0(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=e.type!=="webgpu"?s:[];for(let g of p){a&&g.checkDeprecations(c,a);let m=g.getModuleSource(i,"wgsl");l+=m;let _=g.injections[i];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+=VS,l=Kc(l,i,h),l+=S0(u[i],f),l+=c,l=Kc(l,i,d),l}function kS(e,t){let{id:r,source:i,stage:s,language:n="glsl",modules:o,defines:a={},hookFunctions:c=[],inject:l={},prologue:u=!0,log:f}=t;gi(typeof i=="string","shader source must be a string");let h=n==="glsl"?US(i).version:-1,d=e.shaderLanguageVersion,p=h===100?"#version 100":"#version 300 es",m=i.split(`
`).slice(1).join(`
`),_={};o.forEach(F=>{Object.assign(_,F.getDefines())}),Object.assign(_,a);let y="";switch(n){case"wgsl":break;case"glsl":y=u?`${p}
// ----- PROLOGUE -------------------------
${kD({id:r,source:i,stage:s})}
${`#define SHADER_TYPE_${s.toUpperCase()}`}
${FS(e)}
${s==="fragment"?UD:""}
// ----- APPLICATION DEFINES -------------------------
${VD(_)}
`:`${p}
`;break}let x=v0(c),E={},P={},B={};for(let F in l){let M=typeof l[F]=="string"?{injection:l[F],order:0}:l[F],v=/^(v|f)s:(#)?([\w-]+)$/.exec(F);if(v){let T=v[2],L=v[3];T?L==="decl"?P[F]=[M]:B[F]=[M]:E[F]=[M]}else B[F]=[M]}for(let F of o){f&&F.checkDeprecations(m,f);let M=F.getModuleSource(s);y+=M;let v=F.injections[s];for(let T in v){let L=/^(v|f)s:#([\w-]+)$/.exec(T);if(L){let z=L[2]==="decl"?P:B;z[T]=z[T]||[],z[T].push(v[T])}else E[T]=E[T]||[],E[T].push(v[T])}}return y+="// ----- MAIN SHADER SOURCE -------------------------",y+=VS,y=Kc(y,s,P),y+=S0(x[s],E),y+=m,y=Kc(y,s,B),n==="glsl"&&h!==d&&(y=LS(y,s)),y.trim()}function w0(e){return function(r){let i={};for(let s of e){let n=s.getUniforms(r,i);Object.assign(i,n)}return i}}function kD(e){let{id:t,source:r,stage:i}=e;return t&&r.indexOf("SHADER_NAME")===-1?`
#define SHADER_NAME ${t}_${i}
`:""}function VD(e={}){let t="";for(let r in e){let i=e[r];(i||Number.isFinite(i))&&(t+=`#define ${r.toUpperCase()} ${e[r]}
`)}return t}var Vo=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Vo.defaultShaderAssembler=Vo.defaultShaderAssembler||new Vo,Vo.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(r=>r.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let r=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(t,r){r&&(t=Object.assign(r,{hook:t})),this._hookFunctions.push(t)}assembleShader(t){let r=this._getModuleList(t.modules),i=this._hookFunctions,s=b0(t);return{...zS({platformInfo:t.platformInfo,...s,modules:r,hookFunctions:i}),modules:r}}assembleShaderPair(t){let r=b0(t),i=this._getModuleList(t.modules),s=this._hookFunctions,{platformInfo:n}=t;return{...t.platformInfo.shaderLanguage==="wgsl"?HS({platformInfo:n,...r,modules:i,hookFunctions:s}):GS({platformInfo:n,...r,modules:i,hookFunctions:s}),modules:i}}_getModuleList(t=[]){let r=new Array(this._defaultModules.length+t.length),i={},s=0;for(let n=0,o=this._defaultModules.length;n<o;++n){let a=this._defaultModules[n],c=a.name;r[s++]=a,i[c]=!0}for(let n=0,o=t.length;n<o;++n){let a=t[n],c=a.name;i[c]||(r[s++]=a,i[c]=!0)}return r.length=s,Ze.instantiateModules(r)}},bs=Vo;Y(bs,"defaultShaderAssembler");function P0(e){if(!e.normalized&&(e.normalized=!0,e.uniformPropTypes&&!e.getUniforms)){let t=new Ze(e);e.getUniforms=t.getUniforms.bind(t)}return e}var zD=`out vec4 transform_output;
void main() {
transform_output = vec4(0);
}`,HD=`#version 300 es
${zD}`;function $c(e){let{input:t,inputChannels:r,output:i}=e||{};if(!t)return HD;if(!r)throw new Error("inputChannels");let s=GD(r),n=WS(t,r);return`#version 300 es
in ${s} ${t};
out vec4 ${i};
void main() {
${i} = ${n};
}`}function GD(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${e}`)}}function WS(e,t){switch(t){case 1:return`vec4(${e}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${e}, 0.0, 1.0)`;case 3:return`vec4(${e}, 1.0)`;case 4:return e;default:throw new Error(`invalid channels: ${t}`)}}var D=new Ve({id:"luma.gl"});var M0=class{stats=new Map;getStats(t){return this.get(t)}get(t){return this.stats.has(t)||this.stats.set(t,new Ee({id:t})),this.stats.get(t)}},zo=new M0;function WD(){let e="9.0.14",t="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==e)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${e}`);return globalThis.luma||(be()&&D.log(1,`${e} - ${t}`)(),globalThis.luma=globalThis.luma||{VERSION:e,version:e,log:D,stats:zo}),e}var jS=WD();function jD(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)?e:null}function Es(e){return Array.isArray(e)?e.length===0||typeof e[0]=="number"?e:null:jD(e)}var R0={};function Wt(e="id"){R0[e]=R0[e]||1;let t=R0[e]++;return`${e}-${t}`}function Ss(e){let t=!0;for(let r in e){t=!1;break}return t}var et=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(t,r,i){if(!t)throw new Error("no device");this._device=t,this.props=XD(r,i);let s=this.props.id!=="undefined"?this.props.id:Wt(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(t){this._attachedResources.add(t)}detachResource(t){this._attachedResources.delete(t)}destroyAttachedResource(t){this._attachedResources.delete(t)&&t.destroy()}destroyAttachedResources(){for(let t of Object.values(this._attachedResources))t.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let t=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];t.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(t,r=this[Symbol.toStringTag]){let i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").addCount(t),i.get(`${r} Memory`).addCount(t),this.allocatedBytes=t}trackDeallocatedMemory(t=this[Symbol.toStringTag]){let r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${t} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let t=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];t.get("Resources Created").incrementCount(),t.get(`${r}s Created`).incrementCount(),t.get(`${r}s Active`).incrementCount()}};Y(et,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function XD(e,t){let r={...t};for(let i in e)e[i]!==void 0&&(r[i]=e[i]);return r}var Jc=class extends et{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(t,r){let i={...r};(r.usage||0)&Jc.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array&&(i.indexType="uint16")),super(t,i,Jc.defaultProps),this.usage=r.usage||0,this.indexType=i.indexType,this.updateTimestamp=t.incrementTimestamp()}readSyncWebGL(t,r){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(t,r,i){let s=ArrayBuffer.isView(t)?t.buffer:t,n=Math.min(t?t.byteLength:i,Jc.DEBUG_DATA_MAX_LENGTH);t===null?this.debugData=new ArrayBuffer(n):r===0&&i===t.byteLength?this.debugData=s.slice(0,n):this.debugData=s.slice(r,r+n)}},Q=Jc;Y(Q,"defaultProps",{...et.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),Y(Q,"MAP_READ",1),Y(Q,"MAP_WRITE",2),Y(Q,"COPY_SRC",4),Y(Q,"COPY_DST",8),Y(Q,"INDEX",16),Y(Q,"VERTEX",32),Y(Q,"UNIFORM",64),Y(Q,"STORAGE",128),Y(Q,"INDIRECT",256),Y(Q,"QUERY_RESOLVE",512),Y(Q,"DEBUG_DATA_MAX_LENGTH",32);function Mh(e){let t=XS[e],r=YD(t),i=e.includes("norm"),s=!i&&!e.startsWith("float"),n=e.startsWith("s");return{dataType:XS[e],byteLength:r,integer:s,signed:n,normalized:i}}function YD(e){return qD[e]}var XS={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},qD={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var KD=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],$D=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function YS(e){return KD.some(t=>e.startsWith(t))}function Rh(e){let t=$D.exec(e);if(t){let[,r,i,s,n,o]=t;if(r){let a=`${s}${i}`,c=Mh(a);return{format:r,components:r.length,srgb:n==="-srgb",unsized:o==="-unsized",webgl:o==="-webgl",...c}}}return ZD(e)}var JD={"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 ZD(e){let t=JD[e];if(!t)throw new Error(`Unknown format ${e}`);return{format:t.format||"",components:t.components||t.format?.length||1,byteLength:t.bpp||1,srgb:!1,unsized:!1}}var Zc=class{},Qc=class{features;disabledFeatures;constructor(t=[],r){this.features=new Set(t),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(t){return!this.disabledFeatures[t]&&this.features.has(t)}},I0=class{get[Symbol.toStringTag](){return"Device"}constructor(t){this.props={...I0.defaultProps,...t},this.id=this.props.id||Wt(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=zo;_lumaData={};isTextureFormatCompressed(t){return YS(t)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(t){return(t instanceof Promise||typeof t=="string")&&(t={data:t}),this._createTexture(t)}createCommandEncoder(t={}){throw new Error("not implemented")}readPixelsToArrayWebGL(t,r){throw new Error("not implemented")}readPixelsToBufferWebGL(t,r){throw new Error("not implemented")}setParametersWebGL(t){throw new Error("not implemented")}getParametersWebGL(t){throw new Error("not implemented")}withParametersWebGL(t,r){throw new Error("not implemented")}clearWebGL(t){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(t){this.props.onError(t)}_getBufferProps(t){(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let r={...t};return(t.usage||0)&Q.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?r.indexType="uint32":t.data instanceof Uint16Array?r.indexType="uint16":D.warn("indices buffer content must be of integer type")()),r}},Qe=I0;Y(Qe,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(D.get("debug")),spector:Boolean(D.get("spector")||D.get("spectorjs")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:t=>D.error(t.message)}),Y(Qe,"VERSION",jS);function tt(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}var tl=new Map,B0=class{static registerDevices(t){for(let r of t)tt(r.type&&r.isSupported&&r.create),tl.set(r.type,r)}static getAvailableDevices(){return Array.from(tl).map(t=>t.type)}static getSupportedDevices(){return Array.from(tl).filter(t=>t.isSupported()).map(t=>t.type)}static setDefaultDeviceProps(t){Object.assign(Qe.defaultProps,t)}static async attachDevice(t){let r=qS(t.devices)||tl;if(t.handle instanceof WebGL2RenderingContext){let i=r.get("webgl");if(i)return await i.attach(t.handle)}if(t.handle===null){let i=r.get("unknown");if(i)return await i.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(t={}){t={...B0.defaultProps,...t},t.gl&&(t.type="webgl");let r=qS(t.devices)||tl;switch(t.type){case"webgpu":let i=r.get("webgpu");if(i)return await i.create(t);break;case"webgl":let s=r.get("webgl");if(s)return await s.create(t);break;case"unknown":let n=r.get("unknown");if(n)return await n.create(t);break;case"best-available":if(i=r.get("webgpu"),i?.isSupported?.())return await i.create(t);if(s=r.get("webgl"),s?.isSupported?.())return await s.create(t);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(t=!0){let r=HTMLCanvasElement.prototype;if(!t&&r.originalGetContext){r.getContext=r.originalGetContext,r.originalGetContext=void 0;return}r.originalGetContext=r.getContext,r.getContext=function(i,s){return i==="webgl"||i==="experimental-webgl"?this.originalGetContext("webgl2",s):this.originalGetContext(i,s)}}},ze=B0;Y(ze,"defaultProps",{...Qe.defaultProps,type:"best-available",devices:void 0}),Y(ze,"stats",zo),Y(ze,"log",D);function qS(e){if(!e||e?.length===0)return null;let t=new Map;for(let r of e)t.set(r.type,r);return t}var QD=be()&&typeof document<"u",Ih=()=>QD&&document.readyState==="complete",tU={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},vs=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return Ih()}constructor(t){if(this.props={...tU,...t},t=this.props,!be()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(t.canvas)typeof t.canvas=="string"?this.canvas=iU(t.canvas):this.canvas=t.canvas;else{let r=sU(t),i=rU(t?.container||null);i.insertBefore(r,i.firstChild),this.canvas=r,t?.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&&t.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let i of r)i.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(t){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(t=t===void 0?this.props.useDevicePixels:t,!t||t<=0)?1:t===!0?typeof window<"u"&&window.devicePixelRatio||1:t}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 t=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*t,r.clientHeight*t]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[t,r]=this.getPixelSize();return t/r}cssToDeviceRatio(){try{let[t]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?t/r:1}catch{return 1}}cssToDevicePixels(t,r=!0){let i=this.cssToDeviceRatio(),[s,n]=this.getDrawingBufferSize();return nU(t,i,s,n,r)}setDevicePixelRatio(t,r={}){if(!this.htmlCanvas)return;let i="width"in r?r.width:this.htmlCanvas.clientWidth,s="height"in r?r.height:this.htmlCanvas.clientHeight;(!i||!s)&&(D.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,i=this.htmlCanvas.width||1,s=this.htmlCanvas.height||1);let n=this._canvasSizeInfo;if(n.clientWidth!==i||n.clientHeight!==s||n.devicePixelRatio!==t){let o=t,a=Math.floor(i*o),c=Math.floor(s*o);this.htmlCanvas.width=a,this.htmlCanvas.height=c;let[l,u]=this.getDrawingBufferSize();(l!==a||u!==c)&&(o=Math.min(l/i,u/s),this.htmlCanvas.width=Math.floor(i*o),this.htmlCanvas.height=Math.floor(s*o),D.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=s,this._canvasSizeInfo.devicePixelRatio=t}}getDrawingBufferSize(){let t=this.device.gl;if(!t)throw new Error("canvas size");return[t.drawingBufferWidth,t.drawingBufferHeight]}_setAutoCreatedCanvasId(t){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=t)}};Y(vs,"pageLoaded",eU());function eU(){return Ih()||typeof window>"u"?Promise.resolve():new Promise(e=>{window.addEventListener("load",()=>e())})}function rU(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t&&!Ih())throw new Error(`Accessing '${e}' before page was loaded`);if(!t)throw new Error(`${e} is not an HTML element`);return t}else if(e)return e;return document.body}function iU(e){let t=document.getElementById(e);if(!t&&!Ih())throw new Error(`Accessing '${e}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}function sU(e){let{width:t,height:r}=e,i=document.createElement("canvas");return i.id="lumagl-auto-created-canvas",i.width=t||1,i.height=r||1,i.style.width=Number.isFinite(t)?`${t}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",i}function nU(e,t,r,i,s){let n=e,o=KS(n[0],t,r),a=$S(n[1],t,i,s),c=KS(n[0]+1,t,r),l=c===r-1?c:c-1;c=$S(n[1]+1,t,i,s);let u;return s?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function KS(e,t,r){return Math.min(Math.round(e*t),r-1)}function $S(e,t,r,i){return i?Math.max(0,r-1-Math.round(e*t)):Math.min(Math.round(e*t),r-1)}var O0=class extends et{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(t,r,i=O0.defaultProps){super(t,r,i),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=t.incrementTimestamp()}},xt=O0;Y(xt,"defaultProps",{...et.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(xt,"COPY_SRC",1),Y(xt,"COPY_DST",2),Y(xt,"TEXTURE_BINDING",4),Y(xt,"STORAGE_BINDING",8),Y(xt,"RENDER_ATTACHMENT",16);var F0=class extends et{get[Symbol.toStringTag](){return"TextureView"}constructor(t,r){super(t,r,F0.defaultProps)}},Cs=F0;Y(Cs,"defaultProps",{...et.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function ZS(e,t,r){let i="",s=t.split(/\r?\n/),n=e.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(i+=QS(s[a-1],a,r);n.length>o&&n[o].lineNum===a;){let c=n[o++];i+=JS(c,s,c.lineNum,{...r,inlineSource:!1})}return i;case"issues":case"no":for(let a of e)i+=JS(a,s,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function JS(e,t,r,i){if(i?.inlineSource){let s=oU(t,r),n=e.linePos>0?`${" ".repeat(e.linePos+5)}^^^
`:"";return`
${s}${n}${e.type.toUpperCase()}: ${e.message}
`}return i?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function oU(e,t,r){let i="";for(let s=t-2;s<=t;s++){let n=e[s-1];n!==void 0&&(i+=QS(n,t,r))}return i}function QS(e,t,r){let i=r?.html?cU(e):e;return`${aU(String(t),4)}: ${i}${r?.html?"<br/>":`
`}`}function aU(e,t){let r="";for(let i=e.length;i<t;++i)r+=" ";return r+e}function cU(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function N0(e,t){return{name:lU(e,t),language:"glsl",version:uU(e)}}function lU(e,t="unnamed"){let i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return i?i[1]:t}function uU(e){let t=100,r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(t=i)}return t}var L0=class extends et{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(t,r){super(t,{id:fU(r),...r},L0.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(t=this.props.debug){switch(t){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(t){if(typeof document>"u"||!document?.createElement)return;let r=N0(this.source).name,i=`${this.stage} ${r}`,s=ZS(t,this.source,{showSourceCode:"all",html:!0}),n=this.getTranslatedSource();n&&(s+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${n}</pre></code>`);let o=document.createElement("Button");o.innerHTML=`
<h1>Shader Compilation Error in ${i}</h1><br /><br />
<code style="user-select:text;"><pre>
${s}
</pre></code>`,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)}}},ws=L0;Y(ws,"defaultProps",{...et.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function fU(e){return N0(e.source).name||e.id||Wt(`unnamed ${e.stage}-shader`)}var D0=class extends et{get[Symbol.toStringTag](){return"Sampler"}constructor(t,r){super(t,r,D0.defaultProps)}},Ps=D0;Y(Ps,"defaultProps",{...et.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 U0=class extends et{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(t,r={}){super(t,r,U0.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(t){let r=!t;if(t){let[i,s]=Array.isArray(t)?t:[t.width,t.height];r=r||s!==this.height||i!==this.width,this.width=i,this.height=s}r&&(D.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 i=this.createColorTexture(r);return this.attachResource(i),i.view}return r instanceof xt?r.view:r});let t=this.props.depthStencilAttachment;if(t)if(typeof t=="string"){let r=this.createDepthStencilTexture(t);this.attachResource(r),this.depthStencilAttachment=r.view}else t instanceof xt?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t){return this.device.createTexture({id:"color-attachment",usage:xt.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}createDepthStencilTexture(t){return this.device.createTexture({id:"depth-stencil-attachment",usage:xt.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,r){for(let i=0;i<this.colorAttachments.length;++i)if(this.colorAttachments[i]){let s=this.device._createTexture({...this.colorAttachments[i].props,width:t,height:r});this.destroyAttachedResource(this.colorAttachments[i]),this.colorAttachments[i]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){let i=this.device._createTexture({...this.depthStencilAttachment.props,width:t,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}}},mi=U0;Y(mi,"defaultProps",{...et.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var k0=class extends et{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(t,r){super(t,r,k0.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(t){throw new Error("Use uniform blocks")}},Or=k0;Y(Or,"defaultProps",{...et.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var V0=class extends et{get[Symbol.toStringTag](){return"RenderPass"}constructor(t,r){super(t,r,V0.defaultProps)}},Ho=V0;Y(Ho,"defaultProps",{...et.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var z0=class extends et{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";constructor(t,r){super(t,r,z0.defaultProps)}},An=z0;Y(An,"defaultProps",{...et.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var H0=class extends et{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(t,r){super(t,r,H0.defaultProps)}},Go=H0;Y(Go,"defaultProps",{...et.defaultProps,measureExecutionTime:void 0});var G0=class extends et{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(t,r){super(t,r,G0.defaultProps)}},Wo=G0;Y(Wo,"defaultProps",{...et.defaultProps});function tv(e){let[t,r]=dU[e],i=t==="i32"||t==="u32",s=t!=="u32",n=pU[t]*r,o=hU(t,r);return{dataType:t,components:r,defaultVertexFormat:o,byteLength:n,integer:i,signed:s}}function hU(e,t){let r;switch(e){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return t<=2?"float16x2":"float16x4"}return t===1?r:`${r}x${t}`}var dU={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},pU={f32:4,f16:2,i32:4,u32:4};function W0(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);let[r,i]=e.split("x"),s=r,n=i?parseInt(i):1,o=Mh(s),a={type:s,components:n,byteLength:o.byteLength*n,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(a.webglOnly=!0),a}function Bh(e,t){let r={};for(let i of e.attributes)r[i.name]=gU(e,t,i.name);return r}function ev(e,t,r=16){let i=Bh(e,t),s=new Array(r).fill(null);for(let n of Object.values(i))s[n.location]=n;return s}function gU(e,t,r){let i=mU(e,r),s=_U(t,r);if(!i)return null;let n=tv(i.type),o=s?.vertexFormat||n.defaultVertexFormat,a=W0(o);return{attributeName:s?.attributeName||i.name,bufferName:s?.bufferName||i.name,location:i.location,shaderType:i.type,shaderDataType:n.dataType,shaderComponents:n.components,vertexFormat:o,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:n.integer,stepMode:s?.stepMode||i.stepMode,byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function mU(e,t){let r=e.attributes.find(i=>i.name===t);return r||D.warn(`shader layout attribute "${t}" not present in shader`),r||null}function _U(e,t){yU(e);let r=xU(e,t);return r||(r=AU(e,t),r)?r:(D.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function yU(e){for(let t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&D.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function xU(e,t){for(let r of e)if(r.format&&r.name===t)return{attributeName:r.name,bufferName:t,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function AU(e,t){for(let r of e){let i=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let o=W0(n.format);i+=o.byteLength}let s=r.attributes?.find(n=>n.attribute===t);if(s)return{attributeName:s.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:i}}return null}function j0(e,t){let r={...e,attributes:e.attributes.map(i=>({...i}))};for(let i of t?.attributes||[]){let s=r.attributes.find(n=>n.name===i.name);s?(s.type=i.type||s.type,s.stepMode=i.stepMode||s.stepMode):D.warn(`shader layout attribute ${i.name} not present in shader`)}return r}var X0=class extends et{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(t,r){super(t,r,X0.defaultProps),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=ev(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(t,r){throw new Error("constant attributes not supported")}},jo=X0;Y(jo,"defaultProps",{...et.defaultProps,renderPipeline:null});var Y0=class extends et{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(t,r){super(t,r,Y0.defaultProps)}},Xo=Y0;Y(Xo,"defaultProps",{...et.defaultProps,layout:void 0,buffers:{}});var q0=class extends et{get[Symbol.toStringTag](){return"QuerySet"}constructor(t,r){super(t,r,q0.defaultProps)}},Yo=q0;Y(Yo,"defaultProps",{...et.defaultProps,type:void 0,count:void 0});var TU={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16}};function rv(e){let t=TU[e];return tt(e),t}function iv(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}var Oh;function Fh(e){return(!Oh||Oh.byteLength<e)&&(Oh=new ArrayBuffer(e)),Oh}function K0(e,t){let r=Fh(e.BYTES_PER_ELEMENT*t);return new e(r,0,t)}function $0(e){let{target:t,source:r,start:i=0,count:s=1}=e,n=r.length,o=s*n,a=0;for(let c=i;a<n;a++)t[c++]=r[a];for(;a<o;)a<o-a?(t.copyWithin(i+a,i,i+a),a*=2):(t.copyWithin(i+a,i,i+o-a),a=o);return e.target}var sv=1024,Nh=class{layout={};byteLength;constructor(t){let r=0;for(let[s,n]of Object.entries(t)){let o=rv(n),{type:a,components:c}=o;r=iv(r,c);let l=r;r+=c,this.layout[s]={type:a,size:c,offset:l}}r+=(4-r%4)%4;let i=r*4;this.byteLength=Math.max(i,sv)}getData(t){let r=Math.max(this.byteLength,sv),i=Fh(r),s={i32:new Int32Array(i),u32:new Uint32Array(i),f32:new Float32Array(i),f16:new Uint16Array(i)};for(let[n,o]of Object.entries(t)){let a=this.layout[n];if(!a){D.warn(`Supplied uniform value ${n} not present in uniform block layout`)();continue}let{type:c,size:l,offset:u}=a,f=s[c];if(l===1){if(typeof o!="number"&&typeof o!="boolean"){D.warn(`Supplied value for single component uniform ${n} is not a number: ${o}`)();continue}f[u]=Number(o)}else{let h=Es(o);if(!h){D.warn(`Supplied value for multi component / array uniform ${n} is not a numeric array: ${o}`)();continue}f.set(h,u)}}return new Uint8Array(i)}has(t){return Boolean(this.layout[t])}get(t){return this.layout[t]}};function nv(e,t,r=16){if(e!==t)return!1;let i=Es(e);if(!i)return!1;let s=Es(t);if(s&&i.length===s.length){for(let n=0;n<i.length;++n)if(s[n]!==i[n])return!1}return!0}function ov(e){let t=Es(e);return t?t.slice():e}var Lh=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(t){if(this.name=t?.name,t?.name&&t?.shaderLayout){let r=t?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===t?.name);if(!r)throw new Error(t?.name);let i=r;for(let s of i.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(t){for(let[r,i]of Object.entries(t))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(t){this.needsRedraw=this.needsRedraw||t}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(t,r){nv(this.uniforms[t],r)||(this.uniforms[t]=ov(r),this.modifiedUniforms[t]=!0,this.modified=!0)}};var el=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(t){for(let[r,i]of Object.entries(t)){let s=r,n=new Nh(i.uniformTypes||{});this.uniformBufferLayouts.set(s,n);let o=new Lh({name:r});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(let t of this.uniformBuffers.values())t.destroy()}setUniforms(t){for(let[r,i]of Object.entries(t))this.uniformBlocks.get(r).setUniforms(i);this.updateUniformBuffers()}getUniformBufferByteLength(t){return this.uniformBufferLayouts.get(t).byteLength}getUniformBufferData(t){let r=this.uniformBlocks.get(t).getAllUniforms();return this.uniformBufferLayouts.get(t).getData(r)}createUniformBuffer(t,r,i){i&&this.setUniforms(i);let s=this.getUniformBufferByteLength(r),n=t.createBuffer({usage:Q.UNIFORM|Q.COPY_DST,byteLength:s}),o=this.getUniformBufferData(r);return n.write(o),n}getManagedUniformBuffer(t,r){if(!this.uniformBuffers.get(r)){let i=this.getUniformBufferByteLength(r),s=t.createBuffer({usage:Q.UNIFORM|Q.COPY_DST,byteLength:i});this.uniformBuffers.set(r,s)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let t=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);t||=i}return t&&D.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(t){let r=this.uniformBlocks.get(t),i=this.uniformBuffers.get(t),s=!1;if(i&&r.needsRedraw){s||=r.needsRedraw;let n=this.getUniformBufferData(t);this.uniformBuffers.get(t).write(n);let a=this.uniformBlocks.get(t).getAllUniforms();D.log(4,`Writing to uniform buffer ${String(t)}`,n,a)()}return s}};function Dh(e){let t=ArrayBuffer.isView(e)?e.constructor:e;switch(t){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(t.constructor.name)}}function rl(e){switch(e){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(e)}}function J0(e,t,r){if(!t||t>4)throw new Error(`size ${t}`);let i=t,s=Dh(e);if(s==="uint8"||s==="sint8"){if(i===1||i===3)throw new Error(`size: ${t}`);return r&&(s=s.replace("int","norm")),`${s}x${i}`}if(s==="uint16"||s==="sint16"){if(i===1||i===3)throw new Error(`size: ${t}`);return r&&(s=s.replace("int","norm")),`${s}x${i}`}return i===1?s:`${s}x${i}`}function av(e){return Es(e)!==null||typeof e=="number"||typeof e=="boolean"}function il(e){let t={bindings:{},uniforms:{}};return Object.keys(e).forEach(r=>{let i=e[r];av(i)?t.uniforms[r]=i:t.bindings[r]=i}),t}function Z0(e,t,r){let{removedProps:i={},deprecatedProps:s={},replacedProps:n={}}=r;for(let a in i)if(a in t){let l=i[a]?`${e}.${i[a]}`:"N/A";D.removed(`${e}.${a}`,l)()}for(let a in s)if(a in t){let c=s[a];D.deprecated(`${e}.${a}`,`${e}.${c}`)()}let o=null;for(let[a,c]of Object.entries(n))a in t&&(D.deprecated(`${e}.${a}`,`${e}.${c}`)(),o=o||Object.assign({},t),o[c]=t[a],delete o[a]);return o||t}var bU="";async function Q0(e,t){return await new Promise((r,i)=>{try{let s=new Image;s.onload=()=>r(s),s.onerror=()=>i(new Error(`Could not load image ${e}.`)),s.crossOrigin=t?.crossOrigin||"anonymous",s.src=e.startsWith("http")?e:bU+e}catch(s){i(s)}})}async function sl(e,t){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",e),t&&(i.id=t),new Promise((s,n)=>{i.onload=s,i.onerror=o=>n(new Error(`Unable to load script '${e}': ${o}`)),r.appendChild(i)})}function nl(e,t,r){if(e===t)return!0;if(!r||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!nl(e[i],t[i],r-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e=="object"&&typeof t=="object"){let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let n of i)if(!t.hasOwnProperty(n)||!nl(e[n],t[n],r-1))return!1;return!0}return!1}function ty(e){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60)}function ey(e){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e)}var ry=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},Vi=class{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(t){throw new Error("Cannot evaluate node")}evaluateString(t){return this.evaluate(t).toString()}},Nt=class extends Vi{constructor(){super()}},Uh=class extends Nt{constructor(t,r,i,s){super(),this.name=t,this.args=r,this.returnType=i,this.body=s}get astNodeType(){return"function"}},iy=class extends Nt{constructor(t){super(),this.expression=t}get astNodeType(){return"staticAssert"}},sy=class extends Nt{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"while"}},ny=class extends Nt{constructor(t){super(),this.body=t}get astNodeType(){return"continuing"}},oy=class extends Nt{constructor(t,r,i,s){super(),this.init=t,this.condition=r,this.increment=i,this.body=s}get astNodeType(){return"for"}},Rs=class extends Nt{constructor(t,r,i,s,n){super(),this.name=t,this.type=r,this.storage=i,this.access=s,this.value=n}get astNodeType(){return"var"}},kh=class extends Nt{constructor(t,r,i){super(),this.name=t,this.type=r,this.value=i}get astNodeType(){return"override"}},Vh=class extends Nt{constructor(t,r,i,s,n){super(),this.name=t,this.type=r,this.storage=i,this.access=s,this.value=n}get astNodeType(){return"let"}},zh=class extends Nt{constructor(t,r,i,s,n){super(),this.name=t,this.type=r,this.storage=i,this.access=s,this.value=n}get astNodeType(){return"const"}evaluate(t){return this.value.evaluate(t)}},Jo;(function(e){e.increment="++",e.decrement="--"})(Jo||(Jo={}));(function(e){function t(r){let i=r;if(i=="parse")throw new Error("Invalid value for IncrementOperator");return e[i]}e.parse=t})(Jo||(Jo={}));var ay=class extends Nt{constructor(t,r){super(),this.operator=t,this.variable=r}get astNodeType(){return"increment"}},al;(function(e){e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})(al||(al={}));(function(e){function t(r){let i=r;if(i=="parse")throw new Error("Invalid value for AssignOperator");return e[i]}e.parse=t})(al||(al={}));var cy=class extends Nt{constructor(t,r,i){super(),this.operator=t,this.variable=r,this.value=i}get astNodeType(){return"assign"}},ly=class extends Nt{constructor(t,r){super(),this.name=t,this.args=r}get astNodeType(){return"call"}},uy=class extends Nt{constructor(t,r){super(),this.body=t,this.continuing=r}get astNodeType(){return"loop"}},fy=class extends Nt{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"body"}},hy=class extends Nt{constructor(t,r,i,s){super(),this.condition=t,this.body=r,this.elseif=i,this.else=s}get astNodeType(){return"if"}},dy=class extends Nt{constructor(t){super(),this.value=t}get astNodeType(){return"return"}},py=class extends Nt{constructor(t){super(),this.name=t}get astNodeType(){return"enable"}},Hh=class extends Nt{constructor(t,r){super(),this.name=t,this.type=r}get astNodeType(){return"alias"}},gy=class extends Nt{constructor(){super()}get astNodeType(){return"discard"}},my=class extends Nt{constructor(){super()}get astNodeType(){return"break"}},_y=class extends Nt{constructor(){super()}get astNodeType(){return"continue"}},zi=class extends Nt{constructor(t){super(),this.name=t}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},ki=class extends zi{constructor(t,r){super(t),this.members=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(t){for(let r=0;r<this.members.length;r++)if(this.members[r].name==t)return r;return-1}},Gh=class extends zi{constructor(t,r,i){super(t),this.format=r,this.access=i}get astNodeType(){return"template"}},yy=class extends zi{constructor(t,r,i,s){super(t),this.storage=r,this.type=i,this.access=s}get astNodeType(){return"pointer"}},Wh=class extends zi{constructor(t,r,i,s){super(t),this.attributes=r,this.format=i,this.count=s}get astNodeType(){return"array"}get isArray(){return!0}},Tn=class extends zi{constructor(t,r,i){super(t),this.format=r,this.access=i}get astNodeType(){return"sampler"}},dr=class extends Vi{constructor(){super()}},jh=class extends dr{constructor(t){super(),this.value=t}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},bn=class extends dr{constructor(t,r){super(),this.type=t,this.args=r}get astNodeType(){return"createExpr"}},xy=class extends dr{constructor(t,r){super(),this.name=t,this.args=r}get astNodeType(){return"callExpr"}evaluate(t){switch(this.name){case"abs":return Math.abs(this.args[0].evaluate(t));case"acos":return Math.acos(this.args[0].evaluate(t));case"acosh":return Math.acosh(this.args[0].evaluate(t));case"asin":return Math.asin(this.args[0].evaluate(t));case"asinh":return Math.asinh(this.args[0].evaluate(t));case"atan":return Math.atan(this.args[0].evaluate(t));case"atan2":return Math.atan2(this.args[0].evaluate(t),this.args[1].evaluate(t));case"atanh":return Math.atanh(this.args[0].evaluate(t));case"ceil":return Math.ceil(this.args[0].evaluate(t));case"clamp":return Math.min(Math.max(this.args[0].evaluate(t),this.args[1].evaluate(t)),this.args[2].evaluate(t));case"cos":return Math.cos(this.args[0].evaluate(t));case"degrees":return this.args[0].evaluate(t)*180/Math.PI;case"distance":return Math.sqrt(Math.pow(this.args[0].evaluate(t)-this.args[1].evaluate(t),2));case"dot":case"exp":return Math.exp(this.args[0].evaluate(t));case"exp2":return Math.pow(2,this.args[0].evaluate(t));case"floor":return Math.floor(this.args[0].evaluate(t));case"fma":return this.args[0].evaluate(t)*this.args[1].evaluate(t)+this.args[2].evaluate(t);case"fract":return this.args[0].evaluate(t)-Math.floor(this.args[0].evaluate(t));case"inverseSqrt":return 1/Math.sqrt(this.args[0].evaluate(t));case"log":return Math.log(this.args[0].evaluate(t));case"log2":return Math.log2(this.args[0].evaluate(t));case"max":return Math.max(this.args[0].evaluate(t),this.args[1].evaluate(t));case"min":return Math.min(this.args[0].evaluate(t),this.args[1].evaluate(t));case"mix":return this.args[0].evaluate(t)*(1-this.args[2].evaluate(t))+this.args[1].evaluate(t)*this.args[2].evaluate(t);case"modf":return this.args[0].evaluate(t)-Math.floor(this.args[0].evaluate(t));case"pow":return Math.pow(this.args[0].evaluate(t),this.args[1].evaluate(t));case"radians":return this.args[0].evaluate(t)*Math.PI/180;case"round":return Math.round(this.args[0].evaluate(t));case"sign":return Math.sign(this.args[0].evaluate(t));case"sin":return Math.sin(this.args[0].evaluate(t));case"sinh":return Math.sinh(this.args[0].evaluate(t));case"saturate":return Math.min(Math.max(this.args[0].evaluate(t),0),1);case"smoothstep":return this.args[0].evaluate(t)*this.args[0].evaluate(t)*(3-2*this.args[0].evaluate(t));case"sqrt":return Math.sqrt(this.args[0].evaluate(t));case"step":return this.args[0].evaluate(t)<this.args[1].evaluate(t)?0:1;case"tan":return Math.tan(this.args[0].evaluate(t));case"tanh":return Math.tanh(this.args[0].evaluate(t));case"trunc":return Math.trunc(this.args[0].evaluate(t));default:throw new Error("Non const function: "+this.name)}}},Ay=class extends dr{constructor(t){super(),this.name=t}get astNodeType(){return"varExpr"}},Xh=class extends dr{constructor(t,r){super(),this.name=t,this.initializer=r}get astNodeType(){return"constExpr"}evaluate(t){var r,i;if(this.initializer instanceof bn){let s=(r=this.postfix)===null||r===void 0?void 0:r.evaluateString(t),n=(i=this.initializer.type)===null||i===void 0?void 0:i.name,o=t.structs.get(n),a=o?.getMemberIndex(s);if(a!=-1)return this.initializer.args[a].evaluate(t);console.log(a)}return this.initializer.evaluate(t)}},Yh=class extends dr{constructor(t){super(),this.value=t}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Ty=class extends dr{constructor(t,r){super(),this.type=t,this.value=r}get astNodeType(){return"bitcastExpr"}},by=class extends dr{constructor(t,r){super(),this.type=t,this.args=r}get astNodeType(){return"typecastExpr"}evaluate(t){return this.args[0].evaluate(t)}},qh=class extends dr{constructor(t){super(),this.contents=t}get astNodeType(){return"groupExpr"}evaluate(t){return this.contents[0].evaluate(t)}},Kh=class extends dr{constructor(){super()}},Ey=class extends Kh{constructor(t,r){super(),this.operator=t,this.right=r}get astNodeType(){return"unaryOp"}evaluate(t){switch(this.operator){case"+":return this.right.evaluate(t);case"-":return-this.right.evaluate(t);case"!":return this.right.evaluate(t)?0:1;case"~":return~this.right.evaluate(t);default:throw new Error("Unknown unary operator: "+this.operator)}}},fr=class extends Kh{constructor(t,r,i){super(),this.operator=t,this.left=r,this.right=i}get astNodeType(){return"binaryOp"}evaluate(t){switch(this.operator){case"+":return this.left.evaluate(t)+this.right.evaluate(t);case"-":return this.left.evaluate(t)-this.right.evaluate(t);case"*":return this.left.evaluate(t)*this.right.evaluate(t);case"/":return this.left.evaluate(t)/this.right.evaluate(t);case"%":return this.left.evaluate(t)%this.right.evaluate(t);case"==":return this.left.evaluate(t)==this.right.evaluate(t)?1:0;case"!=":return this.left.evaluate(t)!=this.right.evaluate(t)?1:0;case"<":return this.left.evaluate(t)<this.right.evaluate(t)?1:0;case">":return this.left.evaluate(t)>this.right.evaluate(t)?1:0;case"<=":return this.left.evaluate(t)<=this.right.evaluate(t)?1:0;case">=":return this.left.evaluate(t)>=this.right.evaluate(t)?1:0;case"&&":return this.left.evaluate(t)&&this.right.evaluate(t)?1:0;case"||":return this.left.evaluate(t)||this.right.evaluate(t)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}},$h=class extends Vi{constructor(){super()}},Sy=class extends $h{constructor(t,r){super(),this.selector=t,this.body=r}get astNodeType(){return"case"}},vy=class extends $h{constructor(t){super(),this.body=t}get astNodeType(){return"default"}},Cy=class extends Vi{constructor(t,r,i){super(),this.name=t,this.type=r,this.attributes=i}get astNodeType(){return"argument"}},wy=class extends Vi{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"elseif"}},Py=class extends Vi{constructor(t,r,i){super(),this.name=t,this.type=r,this.attributes=i}get astNodeType(){return"member"}},Jh=class extends Vi{constructor(t,r){super(),this.name=t,this.value=r}get astNodeType(){return"attribute"}},U,I;(function(e){e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(I||(I={}));var R=class{constructor(t,r,i){this.name=t,this.type=r,this.rule=i}toString(){return this.name}},S=class{};U=S;S.none=new R("",I.reserved,"");S.eof=new R("EOF",I.token,"");S.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")};S.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"),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"),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")};S.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,"@"),attr_left:new R("attr_left",I.token,"[["),attr_right:new R("attr_right",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,"<<=")};S.storage_class=[U.keywords.function,U.keywords.private,U.keywords.workgroup,U.keywords.uniform,U.keywords.storage];S.access_mode=[U.keywords.read,U.keywords.write,U.keywords.read_write];S.sampler_type=[U.keywords.sampler,U.keywords.sampler_comparison];S.sampled_texture_type=[U.keywords.texture_1d,U.keywords.texture_2d,U.keywords.texture_2d_array,U.keywords.texture_3d,U.keywords.texture_cube,U.keywords.texture_cube_array];S.multisampled_texture_type=[U.keywords.texture_multisampled_2d];S.storage_texture_type=[U.keywords.texture_storage_1d,U.keywords.texture_storage_2d,U.keywords.texture_storage_2d_array,U.keywords.texture_storage_3d];S.depth_texture_type=[U.keywords.texture_depth_2d,U.keywords.texture_depth_2d_array,U.keywords.texture_depth_cube,U.keywords.texture_depth_cube_array,U.keywords.texture_depth_multisampled_2d];S.texture_external_type=[U.keywords.texture_external];S.any_texture_type=[...U.sampled_texture_type,...U.multisampled_texture_type,...U.storage_texture_type,...U.depth_texture_type,...U.texture_external_type];S.texel_format=[U.keywords.r8unorm,U.keywords.r8snorm,U.keywords.r8uint,U.keywords.r8sint,U.keywords.r16uint,U.keywords.r16sint,U.keywords.r16float,U.keywords.rg8unorm,U.keywords.rg8snorm,U.keywords.rg8uint,U.keywords.rg8sint,U.keywords.r32uint,U.keywords.r32sint,U.keywords.r32float,U.keywords.rg16uint,U.keywords.rg16sint,U.keywords.rg16float,U.keywords.rgba8unorm,U.keywords.rgba8unorm_srgb,U.keywords.rgba8snorm,U.keywords.rgba8uint,U.keywords.rgba8sint,U.keywords.bgra8unorm,U.keywords.bgra8unorm_srgb,U.keywords.rgb10a2unorm,U.keywords.rg11b10float,U.keywords.rg32uint,U.keywords.rg32sint,U.keywords.rg32float,U.keywords.rgba16uint,U.keywords.rgba16sint,U.keywords.rgba16float,U.keywords.rgba32uint,U.keywords.rgba32sint,U.keywords.rgba32float];S.const_literal=[U.tokens.int_literal,U.tokens.uint_literal,U.tokens.decimal_float_literal,U.tokens.hex_float_literal,U.keywords.true,U.keywords.false];S.literal_or_ident=[U.tokens.ident,U.tokens.int_literal,U.tokens.uint_literal,U.tokens.decimal_float_literal,U.tokens.hex_float_literal];S.element_count_expression=[U.tokens.int_literal,U.tokens.uint_literal,U.tokens.ident];S.template_types=[U.keywords.vec2,U.keywords.vec3,U.keywords.vec4,U.keywords.mat2x2,U.keywords.mat2x3,U.keywords.mat2x4,U.keywords.mat3x2,U.keywords.mat3x3,U.keywords.mat3x4,U.keywords.mat4x2,U.keywords.mat4x3,U.keywords.mat4x4,U.keywords.atomic,U.keywords.bitcast,...U.any_texture_type];S.attribute_name=[U.tokens.ident,U.keywords.block];S.assignment_operators=[U.tokens.equal,U.tokens.plus_equal,U.tokens.minus_equal,U.tokens.times_equal,U.tokens.division_equal,U.tokens.modulo_equal,U.tokens.and_equal,U.tokens.or_equal,U.tokens.xor_equal,U.tokens.shift_right_equal,U.tokens.shift_left_equal];S.increment_operators=[U.tokens.plus_plus,U.tokens.minus_minus];var Zh=class{constructor(t,r,i){this.type=t,this.lexeme=r,this.line=i}toString(){return this.lexeme}isTemplateType(){return S.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==S.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},My=class{constructor(t){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=t??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Zh(S.eof,"",this._line)),this._tokens}scanToken(){let t=this._advance();if(t==`
`)return this._line++,!0;if(this._isWhitespace(t))return!0;if(t=="/"){if(this._peekAhead()=="/"){for(;t!=`
`;){if(this._isAtEnd())return!0;t=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let i=1;for(;i>0;){if(this._isAtEnd())return!0;if(t=this._advance(),t==`
`)this._line++;else if(t=="*"){if(this._peekAhead()=="/"&&(this._advance(),i--,i==0))return!0}else t=="/"&&this._peekAhead()=="*"&&(this._advance(),i++)}return!0}}let r=S.none;for(;;){let i=this._findType(t),s=this._peekAhead();if(t==">"&&(s==">"||s=="=")){let n=!1,o=this._tokens.length-1;for(let a=0;a<5&&o>=0;++a,--o)if(this._tokens[o].type===S.tokens.less_than){o>0&&this._tokens[o-1].isArrayOrTemplateType()&&(n=!0);break}if(n)return this._addToken(i),!0}if(i===S.none){let n=t,o=0,a=2;for(let c=0;c<a;++c)if(n+=this._peekAhead(c),i=this._findType(n),i!==S.none){o=c;break}if(i===S.none)return r===S.none?!1:(this._current--,this._addToken(r),!0);t=n,this._current+=o+1}if(r=i,this._isAtEnd())break;t+=this._advance()}return r===S.none?!1:(this._addToken(r),!0)}_findType(t){for(let r in S.keywords){let i=S.keywords[r];if(this._match(t,i.rule))return i}for(let r in S.tokens){let i=S.tokens[r];if(this._match(t,i.rule))return i}return S.none}_match(t,r){if(typeof r=="string"){if(r==t)return!0}else{let i=r.exec(t);if(i&&i.index==0&&i[0]==t)return!0}return!1}_isAtEnd(){return this._current>=this._source.length}_isWhitespace(t){return t==" "||t==" "||t=="\r"}_advance(t=0){let r=this._source[this._current];return t=t||0,t++,this._current+=t,r}_peekAhead(t=0){return t=t||0,this._current+t>=this._source.length?"\0":this._source[this._current+t]}_addToken(t){let r=this._source.substring(this._start,this._current);this._tokens.push(new Zh(t,r,this._line))}},Ry=class{constructor(){this._tokens=[],this._current=0,this._context=new ry}parse(t){this._initialize(t);let r=[];for(;!this._isAtEnd();){let i=this._global_decl_or_directive();if(!i)break;r.push(i)}return r}_initialize(t){if(t)if(typeof t=="string"){let r=new My(t);this._tokens=r.scanTokens()}else this._tokens=t;else this._tokens=[];this._current=0}_error(t,r){return console.error(t,r),{token:t,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==S.eof}_match(t){if(t instanceof R)return this._check(t)?(this._advance(),!0):!1;for(let r=0,i=t.length;r<i;++r){let s=t[r];if(this._check(s))return this._advance(),!0}return!1}_consume(t,r){if(this._check(t))return this._advance();throw this._error(this._peek(),r)}_check(t){if(this._isAtEnd())return!1;let r=this._peek();if(t instanceof Array){let i=r.type;return t.indexOf(i)!=-1}return r.type==t}_advance(){return this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(S.tokens.semicolon)&&!this._isAtEnd(););if(this._match(S.keywords.alias)){let r=this._type_alias();return this._consume(S.tokens.semicolon,"Expected ';'"),r}if(this._match(S.keywords.enable)){let r=this._enable_directive();return this._consume(S.tokens.semicolon,"Expected ';'"),r}let t=this._attribute();if(this._check(S.keywords.var)){let r=this._global_variable_decl();return r!=null&&(r.attributes=t),this._consume(S.tokens.semicolon,"Expected ';'."),r}if(this._check(S.keywords.override)){let r=this._override_variable_decl();return r!=null&&(r.attributes=t),this._consume(S.tokens.semicolon,"Expected ';'."),r}if(this._check(S.keywords.let)){let r=this._global_let_decl();return r!=null&&(r.attributes=t),this._consume(S.tokens.semicolon,"Expected ';'."),r}if(this._check(S.keywords.const)){let r=this._global_const_decl();return r!=null&&(r.attributes=t),this._consume(S.tokens.semicolon,"Expected ';'."),r}if(this._check(S.keywords.struct)){let r=this._struct_decl();return r!=null&&(r.attributes=t),r}if(this._check(S.keywords.fn)){let r=this._function_decl();return r!=null&&(r.attributes=t),r}return null}_function_decl(){if(!this._match(S.keywords.fn))return null;let t=this._consume(S.tokens.ident,"Expected function name.").toString();this._consume(S.tokens.paren_left,"Expected '(' for function arguments.");let r=[];if(!this._check(S.tokens.paren_right))do{if(this._check(S.tokens.paren_right))break;let n=this._attribute(),o=this._consume(S.tokens.ident,"Expected argument name.").toString();this._consume(S.tokens.colon,"Expected ':' for argument type.");let a=this._attribute(),c=this._type_decl();c!=null&&(c.attributes=a,r.push(new Cy(o,c,n)))}while(this._match(S.tokens.comma));this._consume(S.tokens.paren_right,"Expected ')' after function arguments.");let i=null;if(this._match(S.tokens.arrow)){let n=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=n)}let s=this._compound_statement();return new Uh(t,r,i,s)}_compound_statement(){let t=[];for(this._consume(S.tokens.brace_left,"Expected '{' for block.");!this._check(S.tokens.brace_right);){let r=this._statement();r!==null&&t.push(r)}return this._consume(S.tokens.brace_right,"Expected '}' for block."),t}_statement(){for(;this._match(S.tokens.semicolon)&&!this._isAtEnd(););if(this._check(S.keywords.if))return this._if_statement();if(this._check(S.keywords.switch))return this._switch_statement();if(this._check(S.keywords.loop))return this._loop_statement();if(this._check(S.keywords.for))return this._for_statement();if(this._check(S.keywords.while))return this._while_statement();if(this._check(S.keywords.continuing))return this._continuing_statement();if(this._check(S.keywords.static_assert))return this._static_assert_statement();if(this._check(S.tokens.brace_left))return this._compound_statement();let t=null;return this._check(S.keywords.return)?t=this._return_statement():this._check([S.keywords.var,S.keywords.let,S.keywords.const])?t=this._variable_statement():this._match(S.keywords.discard)?t=new gy:this._match(S.keywords.break)?t=new my:this._match(S.keywords.continue)?t=new _y:t=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement(),t!=null&&this._consume(S.tokens.semicolon,"Expected ';' after statement."),t}_static_assert_statement(){if(!this._match(S.keywords.static_assert))return null;let t=this._optional_paren_expression();return new iy(t)}_while_statement(){if(!this._match(S.keywords.while))return null;let t=this._optional_paren_expression(),r=this._compound_statement();return new sy(t,r)}_continuing_statement(){if(!this._match(S.keywords.continuing))return null;let t=this._compound_statement();return new ny(t)}_for_statement(){if(!this._match(S.keywords.for))return null;this._consume(S.tokens.paren_left,"Expected '('.");let t=this._check(S.tokens.semicolon)?null:this._for_init();this._consume(S.tokens.semicolon,"Expected ';'.");let r=this._check(S.tokens.semicolon)?null:this._short_circuit_or_expression();this._consume(S.tokens.semicolon,"Expected ';'.");let i=this._check(S.tokens.paren_right)?null:this._for_increment();this._consume(S.tokens.paren_right,"Expected ')'.");let s=this._compound_statement();return new oy(t,r,i,s)}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(S.keywords.var)){let t=this._variable_decl();if(t===null)throw this._error(this._peek(),"Variable declaration expected.");let r=null;return this._match(S.tokens.equal)&&(r=this._short_circuit_or_expression()),new Rs(t.name,t.type,t.storage,t.access,r)}if(this._match(S.keywords.let)){let t=this._consume(S.tokens.ident,"Expected name for let.").toString(),r=null;if(this._match(S.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}this._consume(S.tokens.equal,"Expected '=' for let.");let i=this._short_circuit_or_expression();return new Vh(t,r,null,null,i)}if(this._match(S.keywords.const)){let t=this._consume(S.tokens.ident,"Expected name for const.").toString(),r=null;if(this._match(S.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}this._consume(S.tokens.equal,"Expected '=' for const.");let i=this._short_circuit_or_expression();return new zh(t,r,null,null,i)}return null}_increment_decrement_statement(){let t=this._current,r=this._unary_expression();if(r==null)return null;if(!this._check(S.increment_operators))return this._current=t,null;let i=this._consume(S.increment_operators,"Expected increment operator");return new ay(i.type===S.tokens.plus_plus?Jo.increment:Jo.decrement,r)}_assignment_statement(){let t=null;if(this._check(S.tokens.brace_right))return null;let r=this._match(S.tokens.underscore);if(r||(t=this._unary_expression()),!r&&t==null)return null;let i=this._consume(S.assignment_operators,"Expected assignment operator."),s=this._short_circuit_or_expression();return new cy(al.parse(i.lexeme),t,s)}_func_call_statement(){if(!this._check(S.tokens.ident))return null;let t=this._current,r=this._consume(S.tokens.ident,"Expected function name."),i=this._argument_expression_list();return i===null?(this._current=t,null):new ly(r.lexeme,i)}_loop_statement(){if(!this._match(S.keywords.loop))return null;this._consume(S.tokens.brace_left,"Expected '{' for loop.");let t=[],r=this._statement();for(;r!==null;){if(Array.isArray(r))for(let s of r)t.push(s);else t.push(r);r=this._statement()}let i=null;return this._match(S.keywords.continuing)&&(i=this._compound_statement()),this._consume(S.tokens.brace_right,"Expected '}' for loop."),new uy(t,i)}_switch_statement(){if(!this._match(S.keywords.switch))return null;let t=this._optional_paren_expression();this._consume(S.tokens.brace_left,"Expected '{' for switch.");let r=this._switch_body();if(r==null||r.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(S.tokens.brace_right,"Expected '}' for switch."),new fy(t,r)}_switch_body(){let t=[];if(this._match(S.keywords.case)){let r=this._case_selectors();this._match(S.tokens.colon),this._consume(S.tokens.brace_left,"Exected '{' for switch case.");let i=this._case_body();this._consume(S.tokens.brace_right,"Exected '}' for switch case."),t.push(new Sy(r,i))}if(this._match(S.keywords.default)){this._match(S.tokens.colon),this._consume(S.tokens.brace_left,"Exected '{' for switch default.");let r=this._case_body();this._consume(S.tokens.brace_right,"Exected '}' for switch default."),t.push(new vy(r))}if(this._check([S.keywords.default,S.keywords.case])){let r=this._switch_body();t.push(r[0])}return t}_case_selectors(){var t,r,i,s;let n=[(r=(t=this._shift_expression())===null||t===void 0?void 0:t.evaluate(this._context).toString())!==null&&r!==void 0?r:""];for(;this._match(S.tokens.comma);)n.push((s=(i=this._shift_expression())===null||i===void 0?void 0:i.evaluate(this._context).toString())!==null&&s!==void 0?s:"");return n}_case_body(){if(this._match(S.keywords.fallthrough))return this._consume(S.tokens.semicolon,"Expected ';'"),[];let t=this._statement();if(t==null)return[];t instanceof Array||(t=[t]);let r=this._case_body();return r.length==0?t:[...t,r[0]]}_if_statement(){if(!this._match(S.keywords.if))return null;let t=this._optional_paren_expression(),r=this._compound_statement(),i=[];this._match_elseif()&&(i=this._elseif_statement(i));let s=null;return this._match(S.keywords.else)&&(s=this._compound_statement()),new hy(t,r,i,s)}_match_elseif(){return this._tokens[this._current].type===S.keywords.else&&this._tokens[this._current+1].type===S.keywords.if?(this._advance(),this._advance(),!0):!1}_elseif_statement(t=[]){let r=this._optional_paren_expression(),i=this._compound_statement();return t.push(new wy(r,i)),this._match_elseif()&&this._elseif_statement(t),t}_return_statement(){if(!this._match(S.keywords.return))return null;let t=this._short_circuit_or_expression();return new dy(t)}_short_circuit_or_expression(){let t=this._short_circuit_and_expr();for(;this._match(S.tokens.or_or);)t=new fr(this._previous().toString(),t,this._short_circuit_and_expr());return t}_short_circuit_and_expr(){let t=this._inclusive_or_expression();for(;this._match(S.tokens.and_and);)t=new fr(this._previous().toString(),t,this._inclusive_or_expression());return t}_inclusive_or_expression(){let t=this._exclusive_or_expression();for(;this._match(S.tokens.or);)t=new fr(this._previous().toString(),t,this._exclusive_or_expression());return t}_exclusive_or_expression(){let t=this._and_expression();for(;this._match(S.tokens.xor);)t=new fr(this._previous().toString(),t,this._and_expression());return t}_and_expression(){let t=this._equality_expression();for(;this._match(S.tokens.and);)t=new fr(this._previous().toString(),t,this._equality_expression());return t}_equality_expression(){let t=this._relational_expression();return this._match([S.tokens.equal_equal,S.tokens.not_equal])?new fr(this._previous().toString(),t,this._relational_expression()):t}_relational_expression(){let t=this._shift_expression();for(;this._match([S.tokens.less_than,S.tokens.greater_than,S.tokens.less_than_equal,S.tokens.greater_than_equal]);)t=new fr(this._previous().toString(),t,this._shift_expression());return t}_shift_expression(){let t=this._additive_expression();for(;this._match([S.tokens.shift_left,S.tokens.shift_right]);)t=new fr(this._previous().toString(),t,this._additive_expression());return t}_additive_expression(){let t=this._multiplicative_expression();for(;this._match([S.tokens.plus,S.tokens.minus]);)t=new fr(this._previous().toString(),t,this._multiplicative_expression());return t}_multiplicative_expression(){let t=this._unary_expression();for(;this._match([S.tokens.star,S.tokens.forward_slash,S.tokens.modulo]);)t=new fr(this._previous().toString(),t,this._unary_expression());return t}_unary_expression(){return this._match([S.tokens.minus,S.tokens.bang,S.tokens.tilde,S.tokens.star,S.tokens.and])?new Ey(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let t=this._primary_expression(),r=this._postfix_expression();return r&&(t.postfix=r),t}_postfix_expression(){if(this._match(S.tokens.bracket_left)){let t=this._short_circuit_or_expression();this._consume(S.tokens.bracket_right,"Expected ']'.");let r=this._postfix_expression();return r&&(t.postfix=r),t}if(this._match(S.tokens.period)){let t=this._consume(S.tokens.ident,"Expected member name."),r=this._postfix_expression(),i=new jh(t.lexeme);return r&&(i.postfix=r),i}return null}_getStruct(t){return this._context.aliases.has(t)?this._context.aliases.get(t).type:this._context.structs.has(t)?this._context.structs.get(t):null}_primary_expression(){if(this._match(S.tokens.ident)){let i=this._previous().toString();if(this._check(S.tokens.paren_left)){let s=this._argument_expression_list(),n=this._getStruct(i);return n!=null?new bn(n,s):new xy(i,s)}if(this._context.constants.has(i)){let s=this._context.constants.get(i);return new Xh(i,s.value)}return new Ay(i)}if(this._match(S.const_literal))return new Yh(parseFloat(this._previous().toString()));if(this._check(S.tokens.paren_left))return this._paren_expression();if(this._match(S.keywords.bitcast)){this._consume(S.tokens.less_than,"Expected '<'.");let i=this._type_decl();this._consume(S.tokens.greater_than,"Expected '>'.");let s=this._paren_expression();return new Ty(i,s)}let t=this._type_decl(),r=this._argument_expression_list();return new by(t,r)}_argument_expression_list(){if(!this._match(S.tokens.paren_left))return null;let t=[];do{if(this._check(S.tokens.paren_right))break;let r=this._short_circuit_or_expression();t.push(r)}while(this._match(S.tokens.comma));return this._consume(S.tokens.paren_right,"Expected ')' for agument list"),t}_optional_paren_expression(){this._match(S.tokens.paren_left);let t=this._short_circuit_or_expression();return this._match(S.tokens.paren_right),new qh([t])}_paren_expression(){this._consume(S.tokens.paren_left,"Expected '('.");let t=this._short_circuit_or_expression();return this._consume(S.tokens.paren_right,"Expected ')'."),new qh([t])}_struct_decl(){if(!this._match(S.keywords.struct))return null;let t=this._consume(S.tokens.ident,"Expected name for struct.").toString();this._consume(S.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(S.tokens.brace_right);){let s=this._attribute(),n=this._consume(S.tokens.ident,"Expected variable name.").toString();this._consume(S.tokens.colon,"Expected ':' for struct member type.");let o=this._attribute(),a=this._type_decl();a!=null&&(a.attributes=o),this._check(S.tokens.brace_right)?this._match(S.tokens.comma):this._consume(S.tokens.comma,"Expected ',' for struct member."),r.push(new Py(n,a,s))}this._consume(S.tokens.brace_right,"Expected '}' after struct body.");let i=new ki(t,r);return this._context.structs.set(t,i),i}_global_variable_decl(){let t=this._variable_decl();return t&&this._match(S.tokens.equal)&&(t.value=this._const_expression()),t}_override_variable_decl(){let t=this._override_decl();return t&&this._match(S.tokens.equal)&&(t.value=this._const_expression()),t}_global_const_decl(){if(!this._match(S.keywords.const))return null;let t=this._consume(S.tokens.ident,"Expected variable name"),r=null;if(this._match(S.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}let i=null;if(this._match(S.tokens.equal)){let n=this._short_circuit_or_expression();if(n instanceof bn)i=n;else if(n instanceof Xh&&n.initializer instanceof bn)i=n.initializer;else try{let o=n.evaluate(this._context);i=new Yh(o)}catch{i=n}}let s=new zh(t.toString(),r,"","",i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match(S.keywords.let))return null;let t=this._consume(S.tokens.ident,"Expected variable name"),r=null;if(this._match(S.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}let i=null;return this._match(S.tokens.equal)&&(i=this._const_expression()),new Vh(t.toString(),r,"","",i)}_const_expression(){if(this._match(S.const_literal))return new jh(this._previous().toString());let t=this._type_decl();this._consume(S.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(S.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(S.tokens.comma));)this._advance();return this._consume(S.tokens.paren_right,"Expected ')'."),new bn(t,r)}_variable_decl(){if(!this._match(S.keywords.var))return null;let t="",r="";this._match(S.tokens.less_than)&&(t=this._consume(S.storage_class,"Expected storage_class.").toString(),this._match(S.tokens.comma)&&(r=this._consume(S.access_mode,"Expected access_mode.").toString()),this._consume(S.tokens.greater_than,"Expected '>'."));let i=this._consume(S.tokens.ident,"Expected variable name"),s=null;if(this._match(S.tokens.colon)){let n=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=n)}return new Rs(i.toString(),s,t,r,null)}_override_decl(){if(!this._match(S.keywords.override))return null;let t=this._consume(S.tokens.ident,"Expected variable name"),r=null;if(this._match(S.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}return new kh(t.toString(),r,null)}_enable_directive(){let t=this._consume(S.tokens.ident,"identity expected.");return new py(t.toString())}_type_alias(){let t=this._consume(S.tokens.ident,"identity expected.");this._consume(S.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 i=new Hh(t.toString(),r);return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([S.tokens.ident,...S.texel_format,S.keywords.bool,S.keywords.f32,S.keywords.i32,S.keywords.u32])){let i=this._advance(),s=i.toString();return this._context.structs.has(s)?this._context.structs.get(s):this._context.aliases.has(s)?this._context.aliases.get(s).type:new zi(i.toString())}let t=this._texture_sampler_types();if(t)return t;if(this._check(S.template_types)){let i=this._advance().toString(),s=null,n=null;return this._match(S.tokens.less_than)&&(s=this._type_decl(),n=null,this._match(S.tokens.comma)&&(n=this._consume(S.access_mode,"Expected access_mode for pointer").toString()),this._consume(S.tokens.greater_than,"Expected '>' for type.")),new Gh(i,s,n)}if(this._match(S.keywords.ptr)){let i=this._previous().toString();this._consume(S.tokens.less_than,"Expected '<' for pointer.");let s=this._consume(S.storage_class,"Expected storage_class for pointer");this._consume(S.tokens.comma,"Expected ',' for pointer.");let n=this._type_decl(),o=null;return this._match(S.tokens.comma)&&(o=this._consume(S.access_mode,"Expected access_mode for pointer").toString()),this._consume(S.tokens.greater_than,"Expected '>' for pointer."),new yy(i,s.toString(),n,o)}let r=this._attribute();if(this._match(S.keywords.array)){let i=null,s=-1,n=this._previous();if(this._match(S.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let o="";this._match(S.tokens.comma)&&(o=this._shift_expression().evaluate(this._context).toString()),this._consume(S.tokens.greater_than,"Expected '>' for array."),s=o?parseInt(o):0}return new Wh(n.toString(),r,i,s)}return null}_texture_sampler_types(){if(this._match(S.sampler_type))return new Tn(this._previous().toString(),null,null);if(this._match(S.depth_texture_type))return new Tn(this._previous().toString(),null,null);if(this._match(S.sampled_texture_type)||this._match(S.multisampled_texture_type)){let t=this._previous();this._consume(S.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(S.tokens.greater_than,"Expected '>' for sampler type."),new Tn(t.toString(),r,null)}if(this._match(S.storage_texture_type)){let t=this._previous();this._consume(S.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(S.texel_format,"Invalid texel format.").toString();this._consume(S.tokens.comma,"Expected ',' after texel format.");let i=this._consume(S.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(S.tokens.greater_than,"Expected '>' for sampler type."),new Tn(t.toString(),r,i)}return null}_attribute(){let t=[];for(;this._match(S.tokens.attr);){let r=this._consume(S.attribute_name,"Expected attribute name"),i=new Jh(r.toString(),null);if(this._match(S.tokens.paren_left)){if(i.value=this._consume(S.literal_or_ident,"Expected attribute value").toString(),this._check(S.tokens.comma)){this._advance();do{let s=this._consume(S.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(s)}while(this._match(S.tokens.comma))}this._consume(S.tokens.paren_right,"Expected ')'")}t.push(i)}for(;this._match(S.tokens.attr_left);){if(!this._check(S.tokens.attr_right))do{let r=this._consume(S.attribute_name,"Expected attribute name"),i=new Jh(r.toString(),null);if(this._match(S.tokens.paren_left)){if(i.value=[this._consume(S.literal_or_ident,"Expected attribute value").toString()],this._check(S.tokens.comma)){this._advance();do{let s=this._consume(S.literal_or_ident,"Expected attribute value").toString();i.value.push(s)}while(this._match(S.tokens.comma))}this._consume(S.tokens.paren_right,"Expected ')'")}t.push(i)}while(this._match(S.tokens.comma));this._consume(S.tokens.attr_right,"Expected ']]' after attribute declarations")}return t.length==0?null:t}},Is=class{constructor(t,r){this.name=t,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Qh=class{constructor(t,r,i){this.name=t,this.type=r,this.attributes=i,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}},qo=class extends Is{constructor(t,r){super(t,r),this.members=[],this.align=0}get isStruct(){return!0}},ol=class extends Is{constructor(t,r){super(t,r),this.count=0,this.stride=0}get isArray(){return!0}},td=class extends Is{constructor(t,r,i,s){super(t,i),this.format=r,this.access=s}get isTemplate(){return!0}},Ms;(function(e){e[e.Uniform=0]="Uniform",e[e.Storage=1]="Storage",e[e.Texture=2]="Texture",e[e.Sampler=3]="Sampler",e[e.StorageTexture=4]="StorageTexture"})(Ms||(Ms={}));var Ko=class{constructor(t,r,i,s,n,o,a){this.name=t,this.type=r,this.group=i,this.binding=s,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}},Iy=class{constructor(t,r){this.name=t,this.type=r}},$o=class{constructor(t,r){this.align=t,this.size=r}},By=class{constructor(t,r,i,s){this.name=t,this.type=r,this.locationType=i,this.location=s,this.interpolation=null}},ed=class{constructor(t,r,i,s){this.name=t,this.type=r,this.locationType=i,this.location=s}},Oy=class{constructor(t,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.name=t,this.stage=r}},Fy=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},Ny=class{constructor(t,r,i,s){this.name=t,this.type=r,this.attributes=i,this.id=s}},hr=class{constructor(t){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Fy,this._types=new Map,t&&this.update(t)}_isStorageTexture(t){return t.name=="texture_storage_1d"||t.name=="texture_storage_2d"||t.name=="texture_storage_2d_array"||t.name=="texture_storage_3d"}update(t){let i=new Ry().parse(t);for(let s of i){if(s instanceof ki){let n=this._getTypeInfo(s,null);n instanceof qo&&this.structs.push(n);continue}if(s instanceof Hh){this.aliases.push(this._getAliasInfo(s));continue}if(s instanceof kh){let n=s,o=this._getAttributeNum(n.attributes,"id",0),a=n.type!=null?this._getTypeInfo(n.type,n.attributes):null;this.overrides.push(new Ny(n.name,a,n.attributes,o));continue}if(this._isUniformVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new Ko(n.name,c,o,a,n.attributes,Ms.Uniform,n.access);this.uniforms.push(l);continue}if(this._isStorageVar(s)){let n=s,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 Ko(n.name,c,o,a,n.attributes,l?Ms.StorageTexture:Ms.Storage,n.access);this.storage.push(u);continue}if(this._isTextureVar(s)){let n=s,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 Ko(n.name,c,o,a,n.attributes,l?Ms.StorageTexture:Ms.Texture,n.access);l?this.storage.push(u):this.textures.push(u);continue}if(this._isSamplerVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new Ko(n.name,c,o,a,n.attributes,Ms.Sampler,n.access);this.samplers.push(l);continue}if(s instanceof Uh){let n=this._getAttribute(s,"vertex"),o=this._getAttribute(s,"fragment"),a=this._getAttribute(s,"compute"),c=n||o||a;if(c){let l=new Oy(s.name,c.name);l.inputs=this._getInputs(s.args),l.outputs=this._getOutputs(s.returnType),this.entry[c.name].push(l)}continue}}}getBindGroups(){let t=[];function r(i,s){i>=t.length&&(t.length=i+1),t[i]===void 0&&(t[i]=[]),s>=t[i].length&&(t[i].length=s+1)}for(let i of this.uniforms){r(i.group,i.binding);let s=t[i.group];s[i.binding]=i}for(let i of this.storage){r(i.group,i.binding);let s=t[i.group];s[i.binding]=i}for(let i of this.textures){r(i.group,i.binding);let s=t[i.group];s[i.binding]=i}for(let i of this.samplers){r(i.group,i.binding);let s=t[i.group];s[i.binding]=i}return t}_getOutputs(t,r=void 0){if(r===void 0&&(r=[]),t instanceof ki)this._getStructOutputs(t,r);else{let i=this._getOutputInfo(t);i!==null&&r.push(i)}return r}_getStructOutputs(t,r){for(let i of t.members)if(i.type instanceof ki)this._getStructOutputs(i.type,r);else{let s=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(s!==null){let n=this._getTypeInfo(i.type,i.type.attributes),o=this._parseInt(s.value),a=new ed(i.name,n,s.name,o);r.push(a)}}}_getOutputInfo(t){let r=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(r!==null){let i=this._getTypeInfo(t,t.attributes),s=this._parseInt(r.value);return new ed("",i,r.name,s)}return null}_getInputs(t,r=void 0){r===void 0&&(r=[]);for(let i of t)if(i.type instanceof ki)this._getStructInputs(i.type,r);else{let s=this._getInputInfo(i);s!==null&&r.push(s)}return r}_getStructInputs(t,r){for(let i of t.members)if(i.type instanceof ki)this._getStructInputs(i.type,r);else{let s=this._getInputInfo(i);s!==null&&r.push(s)}}_getInputInfo(t){let r=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(r!==null){let i=this._getAttribute(t,"interpolation"),s=this._getTypeInfo(t.type,t.attributes),n=this._parseInt(r.value),o=new By(t.name,s,r.name,n);return i!==null&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(t){return t instanceof Array&&(t=t[0]),t}_parseInt(t){t instanceof Array&&(t=t[0]);let r=parseInt(t);return isNaN(r)?t:r}_getAlias(t){for(let r of this.aliases)if(r.name==t)return r.type;return null}_getAliasInfo(t){return new Iy(t.name,this._getTypeInfo(t.type,null))}_getTypeInfo(t,r){if(this._types.has(t))return this._types.get(t);if(t instanceof Wh){let s=t,n=this._getTypeInfo(s.format,s.attributes),o=new ol(s.name,r);return o.format=n,o.count=s.count,this._types.set(t,o),this._updateTypeInfo(o),o}if(t instanceof ki){let s=t,n=new qo(s.name,r);for(let o of s.members){let a=this._getTypeInfo(o.type,o.attributes);n.members.push(new Qh(o.name,a,o.attributes))}return this._types.set(t,n),this._updateTypeInfo(n),n}if(t instanceof Tn){let s=t,n=s.format instanceof zi,o=s.format?n?this._getTypeInfo(s.format,null):new Is(s.format,null):null,a=new td(s.name,o,r,s.access);return this._types.set(t,a),this._updateTypeInfo(a),a}if(t instanceof Gh){let s=t,n=s.format?this._getTypeInfo(s.format,null):null,o=new td(s.name,n,r,s.access);return this._types.set(t,o),this._updateTypeInfo(o),o}let i=new Is(t.name,r);return this._types.set(t,i),this._updateTypeInfo(i),i}_updateTypeInfo(t){var r,i;let s=this._getTypeSize(t);if(t.size=(r=s?.size)!==null&&r!==void 0?r:0,t instanceof ol){let n=this._getTypeSize(t.format);t.stride=(i=n?.size)!==null&&i!==void 0?i:0,this._updateTypeInfo(t.format)}t instanceof qo&&this._updateStructInfo(t)}_updateStructInfo(t){var r;let i=0,s=0,n=0,o=0;for(let a=0,c=t.members.length;a<c;++a){let l=t.members[a],u=this._getTypeSize(l);if(!u)continue;(r=this._getAlias(l.type.name))!==null&&r!==void 0||l.type;let f=u.align,h=u.size;i=this._roundUp(f,i+s),s=h,n=i,o=Math.max(o,f),l.offset=i,l.size=h,this._updateTypeInfo(l.type)}t.size=this._roundUp(o,n+s),t.align=o}_getTypeSize(t){var r;if(t==null)return null;let i=this._getAttributeNum(t.attributes,"size",0),s=this._getAttributeNum(t.attributes,"align",0);if(t instanceof Qh&&(t=t.type),t instanceof Is){let n=this._getAlias(t.name);n!==null&&(t=n)}{let n=hr._typeInfo[t.name];if(n!==void 0){let o=t.format==="f16"?2:1;return new $o(Math.max(s,n.align/o),Math.max(i,n.size/o))}}{let n=hr._typeInfo[t.name.substring(0,t.name.length-1)];if(n){let o=t.name[t.name.length-1]==="h"?2:1;return new $o(Math.max(s,n.align/o),Math.max(i,n.size/o))}}if(t instanceof ol){let n=t,o=8,a=8,c=this._getTypeSize(n.format);c!==null&&(a=c.size,o=c.align);let l=n.count,u=this._getAttributeNum((r=t?.attributes)!==null&&r!==void 0?r:null,"stride",this._roundUp(o,a));return a=l*u,i&&(a=i),new $o(Math.max(s,o),Math.max(i,a))}if(t instanceof qo){let n=0,o=0,a=0,c=0,l=0;for(let u of t.members){let f=this._getTypeSize(u.type);f!==null&&(n=Math.max(f.align,n),a=this._roundUp(f.align,a+c),c=f.size,l=a)}return o=this._roundUp(n,l+c),new $o(Math.max(s,n),Math.max(i,o))}return null}_isUniformVar(t){return t instanceof Rs&&t.storage=="uniform"}_isStorageVar(t){return t instanceof Rs&&t.storage=="storage"}_isTextureVar(t){return t instanceof Rs&&t.type!==null&&hr._textureTypes.indexOf(t.type.name)!=-1}_isSamplerVar(t){return t instanceof Rs&&t.type!==null&&hr._samplerTypes.indexOf(t.type.name)!=-1}_getAttribute(t,r){let i=t;if(!i||!i.attributes)return null;let s=i.attributes;for(let n of s)if(n.name==r)return n;return null}_getAttributeNum(t,r,i){if(t===null)return i;for(let s of t)if(s.name==r){let n=s!==null&&s.value!==null?s.value:i;return n instanceof Array&&(n=n[0]),typeof n=="number"?n:typeof n=="string"?parseInt(n):i}return i}_roundUp(t,r){return Math.ceil(r/t)*t}};hr._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}};hr._textureTypes=S.any_texture_type.map(e=>e.name);hr._samplerTypes=S.sampler_type.map(e=>e.name);function Ly(e){let t={attributes:[],bindings:[]},r;try{r=EU(e)}catch(n){return D.error(n.message)(),t}for(let n of r.uniforms){let o=[];for(let a of n.type.members)o.push({name:a.name,type:cv(a.type)});t.bindings.push({type:"uniform",name:n.name,location:n.binding,group:n.group,members:o})}let i=r.entry.vertex[0],s=i?.inputs.length||0;for(let n=0;n<s;n++){let o=i.inputs[n];if(o.locationType==="location"){let a=cv(o.type);t.attributes.push({name:o.name,location:o.location,type:a})}}return t}function cv(e){return e.format?`${e.name}<${e.format.name}>`:e.name}function EU(e){try{return new hr(e)}catch(t){if(t instanceof Error)throw t;let r="WGSL parse error";throw typeof t=="object"&&t?.message&&(r+=`: ${t.message} `),typeof t=="object"&&t?.token&&(r+=t.token.line||""),new Error(r,{cause:t})}}var SU=`#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
}
`,Dy={name:"fp32",vs:SU};var vU=new Float32Array([0,1,1,1]),CU=`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;
}
}
`,wU=`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);
}
`,rd={name:"picking",vs:CU,fs:wU,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:new Float32Array([0,0,0]),highlightColor:vU},getUniforms:PU};function PU(e={},t){let r={};if(e.highlightedObjectColor!==void 0)if(e.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let i=e.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=i}if(e.highlightColor){let i=Array.from(e.highlightColor,s=>s/255);Number.isFinite(i[3])||(i[3]=1),r.highlightColor=i}return e.isActive!==void 0&&(r.isActive=Boolean(e.isActive),r.isAttribute=Boolean(e.isAttribute)),e.useFloatColors!==void 0&&(r.useFloatColors=Boolean(e.useFloatColors)),r}function id(e,t=[],r=0){let i=Math.fround(e),s=e-i;return t[r]=i,t[r+1]=s,t}function Uy(e){return e-Math.fround(e)}function ky(e){let t=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let s=r*4+i;id(e[i*4+r],t,s*2)}return t}var lv=`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 uv=`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 MU={ONE:1};function RU(){return MU}var Hi={name:"fp64-arithmetic",vs:lv,getUniforms:RU,fp64ify:id,fp64LowPart:Uy,fp64ifyMatrix4:ky},sd={name:"fp64",vs:uv,dependencies:[Hi],fp64ify:id,fp64LowPart:Uy,fp64ifyMatrix4:ky};var IU=1/Math.PI*180,BU=1/180*Math.PI,OU={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...OU}};var St=globalThis.mathgl.config;function cl(e,{precision:t=St.precision}={}){return e=FU(e),`${parseFloat(e.toPrecision(t))}`}function tr(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Vy(e){return En(e)}function zy(e){return Zt(e)}function En(e,t){return Hy(e,r=>r*BU,t)}function Zt(e,t){return Hy(e,r=>r*IU,t)}function ht(e,t,r){return Hy(e,i=>Math.max(t,Math.min(r,i)))}function se(e,t,r){return tr(e)?e.map((i,s)=>se(i,t[s],r)):r*t+(1-r)*e}function Ct(e,t,r){let i=St.EPSILON;r&&(St.EPSILON=r);try{if(e===t)return!0;if(tr(e)&&tr(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!Ct(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=St.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{St.EPSILON=i}}function FU(e){return Math.round(e/St.EPSILON)*St.EPSILON}function NU(e){return e.clone?e.clone():new Array(e.length)}function Hy(e,t,r){if(tr(e)){let i=e;r=r||NU(i);for(let s=0;s<r.length&&s<i.length;++s){let n=typeof e=="number"?e:e[s];r[s]=t(n,s,r)}return r}return t(e)}var Bs=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=t[i+r];return this.check()}toArray(t=[],r=0){for(let i=0;i<this.ELEMENTS;++i)t[r+i]=this[i];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:tr(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(St)}formatString(t){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+cl(this[i],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Ct(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,i){if(i===void 0)return this.lerp(this,t,r);for(let s=0;s<this.ELEMENTS;++s){let n=t[s],o=typeof r=="number"?r:r[s];this[s]=n+i*(o-n)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],t[i]),r[i]);return this.check()}add(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(St.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=t;return this.check()}addScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],t),r);return this.check()}get elements(){return this}};function LU(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function ct(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Os(e,t,r=""){if(St.debug&&!LU(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}function fe(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Fs=class extends Bs{get x(){return this[0]}set x(t){this[0]=ct(t)}get y(){return this[1]}set y(t){this[1]=ct(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let i=0;i<this.ELEMENTS;++i){let s=this[i]-t[i];r+=s*s}return ct(r)}dot(t){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*t[i];return ct(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return fe(t>=0&&t<this.ELEMENTS,"index is out of range"),ct(this[t])}setComponent(t,r){return fe(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){return this.add(new this.constructor(t).multiplyScalar(r))}};var Qt={};$t(Qt,{add:()=>zU,angle:()=>i4,ceil:()=>HU,clone:()=>DU,copy:()=>kU,create:()=>fv,cross:()=>QU,dist:()=>h4,distance:()=>gv,div:()=>f4,divide:()=>pv,dot:()=>ZU,equals:()=>a4,exactEquals:()=>o4,floor:()=>GU,forEach:()=>g4,fromValues:()=>UU,inverse:()=>$U,len:()=>c4,length:()=>_v,lerp:()=>t4,max:()=>jU,min:()=>WU,mul:()=>u4,multiply:()=>dv,negate:()=>KU,normalize:()=>JU,random:()=>e4,rotate:()=>r4,round:()=>XU,scale:()=>YU,scaleAndAdd:()=>qU,set:()=>VU,sqrDist:()=>d4,sqrLen:()=>p4,squaredDistance:()=>mv,squaredLength:()=>yv,str:()=>n4,sub:()=>l4,subtract:()=>hv,transformMat2:()=>Gy,transformMat2d:()=>Wy,transformMat3:()=>ll,transformMat4:()=>ul,zero:()=>s4});var wt=typeof Float32Array<"u"?Float32Array:Array,_i=Math.random;function pr(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var cct=Math.PI/180;function fv(){let e=new wt(2);return wt!=Float32Array&&(e[0]=0,e[1]=0),e}function DU(e){let t=new wt(2);return t[0]=e[0],t[1]=e[1],t}function UU(e,t){let r=new wt(2);return r[0]=e,r[1]=t,r}function kU(e,t){return e[0]=t[0],e[1]=t[1],e}function VU(e,t,r){return e[0]=t,e[1]=r,e}function zU(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function hv(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function dv(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function pv(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function HU(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function GU(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function WU(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function jU(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function XU(e,t){return e[0]=pr(t[0]),e[1]=pr(t[1]),e}function YU(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function qU(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e}function gv(e,t){let r=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(r*r+i*i)}function mv(e,t){let r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i}function _v(e){let t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function yv(e){let t=e[0],r=e[1];return t*t+r*r}function KU(e,t){return e[0]=-t[0],e[1]=-t[1],e}function $U(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function JU(e,t){let r=t[0],i=t[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e}function ZU(e,t){return e[0]*t[0]+e[1]*t[1]}function QU(e,t,r){let i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e}function t4(e,t,r,i){let s=t[0],n=t[1];return e[0]=s+i*(r[0]-s),e[1]=n+i*(r[1]-n),e}function e4(e,t){t=t===void 0?1:t;let r=_i()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function Gy(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e}function Wy(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s+r[4],e[1]=r[1]*i+r[3]*s+r[5],e}function ll(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[3]*s+r[6],e[1]=r[1]*i+r[4]*s+r[7],e}function ul(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[4]*s+r[12],e[1]=r[1]*i+r[5]*s+r[13],e}function r4(e,t,r,i){let s=t[0]-r[0],n=t[1]-r[1],o=Math.sin(i),a=Math.cos(i);return e[0]=s*a-n*o+r[0],e[1]=s*o+n*a+r[1],e}function i4(e,t){let r=e[0],i=e[1],s=t[0],n=t[1],o=Math.sqrt((r*r+i*i)*(s*s+n*n)),a=o&&(r*s+i*n)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function s4(e){return e[0]=0,e[1]=0,e}function n4(e){return`vec2(${e[0]}, ${e[1]})`}function o4(e,t){return e[0]===t[0]&&e[1]===t[1]}function a4(e,t){let r=e[0],i=e[1],s=t[0],n=t[1];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var c4=_v,l4=hv,u4=dv,f4=pv,h4=gv,d4=mv,p4=yv,g4=function(){let e=fv();return function(t,r,i,s,n,o){let a,c;for(r||(r=2),i||(i=0),s?c=Math.min(s*r+i,t.length):c=t.length,a=i;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],n(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}}();function nd(e,t,r){let i=t[0],s=t[1],n=r[3]*i+r[7]*s||1;return e[0]=(r[0]*i+r[4]*s)/n,e[1]=(r[1]*i+r[5]*s)/n,e}function od(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[3]*i+r[7]*s+r[11]*n||1;return e[0]=(r[0]*i+r[4]*s+r[8]*n)/o,e[1]=(r[1]*i+r[5]*s+r[9]*n)/o,e[2]=(r[2]*i+r[6]*s+r[10]*n)/o,e}function xv(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e[2]=t[2],e}function Av(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e[2]=t[2],e[3]=t[3],e}function ad(e,t,r){let i=t[0],s=t[1],n=t[2];return e[0]=r[0]*i+r[3]*s+r[6]*n,e[1]=r[1]*i+r[4]*s+r[7]*n,e[2]=r[2]*i+r[5]*s+r[8]*n,e[3]=t[3],e}var Fr=class extends Fs{constructor(t=0,r=0){super(2),tr(t)&&arguments.length===1?this.copy(t):(St.debug&&(ct(t),ct(r)),this[0]=t,this[1]=r)}set(t,r){return this[0]=t,this[1]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return St.debug&&(ct(t.x),ct(t.y)),this[0]=t.x,this[1]=t.y,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return ul(this,this,t),this.check()}transformAsVector(t){return nd(this,this,t),this.check()}transformByMatrix3(t){return ll(this,this,t),this.check()}transformByMatrix2x3(t){return Wy(this,this,t),this.check()}transformByMatrix2(t){return Gy(this,this,t),this.check()}};var jt={};$t(jt,{add:()=>x4,angle:()=>Ky,bezier:()=>B4,ceil:()=>A4,clone:()=>m4,copy:()=>_4,create:()=>cd,cross:()=>Sn,dist:()=>z4,distance:()=>Sv,div:()=>V4,divide:()=>Ev,dot:()=>fl,equals:()=>D4,exactEquals:()=>L4,floor:()=>T4,forEach:()=>W4,fromValues:()=>ud,hermite:()=>I4,inverse:()=>P4,len:()=>$y,length:()=>ld,lerp:()=>M4,max:()=>E4,min:()=>b4,mul:()=>k4,multiply:()=>bv,negate:()=>w4,normalize:()=>jy,random:()=>O4,rotateX:()=>Xy,rotateY:()=>Yy,rotateZ:()=>qy,round:()=>S4,scale:()=>v4,scaleAndAdd:()=>C4,set:()=>y4,slerp:()=>R4,sqrDist:()=>H4,sqrLen:()=>G4,squaredDistance:()=>vv,squaredLength:()=>Cv,str:()=>N4,sub:()=>U4,subtract:()=>Tv,transformMat3:()=>hl,transformMat4:()=>vn,transformQuat:()=>dl,zero:()=>F4});function cd(){let e=new wt(3);return wt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function m4(e){let t=new wt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function ld(e){let t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function ud(e,t,r){let i=new wt(3);return i[0]=e,i[1]=t,i[2]=r,i}function _4(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function y4(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e}function x4(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Tv(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function bv(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Ev(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function A4(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function T4(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function b4(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function E4(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function S4(e,t){return e[0]=pr(t[0]),e[1]=pr(t[1]),e[2]=pr(t[2]),e}function v4(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function C4(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function Sv(e,t){let r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(r*r+i*i+s*s)}function vv(e,t){let r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return r*r+i*i+s*s}function Cv(e){let t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i}function w4(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function P4(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function jy(e,t){let r=t[0],i=t[1],s=t[2],n=r*r+i*i+s*s;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function fl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Sn(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[0],a=r[1],c=r[2];return e[0]=s*c-n*a,e[1]=n*o-i*c,e[2]=i*a-s*o,e}function M4(e,t,r,i){let s=t[0],n=t[1],o=t[2];return e[0]=s+i*(r[0]-s),e[1]=n+i*(r[1]-n),e[2]=o+i*(r[2]-o),e}function R4(e,t,r,i){let s=Math.acos(Math.min(Math.max(fl(t,r),-1),1)),n=Math.sin(s),o=Math.sin((1-i)*s)/n,a=Math.sin(i*s)/n;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function I4(e,t,r,i,s,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 e[0]=t[0]*a+r[0]*c+i[0]*l+s[0]*u,e[1]=t[1]*a+r[1]*c+i[1]*l+s[1]*u,e[2]=t[2]*a+r[2]*c+i[2]*l+s[2]*u,e}function B4(e,t,r,i,s,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 e[0]=t[0]*l+r[0]*u+i[0]*f+s[0]*h,e[1]=t[1]*l+r[1]*u+i[1]*f+s[1]*h,e[2]=t[2]*l+r[2]*u+i[2]*f+s[2]*h,e}function O4(e,t){t=t===void 0?1:t;let r=_i()*2*Math.PI,i=_i()*2-1,s=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(r)*s,e[1]=Math.sin(r)*s,e[2]=i*t,e}function vn(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[3]*i+r[7]*s+r[11]*n+r[15];return o=o||1,e[0]=(r[0]*i+r[4]*s+r[8]*n+r[12])/o,e[1]=(r[1]*i+r[5]*s+r[9]*n+r[13])/o,e[2]=(r[2]*i+r[6]*s+r[10]*n+r[14])/o,e}function hl(e,t,r){let i=t[0],s=t[1],n=t[2];return e[0]=i*r[0]+s*r[3]+n*r[6],e[1]=i*r[1]+s*r[4]+n*r[7],e[2]=i*r[2]+s*r[5]+n*r[8],e}function dl(e,t,r){let i=r[0],s=r[1],n=r[2],o=r[3],a=t[0],c=t[1],l=t[2],u=s*l-n*c,f=n*a-i*l,h=i*c-s*a,d=s*h-n*f,p=n*u-i*h,g=i*f-s*u,m=o*2;return u*=m,f*=m,h*=m,d*=2,p*=2,g*=2,e[0]=a+u+d,e[1]=c+f+p,e[2]=l+h+g,e}function Xy(e,t,r,i){let s=[],n=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],n[0]=s[0],n[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),n[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Yy(e,t,r,i){let s=[],n=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],n[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),n[1]=s[1],n[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function qy(e,t,r,i){let s=[],n=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],n[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),n[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),n[2]=s[2],e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Ky(e,t){let r=e[0],i=e[1],s=e[2],n=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+i*i+s*s)*(n*n+o*o+a*a)),l=c&&fl(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function F4(e){return e[0]=0,e[1]=0,e[2]=0,e}function N4(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function L4(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function D4(e,t){let r=e[0],i=e[1],s=e[2],n=t[0],o=t[1],a=t[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var U4=Tv,k4=bv,V4=Ev,z4=Sv,H4=vv,$y=ld,G4=Cv,W4=function(){let e=cd();return function(t,r,i,s,n,o){let a,c;for(r||(r=3),i||(i=0),s?c=Math.min(s*r+i,t.length):c=t.length,a=i;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],n(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}}();var Jy=[0,0,0],fd,w=class extends Fs{static get ZERO(){return fd||(fd=new w(0,0,0),Object.freeze(fd)),fd}constructor(t=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&tr(t)?this.copy(t):(St.debug&&(ct(t),ct(r),ct(i)),this[0]=t,this[1]=r,this[2]=i)}set(t,r,i){return this[0]=t,this[1]=r,this[2]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return St.debug&&(ct(t.x),ct(t.y),ct(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=ct(t)}angle(t){return Ky(this,t)}cross(t){return Sn(this,this,t),this.check()}rotateX({radians:t,origin:r=Jy}){return Xy(this,this,r,t),this.check()}rotateY({radians:t,origin:r=Jy}){return Yy(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=Jy}){return qy(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return vn(this,this,t),this.check()}transformAsVector(t){return od(this,this,t),this.check()}transformByMatrix3(t){return hl(this,this,t),this.check()}transformByMatrix2(t){return xv(this,this,t),this.check()}transformByQuaternion(t){return dl(this,this,t),this.check()}};var hd,Qo=class extends Fs{static get ZERO(){return hd||(hd=new Qo(0,0,0,0),Object.freeze(hd)),hd}constructor(t=0,r=0,i=0,s=0){super(-0,-0,-0,-0),tr(t)&&arguments.length===1?this.copy(t):(St.debug&&(ct(t),ct(r),ct(i),ct(s)),this[0]=t,this[1]=r,this[2]=i,this[3]=s)}set(t,r,i,s){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return St.debug&&(ct(t.x),ct(t.y),ct(t.z),ct(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=ct(t)}get w(){return this[3]}set w(t){this[3]=ct(t)}transform(t){return vn(this,this,t),this.check()}transformByMatrix3(t){return ad(this,this,t),this.check()}transformByMatrix2(t){return Av(this,this,t),this.check()}transformByQuaternion(t){return dl(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var ta=class extends Bs{toString(){let t="[";if(St.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)t+=` ${this[i*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,i){return this[r*this.RANK+t]=ct(i),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let i=t*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[i+s];return r}setColumn(t,r){let i=t*this.RANK;for(let s=0;s<this.RANK;++s)this[i+s]=r[s];return this}};function wv(){let e=new wt(9);return wt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Pv(e,t){if(e===t){let r=t[1],i=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function Mv(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=u*o-a*l,h=-u*n+a*c,d=l*n-o*c,p=r*f+i*h+s*d;return p?(p=1/p,e[0]=f*p,e[1]=(-u*i+s*l)*p,e[2]=(a*i-s*o)*p,e[3]=h*p,e[4]=(u*r-s*c)*p,e[5]=(-a*r+s*n)*p,e[6]=d*p,e[7]=(-l*r+i*c)*p,e[8]=(o*r-i*n)*p,e):null}function Rv(e){let t=e[0],r=e[1],i=e[2],s=e[3],n=e[4],o=e[5],a=e[6],c=e[7],l=e[8];return t*(l*n-o*c)+r*(-l*s+o*a)+i*(c*s-n*a)}function Zy(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=r[0],d=r[1],p=r[2],g=r[3],m=r[4],_=r[5],y=r[6],x=r[7],E=r[8];return e[0]=h*i+d*o+p*l,e[1]=h*s+d*a+p*u,e[2]=h*n+d*c+p*f,e[3]=g*i+m*o+_*l,e[4]=g*s+m*a+_*u,e[5]=g*n+m*c+_*f,e[6]=y*i+x*o+E*l,e[7]=y*s+x*a+E*u,e[8]=y*n+x*c+E*f,e}function Iv(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=r[0],d=r[1];return e[0]=i,e[1]=s,e[2]=n,e[3]=o,e[4]=a,e[5]=c,e[6]=h*i+d*o+l,e[7]=h*s+d*a+u,e[8]=h*n+d*c+f,e}function Bv(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=Math.sin(r),d=Math.cos(r);return e[0]=d*i+h*o,e[1]=d*s+h*a,e[2]=d*n+h*c,e[3]=d*o-h*i,e[4]=d*a-h*s,e[5]=d*c-h*n,e[6]=l,e[7]=u,e[8]=f,e}function Qy(e,t,r){let i=r[0],s=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Ov(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r+r,a=i+i,c=s+s,l=r*o,u=i*o,f=i*a,h=s*o,d=s*a,p=s*c,g=n*o,m=n*a,_=n*c;return e[0]=1-f-p,e[3]=u-_,e[6]=h+m,e[1]=u+_,e[4]=1-l-p,e[7]=d-g,e[2]=h-m,e[5]=d+g,e[8]=1-l-f,e}var tx;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(tx||(tx={}));var X4=Object.freeze([1,0,0,0,1,0,0,0,1]),mt=class extends ta{static get IDENTITY(){return q4()}static get ZERO(){return Y4()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return tx}constructor(t,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):r.length>0?this.copy([t,...r]):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}identity(){return this.copy(X4)}fromObject(t){return this.check()}fromQuaternion(t){return Ov(this,t),this.check()}set(t,r,i,s,n,o,a,c,l){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,this[4]=n,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(t,r,i,s,n,o,a,c,l){return this[0]=t,this[1]=s,this[2]=a,this[3]=r,this[4]=n,this[5]=c,this[6]=i,this[7]=o,this[8]=l,this.check()}determinant(){return Rv(this)}transpose(){return Pv(this,this),this.check()}invert(){return Mv(this,this),this.check()}multiplyLeft(t){return Zy(this,t,this),this.check()}multiplyRight(t){return Zy(this,this,t),this.check()}rotate(t){return Bv(this,this,t),this.check()}scale(t){return Array.isArray(t)?Qy(this,this,t):Qy(this,this,[t,t]),this.check()}translate(t){return Iv(this,this,t),this.check()}transform(t,r){let i;switch(t.length){case 2:i=ll(r||[-0,-0],t,this);break;case 3:i=hl(r||[-0,-0,-0],t,this);break;case 4:i=ad(r||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Os(i,t.length),i}transformVector(t,r){return this.transform(t,r)}transformVector2(t,r){return this.transform(t,r)}transformVector3(t,r){return this.transform(t,r)}},dd,pd=null;function Y4(){return dd||(dd=new mt([0,0,0,0,0,0,0,0,0]),Object.freeze(dd)),dd}function q4(){return pd||(pd=new mt,Object.freeze(pd)),pd}var Vt={};$t(Vt,{add:()=>x6,adjoint:()=>t6,clone:()=>$4,copy:()=>J4,create:()=>K4,decompose:()=>u6,determinant:()=>ix,equals:()=>E6,exactEquals:()=>b6,frob:()=>y6,fromQuat:()=>ux,fromQuat2:()=>a6,fromRotation:()=>i6,fromRotationTranslation:()=>Nv,fromRotationTranslationScale:()=>f6,fromRotationTranslationScaleOrigin:()=>h6,fromScaling:()=>r6,fromTranslation:()=>e6,fromValues:()=>Z4,fromXRotation:()=>s6,fromYRotation:()=>n6,fromZRotation:()=>o6,frustum:()=>fx,getRotation:()=>l6,getScaling:()=>Lv,getTranslation:()=>c6,identity:()=>Fv,invert:()=>rx,lookAt:()=>px,mul:()=>S6,multiply:()=>pl,multiplyScalar:()=>A6,multiplyScalarAndAdd:()=>T6,ortho:()=>dx,orthoNO:()=>Uv,orthoZO:()=>g6,perspective:()=>hx,perspectiveFromFieldOfView:()=>p6,perspectiveNO:()=>Dv,perspectiveZO:()=>d6,rotate:()=>ox,rotateX:()=>ax,rotateY:()=>cx,rotateZ:()=>lx,scale:()=>nx,set:()=>Q4,str:()=>_6,sub:()=>v6,subtract:()=>kv,targetTo:()=>m6,translate:()=>sx,transpose:()=>ex});function K4(){let e=new wt(16);return wt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function $4(e){let t=new wt(16);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 J4(e,t){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 Z4(e,t,r,i,s,n,o,a,c,l,u,f,h,d,p,g){let m=new wt(16);return m[0]=e,m[1]=t,m[2]=r,m[3]=i,m[4]=s,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 Q4(e,t,r,i,s,n,o,a,c,l,u,f,h,d,p,g,m){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e[4]=n,e[5]=o,e[6]=a,e[7]=c,e[8]=l,e[9]=u,e[10]=f,e[11]=h,e[12]=d,e[13]=p,e[14]=g,e[15]=m,e}function Fv(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ex(e,t){if(e===t){let r=t[1],i=t[2],s=t[3],n=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=n,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function rx(e,t){let r=t[0],i=t[1],s=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=r*a-i*o,x=r*c-s*o,E=r*l-n*o,P=i*c-s*a,B=i*l-n*a,F=s*l-n*c,M=u*g-f*p,v=u*m-h*p,T=u*_-d*p,L=f*m-h*g,V=f*_-d*g,z=h*_-d*m,W=y*z-x*V+E*L+P*T-B*v+F*M;return W?(W=1/W,e[0]=(a*z-c*V+l*L)*W,e[1]=(s*V-i*z-n*L)*W,e[2]=(g*F-m*B+_*P)*W,e[3]=(h*B-f*F-d*P)*W,e[4]=(c*T-o*z-l*v)*W,e[5]=(r*z-s*T+n*v)*W,e[6]=(m*E-p*F-_*x)*W,e[7]=(u*F-h*E+d*x)*W,e[8]=(o*V-a*T+l*M)*W,e[9]=(i*T-r*V-n*M)*W,e[10]=(p*B-g*E+_*y)*W,e[11]=(f*E-u*B-d*y)*W,e[12]=(a*v-o*L-c*M)*W,e[13]=(r*L-i*v+s*M)*W,e[14]=(g*x-p*P-m*y)*W,e[15]=(u*P-f*x+h*y)*W,e):null}function t6(e,t){let r=t[0],i=t[1],s=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=r*a-i*o,x=r*c-s*o,E=r*l-n*o,P=i*c-s*a,B=i*l-n*a,F=s*l-n*c,M=u*g-f*p,v=u*m-h*p,T=u*_-d*p,L=f*m-h*g,V=f*_-d*g,z=h*_-d*m;return e[0]=a*z-c*V+l*L,e[1]=s*V-i*z-n*L,e[2]=g*F-m*B+_*P,e[3]=h*B-f*F-d*P,e[4]=c*T-o*z-l*v,e[5]=r*z-s*T+n*v,e[6]=m*E-p*F-_*x,e[7]=u*F-h*E+d*x,e[8]=o*V-a*T+l*M,e[9]=i*T-r*V-n*M,e[10]=p*B-g*E+_*y,e[11]=f*E-u*B-d*y,e[12]=a*v-o*L-c*M,e[13]=r*L-i*v+s*M,e[14]=g*x-p*P-m*y,e[15]=u*P-f*x+h*y,e}function ix(e){let t=e[0],r=e[1],i=e[2],s=e[3],n=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],p=e[13],g=e[14],m=e[15],_=t*o-r*n,y=t*a-i*n,x=r*a-i*o,E=l*p-u*d,P=l*g-f*d,B=u*g-f*p,F=t*B-r*P+i*E,M=n*B-o*P+a*E,v=l*x-u*y+f*_,T=d*x-p*y+g*_;return c*F-s*M+m*v-h*T}function pl(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=t[9],d=t[10],p=t[11],g=t[12],m=t[13],_=t[14],y=t[15],x=r[0],E=r[1],P=r[2],B=r[3];return e[0]=x*i+E*a+P*f+B*g,e[1]=x*s+E*c+P*h+B*m,e[2]=x*n+E*l+P*d+B*_,e[3]=x*o+E*u+P*p+B*y,x=r[4],E=r[5],P=r[6],B=r[7],e[4]=x*i+E*a+P*f+B*g,e[5]=x*s+E*c+P*h+B*m,e[6]=x*n+E*l+P*d+B*_,e[7]=x*o+E*u+P*p+B*y,x=r[8],E=r[9],P=r[10],B=r[11],e[8]=x*i+E*a+P*f+B*g,e[9]=x*s+E*c+P*h+B*m,e[10]=x*n+E*l+P*d+B*_,e[11]=x*o+E*u+P*p+B*y,x=r[12],E=r[13],P=r[14],B=r[15],e[12]=x*i+E*a+P*f+B*g,e[13]=x*s+E*c+P*h+B*m,e[14]=x*n+E*l+P*d+B*_,e[15]=x*o+E*u+P*p+B*y,e}function sx(e,t,r){let i=r[0],s=r[1],n=r[2],o,a,c,l,u,f,h,d,p,g,m,_;return t===e?(e[12]=t[0]*i+t[4]*s+t[8]*n+t[12],e[13]=t[1]*i+t[5]*s+t[9]*n+t[13],e[14]=t[2]*i+t[6]*s+t[10]*n+t[14],e[15]=t[3]*i+t[7]*s+t[11]*n+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],u=t[4],f=t[5],h=t[6],d=t[7],p=t[8],g=t[9],m=t[10],_=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=u,e[5]=f,e[6]=h,e[7]=d,e[8]=p,e[9]=g,e[10]=m,e[11]=_,e[12]=o*i+u*s+p*n+t[12],e[13]=a*i+f*s+g*n+t[13],e[14]=c*i+h*s+m*n+t[14],e[15]=l*i+d*s+_*n+t[15]),e}function nx(e,t,r){let i=r[0],s=r[1],n=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ox(e,t,r,i){let s=i[0],n=i[1],o=i[2],a=Math.sqrt(s*s+n*n+o*o),c,l,u,f,h,d,p,g,m,_,y,x,E,P,B,F,M,v,T,L,V,z,W,Z;return a<1e-6?null:(a=1/a,s*=a,n*=a,o*=a,l=Math.sin(r),c=Math.cos(r),u=1-c,f=t[0],h=t[1],d=t[2],p=t[3],g=t[4],m=t[5],_=t[6],y=t[7],x=t[8],E=t[9],P=t[10],B=t[11],F=s*s*u+c,M=n*s*u+o*l,v=o*s*u-n*l,T=s*n*u-o*l,L=n*n*u+c,V=o*n*u+s*l,z=s*o*u+n*l,W=n*o*u-s*l,Z=o*o*u+c,e[0]=f*F+g*M+x*v,e[1]=h*F+m*M+E*v,e[2]=d*F+_*M+P*v,e[3]=p*F+y*M+B*v,e[4]=f*T+g*L+x*V,e[5]=h*T+m*L+E*V,e[6]=d*T+_*L+P*V,e[7]=p*T+y*L+B*V,e[8]=f*z+g*W+x*Z,e[9]=h*z+m*W+E*Z,e[10]=d*z+_*W+P*Z,e[11]=p*z+y*W+B*Z,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function ax(e,t,r){let i=Math.sin(r),s=Math.cos(r),n=t[4],o=t[5],a=t[6],c=t[7],l=t[8],u=t[9],f=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=n*s+l*i,e[5]=o*s+u*i,e[6]=a*s+f*i,e[7]=c*s+h*i,e[8]=l*s-n*i,e[9]=u*s-o*i,e[10]=f*s-a*i,e[11]=h*s-c*i,e}function cx(e,t,r){let i=Math.sin(r),s=Math.cos(r),n=t[0],o=t[1],a=t[2],c=t[3],l=t[8],u=t[9],f=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=n*s-l*i,e[1]=o*s-u*i,e[2]=a*s-f*i,e[3]=c*s-h*i,e[8]=n*i+l*s,e[9]=o*i+u*s,e[10]=a*i+f*s,e[11]=c*i+h*s,e}function lx(e,t,r){let i=Math.sin(r),s=Math.cos(r),n=t[0],o=t[1],a=t[2],c=t[3],l=t[4],u=t[5],f=t[6],h=t[7];return t!==e&&(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[0]=n*s+l*i,e[1]=o*s+u*i,e[2]=a*s+f*i,e[3]=c*s+h*i,e[4]=l*s-n*i,e[5]=u*s-o*i,e[6]=f*s-a*i,e[7]=h*s-c*i,e}function e6(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function r6(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function i6(e,t,r){let i=r[0],s=r[1],n=r[2],o=Math.sqrt(i*i+s*s+n*n),a,c,l;return o<1e-6?null:(o=1/o,i*=o,s*=o,n*=o,c=Math.sin(t),a=Math.cos(t),l=1-a,e[0]=i*i*l+a,e[1]=s*i*l+n*c,e[2]=n*i*l-s*c,e[3]=0,e[4]=i*s*l-n*c,e[5]=s*s*l+a,e[6]=n*s*l+i*c,e[7]=0,e[8]=i*n*l+s*c,e[9]=s*n*l-i*c,e[10]=n*n*l+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function s6(e,t){let r=Math.sin(t),i=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function n6(e,t){let r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function o6(e,t){let r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Nv(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=i+i,c=s+s,l=n+n,u=i*a,f=i*c,h=i*l,d=s*c,p=s*l,g=n*l,m=o*a,_=o*c,y=o*l;return e[0]=1-(d+g),e[1]=f+y,e[2]=h-_,e[3]=0,e[4]=f-y,e[5]=1-(u+g),e[6]=p+m,e[7]=0,e[8]=h+_,e[9]=p-m,e[10]=1-(u+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function a6(e,t){let r=new wt(3),i=-t[0],s=-t[1],n=-t[2],o=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=i*i+s*s+n*n+o*o;return f>0?(r[0]=(a*o+u*i+c*n-l*s)*2/f,r[1]=(c*o+u*s+l*i-a*n)*2/f,r[2]=(l*o+u*n+a*s-c*i)*2/f):(r[0]=(a*o+u*i+c*n-l*s)*2,r[1]=(c*o+u*s+l*i-a*n)*2,r[2]=(l*o+u*n+a*s-c*i)*2),Nv(e,t,r),e}function c6(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Lv(e,t){let r=t[0],i=t[1],s=t[2],n=t[4],o=t[5],a=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(r*r+i*i+s*s),e[1]=Math.sqrt(n*n+o*o+a*a),e[2]=Math.sqrt(c*c+l*l+u*u),e}function l6(e,t){let r=new wt(3);Lv(r,t);let i=1/r[0],s=1/r[1],n=1/r[2],o=t[0]*i,a=t[1]*s,c=t[2]*n,l=t[4]*i,u=t[5]*s,f=t[6]*n,h=t[8]*i,d=t[9]*s,p=t[10]*n,g=o+u+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,e[3]=.25*m,e[0]=(f-d)/m,e[1]=(h-c)/m,e[2]=(a-l)/m):o>u&&o>p?(m=Math.sqrt(1+o-u-p)*2,e[3]=(f-d)/m,e[0]=.25*m,e[1]=(a+l)/m,e[2]=(h+c)/m):u>p?(m=Math.sqrt(1+u-o-p)*2,e[3]=(h-c)/m,e[0]=(a+l)/m,e[1]=.25*m,e[2]=(f+d)/m):(m=Math.sqrt(1+p-o-u)*2,e[3]=(a-l)/m,e[0]=(h+c)/m,e[1]=(f+d)/m,e[2]=.25*m),e}function u6(e,t,r,i){t[0]=i[12],t[1]=i[13],t[2]=i[14];let s=i[0],n=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],h=i[10];r[0]=Math.sqrt(s*s+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=s*d,_=n*p,y=o*g,x=a*d,E=c*p,P=l*g,B=u*d,F=f*p,M=h*g,v=m+E+M,T=0;return v>0?(T=Math.sqrt(v+1)*2,e[3]=.25*T,e[0]=(P-F)/T,e[1]=(B-y)/T,e[2]=(_-x)/T):m>E&&m>M?(T=Math.sqrt(1+m-E-M)*2,e[3]=(P-F)/T,e[0]=.25*T,e[1]=(_+x)/T,e[2]=(B+y)/T):E>M?(T=Math.sqrt(1+E-m-M)*2,e[3]=(B-y)/T,e[0]=(_+x)/T,e[1]=.25*T,e[2]=(P+F)/T):(T=Math.sqrt(1+M-m-E)*2,e[3]=(_-x)/T,e[0]=(B+y)/T,e[1]=(P+F)/T,e[2]=.25*T),e}function f6(e,t,r,i){let s=t[0],n=t[1],o=t[2],a=t[3],c=s+s,l=n+n,u=o+o,f=s*c,h=s*l,d=s*u,p=n*l,g=n*u,m=o*u,_=a*c,y=a*l,x=a*u,E=i[0],P=i[1],B=i[2];return e[0]=(1-(p+m))*E,e[1]=(h+x)*E,e[2]=(d-y)*E,e[3]=0,e[4]=(h-x)*P,e[5]=(1-(f+m))*P,e[6]=(g+_)*P,e[7]=0,e[8]=(d+y)*B,e[9]=(g-_)*B,e[10]=(1-(f+p))*B,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function h6(e,t,r,i,s){let n=t[0],o=t[1],a=t[2],c=t[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,E=c*f,P=i[0],B=i[1],F=i[2],M=s[0],v=s[1],T=s[2],L=(1-(g+_))*P,V=(d+E)*P,z=(p-x)*P,W=(d-E)*B,Z=(1-(h+_))*B,ut=(m+y)*B,st=(p+x)*F,Rt=(m-y)*F,gt=(1-(h+g))*F;return e[0]=L,e[1]=V,e[2]=z,e[3]=0,e[4]=W,e[5]=Z,e[6]=ut,e[7]=0,e[8]=st,e[9]=Rt,e[10]=gt,e[11]=0,e[12]=r[0]+M-(L*M+W*v+st*T),e[13]=r[1]+v-(V*M+Z*v+Rt*T),e[14]=r[2]+T-(z*M+ut*v+gt*T),e[15]=1,e}function ux(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r+r,a=i+i,c=s+s,l=r*o,u=i*o,f=i*a,h=s*o,d=s*a,p=s*c,g=n*o,m=n*a,_=n*c;return e[0]=1-f-p,e[1]=u+_,e[2]=h-m,e[3]=0,e[4]=u-_,e[5]=1-l-p,e[6]=d+g,e[7]=0,e[8]=h+m,e[9]=d-g,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function fx(e,t,r,i,s,n,o){let a=1/(r-t),c=1/(s-i),l=1/(n-o);return e[0]=n*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(s+i)*c,e[10]=(o+n)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*n*2*l,e[15]=0,e}function Dv(e,t,r,i,s){let n=1/Math.tan(t/2);if(e[0]=n/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(i-s);e[10]=(s+i)*o,e[14]=2*s*i*o}else e[10]=-1,e[14]=-2*i;return e}var hx=Dv;function d6(e,t,r,i,s){let n=1/Math.tan(t/2);if(e[0]=n/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(i-s);e[10]=s*o,e[14]=s*i*o}else e[10]=-1,e[14]=-i;return e}function p6(e,t,r,i){let s=Math.tan(t.upDegrees*Math.PI/180),n=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(s+n);return e[0]=c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-((o-a)*c*.5),e[9]=(s-n)*l*.5,e[10]=i/(r-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*r/(r-i),e[15]=0,e}function Uv(e,t,r,i,s,n,o){let a=1/(t-r),c=1/(i-s),l=1/(n-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(s+i)*c,e[14]=(o+n)*l,e[15]=1,e}var dx=Uv;function g6(e,t,r,i,s,n,o){let a=1/(t-r),c=1/(i-s),l=1/(n-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*a,e[13]=(s+i)*c,e[14]=n*l,e[15]=1,e}function px(e,t,r,i){let s,n,o,a,c,l,u,f,h,d,p=t[0],g=t[1],m=t[2],_=i[0],y=i[1],x=i[2],E=r[0],P=r[1],B=r[2];return Math.abs(p-E)<1e-6&&Math.abs(g-P)<1e-6&&Math.abs(m-B)<1e-6?Fv(e):(f=p-E,h=g-P,d=m-B,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,n=y*d-x*h,o=x*f-_*d,a=_*h-y*f,s=Math.sqrt(n*n+o*o+a*a),s?(s=1/s,n*=s,o*=s,a*=s):(n=0,o=0,a=0),c=h*a-d*o,l=d*n-f*a,u=f*o-h*n,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),e[0]=n,e[1]=c,e[2]=f,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(n*p+o*g+a*m),e[13]=-(c*p+l*g+u*m),e[14]=-(f*p+h*g+d*m),e[15]=1,e)}function m6(e,t,r,i){let s=t[0],n=t[1],o=t[2],a=i[0],c=i[1],l=i[2],u=s-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),e[0]=p,e[1]=g,e[2]=m,e[3]=0,e[4]=f*m-h*g,e[5]=h*p-u*m,e[6]=u*g-f*p,e[7]=0,e[8]=u,e[9]=f,e[10]=h,e[11]=0,e[12]=s,e[13]=n,e[14]=o,e[15]=1,e}function _6(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function y6(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function x6(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function kv(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function A6(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function T6(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e[9]=t[9]+r[9]*i,e[10]=t[10]+r[10]*i,e[11]=t[11]+r[11]*i,e[12]=t[12]+r[12]*i,e[13]=t[13]+r[13]*i,e[14]=t[14]+r[14]*i,e[15]=t[15]+r[15]*i,e}function b6(e,t){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]}function E6(e,t){let r=e[0],i=e[1],s=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=t[0],x=t[1],E=t[2],P=t[3],B=t[4],F=t[5],M=t[6],v=t[7],T=t[8],L=t[9],V=t[10],z=t[11],W=t[12],Z=t[13],ut=t[14],st=t[15];return Math.abs(r-y)<=1e-6*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-x)<=1e-6*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&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-F)<=1e-6*Math.max(1,Math.abs(a),Math.abs(F))&&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-L)<=1e-6*Math.max(1,Math.abs(f),Math.abs(L))&&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-ut)<=1e-6*Math.max(1,Math.abs(m),Math.abs(ut))&&Math.abs(_-st)<=1e-6*Math.max(1,Math.abs(_),Math.abs(st))}var S6=pl,v6=kv;var Be={};$t(Be,{add:()=>gx,ceil:()=>C6,clone:()=>zv,copy:()=>Gv,create:()=>Vv,cross:()=>F6,dist:()=>H6,distance:()=>qv,div:()=>z6,divide:()=>Yv,dot:()=>yx,equals:()=>U6,exactEquals:()=>$v,floor:()=>w6,forEach:()=>X6,fromValues:()=>Hv,inverse:()=>O6,len:()=>W6,length:()=>gd,lerp:()=>xx,max:()=>M6,min:()=>P6,mul:()=>V6,multiply:()=>Xv,negate:()=>B6,normalize:()=>_x,random:()=>N6,round:()=>R6,scale:()=>mx,scaleAndAdd:()=>I6,set:()=>Wv,sqrDist:()=>G6,sqrLen:()=>j6,squaredDistance:()=>Kv,squaredLength:()=>md,str:()=>D6,sub:()=>k6,subtract:()=>jv,transformMat4:()=>Ax,transformQuat:()=>Tx,zero:()=>L6});function Vv(){let e=new wt(4);return wt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function zv(e){let t=new wt(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Hv(e,t,r,i){let s=new wt(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function Gv(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Wv(e,t,r,i,s){return e[0]=t,e[1]=r,e[2]=i,e[3]=s,e}function gx(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function jv(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function Xv(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function Yv(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function C6(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function w6(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function P6(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function M6(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function R6(e,t){return e[0]=pr(t[0]),e[1]=pr(t[1]),e[2]=pr(t[2]),e[3]=pr(t[3]),e}function mx(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function I6(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e}function qv(e,t){let r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2],n=t[3]-e[3];return Math.sqrt(r*r+i*i+s*s+n*n)}function Kv(e,t){let r=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2],n=t[3]-e[3];return r*r+i*i+s*s+n*n}function gd(e){let t=e[0],r=e[1],i=e[2],s=e[3];return Math.sqrt(t*t+r*r+i*i+s*s)}function md(e){let t=e[0],r=e[1],i=e[2],s=e[3];return t*t+r*r+i*i+s*s}function B6(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function O6(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function _x(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r*r+i*i+s*s+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=i*o,e[2]=s*o,e[3]=n*o,e}function yx(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function F6(e,t,r,i){let s=r[0]*i[1]-r[1]*i[0],n=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],u=t[0],f=t[1],h=t[2],d=t[3];return e[0]=f*l-h*c+d*a,e[1]=-(u*l)+h*o-d*n,e[2]=u*c-f*o+d*s,e[3]=-(u*a)+f*n-h*s,e}function xx(e,t,r,i){let s=t[0],n=t[1],o=t[2],a=t[3];return e[0]=s+i*(r[0]-s),e[1]=n+i*(r[1]-n),e[2]=o+i*(r[2]-o),e[3]=a+i*(r[3]-a),e}function N6(e,t){t=t===void 0?1:t;let r,i,s,n,o,a;do r=_i()*2-1,i=_i()*2-1,o=r*r+i*i;while(o>=1);do s=_i()*2-1,n=_i()*2-1,a=s*s+n*n;while(a>=1);let c=Math.sqrt((1-o)/a);return e[0]=t*r,e[1]=t*i,e[2]=t*s*c,e[3]=t*n*c,e}function Ax(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3];return e[0]=r[0]*i+r[4]*s+r[8]*n+r[12]*o,e[1]=r[1]*i+r[5]*s+r[9]*n+r[13]*o,e[2]=r[2]*i+r[6]*s+r[10]*n+r[14]*o,e[3]=r[3]*i+r[7]*s+r[11]*n+r[15]*o,e}function Tx(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[0],a=r[1],c=r[2],l=r[3],u=l*i+a*n-c*s,f=l*s+c*i-o*n,h=l*n+o*s-a*i,d=-o*i-a*s-c*n;return e[0]=u*l+d*-o+f*-c-h*-a,e[1]=f*l+d*-a+h*-o-u*-c,e[2]=h*l+d*-c+u*-a-f*-o,e[3]=t[3],e}function L6(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function D6(e){return`vec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}function $v(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function U6(e,t){let r=e[0],i=e[1],s=e[2],n=e[3],o=t[0],a=t[1],c=t[2],l=t[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var k6=jv,V6=Xv,z6=Yv,H6=qv,G6=Kv,W6=gd,j6=md,X6=function(){let e=Vv();return function(t,r,i,s,n,o){let a,c;for(r||(r=4),i||(i=0),s?c=Math.min(s*r+i,t.length):c=t.length,a=i;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],n(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}}();var Sx;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Sx||(Sx={}));var Y6=45*Math.PI/180,q6=1,bx=.1,Ex=500,K6=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),q=class extends ta{static get IDENTITY(){return J6()}static get ZERO(){return $6()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Sx}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,i,s,n,o,a,c,l,u,f,h,d,p,g,m){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,this[4]=n,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=h,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(t,r,i,s,n,o,a,c,l,u,f,h,d,p,g,m){return this[0]=t,this[1]=n,this[2]=l,this[3]=d,this[4]=r,this[5]=o,this[6]=u,this[7]=p,this[8]=i,this[9]=a,this[10]=f,this[11]=g,this[12]=s,this[13]=c,this[14]=h,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(K6)}fromObject(t){return this.check()}fromQuaternion(t){return ux(this,t),this.check()}frustum(t){let{left:r,right:i,bottom:s,top:n,near:o=bx,far:a=Ex}=t;return a===1/0?Z6(this,r,i,s,n,o):fx(this,r,i,s,n,o,a),this.check()}lookAt(t){let{eye:r,center:i=[0,0,0],up:s=[0,1,0]}=t;return px(this,r,i,s),this.check()}ortho(t){let{left:r,right:i,bottom:s,top:n,near:o=bx,far:a=Ex}=t;return dx(this,r,i,s,n,o,a),this.check()}orthographic(t){let{fovy:r=Y6,aspect:i=q6,focalDistance:s=1,near:n=bx,far:o=Ex}=t;Jv(r);let a=r/2,c=s*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:n,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:i=1,near:s=.1,far:n=500}=t;return Jv(r),hx(this,r,i,s,n),this.check()}determinant(){return ix(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),s=1/i[0],n=1/i[1],o=1/i[2];return t[0]=this[0]*s,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*n,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*n,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),s=1/i[0],n=1/i[1],o=1/i[2];return t[0]=this[0]*s,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*n,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*n,t[8]=this[10]*o,t}transpose(){return ex(this,this),this.check()}invert(){return rx(this,this),this.check()}multiplyLeft(t){return pl(this,t,this),this.check()}multiplyRight(t){return pl(this,this,t),this.check()}rotateX(t){return ax(this,this,t),this.check()}rotateY(t){return cx(this,this,t),this.check()}rotateZ(t){return lx(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return ox(this,this,t,r),this.check()}scale(t){return nx(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return sx(this,this,t),this.check()}transform(t,r){return t.length===4?(r=Ax(r||[-0,-0,-0,-0],t,this),Os(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:i}=t,s;switch(i){case 2:s=ul(r||[-0,-0],t,this);break;case 3:s=vn(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Os(s,t.length),s}transformAsVector(t,r){let i;switch(t.length){case 2:i=nd(r||[-0,-0],t,this);break;case 3:i=od(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Os(i,t.length),i}transformPoint(t,r){return this.transformAsPoint(t,r)}transformVector(t,r){return this.transformAsPoint(t,r)}transformDirection(t,r){return this.transformAsVector(t,r)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,i){return this.identity().translate([t,r,i])}},_d,yd;function $6(){return _d||(_d=new q([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(_d)),_d}function J6(){return yd||(yd=new q,Object.freeze(yd)),yd}function Jv(e){if(e>Math.PI*2)throw Error("expected radians")}function Z6(e,t,r,i,s,n){let o=2*n/(r-t),a=2*n/(s-i),c=(r+t)/(r-t),l=(s+i)/(s-i),u=-1,f=-1,h=-2*n;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=f,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}function Zv(){let e=new wt(4);return wt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Qv(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function vx(e,t,r){r=r*.5;let i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function Cx(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=r[0],c=r[1],l=r[2],u=r[3];return e[0]=i*u+o*a+s*l-n*c,e[1]=s*u+o*c+n*a-i*l,e[2]=n*u+o*l+i*c-s*a,e[3]=o*u-i*a-s*c-n*l,e}function tC(e,t,r){r*=.5;let i=t[0],s=t[1],n=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=i*c+o*a,e[1]=s*c+n*a,e[2]=n*c-s*a,e[3]=o*c-i*a,e}function eC(e,t,r){r*=.5;let i=t[0],s=t[1],n=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=i*c-n*a,e[1]=s*c+o*a,e[2]=n*c+i*a,e[3]=o*c-s*a,e}function rC(e,t,r){r*=.5;let i=t[0],s=t[1],n=t[2],o=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=i*c+s*a,e[1]=s*c-i*a,e[2]=n*c+o*a,e[3]=o*c-n*a,e}function iC(e,t){let r=t[0],i=t[1],s=t[2];return e[0]=r,e[1]=i,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-s*s)),e}function gl(e,t,r,i){let s=t[0],n=t[1],o=t[2],a=t[3],c=r[0],l=r[1],u=r[2],f=r[3],h,d,p,g,m;return h=s*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-i)*d)/m,g=Math.sin(i*d)/m):(p=1-i,g=i),e[0]=p*s+g*c,e[1]=p*n+g*l,e[2]=p*o+g*u,e[3]=p*a+g*f,e}function sC(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r*r+i*i+s*s+n*n,a=o?1/o:0;return e[0]=-r*a,e[1]=-i*a,e[2]=-s*a,e[3]=n*a,e}function nC(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function wx(e,t){let r=t[0]+t[4]+t[8],i;if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let n=(s+1)%3,o=(s+2)%3;i=Math.sqrt(t[s*3+s]-t[n*3+n]-t[o*3+o]+1),e[s]=.5*i,i=.5/i,e[3]=(t[n*3+o]-t[o*3+n])*i,e[n]=(t[n*3+s]+t[s*3+n])*i,e[o]=(t[o*3+s]+t[s*3+o])*i}return e}var oC=gx;var aC=mx,cC=yx,lC=xx,uC=gd;var fC=md;var hC=_x;var dC=function(){let e=cd(),t=ud(1,0,0),r=ud(0,1,0);return function(i,s,n){let o=fl(s,n);return o<-.999999?(Sn(e,t,s),$y(e)<1e-6&&Sn(e,r,s),jy(e,e),vx(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Sn(e,s,n),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,hC(i,i))}}(),Yct=function(){let e=Zv(),t=Zv();return function(r,i,s,n,o,a){return gl(e,i,o,a),gl(t,s,n,a),gl(r,e,t,2*a*(1-a)),r}}(),qct=function(){let e=wv();return function(t,r,i,s){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],hC(t,wx(t,e))}}();var Q6=[0,0,0,1],gr=class extends Bs{constructor(t=0,r=0,i=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,i,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,i,s){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return wx(this,t),this.check()}fromAxisRotation(t,r){return vx(this,t,r),this.check()}identity(){return Qv(this),this.check()}setAxisAngle(t,r){return this.fromAxisRotation(t,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=ct(t)}get y(){return this[1]}set y(t){this[1]=ct(t)}get z(){return this[2]}set z(t){this[2]=ct(t)}get w(){return this[3]}set w(t){this[3]=ct(t)}len(){return uC(this)}lengthSquared(){return fC(this)}dot(t){return cC(this,t)}rotationTo(t,r){return dC(this,t,r),this.check()}add(t){return oC(this,this,t),this.check()}calculateW(){return iC(this,this),this.check()}conjugate(){return nC(this,this),this.check()}invert(){return sC(this,this),this.check()}lerp(t,r,i){return i===void 0?this.lerp(this,t,r):(lC(this,t,r,i),this.check())}multiplyRight(t){return Cx(this,this,t),this.check()}multiplyLeft(t){return Cx(this,t,this),this.check()}normalize(){let t=this.len(),r=t>0?1/t:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,t===0&&(this[3]=1),this.check()}rotateX(t){return tC(this,this,t),this.check()}rotateY(t){return eC(this,this,t),this.check()}rotateZ(t){return rC(this,this,t),this.check()}scale(t){return aC(this,this,t),this.check()}slerp(t,r,i){let s,n,o;switch(arguments.length){case 1:({start:s=Q6,target:n,ratio:o}=t);break;case 2:s=this,n=t,o=r;break;default:s=t,n=r,o=i}return gl(this,s,n,o),this.check()}transformVector4(t,r=new Qo){return Tx(r,t,this),Os(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,r){return this.setAxisAngle(t,r)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var pC=1e-6,tk=6371e3,Nr=class{constructor({phi:t=0,theta:r=0,radius:i=1,bearing:s,pitch:n,altitude:o,radiusScale:a=tk}={}){this.phi=t,this.theta=r,this.radius=i||o||1,this.radiusScale=a||1,s!==void 0&&(this.bearing=s),n!==void 0&&(this.pitch=n),this.check()}toString(){return this.formatString(St)}formatString({printTypes:t=!1}){let r=cl;return`${t?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(t){return Ct(this.radius,t.radius)&&Ct(this.theta,t.theta)&&Ct(this.phi,t.phi)}exactEquals(t){return this.radius===t.radius&&this.theta===t.theta&&this.phi===t.phi}get bearing(){return 180-Zt(this.phi)}set bearing(t){this.phi=Math.PI-En(t)}get pitch(){return Zt(this.theta)}set pitch(t){this.theta=En(t)}get longitude(){return Zt(this.phi)}get latitude(){return Zt(this.theta)}get lng(){return Zt(this.phi)}get lat(){return Zt(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(t,r,i){return this.radius=t,this.phi=r,this.theta=i,this.check()}clone(){return new Nr().copy(this)}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this.check()}fromLngLatZ([t,r,i]){return this.radius=1+i/this.radiusScale,this.phi=En(r),this.theta=En(t),this.check()}fromVector3(t){return this.radius=ld(t),this.radius>0&&(this.theta=Math.atan2(t[0],t[1]),this.phi=Math.acos(ht(t[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(pC,Math.min(Math.PI-pC,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 mr={};$t(mr,{EPSILON1:()=>ek,EPSILON10:()=>uk,EPSILON11:()=>fk,EPSILON12:()=>hk,EPSILON13:()=>dk,EPSILON14:()=>pk,EPSILON15:()=>gk,EPSILON16:()=>mk,EPSILON17:()=>_k,EPSILON18:()=>yk,EPSILON19:()=>xk,EPSILON2:()=>rk,EPSILON20:()=>Ak,EPSILON3:()=>ik,EPSILON4:()=>sk,EPSILON5:()=>nk,EPSILON6:()=>ok,EPSILON7:()=>ak,EPSILON8:()=>ck,EPSILON9:()=>lk,PI_OVER_FOUR:()=>bk,PI_OVER_SIX:()=>Ek,PI_OVER_TWO:()=>Tk,TWO_PI:()=>Sk});var ek=.1,rk=.01,ik=.001,sk=1e-4,nk=1e-5,ok=1e-6,ak=1e-7,ck=1e-8,lk=1e-9,uk=1e-10,fk=1e-11,hk=1e-12,dk=1e-13,pk=1e-14,gk=1e-15,mk=1e-16,_k=1e-17,yk=1e-18,xk=1e-19,Ak=1e-20,Tk=Math.PI/2,bk=Math.PI/4,Ek=Math.PI/6,Sk=Math.PI*2;var Px=`#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 vk={lightSources:{}};function Mx(e={}){let{color:t=[0,0,0],intensity:r=1}=e;return t.map(i=>i*r/255)}function Ck({ambientLight:e,pointLights:t=[],directionalLights:r=[]}){let i={};return e?i["lighting_uAmbientLight.color"]=Mx(e):i["lighting_uAmbientLight.color"]=[0,0,0],t.forEach((s,n)=>{i[`lighting_uPointLight[${n}].color`]=Mx(s),i[`lighting_uPointLight[${n}].position`]=s.position,i[`lighting_uPointLight[${n}].attenuation`]=s.attenuation||[1,0,0]}),i.lighting_uPointLightCount=t.length,r.forEach((s,n)=>{i[`lighting_uDirectionalLight[${n}].color`]=Mx(s),i[`lighting_uDirectionalLight[${n}].direction`]=s.direction}),i.lighting_uDirectionalLightCount=r.length,i}function gC(e=vk){if("lightSources"in e){let{ambientLight:t,pointLights:r,directionalLights:i}=e.lightSources||{};return t||r&&r.length>0||i&&i.length>0?Object.assign({},Ck({ambientLight:t,pointLights:r,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in e){let t={pointLights:[],directionalLights:[]};for(let r of e.lights||[])switch(r.type){case"ambient":t.ambientLight=r;break;case"directional":t.directionalLights?.push(r);break;case"point":t.pointLights?.push(r);break;default:}return gC({lightSources:t})}return{}}var ml={name:"lights",vs:Px,fs:Px,getUniforms:gC,defines:{MAX_LIGHTS:3}};var Rx=`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 wk={};function Pk(e){let{ambient:t=.35,diffuse:r=.6,shininess:i=32,specularColor:s=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:r,lighting_uShininess:i,lighting_uSpecularColor:s.map(n=>n/255)}}function mC(e=wk){if(!("material"in e))return{};let{material:t}=e;return t?Pk(t):{lighting_uEnabled:!1}}var _r={name:"gouraud-lighting",dependencies:[ml],vs:Rx,defines:{LIGHTING_VERTEX:1},getUniforms:mC},Ns={name:"phong-lighting",dependencies:[ml],fs:Rx,defines:{LIGHTING_FRAGMENT:1},getUniforms:mC};var _C=`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 yC=`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 Cn={name:"pbr",vs:_C,fs:yC,defines:{LIGHTING_FRAGMENT:1},dependencies:[ml]};var xC="#define SMOOTH_EDGE_RADIUS 0.5",Mk=`
${xC}
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)
);
`,Rk=`
${xC}
struct FragmentGeometry {
vec2 uv;
} geometry;
float smoothedge(float edge, float x) {
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
}
`,AC={name:"geometry",vs:Mk,fs:Rk};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 Se={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ft={common:0,meters:1,pixels:2},_l={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},TC={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};var Ik=Object.keys(X).map(e=>`const int COORDINATE_SYSTEM_${e} = ${X[e]};`).join(""),Bk=Object.keys(Se).map(e=>`const int PROJECTION_MODE_${e} = ${Se[e]};`).join(""),Ok=Object.keys(Ft).map(e=>`const int UNIT_${e.toUpperCase()} = ${Ft[e]};`).join(""),bC=`${Ik}
${Bk}
${Ok}
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 Fk(e,t){if(e===t)return!0;if(Array.isArray(e)){let r=e.length;if(!t||t.length!==r)return!1;for(let i=0;i<r;i++)if(e[i]!==t[i])return!1;return!0}return!1}function He(e){let t={},r;return i=>{for(let s in i)if(!Fk(i[s],t[s])){r=e(i),t=i;break}return r}}var EC=[0,0,0,0],Nk=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],SC=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Lk=[0,0,0],vC=[0,0,0],Dk=He(kk);function Ix(e,t,r=vC){r.length<3&&(r=[r[0],r[1],0]);let i=r,s,n=!0;switch(t===X.LNGLAT_OFFSETS||t===X.METER_OFFSETS?s=r:s=e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case Se.WEB_MERCATOR:(t===X.LNGLAT||t===X.CARTESIAN)&&(s=[0,0,0],n=!1);break;case Se.WEB_MERCATOR_AUTO_OFFSET:t===X.LNGLAT?i=s:t===X.CARTESIAN&&(i=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],s=e.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case Se.IDENTITY:i=e.position.map(Math.fround),i[2]=i[2]||0;break;case Se.GLOBE:n=!1,s=null;break;default:n=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:i,offsetMode:n}}function Uk(e,t,r){let{viewMatrixUncentered:i,projectionMatrix:s}=e,{viewMatrix:n,viewProjectionMatrix:o}=e,a=EC,c=EC,l=e.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:h}=Ix(e,t,r);return h&&(c=e.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Be.transformMat4([],c,o),n=i||n,o=Vt.multiply([],s,n),o=Vt.multiply([],o,Nk)),{viewMatrix:n,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function xd({viewport:e,devicePixelRatio:t=1,modelMatrix:r=null,coordinateSystem:i=X.DEFAULT,coordinateOrigin:s=vC,autoWrapLongitude:n=!1}){i===X.DEFAULT&&(i=e.isGeospatial?X.LNGLAT:X.CARTESIAN);let o=Dk({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:s});return o.project_uWrapLongitude=n,o.project_uModelMatrix=r||SC,o}function kk({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:s,viewProjectionMatrix:n,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=Uk(e,r,i),u=e.getDistanceScales(),f=[e.width*t,e.height*t],h=Be.transformMat4([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,d={project_uCoordinateSystem:r,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:c,project_uCommonOrigin:o.slice(0,3),project_uCenter:s,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:f,project_uDevicePixelRatio:t,project_uFocalDistance:h,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Lk,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:n,project_uModelMatrix:SC,project_uCameraPosition:a};if(l){let p=e.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:e._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 Vk={};function zk(e=Vk){return"viewport"in e?xd(e):{}}var te={name:"project",dependencies:[Dy,AC],vs:bC,getUniforms:zk};var Hk=`
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);
}
`,dt={name:"project32",dependencies:[te],vs:Hk};function Bx(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ls(e,t){let r=Be.transformMat4([],t,e);return Be.scale(r,r,1/r[3]),r}function Ox(e,t){let r=e%t;return r<0?t+r:r}function CC(e,t,r){return r*t+(1-r)*e}function yl(e,t,r){return e<t?t:e>r?r:e}function Gk(e){return Math.log(e)*Math.LOG2E}var ea=Math.log2||Gk;function Lr(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var Dr=Math.PI,wC=Dr/4,yr=Dr/180,Fx=180/Dr,ra=512,Ad=4003e4,ia=85.051129,PC=1.5;function xl(e){return Math.pow(2,e)}function Td(e){return ea(e)}function Xt(e){let[t,r]=e;Lr(Number.isFinite(t)),Lr(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=t*yr,s=r*yr,n=ra*(i+Dr)/(2*Dr),o=ra*(Dr+Math.log(Math.tan(wC+s*.5)))/(2*Dr);return[n,o]}function _e(e){let[t,r]=e,i=t/ra*(2*Dr)-Dr,s=2*(Math.atan(Math.exp(r/ra*(2*Dr)-Dr))-wC);return[i*Fx,s*Fx]}function Al(e){let{latitude:t}=e;Lr(Number.isFinite(t));let r=Math.cos(t*yr);return Td(Ad*r)-9}function Pn(e){let t=Math.cos(e*yr);return ra/Ad/t}function sa(e){let{latitude:t,longitude:r,highPrecision:i=!1}=e;Lr(Number.isFinite(t)&&Number.isFinite(r));let s=ra,n=Math.cos(t*yr),o=s/360,a=o/n,c=s/Ad/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(i){let u=yr*Math.tan(t*yr)/n,f=o*u/2,h=s/Ad*u,d=h/a*c;l.unitsPerDegree2=[0,f,h],l.unitsPerMeter2=[d,0,d]}return l}function Tl(e,t){let[r,i,s]=e,[n,o,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=sa({longitude:r,latitude:i,highPrecision:!0}),u=Xt(e);u[0]+=n*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=_e(u),h=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[f[0],f[1],h]:f}function bd(e){let{height:t,pitch:r,bearing:i,altitude:s,scale:n,center:o}=e,a=Bx();Vt.translate(a,a,[0,0,-s]),Vt.rotateX(a,a,-r*yr),Vt.rotateZ(a,a,i*yr);let c=n/t;return Vt.scale(a,a,[c,c,c]),o&&Vt.translate(a,a,jt.negate([],o)),a}function Nx(e){let{width:t,height:r,altitude:i,pitch:s=0,offset:n,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e,{fovy:u=wn(PC)}=e;i!==void 0&&(u=wn(i));let f=u*yr,h=s*yr,d=Mn(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(yl(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:t/r,focalDistance:d,near:c,far:x}}function wn(e){return 2*Math.atan(.5/e)*Fx}function Mn(e){return .5/Math.tan(.5*e*yr)}function na(e,t){let[r,i,s=0]=e;return Lr(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(s)),Ls(t,[r,i,s,1])}function xr(e,t,r=0){let[i,s,n]=e;if(Lr(Number.isFinite(i)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(n))return Ls(t,[i,s,n,1]);let o=Ls(t,[i,s,0,1]),a=Ls(t,[i,s,1,1]),c=o[2],l=a[2],u=c===l?0:((r||0)-c)/(l-c);return Qt.lerp([],o,a,u)}function Ed(e){let{width:t,height:r,bounds:i,minExtent:s=0,maxZoom:n=24,offset:o=[0,0]}=e,[[a,c],[l,u]]=i,f=Wk(e.padding),h=Xt([a,yl(u,-ia,ia)]),d=Xt([l,yl(c,-ia,ia)]),p=[Math.max(Math.abs(d[0]-h[0]),s),Math.max(Math.abs(d[1]-h[1]),s)],g=[t-f.left-f.right-Math.abs(o[0])*2,r-f.top-f.bottom-Math.abs(o[1])*2];Lr(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/_,E=[(d[0]+h[0])/2+y,(d[1]+h[1])/2+x],P=_e(E),B=Math.min(n,ea(Math.abs(Math.min(m,_))));return Lr(Number.isFinite(B)),{longitude:P[0],latitude:P[1],zoom:B}}function Wk(e=0){return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:(Lr(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var MC=Math.PI/180;function Sd(e,t=0){let{width:r,height:i,unproject:s}=e,n={targetZ:t},o=s([0,i],n),a=s([r,i],n),c,l,u=e.fovy?.5*e.fovy*MC:Math.atan(.5/e.altitude),f=(90-e.pitch)*MC;return u>f-.01?(c=RC(e,0,t),l=RC(e,r,t)):(c=s([0,0],n),l=s([r,0],n)),[o,a,l,c]}function RC(e,t,r){let{pixelUnprojectionMatrix:i}=e,s=Ls(i,[t,0,1,1]),n=Ls(i,[t,e.height,1,1]),a=(r*e.distanceScales.unitsPerMeter[2]-s[2])/(n[2]-s[2]),c=Qt.lerp([],s,n,a),l=_e(c);return l.push(r),l}var IC=512;function Lx(e){let{width:t,height:r,pitch:i=0}=e,{longitude:s,latitude:n,zoom:o,bearing:a=0}=e;(s<-180||s>180)&&(s=Ox(s+180,360)-180),(a<-180||a>180)&&(a=Ox(a+180,360)-180);let c=ea(r/IC);if(o<=c)o=c,n=0;else{let l=r/2/Math.pow(2,o),u=_e([0,l])[1];if(n<u)n=u;else{let f=_e([0,IC-l])[1];n>f&&(n=f)}}return{width:t,height:r,longitude:s,latitude:n,zoom:o,pitch:i,bearing:a}}var BC=.01,Xk=["longitude","latitude","zoom"],OC={curve:1.414,speed:1.2};function Dx(e,t,r,i){let{startZoom:s,startCenterXY:n,uDelta:o,w0:a,u1:c,S:l,rho:u,rho2:f,r0:h}=FC(e,t,i);if(c<BC){let E={};for(let P of Xk){let B=e[P],F=t[P];E[P]=CC(B,F,r)}return E}let d=r*l,p=Math.cosh(h)/Math.cosh(h+u*d),g=a*((Math.cosh(h)*Math.tanh(h+u*d)-Math.sinh(h))/f)/c,m=1/p,_=s+Td(m),y=Qt.scale([],o,g);Qt.add(y,y,n);let x=_e(y);return{longitude:x[0],latitude:x[1],zoom:_}}function Ux(e,t,r){let i={...OC,...r},{screenSpeed:s,speed:n,maxDuration:o}=i,{S:a,rho:c}=FC(e,t,i),l=1e3*a,u;return Number.isFinite(s)?u=l/(s/c):u=l/n,Number.isFinite(o)&&u>o?0:u}function FC(e,t,r){r=Object.assign({},OC,r);let i=r.curve,s=e.zoom,n=[e.longitude,e.latitude],o=xl(s),a=t.zoom,c=[t.longitude,t.latitude],l=xl(a-s),u=Xt(n),f=Xt(c),h=Qt.sub([],f,u),d=Math.max(e.width,e.height),p=d/l,g=Qt.length(h)*o,m=Math.max(g,BC),_=i*i,y=(p*p-d*d+_*_*m*m)/(2*d*_*m),x=(p*p-d*d-_*_*m*m)/(2*p*_*m),E=Math.log(Math.sqrt(y*y+1)-y),P=Math.log(Math.sqrt(x*x+1)-x),B=(P-E)/i;return{startZoom:s,startCenterXY:u,uDelta:h,w0:d,u1:g,S:B,rho:i,rho2:_,r0:E,r1:P}}var qk=`
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;
}
`,Kk=`
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;
}
`,$k=He(eV),Jk=He(rV),Zk=[0,0,0,1],Qk=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function tV(e,t){let[r,i,s]=e,n=xr([r,i,s],t);return Number.isFinite(s)?n:[n[0],n[1],0]}function eV({viewport:e,center:t}){return new q(e.viewProjectionMatrix).invert().transform(t)}function rV({viewport:e,shadowMatrices:t}){let r=[],i=e.pixelUnprojectionMatrix,s=e.isGeospatial?void 0:1,n=[[0,0,s],[e.width,0,s],[0,e.height,s],[e.width,e.height,s],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(o=>tV(o,i));for(let o of t){let a=o.clone().translate(new w(e.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 iV(e,t){let{shadowEnabled:r=!0}=e;if(!r||!e.shadowMatrices||!e.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};let i={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:e.shadowMaps?e.shadowMaps.length>0:!1,shadow_uColor:e.shadowColor||Zk,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},s=$k({viewport:e.viewport,center:t.project_uCenter}),n=[],o=Jk({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let a=0;a<e.shadowMatrices.length;a++){let c=o[a],l=c.clone().translate(new w(e.viewport.center).negate());t.project_uCoordinateSystem===X.LNGLAT&&t.project_uProjectionMode===Se.WEB_MERCATOR?(o[a]=l,n[a]=s):(o[a]=c.clone().multiplyRight(Qk),n[a]=l.transform(s))}for(let a=0;a<o.length;a++)i[`shadow_uViewProjectionMatrices[${a}]`]=o[a],i[`shadow_uProjectCenters[${a}]`]=n[a];for(let a=0;a<2;a++)i[`shadow_uShadowMap${a}`]=e.shadowMaps&&e.shadowMaps[a]||e.dummyShadowMap;return i}var oa={name:"shadow",dependencies:[te],vs:qk,fs:Kk,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
position = shadow_setVertexPosition(geometry.position);
`,"fs:DECKGL_FILTER_COLOR":`
color = shadow_filterShadowColor(color);
`},getUniforms:(e={},t={})=>"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?iV(e,t):{}};var _t={...rd,defaultUniforms:{...rd.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 sV=[te],nV=["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 aa(){let e=bs.getDefaultShaderAssembler();for(let t of sV)e.addDefaultModule(t);for(let t of nV)e.addShaderHook(t);return e}var oV=[255,255,255],aV=1,cV=0,ca=class{constructor(t={}){this.type="ambient";let{color:r=oV}=t,{intensity:i=aV}=t;this.id=t.id||`ambient-${cV++}`,this.color=r,this.intensity=i}};var lV=[255,255,255],uV=1,fV=[0,0,-1],hV=0,Gi=class{constructor(t={}){this.type="directional";let{color:r=lV}=t,{intensity:i=uV}=t,{direction:s=fV}=t,{_shadow:n=!1}=t;this.id=t.id||`directional-${hV++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new w(s).normalize().toArray(),this.shadow=n}getProjectedLight(t){return this}};var Rn=class{constructor(t,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=t,this.props={...r}}setProps(t){Object.assign(this.props,t)}render(t){}cleanup(){}};var ye=class extends Rn{constructor(){super(...arguments),this._lastRenderIndex=-1}render(t){let[r,i]=this.device.canvasContext.getDrawingBufferSize(),s=t.clearCanvas??!0,n=t.clearColor??(s?[0,0,0,0]:!1),o=s?1:!1,a=s?0:!1,c=t.colorMask??15,l={viewport:[0,0,r,i]};t.colorMask&&(l.colorMask=c),t.scissorRect&&(l.scissorRect=t.scissorRect);let u=this.device.beginRenderPass({framebuffer:t.target,parameters:l,clearColor:n,clearDepth:o,clearStencil:a});try{return this._drawLayers(u,t)}finally{u.end()}}_drawLayers(t,r){let{target:i,moduleParameters:s,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(t,{target:i,moduleParameters:s,viewport:p,view:f,pass:r.pass,layers:r.layers},h);l.push(g)}}return l}_getDrawLayerParams(t,{layers:r,pass:i,isPicking:s=!1,layerFilter:n,cullRect:o,effects:a,moduleParameters:c},l=!1){let u=[],f=NC(this._lastRenderIndex+1),h={layer:r[0],viewport:t,isPicking:s,renderPass:i,cullRect:o},d={};for(let p=0;p<r.length;p++){let g=r[p],m=this._shouldDrawLayer(g,h,n,d),_={shouldDrawLayer:m};m&&!l&&(_.layerRenderIndex=f(g,m),_.moduleParameters=this._getModuleParameters(g,a,i,c),_.layerParameters={...g.context.deck?.props.parameters,...this.getLayerParameters(g,p,t)}),u[p]=_}return u}_drawLayersInViewport(t,{layers:r,moduleParameters:i,pass:s,target:n,viewport:o,view:a},c){let l=dV(this.device,{moduleParameters:i,target:n,viewport:o});if(a&&a.props.clear){let f=a.props.clear===!0?{color:!0,depth:!0}:a.props.clear;this.device.withParametersWebGL({scissorTest:!0,scissor:l},()=>this.device.clearWebGL(f))}let u={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};t.setParameters({viewport:l});for(let f=0;f<r.length;f++){let h=r[f],{shouldDrawLayer:d,layerRenderIndex:p,moduleParameters:g,layerParameters:m}=c[f];if(d&&h.props.pickable&&u.pickableCount++,h.isComposite)u.compositeCount++;else if(d){u.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,p),g.viewport=o,h.context.renderPass=t;try{h._drawLayer({renderPass:t,moduleParameters:g,uniforms:{layerIndex:p},parameters:m})}catch(_){h.raiseError(_,`drawing ${h} to ${s}`)}}}return u}shouldDrawLayer(t){return!0}getModuleParameters(t,r){return null}getLayerParameters(t,r,i){return t.props.parameters}_shouldDrawLayer(t,r,i,s){if(!(t.props.visible&&this.shouldDrawLayer(t)))return!1;r.layer=t;let o=t.parent;for(;o;){if(!o.props.visible||!o.filterSubLayer(r))return!1;r.layer=o,o=o.parent}if(i){let a=r.layer.id;if(a in s||(s[a]=i(r)),!s[a])return!1}return t.activateViewport(r.viewport),!0}_getModuleParameters(t,r,i,s){let n=this.device.canvasContext.cssToDeviceRatio(),o=Object.assign(Object.create(t.internalState?.propsInTransition||t.props),{autoWrapLongitude:t.wrapLongitude,viewport:t.context.viewport,mousePosition:t.context.mousePosition,picking:{isActive:0},devicePixelRatio:n});if(r)for(let a of r)Object.assign(o,a.getModuleParameters?.(t));return Object.assign(o,this.getModuleParameters(t,r),s)}};function NC(e=0,t={}){let r={},i=(s,n)=>{let o=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in t)&&i(s.parent,!1),c in r){let u=r[c]=r[c]||NC(t[c],t);l=u(s,n),r[a]=u}else Number.isFinite(o)?(l=o+(t[c]||0),r[a]=null):l=e;return n&&l>=e&&(e=l+1),t[a]=l,l};return i}function dV(e,{moduleParameters:t,target:r,viewport:i}){let s=t&&t.devicePixelRatio||e.canvasContext.cssToDeviceRatio(),[,n]=e.canvasContext.getDrawingBufferSize(),o=r?r.height:n,a=i;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}var bl=class extends ye{constructor(t,r){super(t,r),this.shadowMap=t.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=t.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=t.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(t){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),s=t.viewports[0],n=s.width*i,o=s.height*i,a=[1,1,1,1];(n!==r.width||o!==r.height)&&r.resize({width:n,height:o}),super.render({...t,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(t,r,i){return{...t.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(t){return t.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 pV={color:[255,255,255],intensity:1},LC=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],gV=[0,0,0,200/255],Ds=class{constructor(t={}){this.id="lighting-effect",this.shadowColor=gV,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(t)}setup(t){this.context=t;let{device:r,deck:i}=t;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(oa),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(t){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(let r in t){let i=t[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=t}preRender({layers:t,layerFilter:r,viewports:i,onViewportActive:s,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;o<this.shadowPasses.length;o++)this.shadowPasses[o].render({layers:t,layerFilter:r,viewports:i,onViewportActive:s,views:n,moduleParameters:{shadowLightId:o,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}})}}getModuleParameters(t){let r=this.shadow?{shadowMaps:this.shadowMaps,dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{};return r.lightSources={ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(i=>i.getProjectedLight({layer:t})),pointLights:this.pointLights.map(i=>i.getProjectedLight({layer:t}))},r}cleanup(t){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,t.deck._removeDefaultShaderModule(oa))}_calculateMatrices(){let t=[];for(let r of this.directionalLights){let i=new q().lookAt({eye:new w(r.direction).negate()});t.push(i)}return t}_createShadowPasses(t){for(let r=0;r<this.directionalLights.length;r++){let i=new bl(t);this.shadowPasses[r]=i,this.shadowMaps[r]=i.shadowMap}}_applyDefaultLights(){let{ambientLight:t,pointLights:r,directionalLights:i}=this;!t&&r.length===0&&i.length===0&&(this.ambientLight=new ca(pV),this.directionalLights.push(new Gi(LC[0]),new Gi(LC[1])))}};var kx=class{constructor(t={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(t)}setOptions(t){Object.assign(this.opts,t)}allocate(t,r,{size:i=1,type:s,padding:n=0,copy:o=!1,initialize:a=!1,maxCount:c}){let l=s||t&&t.constructor||Float32Array,u=r*i+n;if(ArrayBuffer.isView(t)){if(u<=t.length)return t;if(u*t.BYTES_PER_ELEMENT<=t.buffer.byteLength)return new l(t.buffer,0,u)}let f=1/0;c&&(f=c*i+n);let h=this._allocate(l,u,a,f);return t&&o?h.set(t):a||h.fill(0,0,4),this._release(t),h}release(t){this._release(t)}_allocate(t,r,i,s){let n=Math.max(Math.ceil(r*this.opts.overAlloc),1);n>s&&(n=s);let o=this._pool,a=t.BYTES_PER_ELEMENT*n,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new t(o.splice(c,1)[0],0,n);return i&&l.fill(0),l}return new t(n)}_release(t){if(!ArrayBuffer.isView(t))return;let r=this._pool,{buffer:i}=t,{byteLength:s}=i,n=r.findIndex(o=>o.byteLength>=s);n<0?r.push(i):(n>0||r.length<this.opts.poolSize)&&r.splice(n,0,i),r.length>this.opts.poolSize&&r.shift()}},Ur=new kx;function ua(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function In(e,t){let r=e%t;return r<0?t+r:r}function UC(e){return[e[12],e[13],e[14]]}function kC(e){return{left:la(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:la(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:la(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:la(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:la(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:la(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}var DC=new w;function la(e,t,r,i){DC.set(e,t,r);let s=DC.len();return{distance:i/s,normal:new w(-e/s,-t/s,-r/s)}}function kr(e){return e-Math.fround(e)}var El;function vd(e,t){let{size:r=1,startIndex:i=0}=t,s=t.endIndex!==void 0?t.endIndex:e.length,n=(s-i)/r;El=Ur.allocate(El,n,{type:Float32Array,size:r*2});let o=i,a=0;for(;o<s;){for(let c=0;c<r;c++){let l=e[o++];El[a+c]=l,El[a+c+r]=kr(l)}a+=r*2}return El.subarray(0,n*r*2)}function VC(e){let t=null,r=!1;for(let i of e)i&&(t?(r||(t=[[t[0][0],t[0][1]],[t[1][0],t[1][1]]],r=!0),t[0][0]=Math.min(t[0][0],i[0][0]),t[0][1]=Math.min(t[0][1],i[0][1]),t[1][0]=Math.max(t[1][0],i[1][0]),t[1][1]=Math.max(t[1][1],i[1][1])):t=i);return t}var mV=Math.PI/180,_V=ua(),zC=[0,0,0],yV={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function xV({width:e,height:t,orthographic:r,fovyRadians:i,focalDistance:s,padding:n,near:o,far:a}){let c=e/t,l=r?new q().orthographic({fovy:i,aspect:c,focalDistance:s,near:o,far:a}):new q().perspective({fovy:i,aspect:c,near:o,far:a});if(n){let{left:u=0,right:f=0,top:h=0,bottom:d=0}=n,p=ht((u+e-f)/2,0,e)-e/2,g=ht((h+t-d)/2,0,t)-t/2;l[8]-=p*2/e,l[9]+=g*2/t}return l}var Cd=class{constructor(t={}){this._frustumPlanes={},this.id=t.id||this.constructor.displayName||"viewport",this.x=t.x||0,this.y=t.y||0,this.width=t.width||1,this.height=t.height||1,this.zoom=t.zoom||0,this.padding=t.padding,this.distanceScales=t.distanceScales||yV,this.focalDistance=t.focalDistance||1,this.position=t.position||zC,this.modelMatrix=t.modelMatrix||null;let{longitude:r,latitude:i}=t;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(r),this._initProps(t),this._initMatrices(t),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?Se.WEB_MERCATOR:Se.WEB_MERCATOR_AUTO_OFFSET:Se.IDENTITY}equals(t){return t instanceof Cd?this===t?!0:t.width===this.width&&t.height===this.height&&t.scale===this.scale&&Ct(t.projectionMatrix,this.projectionMatrix)&&Ct(t.viewMatrix,this.viewMatrix):!1}project(t,{topLeft:r=!0}={}){let i=this.projectPosition(t),s=na(i,this.pixelProjectionMatrix),[n,o]=s,a=r?o:this.height-o;return t.length===2?[n,a]:[n,a,s[2]]}unproject(t,{topLeft:r=!0,targetZ:i}={}){let[s,n,o]=t,a=r?n:this.height-n,c=i&&i*this.distanceScales.unitsPerMeter[2],l=xr([s,a,o],this.pixelUnprojectionMatrix,c),[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(i)?[u,f,i]:[u,f]}projectPosition(t){let[r,i]=this.projectFlat(t),s=(t[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,i,s]}unprojectPosition(t){let[r,i]=this.unprojectFlat(t),s=(t[2]||0)*this.distanceScales.metersPerUnit[2];return[r,i,s]}projectFlat(t){if(this.isGeospatial){let r=Xt(t);return r[1]=ht(r[1],-318,830),r}return t}unprojectFlat(t){return this.isGeospatial?_e(t):t}getBounds(t={}){let r={targetZ:t.z||0},i=this.unproject([0,0],r),s=this.unproject([this.width,0],r),n=this.unproject([0,this.height],r),o=this.unproject([this.width,this.height],r);return[Math.min(i[0],s[0],n[0],o[0]),Math.min(i[1],s[1],n[1],o[1]),Math.max(i[0],s[0],n[0],o[0]),Math.max(i[1],s[1],n[1],o[1])]}getDistanceScales(t){return t?sa({longitude:t[0],latitude:t[1],highPrecision:!0}):this.distanceScales}containsPixel({x:t,y:r,width:i=1,height:s=1}){return t<this.x+this.width&&this.x<t+i&&r<this.y+this.height&&this.y<r+s}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,kC(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(t,r){return null}_initProps(t){let r=t.longitude,i=t.latitude;this.isGeospatial&&(Number.isFinite(t.zoom)||(this.zoom=Al({latitude:i})+Math.log2(this.focalDistance)),this.distanceScales=t.distanceScales||sa({latitude:i,longitude:r}));let s=Math.pow(2,this.zoom);this.scale=s;let{position:n,modelMatrix:o}=t,a=zC;if(n&&(a=o?new q(o).transformAsVector(n,[]):n),this.isGeospatial){let c=this.projectPosition([r,i,0]);this.center=new w(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(t){let{viewMatrix:r=_V,projectionMatrix:i=null,orthographic:s=!1,fovyRadians:n,fovy:o=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:u=1}=t;this.viewMatrixUncentered=r,this.viewMatrix=new q().multiplyRight(r).translate(new w(this.center).negate()),this.projectionMatrix=i||xV({width:this.width,height:this.height,orthographic:s,fovyRadians:n||o*mV,focalDistance:u,padding:l,near:a,far:c});let f=ua();Vt.multiply(f,f,this.projectionMatrix),Vt.multiply(f,f,this.viewMatrix),this.viewProjectionMatrix=f,this.viewMatrixInverse=Vt.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=UC(this.viewMatrixInverse);let h=ua(),d=ua();Vt.scale(h,h,[this.width/2,-this.height/2,1]),Vt.translate(h,h,[1,-1,0]),Vt.multiply(d,h,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=Vt.invert(ua(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||k.warn("Pixel project matrix not invertible")()}},xe=Cd;(()=>{Cd.displayName="Viewport"})();var Sl=class extends xe{constructor(t={}){let{latitude:r=0,longitude:i=0,zoom:s=0,pitch:n=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:u,orthographic:f=!1,projectionMatrix:h,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:_=!1}=t,{width:y,height:x,altitude:E=1.5}=t,P=Math.pow(2,s);y=y||1,x=x||1;let B,F=null;if(h)E=h[5]/2,B=wn(E);else{t.fovy?(B=t.fovy,E=Mn(B)):B=wn(E);let v;if(m){let{top:T=0,bottom:L=0}=m;v=[0,ht((T+x-L)/2,0,x)-x/2]}F=Nx({width:y,height:x,scale:P,center:g&&[0,0,g[2]*Pn(r)],offset:v,pitch:n,fovy:B,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(F.near=l),Number.isFinite(u)&&(F.far=u)}let M=bd({height:x,pitch:n,bearing:o,scale:P,altitude:E});p&&(M=new q().translate([512*p,0,0]).multiplyLeft(M)),super({...t,width:y,height:x,viewMatrix:M,longitude:i,latitude:r,zoom:s,...F,fovy:B,focalDistance:E}),this.latitude=r,this.longitude=i,this.zoom=s,this.pitch=n,this.bearing=o,this.altitude=E,this.fovy=B,this.orthographic=f,this._subViewports=d?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let t=this.getBounds(),r=Math.floor((t[0]+180)/360),i=Math.ceil((t[2]-180)/360);for(let s=r;s<=i;s++){let n=s?new Sl({...this,worldOffset:s}):this;this._subViewports.push(n)}}return this._subViewports}projectPosition(t){if(this._pseudoMeters)return super.projectPosition(t);let[r,i]=this.projectFlat(t),s=(t[2]||0)*Pn(t[1]);return[r,i,s]}unprojectPosition(t){if(this._pseudoMeters)return super.unprojectPosition(t);let[r,i]=this.unprojectFlat(t),s=(t[2]||0)/Pn(i);return[r,i,s]}addMetersToLngLat(t,r){return Tl(t,r)}panByPosition(t,r){let i=xr(r,this.pixelUnprojectionMatrix),s=this.projectFlat(t),n=Qt.add([],s,Qt.negate([],i)),o=Qt.add([],this.center,n),[a,c]=this.unprojectFlat(o);return{longitude:a,latitude:c}}getBounds(t={}){let r=Sd(this,t.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(t,r={}){let{width:i,height:s}=this,{longitude:n,latitude:o,zoom:a}=Ed({width:i,height:s,bounds:t,...r});return new Sl({width:i,height:s,longitude:n,latitude:o,zoom:a})}},ne=Sl;(()=>{Sl.displayName="WebMercatorViewport"})();var HC=[0,0,0];function Vx(e,t,r=!1){let i=t.projectPosition(e);if(r&&t instanceof ne){let[s,n,o=0]=e,a=t.getDistanceScales([s,n]);i[2]=o*a.unitsPerMeter[2]}return i}function AV(e){let{viewport:t,modelMatrix:r,coordinateOrigin:i}=e,{coordinateSystem:s,fromCoordinateSystem:n,fromCoordinateOrigin:o}=e;return s===X.DEFAULT&&(s=t.isGeospatial?X.LNGLAT:X.CARTESIAN),n===void 0&&(n=s),o===void 0&&(o=i),{viewport:t,coordinateSystem:s,coordinateOrigin:i,modelMatrix:r,fromCoordinateSystem:n,fromCoordinateOrigin:o}}function zx(e,{viewport:t,modelMatrix:r,coordinateSystem:i,coordinateOrigin:s,offsetMode:n}){let[o,a,c=0]=e;switch(r&&([o,a,c]=Be.transformMat4([],[o,a,c,1],r)),i){case X.LNGLAT:return Vx([o,a,c],t,n);case X.LNGLAT_OFFSETS:return Vx([o+s[0],a+s[1],c+(s[2]||0)],t,n);case X.METER_OFFSETS:return Vx(Tl(s,[o,a,c]),t,n);case X.CARTESIAN:default:return t.isGeospatial?[o+s[0],a+s[1],c+s[2]]:t.projectPosition([o,a,c])}}function wd(e,t){let{viewport:r,coordinateSystem:i,coordinateOrigin:s,modelMatrix:n,fromCoordinateSystem:o,fromCoordinateOrigin:a}=AV(t),{autoOffset:c=!0}=t,{geospatialOrigin:l=HC,shaderCoordinateOrigin:u=HC,offsetMode:f=!1}=c?Ix(r,i,s):{},h=zx(e,{viewport:r,modelMatrix:n,coordinateSystem:o,coordinateOrigin:a,offsetMode:f});if(f){let d=r.projectPosition(l||u);jt.sub(h,h,d)}return h}var TV=[255,255,255],bV=1,EV=[0,0,1],SV=[0,0,1],vV=0,fa=class{constructor(t={}){this.type="point";let{color:r=TV}=t,{intensity:i=bV}=t,{position:s=SV}=t;this.id=t.id||`point-${vV++}`,this.color=r,this.intensity=i,this.type="point",this.position=s,this.attenuation=CV(t),this.projectedLight={...this}}getProjectedLight({layer:t}){let{projectedLight:r}=this,i=t.context.viewport,{coordinateSystem:s,coordinateOrigin:n}=t.props,o=wd(this.position,{viewport:i,coordinateSystem:s,coordinateOrigin:n,fromCoordinateSystem:i.isGeospatial?X.LNGLAT:X.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=o,r}};function CV(e){return e.attenuation?e.attenuation:"intensity"in e?[0,0,e.intensity||0]:EV}var vl=class extends fa{getProjectedLight({layer:t}){let{projectedLight:r}=this,i=t.context.viewport,{coordinateSystem:s,coordinateOrigin:n,modelMatrix:o}=t.props,{project_uCameraPosition:a}=xd({viewport:i,modelMatrix:o,coordinateSystem:s,coordinateOrigin:n});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var Bn=Math.PI/180,wV=1e3*60*60*24,PV=2440588,MV=2451545,Pd=Bn*23.4397,RV=357.5291,IV=.98560028,BV=280.147,OV=360.9856235;function GC(e,t,r){let i=Bn*-r,s=Bn*t,n=NV(e),o=GV(n),a=VV(n,i)-o.rightAscension;return{azimuth:UV(a,s,o.declination),altitude:kV(a,s,o.declination)}}function Md(e,t,r){let{azimuth:i,altitude:s}=GC(e,t,r);return[Math.sin(i)*Math.cos(s),Math.cos(i)*Math.cos(s),-Math.sin(s)]}function FV(e){return(typeof e=="number"?e:e.getTime())/wV-.5+PV}function NV(e){return FV(e)-MV}function LV(e,t){let r=e;return Math.atan2(Math.sin(r)*Math.cos(Pd)-Math.tan(t)*Math.sin(Pd),Math.cos(r))}function DV(e,t){let r=e;return Math.asin(Math.sin(t)*Math.cos(Pd)+Math.cos(t)*Math.sin(Pd)*Math.sin(r))}function UV(e,t,r){let i=e,s=t,n=r;return Math.atan2(Math.sin(i),Math.cos(i)*Math.sin(s)-Math.tan(n)*Math.cos(s))}function kV(e,t,r){let i=e,s=t,n=r;return Math.asin(Math.sin(s)*Math.sin(n)+Math.cos(s)*Math.cos(n)*Math.cos(i))}function VV(e,t){return Bn*(BV+OV*e)-t}function zV(e){return Bn*(RV+IV*e)}function HV(e){let t=e,r=Bn*(1.9148*Math.sin(t)+.02*Math.sin(2*t)+3e-4*Math.sin(3*t)),i=Bn*102.9372;return t+r+i+Math.PI}function GV(e){let t=zV(e),r=HV(t);return{declination:DV(r,0),rightAscension:LV(r,0)}}var Cl=class extends Gi{constructor(t){super(t),this.timestamp=t.timestamp}getProjectedLight({layer:t}){let{viewport:r}=t.context;if(r.resolution&&r.resolution>0){let[s,n,o]=Md(this.timestamp,0,0);this.direction=[s,-o,n]}else{let{latitude:s,longitude:n}=r;this.direction=Md(this.timestamp,s,n)}return this}};var WV=1,jV=1,On=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(t){let{delay:r=0,duration:i=Number.POSITIVE_INFINITY,rate:s=1,repeat:n=1}=t,o=WV++,a={time:0,delay:r,duration:i,rate:s,repeat:n};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(t){this.channels.delete(t);for(let[r,i]of this.animations)i.channel===t&&this.detachAnimation(r)}isFinished(t){let r=this.channels.get(t);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(t){if(t===void 0)return this.time;let r=this.channels.get(t);return r===void 0?-1:r.time}setTime(t){this.time=Math.max(0,t);let r=this.channels.values();for(let s of r)this._setChannelTime(s,this.time);let i=this.animations.values();for(let s of i){let{animation:n,channel:o}=s;n.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,r){let i=jV++;return this.animations.set(i,{animation:t,channel:r}),t.setTime(this.getTime(r)),i}detachAnimation(t){this.animations.delete(t)}update(t){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=t),this.setTime(this.time+(t-this.lastEngineTime)),this.lastEngineTime=t)}_setChannelTime(t,r){let i=r-t.delay,s=t.duration*t.repeat;i>=s?t.time=t.duration*t.rate:(t.time=Math.max(0,i)%t.duration,t.time*=t.rate)}};var XV=0,YV={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:ze.stats.get(`animation-loop-${XV++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},wl=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(t){if(this.props={...YV,...t},t=this.props,!t.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=t.stats||new Ee({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:t.autoResizeViewport,autoResizeDrawingBuffer:t.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(t){return this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.props.autoResizeViewport=t.autoResizeViewport||!1),"autoResizeDrawingBuffer"in t&&(this.props.autoResizeDrawingBuffer=t.autoResizeDrawingBuffer||!1),"useDevicePixels"in t&&(this.props.useDevicePixels=t.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let t;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(t!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(t){let r=t instanceof Error?t: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(t){return this.timeline=t,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(t=>{this._resolveNextFrame=t})),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(t){this.display&&(this.display.destroy(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_requestAnimationFrame(){this._running&&(this._animationFrameId=ty(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(ey(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(t){if(this.display){this.display._renderFrame(t);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:t,height:r,aspect:i}=this._getSizeAndAspect();(t!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=r,this.animationProps.aspect=i,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 t=document.createElement("div");document.body.appendChild(t),t.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&&t.appendChild(this.canvas),t.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[t,r]=this.device?.canvasContext?.getPixelSize()||[1,1],i=1,s=this.device?.canvasContext?.canvas;return s&&s.clientHeight?i=s.clientWidth/s.clientHeight:t>0&&r>0&&(i=t/r),{width:t,height:r,aspect:i}}_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(t){t instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[t.offsetX,t.offsetY])}_onMouseleave(t){this._getAnimationProps()._mousePosition=null}};var Rd=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(t){this.id=t.id||Wt("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&tt(this.indices.usage===Q.INDEX)}destroy(){this.indices?.destroy();for(let t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(t){return t.byteLength/12}};function WC(e,t){if(t instanceof Rd)return t;let r=qV(e,t),{attributes:i,bufferLayout:s}=KV(e,t);return new Rd({topology:t.topology||"triangle-list",bufferLayout:s,vertexCount:t.vertexCount,indices:r,attributes:i})}function qV(e,t){if(!t.indices)return;let r=t.indices.value;return e.createBuffer({usage:Q.INDEX,data:r})}function KV(e,t){let r=[],i={};for(let[n,o]of Object.entries(t.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}i[a]=e.createBuffer({data:o.value,id:`${n}-buffer`});let{value:c,size:l,normalized:u}=o;r.push({name:a,format:J0(c,l,u)})}let s=t._calculateVertexCount(t.attributes,t.indices);return{attributes:i,bufferLayout:r,vertexCount:s}}var Id=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(t){let r=xn(Object.values(t).filter(i=>i.dependencies));for(let i of r)t[i.name]=i;D.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[i,s]of Object.entries(t)){let n=i;this.moduleUniforms[n]=s.defaultUniforms||{},this.moduleBindings[n]={}}}destroy(){}setProps(t){for(let r of Object.keys(t)){let i=r,s=t[i],n=this.modules[i];if(!n){D.warn(`Module ${r} not found`)();continue}let o=this.moduleUniforms[i],a=n.getUniforms?.(s,this.moduleUniforms[i])||s;this.moduleUniforms[i]={...o,...a}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let t={};for(let r of Object.values(this.moduleBindings))Object.assign(t,r);return t}getDebugTable(){let t={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[s,n]of Object.entries(i))t[`${r}.${s}`]={type:this.modules[r].uniformTypes?.[s],value:String(n)};return t}};var Hx=class{device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new Hx(t),t._lumaData.defaultPipelineFactory}constructor(t){this.device=t}createRenderPipeline(t){let r={...Or.defaultProps,...t},i=this._hashRenderPipeline(r);if(!this._renderPipelineCache[i]){let s=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});s.hash=i,this._renderPipelineCache[i]={pipeline:s,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(t){let r={...An.defaultProps,...t},i=this._hashComputePipeline(r);if(!this._computePipelineCache[i]){let s=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});s.hash=i,this._computePipelineCache[i]={pipeline:s,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(t){let r=t.hash,i=t instanceof An?this._computePipelineCache:this._renderPipelineCache;i[r].useCount--,i[r].useCount===0&&(i[r].pipeline.destroy(),delete i[r])}_hashComputePipeline(t){return`${this._getHash(t.shader.source)}`}_hashRenderPipeline(t){let r=this._getHash(t.vs.source),i=t.fs?this._getHash(t.fs.source):0,s="-",n=this._getHash(JSON.stringify(t.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${i}V${s}BL${n}`;default:let o=this._getHash(JSON.stringify(t.parameters));return`${r}/${i}V${s}T${t.topology}P${o}BL${n}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}},Pl=Hx;Y(Pl,"defaultProps",{...Or.defaultProps});var Gx=class{device;_cache={};static getDefaultShaderFactory(t){return t._lumaData.defaultShaderFactory||=new Gx(t),t._lumaData.defaultShaderFactory}constructor(t){this.device=t}createShader(t){let r=this._hashShader(t),i=this._cache[r];if(!i){let s=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[r]=i={shader:s,useCount:0}}return i.useCount++,i.shader}release(t){let r=this._hashShader(t),i=this._cache[r];i&&(i.useCount--,i.useCount===0&&(delete this._cache[r],i.shader.destroy()))}_hashShader(t){return`${t.stage}:${t.source}`}},Ml=Gx;Y(Ml,"defaultProps",{...ws.defaultProps});function jC(e,t){let r={},i="Values";if(e.attributes.length===0&&!e.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let s of e.attributes)if(s){let n=`${s.location} ${s.name}: ${s.type}`;r[`in ${n}`]={[i]:s.stepMode||"vertex"}}for(let s of e.varyings||[]){let n=`${s.location} ${s.name}`;r[`out ${n}`]={[i]:JSON.stringify(s.accessor)}}return r}var he=null,Wx=null;function XC(e,{id:t,minimap:r,opaque:i,top:s="0",left:n="0",rgbaScale:o=1}){he||(he=document.createElement("canvas"),he.id=t,he.title=t,he.style.zIndex="100",he.style.position="absolute",he.style.top=s,he.style.left=n,he.style.border="blue 1px solid",he.style.transform="scaleY(-1)",document.body.appendChild(he),Wx=he.getContext("2d")),(he.width!==e.width||he.height!==e.height)&&(he.width=e.width/2,he.height=e.height/2,he.style.width="400px",he.style.height="400px");let a=e.device.readPixelsToArrayWebGL(e),c=Wx.createImageData(e.width,e.height),l=0;for(let u=0;u<a.length;u+=4)c.data[l+u+0]=a[u+0]*o,c.data[l+u+1]=a[u+1]*o,c.data[l+u+2]=a[u+2]*o,c.data[l+u+3]=i?255:a[u+3]*o;Wx.putImageData(c,0,0)}var ha=2,$V=1e4,jx=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(t,r){this.props={...jx.defaultProps,...r},r=this.props,this.id=r.id||Wt("model"),this.device=t,Object.assign(this.userData,r.userData);let i=Object.fromEntries(this.props.modules?.map(a=>[a.name,a])||[]);this.setShaderInputs(r.shaderInputs||new Id(i));let s=JV(t),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=Ly(this.props.source);let{source:a,getUniforms:c}=this.props.shaderAssembler.assembleShader({platformInfo:s,...this.props,modules:n});this.source=a,this._getModuleUniforms=c}else{let{vs:a,fs:c,getUniforms:l}=this.props.shaderAssembler.assembleShaderPair({platformInfo:s,...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||Pl.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||Ml.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.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 t=this._needsRedraw;return this._needsRedraw=!1,t}setNeedsRedraw(t){this._needsRedraw||=t}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(t){this.predraw();let r;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),Ss(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:i}=this.vertexArray,s=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;r=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(t),r?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",r}setGeometry(t){this._gpuGeometry?.destroy();let r=t&&WC(this.device,t);r&&(this.setTopology(r.topology||"triangle-list"),this.bufferLayout=YC(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)),this._gpuGeometry=r}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){this.bufferLayout=this._gpuGeometry?YC(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){nl(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(t){this.instanceCount=t,this.isInstanced===void 0&&t>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(t){this.vertexCount=t,this.setNeedsRedraw("vertexCount")}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new el(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setNeedsRedraw("shaderInputs")}setBindings(t){Object.assign(this.bindings,t),this.setNeedsRedraw("bindings")}setTransformFeedback(t){this.transformFeedback=t,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(t,r){t.indices&&D.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[i,s]of Object.entries(t)){let n=this.bufferLayout.find(c=>qC(c).includes(i));if(!n){D.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let o=qC(n),a=!1;for(let c of o){let l=this._attributeInfos[c];l&&(this.vertexArray.setBuffer(l.location,s),a=!0)}!a&&!(r?.disableWarnings??this.props.disableWarnings)&&D.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,r){for(let[i,s]of Object.entries(t)){let n=this._attributeInfos[i];n?this.vertexArray.setConstantWebGL(n.location,s):(r?.disableWarnings??this.props.disableWarnings)||D.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(t){Ss(t)||(this.pipeline.setUniformsWebGL(t),Object.assign(this.uniforms,t)),this.setNeedsRedraw("uniforms")}updateModuleSettings(t){let{bindings:r,uniforms:i}=il(this._getModuleUniforms(t));Object.assign(this.bindings,r),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let t=0;for(let r of Object.values(this.bindings))r instanceof Cs?t=Math.max(t,r.texture.updateTimestamp):r instanceof Q||r instanceof xt?t=Math.max(t,r.updateTimestamp):r instanceof Ps||(t=Math.max(t,r.buffer.updateTimestamp));return t}_setGeometryAttributes(t){let r={...t.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(s=>s.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices||null),this.setAttributes(t.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate||=t,this.setNeedsRedraw(t)}_updatePipeline(){if(this._pipelineNeedsUpdate){let t=null,r=null;this.pipeline&&(D.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),s=null;this.source?s=i:this.fs&&(s=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:i,fs:s}),this._attributeInfos=Bh(this.pipeline.shaderLayout,this.bufferLayout),t&&this.shaderFactory.release(t),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let t=D.level>3?0:$V;D.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,D.group(ha,`>>> DRAWING MODEL ${this.id}`,{collapsed:D.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=jC(this.pipeline.shaderLayout,this.id);D.table(ha,t)();let r=this.shaderInputs.getDebugTable();for(let[s,n]of Object.entries(this.uniforms))r[s]={value:n};D.table(ha,r)();let i=this._getAttributeDebugTable();D.table(ha,this._attributeInfos)(),D.table(ha,i)(),D.groupEnd(ha)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){let r=D.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let i=t.props.framebuffer;i&&XC(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[r,i]of Object.entries(this._attributeInfos))t[i.location]={name:r,type:i.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[i.location],i.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);t.indices={name:"indices",type:r.indexType,values:i.toString()}}return t}_getBufferOrConstantValues(t,r){let i=rl(r);return(t instanceof Q?new i(t.debugData):t).toString()}},J=jx;Y(J,"defaultProps",{...Or.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:bs.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function YC(e,t){let r=[...e];for(let i of t){let s=r.findIndex(n=>n.name===i.name);s<0?r.push(i):r[s]=i}return r}function JV(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}function qC(e){return e.attributes?e.attributes?.map(t=>t.attribute):[e.name]}var Ar=class{device;model;transformFeedback;static isSupported(t){return t?.info?.type==="webgl"}constructor(t,r=J.defaultProps){tt(Ar.isSupported(t),"BufferTransform not yet implemented on WebGPU"),this.device=t,this.model=new J(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||$c(),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(t){let r=this.device.beginRenderPass(t);this.model.draw(r),r.end()}update(...t){console.warn("TextureTransform#update() not implemented")}getBuffer(t){return this.transformFeedback.getBuffer(t)}readAsync(t){let r=this.getBuffer(t);if(r instanceof Q)return r.readAsync();let{buffer:i,byteOffset:s=0,byteLength:n=i.byteLength}=r;return i.readAsync(s,n)}};var ZV="transform_output",yi=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(t,r){this.device=t,this.sampler=t.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||$c({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:ZV}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){}delete(){this.destroy()}run(t){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...t});this.model.draw(i),i.end()}update(...t){console.warn("TextureTransform#update() not implemented")}getData({packed:t=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:t}=this.bindings[this.currentIndex];return t}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(t){this._updateBindings(t)}_updateBindings(t){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t)}_updateBinding(t,{sourceBuffers:r,sourceTextures:i,targetTexture:s}){if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,i),Object.assign(t.sourceBuffers,r),s){t.targetTexture=s;let{width:n,height:o}=s;t.framebuffer&&t.framebuffer.destroy(),t.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:o,colorAttachments:[s]}),t.framebuffer.resize({width:n,height:o})}return t}_setSourceTextureParameters(){let t=this.currentIndex,{sourceTextures:r}=this.bindings[t];for(let i in r)r[i].sampler=this.sampler}};var it=class{id;topology;vertexCount;indices;attributes;userData={};constructor(t){let{attributes:r={},indices:i=null,vertexCount:s=null}=t;this.id=t.id||Wt("geometry"),this.topology=t.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[n,o]of Object.entries(r)){let a=ArrayBuffer.isView(o)?{value:o}:o;tt(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"?(tt(!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=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return`Geometry ${this.id} attribute ${t}`}_setAttributes(t,r){return this}_calculateVertexCount(t,r){if(r)return r.value.length;let i=1/0;for(let s of Object.values(t)){let{value:n,size:o,constant:a}=s;!a&&n&&o>=1&&(i=Math.min(i,n.length/o))}return tt(Number.isFinite(i)),i}};var QV=`#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;
}
`,KC=[-1,-1,1,-1,-1,1,1,1],Rl=class extends J{constructor(t,r){let i=KC.map(s=>s===-1?0:s);super(t,{...r,vs:QV,vertexCount:4,geometry:new it({topology:"triangle-strip",vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(KC)},aTexCoord:{size:2,value:new Float32Array(i)},aCoordinate:{size:2,value:new Float32Array(i)}}})})}};var Tr=class{id;matrix=new q;display=!0;position=new w;rotation=new w;scale=new w(1,1,1);userData={};props={};constructor(t={}){let{id:r}=t;this.id=r||Wt(this.constructor.name),this._setScenegraphNodeProps(t)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(t){return this._setScenegraphNodeProps(t),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(t){return tt(t.length===3,"setPosition requires vector argument"),this.position=t,this}setRotation(t){return tt(t.length===3,"setRotation requires vector argument"),this.rotation=t,this}setScale(t){return tt(t.length===3,"setScale requires vector argument"),this.scale=t,this}setMatrix(t,r=!0){r?this.matrix.copy(t):this.matrix=t}setMatrixComponents(t){let{position:r,rotation:i,scale:s,update:n=!0}=t;return r&&this.setPosition(r),i&&this.setRotation(i),s&&this.setScale(s),n&&this.updateMatrix(),this}updateMatrix(){let t=this.position,r=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(t),this.matrix.rotateXYZ(r),this.matrix.scale(i),this}update(t={}){let{position:r,rotation:i,scale:s}=t;return r&&this.setPosition(r),i&&this.setRotation(i),s&&this.setScale(s),this.updateMatrix(),this}getCoordinateUniforms(t,r){tt(t),r=r||this.matrix;let i=new q(t).multiplyRight(r),s=i.invert(),n=s.transpose();return{viewMatrix:t,modelMatrix:r,objectMatrix:r,worldMatrix:i,worldInverseMatrix:s,worldInverseTransposeMatrix:n}}_setScenegraphNodeProps(t){"display"in t&&(this.display=t.display),"position"in t&&this.setPosition(t.position),"rotation"in t&&this.setRotation(t.rotation),"scale"in t&&this.setScale(t.scale),"matrix"in t&&this.setMatrix(t.matrix),Object.assign(this.props,t)}};var er=class extends Tr{children;constructor(t={}){t=Array.isArray(t)?{children:t}:t;let{children:r=[]}=t;D.assert(r.every(i=>i instanceof Tr),"every child must an instance of ScenegraphNode"),super(t),this.children=r}getBounds(){let t=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:i})=>{let s=r.getBounds();if(!s)return;let[n,o]=s,a=new w(n).add(o).divide([2,2,2]);i.transformAsPoint(a,a);let c=new w(o).subtract(n).divide([2,2,2]);i.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++)t[0][f]=Math.min(t[0][f],u[f]),t[1][f]=Math.max(t[1][f],u[f])}}),Number.isFinite(t[0][0])?t:null}destroy(){this.children.forEach(t=>t.destroy()),this.removeAll(),super.destroy()}add(...t){for(let r of t)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(t){let r=this.children,i=r.indexOf(t);return i>-1&&r.splice(i,1),this}removeAll(){return this.children=[],this}traverse(t,{worldMatrix:r=new q}={}){let i=new q(r).multiplyRight(this.matrix);for(let s of this.children)s instanceof er?s.traverse(t,{worldMatrix:i}):t(s,{worldMatrix:i})}};var xi=class extends Tr{model;bounds=null;managedResources;constructor(t){super(t),this.model=t.model,this.managedResources=t.managedResources||[],this.bounds=t.bounds||null,this.setProps(t)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(t=>t.destroy()),this.managedResources=[]}draw(t){return this.model.draw(t)}};var Wi=class extends it{constructor(t={}){let{id:r=Wt("cube-geometry"),indices:i=!0}=t;super(i?{...t,id:r,topology:"triangle-list",indices:{size:1,value:t8},attributes:{...a8,...t.attributes}}:{...t,id:r,topology:"triangle-list",indices:void 0,attributes:{...c8,...t.attributes}})}},t8=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]),e8=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]),r8=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]),i8=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]),s8=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]),n8=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]),o8=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]),a8={POSITION:{size:3,value:e8},NORMAL:{size:3,value:r8},TEXCOORD_0:{size:2,value:i8}},c8={POSITION:{size:3,value:s8},TEXCOORD_0:{size:2,value:n8},COLOR_0:{size:3,value:o8}};var Il=class extends it{constructor(t={}){let{id:r=Wt("sphere-geometry")}=t,{indices:i,attributes:s}=l8(t);super({...t,id:r,topology:"triangle-list",indices:i,attributes:{...s,...t.attributes}})}};function l8(e){let{nlat:t=10,nlong:r=10}=e,n=Math.PI-0,o=0,c=2*Math.PI-o,l=(t+1)*(r+1),u=(_,y,x,E,P)=>e.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(t*r*6);for(let _=0;_<=t;_++)for(let y=0;y<=r;y++){let x=y/r,E=_/t,P=y+_*(r+1),B=P*2,F=P*3,M=c*x,v=n*E,T=Math.sin(M),L=Math.cos(M),V=Math.sin(v),z=Math.cos(v),W=L*V,Z=z,ut=T*V,st=u(W,Z,ut,x,E);f[F+0]=st*W,f[F+1]=st*Z,f[F+2]=st*ut,h[F+0]=W,h[F+1]=Z,h[F+2]=ut,d[B+0]=x,d[B+1]=1-E}let m=r+1;for(let _=0;_<r;_++)for(let y=0;y<t;y++){let x=(_*t+y)*6;g[x+0]=y*m+_,g[x+1]=y*m+_+1,g[x+2]=(y+1)*m+_,g[x+3]=(y+1)*m+_,g[x+4]=y*m+_+1,g[x+5]=(y+1)*m+_+1}return{indices:{size:1,value:g},attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:h},TEXCOORD_0:{size:2,value:d}}}}var Bl=class extends Rn{constructor(t,r){super(t,r);let{module:i,fs:s,id:n}=r,o={depthWriteEnabled:!1,depthCompare:"always"};this.model=new Rl(t,{id:n,fs:s,modules:[i],parameters:o})}render(t){this._renderPass(this.device,t)}delete(){this.model.destroy(),this.model=null}_renderPass(t,r){let{clearCanvas:i,inputBuffer:s,outputBuffer:n}=r,o=[s.width,s.height];this.model.shaderInputs.setProps(r.moduleSettings),this.model.setBindings({texSrc:s.colorAttachments[0]}),this.model.setUniforms({texSize:o});let a=this.device.beginRenderPass({framebuffer:n,parameters:{viewport:[0,0,...o]},clearColor:i?[0,0,0,0]:!1,clearDepth:1});this.model.draw(a),a.end()}};var Ol=class{constructor(t,r){this.id=`${t.name}-pass`,this.props=r,P0(t),this.module=t}setup({device:t}){this.passes=u8(t,this.module,this.id)}setProps(t){this.props=t}preRender(){}postRender(t){let r=this.passes,{target:i}=t,s=t.inputBuffer,n=t.swapBuffer;for(let o=0;o<r.length;o++){let a=o===r.length-1,c=i!==void 0&&a;c&&(n=i);let l=!c||Boolean(t.clearCanvas),u={},f=this.module.passes[o].uniforms;u[this.module.name]={...this.props,...f},r[o].render({clearCanvas:l,inputBuffer:s,outputBuffer:n,moduleSettings:u});let h=n;n=s,s=h}return s}cleanup(){if(this.passes){for(let t of this.passes)t.delete();this.passes=void 0}}};function u8(e,t,r){return t.passes.map((i,s)=>{let n=d8(t,i),o=`${r}-${s}`;return new Bl(e,{id:o,module:t,fs:n})})}var $C=`#version 300 es
uniform sampler2D texSrc;
uniform vec2 texSize;
in vec2 position;
in vec2 coordinate;
in vec2 uv;
out vec4 fragColor;
`,f8=e=>`${$C}
void main() {
fragColor = texture(texSrc, coordinate);
fragColor = ${e}(fragColor, texSize, coordinate);
}
`,h8=e=>`${$C}
void main() {
fragColor = ${e}(texSrc, texSize, coordinate);
}
`;function d8(e,t){if(t.filter){let r=typeof t.filter=="string"?t.filter:`${e.name}_filterColor`;return f8(r)}if(t.sampler){let r=typeof t.sampler=="string"?t.sampler:`${e.name}_sampleColor`;return h8(r)}return""}var p8={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"},Vr=class extends ye{constructor(){super(...arguments),this._colorEncoderState=null}render(t){return"pickingFBO"in t?this._drawPickingBuffer(t):super.render(t)}_drawPickingBuffer({layers:t,layerFilter:r,views:i,viewports:s,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:t,layerFilter:r,views:i,viewports:s,onViewportActive:n,cullRect:f,effects:h?.filter(E=>E.useInPicking),pass:d,isPicking:!0,moduleParameters:g,clearColor:[0,0,0,0],colorMask:15,scissorRect:_});return this._colorEncoderState=null,{decodePickingColor:m&&m8.bind(null,m),stats:y}}shouldDrawLayer(t){let{pickable:r,operation:i}=t.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(t,r,i){let s={depthMask:!0,depthTest:!0,depthRange:[0,1],...t.props.parameters},{pickable:n,operation:o}=t.props;return!this._colorEncoderState||o.includes("terrain")?s.blend=!1:n&&o.includes("draw")&&(Object.assign(s,p8),s.blend=!0,s.blendColor=g8(this._colorEncoderState,t,i)),s}_resetColorEncoder(t){return this._colorEncoderState=t?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function g8(e,t,r){let{byLayer:i,byAlpha:s}=e,n,o=i.get(t);return o?(o.viewports.push(r),n=o.a):(n=i.size+1,n<=255?(o={a:n,layer:t,viewports:[r]},i.set(t,o),s[n]=o):(k.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function m8(e,t){let r=e.byAlpha[t[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(t)}}var Us={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"},da=Symbol.for("component"),br=Symbol.for("propTypes"),Bd=Symbol.for("deprecatedProps"),ji=Symbol.for("asyncPropDefaults"),Ai=Symbol.for("asyncPropOriginal"),zr=Symbol.for("asyncPropResolved");function Oe(e,t=()=>!0){return Array.isArray(e)?JC(e,t,[]):t(e)?[e]:[]}function JC(e,t,r){let i=-1;for(;++i<e.length;){let s=e[i];Array.isArray(s)?JC(s,t,r):t(s)&&r.push(s)}return r}function Od({target:e,source:t,start:r=0,count:i=1}){let s=t.length,n=i*s,o=0;for(let a=r;o<s;o++)e[a++]=t[o];for(;o<n;)o<n-o?(e.copyWithin(r+o,r,r+o),o*=2):(e.copyWithin(r+o,r,r+n-o),o=n);return e}var Fl=class{constructor(t,r,i){this._loadCount=0,this._subscribers=new Set,this.id=t,this.context=i,this.setData(r)}subscribe(t){this._subscribers.add(t)}unsubscribe(t){this._subscribers.delete(t)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(t,r){if(t===this._data&&!r)return;this._data=t;let i=++this._loadCount,s=t;typeof t=="string"&&(s=Jt(t)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=t);for(let n of this._subscribers)n.onChange(this.getData())}};var Nl=class{constructor(t){this.protocol=t.protocol||"resource://",this._context={device:t.device,gl:t.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(t){return t.startsWith(this.protocol)?!0:t in this._resources}add({resourceId:t,data:r,forceUpdate:i=!1,persistent:s=!0}){let n=this._resources[t];n?n.setData(r,i):(n=new Fl(t,r,this._context),this._resources[t]=n),n.persistent=s}remove(t){let r=this._resources[t];r&&(r.delete(),delete this._resources[t])}unsubscribe({consumerId:t}){let r=this._consumers[t];if(r){for(let i in r){let s=r[i],n=this._resources[s.resourceId];n&&n.unsubscribe(s)}delete this._consumers[t],this.prune()}}subscribe({resourceId:t,onChange:r,consumerId:i,requestId:s="default"}){let{_resources:n,protocol:o}=this;t.startsWith(o)&&(t=t.replace(o,""),n[t]||this.add({resourceId:t,data:null,persistent:!1}));let a=n[t];if(this._track(i,s,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let t in this._resources)this._resources[t].delete()}_track(t,r,i,s){let n=this._consumers,o=n[t]=n[t]||{},a=o[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=s,a.resourceId=i.id):a={onChange:s,resourceId:i.id},o[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let t of Object.keys(this._resources)){let r=this._resources[t];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[t])}}};var _8="layerManager.setLayers",y8="layerManager.activateViewport",Fn=class{constructor(t,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{kt(y8,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:s,viewport:n,timeline:o}=r||{};this.layers=[],this.resourceManager=new Nl({device:t,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:t,gl:t?.gl,deck:i,shaderAssembler:aa(),defaultShaderModules:[],renderPass:void 0,stats:s||new Ee({id:"deck.gl"}),viewport:n||new xe({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new On,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let t of this.layers)this._finalizeLayer(t)}needsRedraw(t={clearRedrawFlags:!1}){let r=this._needsRedraw;t.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let s=i.getNeedsRedraw(t);r=r||s}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(t){this._needsRedraw=this._needsRedraw||t}setNeedsUpdate(t){this._needsUpdate=this._needsUpdate||t}getLayers({layerIds:t}={}){return t?this.layers.filter(r=>t.find(i=>r.id.indexOf(i)===0)):this.layers}setProps(t){"debug"in t&&(this._debug=t.debug),"userData"in t&&(this.context.userData=t.userData),"layers"in t&&(this._nextLayers=t.layers),"onError"in t&&(this.context.onError=t.onError)}setLayers(t,r){kt(_8,this,r,t),this._lastRenderedLayers=t;let i=Oe(t,Boolean);for(let s of i)s.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let t=this.needsUpdate();t&&(this.setNeedsRedraw(`updating layers: ${t}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,t)),this._nextLayers=null}addDefaultShaderModule(t){let{defaultShaderModules:r}=this.context;r.find(i=>i.name===t.name)||(r.push(t),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(t){let{defaultShaderModules:r}=this.context,i=r.findIndex(s=>s.name===t.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(t,r,i){i.raiseError(r,`${t} of ${i}`)}_updateLayers(t,r){let i={};for(let o of t)i[o.id]?k.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of t)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(r,i,s),this._finalizeOldLayers(i);let n=!1;for(let o of s)if(o.hasUniformTransition()){n=`Uniform transition in ${o}`;break}this._needsUpdate=n,this.layers=s}_updateSublayersRecursively(t,r,i){for(let s of t){s.context=this.context;let n=r[s.id];n===null&&k.warn(`Multiple new layers with same id ${s.id}`)(),r[s.id]=null;let o=null;try{this._debug&&n!==s&&s.validateProps(),n?(this._transferLayerState(n,s),this._updateLayer(s)):this._initializeLayer(s),i.push(s),o=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}o&&this._updateSublayersRecursively(o,r,i)}}_finalizeOldLayers(t){for(let r in t){let i=t[r];i&&this._finalizeLayer(i)}}_initializeLayer(t){try{t._initialize(),t.lifecycle=Us.INITIALIZED}catch(r){this._handleError("initialization",r,t)}}_transferLayerState(t,r){r._transferState(t),r.lifecycle=Us.MATCHED,r!==t&&(t.lifecycle=Us.AWAITING_GC)}_updateLayer(t){try{t._update()}catch(r){this._handleError("update",r,t)}}_finalizeLayer(t){this._needsRedraw=this._needsRedraw||`finalized ${t}`,t.lifecycle=Us.AWAITING_FINALIZATION;try{t._finalize(),t.lifecycle=Us.FINALIZED}catch(r){this._handleError("finalization",r,t)}}};function vt(e,t,r){if(e===t)return!0;if(!r||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!vt(e[i],t[i],r-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e=="object"&&typeof t=="object"){let i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(let n of i)if(!t.hasOwnProperty(n)||!vt(e[n],t[n],r-1))return!1;return!0}return!1}var Ll=class{constructor(t){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=t.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=t.eventManager,this._eventCallbacks={onViewStateChange:t.onViewStateChange,onInteractionStateChange:t.onInteractionStateChange},Object.seal(this),this.setProps(t)}finalize(){for(let t in this.controllers){let r=this.controllers[t];r&&r.finalize()}this.controllers={}}needsRedraw(t={clearRedrawFlags:!1}){let r=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(t){this._needsUpdate=this._needsUpdate||t,this._needsRedraw=this._needsRedraw||t}updateViewStates(){for(let t in this.controllers){let r=this.controllers[t];r&&r.updateTransition()}}getViewports(t){return t?this._viewports.filter(r=>r.containsPixel(t)):this._viewports}getViews(){let t={};return this.views.forEach(r=>{t[r.id]=r}),t}getView(t){return this.views.find(r=>r.id===t)}getViewState(t){let r=typeof t=="string"?this.getView(t):t,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(t){return this._viewportMap[t]}unproject(t,r){let i=this.getViewports(),s={x:t[0],y:t[1]};for(let n=i.length-1;n>=0;--n){let o=i[n];if(o.containsPixel(s)){let a=t.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,r)}}return null}setProps(t){t.views&&this._setViews(t.views),t.viewState&&this._setViewState(t.viewState),("width"in t||"height"in t)&&this._setSize(t.width,t.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(t,r){(t!==this.width||r!==this.height)&&(this.width=t,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(t){t=Oe(t,Boolean),this._diffViews(t,this.views)&&this.setNeedsUpdate("views changed"),this.views=t}_setViewState(t){t?(!vt(t,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=t):k.warn("missing `viewState` or `initialViewState`")()}_createController(t,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(t.id)?.makeViewport({viewState:n,width:this.width,height:this.height})})}_updateController(t,r,i,s){let n=t.controller;if(n&&i){let o={...r,...n,id:t.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!s||s.constructor!==n.type)&&(s=this._createController(t,o)),s&&s.setProps(o),s}return null}_rebuildViewports(){let{views:t}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let s=t.length;s--;){let n=t[s],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&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,o,a,c),a&&this._viewports.unshift(a)}for(let s in r){let n=r[s];n&&!this.controllers[s]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(t=>{t.id&&(this._viewportMap[t.id]=this._viewportMap[t.id]||t)})}_diffViews(t,r){return t.length!==r.length?!0:t.some((i,s)=>!t[s].equals(r[s]))}};var x8=/([0-9]+\.?[0-9]*)(%|px)/;function Xi(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":let t=x8.exec(e);if(t&&t.length>=3){let r=t[2]==="%",i=parseFloat(t[1]);return{position:r?i/100:i,relative:r}}default:throw new Error(`Could not parse position string ${e}`)}}function Yi(e,t){return e.relative?Math.round(e.position*t):e.position}var Fe=class{constructor(t){let{id:r,x:i=0,y:s=0,width:n="100%",height:o="100%",padding:a=null}=t;this.id=r||this.constructor.displayName||"view",this.props={...t,id:this.id},this._x=Xi(i),this._y=Xi(s),this._width=Xi(n),this._height=Xi(o),this._padding=a&&{left:Xi(a.left||0),right:Xi(a.right||0),top:Xi(a.top||0),bottom:Xi(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t?!0:this.ViewportType===t.ViewportType&&vt(this.props,t.props,2)}makeViewport({width:t,height:r,viewState:i}){i=this.filterViewState(i);let s=this.getDimensions({width:t,height:r});return!s.height||!s.width?null:new this.ViewportType({...i,...this.props,...s})}getViewStateId(){let{viewState:t}=this.props;return typeof t=="string"?t:t?.id||this.id}filterViewState(t){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let r={...t};for(let i in this.props.viewState)i!=="id"&&(r[i]=this.props.viewState[i]);return r}return t}getDimensions({width:t,height:r}){let i={x:Yi(this._x,t),y:Yi(this._y,r),width:Yi(this._width,t),height:Yi(this._height,r)};return this._padding&&(i.padding={left:Yi(this._padding.left,t),top:Yi(this._padding.top,r),right:Yi(this._padding.right,t),bottom:Yi(this._padding.bottom,r)}),i}get controller(){let t=this.props.controller;return t?t===!0?{type:this.ControllerType}:typeof t=="function"?{type:t}:{type:this.ControllerType,...t}:null}};var Hr=class{constructor(t){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=t}get inProgress(){return this._inProgress}start(t){this.cancel(),this.settings=t,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:t,settings:r}=this;this._handle=t.addChannel({delay:t.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 ZC=()=>{},Dl={BREAK:1,SNAP_TO_END:2,IGNORE:3},A8=e=>e,T8=Dl.BREAK,Ul=class{constructor(t){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:s,startProps:n,endProps:o,duration:a,easing:c}}=r,l=c(i/a),u=s.interpolateProps(n,o,l);this.propsInTransition=this.getControllerState({...this.props,...u}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new Hr(t.timeline),this.onViewStateChange=t.onViewStateChange||ZC,this.onStateChange=t.onStateChange||ZC}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let r=!1,i=this.props;if(this.props=t,!i||this._shouldIgnoreViewportChange(i,t))return!1;if(this._isTransitionEnabled(t)){let s=i;if(this.transition.inProgress){let{interruption:n,endProps:o}=this.transition.settings;s={...i,...n===Dl.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(s,t),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(t){let{transitionDuration:r,transitionInterpolator:i}=t;return(r>0||r==="auto")&&Boolean(i)}_isUpdateDueToCurrentTransition(t){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(t,this.propsInTransition):!1}_shouldIgnoreViewportChange(t,r){return this.transition.inProgress?this.transition.settings.interruption===Dl.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(t,r):!0}_triggerTransition(t,r){let i=this.getControllerState(t),s=this.getControllerState(r).shortestPathFrom(i),n=r.transitionInterpolator,o=n.getDuration?n.getDuration(t,r):r.transitionDuration;if(o===0)return;let a=n.initializeProps(t,s);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||A8,interpolator:n,interruption:r.transitionInterruption||T8,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(t){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),t?.(r)}}};function At(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}var qi=class{constructor(t){let{compare:r,extract:i,required:s}=t;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=s}arePropsEqual(t,r){for(let i of this._propsToCompare)if(!(i in t)||!(i in r)||!Ct(t[i],r[i]))return!1;return!0}initializeProps(t,r){let i={},s={};for(let n of this._propsToExtract)(n in t||n in r)&&(i[n]=t[n],s[n]=r[n]);return this._checkRequiredProps(i),this._checkRequiredProps(s),{start:i,end:s}}getDuration(t,r){return r.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach(r=>{let i=t[r];At(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var b8=["longitude","latitude","zoom","bearing","pitch"],E8=["longitude","latitude","zoom"],Ae=class extends qi{constructor(t={}){let r=Array.isArray(t)?t:t.transitionProps,i=Array.isArray(t)?{}:t;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:b8,required:E8},super(i.transitionProps),this.opts=i}initializeProps(t,r){let i=super.initializeProps(t,r),{makeViewport:s,around:n}=this.opts;if(s&&n){let o=s(t),a=s(r),c=o.unproject(n);i.start.around=n,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:r.width,height:r.height})}return i}interpolateProps(t,r,i){let s={};for(let n of this._propsToExtract)s[n]=se(t[n]||0,r[n]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...s});Object.assign(s,n.panByPosition(r.aroundPosition,se(t.around,r.around,i)))}return s}};var ks={transitionDuration:0},S8=300,Fd=e=>1-(1-e)*(1-e),pa={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},Nn={},Ne=class{constructor(t){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 Ul({...t,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=t.eventManager,this.onViewStateChange=t.onViewStateChange||(()=>{}),this.onStateChange=t.onStateChange||(()=>{}),this.makeViewport=t.makeViewport}set events(t){this.toggleEvents(this._customEvents,!1),this.toggleEvents(t,!0),this._customEvents=t,this.props&&this.setProps(this.props)}finalize(){for(let t in this._events)this._events[t]&&this.eventManager?.off(t,this.handleEvent);this.transitionManager.finalize()}handleEvent(t){this._controllerState=void 0;let r=this._eventStartBlocked;switch(t.type){case"panstart":return r?!1:this._onPanStart(t);case"panmove":return this._onPan(t);case"panend":return this._onPanEnd(t);case"pinchstart":return r?!1:this._onPinchStart(t);case"pinchmove":return this._onPinch(t);case"pinchend":return this._onPinchEnd(t);case"tripanstart":return r?!1:this._onTriplePanStart(t);case"tripanmove":return this._onTriplePan(t);case"tripanend":return this._onTriplePanEnd(t);case"doubletap":return this._onDoubleTap(t);case"wheel":return this._onWheel(t);case"keydown":return this._onKeyDown(t);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(t){let{x:r,y:i}=this.props,{offsetCenter:s}=t;return[s.x-r,s.y-i]}isPointInBounds(t,r){let{width:i,height:s}=this.props;if(r&&r.handled)return!1;let n=t[0]>=0&&t[0]<=i&&t[1]>=0&&t[1]<=s;return n&&r&&r.stopPropagation(),n}isFunctionKeyPressed(t){let{srcEvent:r}=t;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(t){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},t);this._eventStartBlocked=r}setProps(t){t.dragMode&&(this.dragMode=t.dragMode),this.props=t,"transitionInterpolator"in t||(t.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(t);let{inertia:r}=t;this.inertia=Number.isFinite(r)?r:r===!0?S8:0;let{scrollZoom:i=!0,dragPan:s=!0,dragRotate:n=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=t,u=Boolean(this.onViewStateChange);this.toggleEvents(pa.WHEEL,u&&i),this.toggleEvents(pa.PAN,u),this.toggleEvents(pa.PINCH,u&&(a||c)),this.toggleEvents(pa.TRIPLE_PAN,u&&c),this.toggleEvents(pa.DOUBLE_TAP,u&&o),this.toggleEvents(pa.KEYBOARD,u&&l),this.scrollZoom=i,this.dragPan=s,this.dragRotate=n,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,r){this.eventManager&&t.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(t,r=null,i={}){let s={...t.getViewportProps(),...r},n=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(i),n){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(t){this.onViewStateChange({...t,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(t){Object.assign(this._interactionState,t),this.onStateChange(this._interactionState)}_onPanStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let i=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let s=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(s,ks,{isDragging:!0}),!0}_onPan(t){return this.isDragging()?this._panMove?this._onPanMove(t):this._onPanRotate(t):!1}_onPanEnd(t){return this.isDragging()?this._panMove?this._onPanMoveEnd(t):this._onPanRotateEnd(t):!1}_onPanMove(t){if(!this.dragPan)return!1;let r=this.getCenter(t),i=this.controllerState.pan({pos:r});return this.updateViewport(i,ks,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){let{inertia:r}=this;if(this.dragPan&&r&&t.velocity){let i=this.getCenter(t),s=[i[0]+t.velocityX*r/2,i[1]+t.velocityY*r/2],n=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Fd},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;let r=this.getCenter(t),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,ks,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){let{inertia:r}=this;if(this.dragRotate&&r&&t.velocity){let i=this.getCenter(t),s=[i[0]+t.velocityX*r/2,i[1]+t.velocityY*r/2],n=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Fd},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(t){if(!this.scrollZoom)return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;t.srcEvent.preventDefault();let{speed:i=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=t,o=2/(1+Math.exp(-Math.abs(n*i)));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:s?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,ks,{isDragging:!0}),!0}_onTriplePan(t){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(t);r[0]-=t.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,ks,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(t){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&t.velocityY){let i=this.getCenter(t),s=[i[0],i[1]+=t.velocityY*r/2],n=this.controllerState.rotate({pos:s});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Fd},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return Nn._startPinchRotation=t.rotation,Nn._lastPinchEvent=t,this.updateViewport(i,ks,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=t,s=this.getCenter(t);r=r.zoom({pos:s,scale:i})}if(this.touchRotate){let{rotation:i}=t;r=r.rotate({deltaAngleX:Nn._startPinchRotation-i})}return this.updateViewport(r,ks,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Nn._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=Nn;if(this.touchZoom&&r&&i&&t.scale!==i.scale){let s=this.getCenter(t),n=this.controllerState.rotateEnd(),o=Math.log2(t.scale),a=(o-Math.log2(i.scale))/(t.deltaTime-i.deltaTime),c=Math.pow(2,o+a*r/2);n=n.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:s}),transitionDuration:r,transitionEasing:Fd},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Nn._startPinchRotation=null,Nn._lastPinchEvent=null,!0}_onDoubleTap(t){if(!this.doubleClickZoom)return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let i=this.isFunctionKeyPressed(t),s=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(s,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(t),{zoomSpeed:i,moveSpeed:s,rotateSpeedX:n,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(t.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(t){let{transition:r}=this;return!r||!r.transitionInterpolator?ks:t?{...r,transitionInterpolator:new Ae({...t,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Ki=class{constructor(t,r){this._viewportProps=this.applyConstraints(t),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var QC=5,v8=1.2,kl=class extends Ki{constructor(t){let{width:r,height:i,latitude:s,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:E,normalize:P=!0}=t;At(Number.isFinite(n)),At(Number.isFinite(s)),At(Number.isFinite(o)),super({width:r,height:i,latitude:s,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:E}),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanLngLat:this._unproject(t)})}pan({pos:t,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startBearing:n,startPitch:o}=this.getState();if(!s||n===void 0||o===void 0)return this;let a;return t?a=this._getNewRotation(t,s,o,n):a={bearing:n+r,pitch:o+i},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:t}){return this._getUpdatedState({startZoomLngLat:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:r,scale:i}){let{startZoom:s,startZoomLngLat:n}=this.getState();if(n||(s=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(t)),!n)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=s+Math.log2(i);c=ht(c,a,o);let l=this.makeViewport({...this.getViewportProps(),zoom:c});return this._getUpdatedState({zoom:c,...l.panByPosition(n,t)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(t=2){return this._zoomFromCenter(t)}zoomOut(t=2){return this._zoomFromCenter(1/t)}moveLeft(t=100){return this._panFromCenter([t,0])}moveRight(t=100){return this._panFromCenter([-t,0])}moveUp(t=100){return this._panFromCenter([0,t])}moveDown(t=100){return this._panFromCenter([0,-t])}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}shortestPathFrom(t){let r=t.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:n}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(t){let{maxZoom:r,minZoom:i,zoom:s}=t;t.zoom=ht(s,i,r);let{maxPitch:n,minPitch:o,pitch:a}=t;t.pitch=ht(a,o,n);let{normalize:c=!0}=t;return c&&Object.assign(t,Lx(t)),t}_zoomFromCenter(t){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:t})}_panFromCenter(t){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+t[0],i/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}_unproject(t){let r=this.makeViewport(this.getViewportProps());return t&&r.unproject(t)}_getNewRotation(t,r,i,s){let n=t[0]-r[0],o=t[1]-r[1],a=t[1],c=r[1],{width:l,height:u}=this.getViewportProps(),f=n/l,h=0;o>0?Math.abs(u-c)>QC&&(h=o/(c-u)*v8):o<0&&c>QC&&(h=1-a/c),h=ht(h,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=s+180*f,m=i;return h>0?m=i+h*(p-i):h<0&&(m=i-h*(d-i)),{pitch:m,bearing:g}}},Ln=class extends Ne{constructor(){super(...arguments),this.ControllerState=kl,this.transition={transitionDuration:300,transitionInterpolator:new Ae({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(t){t.position=t.position||[0,0,0];let r=this.props;super.setProps(t),(!r||r.height!==t.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...t,...this.state}))}};var Xx=class extends Fe{constructor(t={}){super(t)}get ViewportType(){return ne}get ControllerType(){return Ln}},Gr=Xx;(()=>{Xx.displayName="MapView"})();var C8=new Ds;function w8(e,t){let r=e.order??1/0,i=t.order??1/0;return r-i}var Vl=class{constructor(t){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=t,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(t){let r=this._defaultEffects;if(!r.find(i=>i.id===t.id)){let i=r.findIndex(s=>w8(s,t)>0);i<0?r.push(t):r.splice(i,0,t),t.setup(this._context),this._setEffects(this.effects)}}setProps(t){"effects"in t&&(vt(t.effects,this.effects,1)||this._setEffects(t.effects))}needsRedraw(t={clearRedrawFlags:!1}){let r=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(t){let r={};for(let s of this.effects)r[s.id]=s;let i=[];for(let s of t){let n=r[s.id],o=s;n&&n!==s?n.setProps?(n.setProps(s.props),o=n):n.cleanup(this._context):n||s.setup(this._context),i.push(o),delete r[s.id]}for(let s in r)r[s].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),t.some(s=>s instanceof Ds)||this._resolvedEffects.push(C8),this._needsRedraw="effects changed"}finalize(){for(let t of this._resolvedEffects)t.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var zl=class extends ye{shouldDrawLayer(t){let{operation:r}=t.props;return r.includes("draw")||r.includes("terrain")}};var P8="deckRenderer.renderLayers",Dn=class{constructor(t){this.device=t,this.gl=t.gl,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new zl(t),this.pickLayersPass=new Vr(t),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(t){this.layerFilter!==t.layerFilter&&(this.layerFilter=t.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==t.drawPickingColors&&(this.drawPickingColors=t.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(t){if(!t.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...t};i.effects&&this._preRender(i.effects,i);let s=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let n=r.render({...i,target:s});i.effects&&this._postRender(i.effects,i),this.renderCount++,kt(P8,this,n,t)}needsRedraw(t={clearRedrawFlags:!1}){let r=this._needsRedraw;return t.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:t}=this;for(let r of t)r.delete();t.length=0}_preRender(t,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of t)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:t}=this,r=this.device.canvasContext.getDrawingBufferSize();t.length===0&&[0,1].map(i=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[s]}))});for(let i of t)i.resize(r)}_postRender(t,r){let{renderBuffers:i}=this,s={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let n of t)if(n.postRender){s.target=n.id===this.lastPostProcessEffect?r.target:void 0;let o=n.postRender(s);s.inputBuffer=o,s.swapBuffer=o===i[0]?i[1]:i[0]}}};var M8={pickedColor:null,pickedObjectIndex:-1};function tw({pickedColors:e,decodePickingColor:t,deviceX:r,deviceY:i,deviceRadius:s,deviceRect:n}){let{x:o,y:a,width:c,height:l}=n,u=s*s,f=-1,h=0;for(let d=0;d<l;d++){let p=d+a-i,g=p*p;if(g>u)h+=4*c;else for(let m=0;m<c;m++){if(e[h+3]-1>=0){let y=m+o-r,x=y*y+g;x<=u&&(u=x,f=h)}h+=4}}if(f>=0){let d=e.slice(f,f+4),p=t(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 M8}function ew({pickedColors:e,decodePickingColor:t}){let r=new Map;if(e){for(let i=0;i<e.length;i+=4)if(e[i+3]-1>=0){let n=e.slice(i,i+4),o=n.join(",");if(!r.has(o)){let a=t(n);a?r.set(o,{...a,color:n}):k.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function Yx({pickInfo:e,viewports:t,pixelRatio:r,x:i,y:s,z:n}){let o=t[0];t.length>1&&(o=R8(e?.pickedViewports||t,{x:i,y:s}));let a;if(o){let c=[i-o.x,s-o.y];n!==void 0&&(c[2]=n),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:s,pixel:[i,s],coordinate:a,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:r}}function rw(e){let{pickInfo:t,lastPickedInfo:r,mode:i,layers:s}=e,{pickedColor:n,pickedLayer:o,pickedObjectIndex:a}=t,c=o?[o]:[];if(i==="hover"){let f=r.index,h=r.layerId,d=o?o.props.id:null;if(d!==h||a!==f){if(d!==h){let p=s.find(g=>g.props.id===h);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=Yx(e),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=qx({layer:f,info:h,mode:i});let d=h.layer;f===o&&i==="hover"&&(r.info=h),u.set(d.id,h),i==="hover"&&d.updateAutoHighlight(h)}),u}function qx({layer:e,info:t,mode:r}){for(;e&&t;){let i=t.layer||null;t.sourceLayer=i,t.layer=e,t=e.getPickingInfo({info:t,mode:r,sourceLayer:i}),e=e.parent}return t}function R8(e,t){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.containsPixel(t))return i}return e[0]}var Hl=class{constructor(t){this._pickable=!0,this.device=t,this.pickLayersPass=new Vr(t),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(t){"layerFilter"in t&&(this.layerFilter=t.layerFilter),"_pickable"in t&&(this._pickable=t._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(t){return this._pickClosestObject(t)}pickObjects(t){return this._pickVisibleObjects(t)}getLastPickedObject({x:t,y:r,layers:i,viewports:s},n=this.lastPickedInfo.info){let o=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=o?i.find(h=>h.id===o):null,l=a&&s.find(h=>h.id===a)||s[0],u=l&&l.unproject([t-l.x,r-l.y]);return{...n,...{x:t,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 t=this.device.gl;this.pickingFBO?.resize({width:t.canvas.width,height:t.canvas.height}),this.depthFBO?.resize({width:t.canvas.width,height:t.canvas.height})}_getPickable(t){if(this._pickable===!1)return null;let r=t.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}_pickClosestObject({layers:t,views:r,viewports:i,x:s,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(t);if(!d||i.length===0)return{result:[],emptyInfo:Yx({viewports:i,x:s,y:n,pixelRatio:h})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,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}),E={x:s-o,y:n-o,width:o*2+1,height:o*2+1},P,B=[],F=new Set;for(let M=0;M<a;M++){let v;if(x){let L=this._drawAndSample({layers:d,views:r,viewports:i,onViewportActive:u,deviceRect:x,cullRect:E,effects:f,pass:`picking:${c}`});v=tw({...L,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:x})}else v={pickedColor:null,pickedObjectIndex:-1};let T;if(v.pickedLayer&&l&&this.depthFBO){let{pickedColors:L}=this._drawAndSample({layers:[v.pickedLayer],views:r,viewports:i,onViewportActive:u,deviceRect:{x:v.pickedX,y:v.pickedY,width:1,height:1},cullRect:E,effects:f,pass:`picking:${c}:z`},!0);L[3]&&(T=L[0])}v.pickedLayer&&M+1<a&&(F.add(v.pickedLayer),v.pickedLayer.disablePickingIndex(v.pickedObjectIndex)),P=rw({pickInfo:v,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:s,y:n,z:T,pixelRatio:h});for(let L of P.values())L.layer&&B.push(L);if(!v.pickedColor)break}for(let M of F)M.restorePickingColors();return{result:B,emptyInfo:P.get(null)}}_pickVisibleObjects({layers:t,views:r,viewports:i,x:s,y:n,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:u,effects:f}){let h=this._getPickable(t);if(!h||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,n],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([s+o,n+a],!0),y=_.x+_.width,x=_.y,E={x:g,y:x,width:y-g,height:m-x},P=this._drawAndSample({layers:h,views:r,viewports:i,onViewportActive:u,deviceRect:E,cullRect:{x:s,y:n,width:o,height:a},effects:f,pass:`picking:${c}`}),B=ew(P),F=new Map,M=[],v=Number.isFinite(l);for(let T=0;T<B.length&&!(v&&M.length>=l);T++){let L=B[T],V={color:L.pickedColor,layer:null,index:L.pickedObjectIndex,picked:!0,x:s,y:n,pixelRatio:d};V=qx({layer:L.pickedLayer,info:V,mode:c});let z=V.layer.id;F.has(z)||F.set(z,new Set);let W=F.get(z),Z=V.object??V.index;W.has(Z)||(W.add(Z),M.push(V))}return M}_drawAndSample({layers:t,views:r,viewports:i,onViewportActive:s,deviceRect:n,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:t,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,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:t,deviceY:r,deviceRadius:i,deviceWidth:s,deviceHeight:n}){let o=Math.max(0,t-i),a=Math.max(0,r-i),c=Math.min(s,t+i+1)-o,l=Math.min(n,r+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var I8={"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}},B8="top-left",iw="__root",Nd=class{constructor({deck:t,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=t,this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(t){t.widgets&&!vt(t.widgets,this.widgets,1)&&this._setWidgets(t.widgets)}finalize(){for(let t of this.getWidgets())this._remove(t);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let t in this.containers)this.containers[t].remove()}addDefault(t){this.defaultWidgets.find(r=>r.id===t.id)||(this._add(t),this.defaultWidgets.push(t),this._setWidgets(this.widgets))}_setWidgets(t){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of t){let s=r[i.id];s?s.viewId!==i.viewId||s.placement!==i.placement?(this._remove(s),this._add(i)):i!==s&&(s.setProps(i.props),i=s):this._add(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let s=r[i];s&&this._remove(s)}this.widgets=t}_add(t){let{viewId:r=null,placement:i=B8}=t,s=t.onAdd({deck:this.deck,viewId:r});s&&this._getContainer(r,i).append(s),t._element=s}_remove(t){t.onRemove(),t._element&&t._element.remove(),t._element=void 0}_getContainer(t,r){let i=t||iw,s=this.containers[i];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[i]=s);let n=s.querySelector(`.${r}`);return n||(n=document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,I8[r]),s.append(n)),n}_updateContainers(){let t=this.deck.width,r=this.deck.height;for(let i in this.containers){let s=this.lastViewports[i]||null,n=i===iw||s,o=this.containers[i];n?(o.style.display="block",o.style.left=`${s?s.x:0}px`,o.style.top=`${s?s.y:0}px`,o.style.width=`${s?s.width:t}px`,o.style.height=`${s?s.height:r}px`):o.style.display="none"}}onRedraw({viewports:t,layers:r}){let i=t.reduce((n,o)=>(n[o.id]=o,n),{}),{lastViewports:s}=this;for(let n of this.getWidgets()){let{viewId:o}=n;if(o){let a=i[o];a&&(n.onViewportChange&&!a.equals(s[o])&&n.onViewportChange(a),n.onRedraw?.({viewports:[a],layers:r}))}else{if(n.onViewportChange)for(let a of t)a.equals(s[a.id])||n.onViewportChange(a);n.onRedraw?.({viewports:t,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(t,r){for(let i of this.getWidgets()){let{viewId:s}=i;(!s||s===t.viewport?.id)&&i.onHover?.(t,r)}}onEvent(t,r){let i=_l[r.type];if(i)for(let s of this.getWidgets()){let{viewId:n}=s;(!n||n===t.viewport?.id)&&s[i.handler]?.(t,r)}}};var O8={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Gl=class{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:t}){let r=document.createElement("div");return r.className="deck-tooltip",Object.assign(r.style,O8),this.deck=t,this.element=r,r}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(t){this.isVisible&&t.id===this.lastViewport?.id&&t!==this.lastViewport&&this.setTooltip(null)}onHover(t){let{deck:r}=this,i=r&&r.props.getTooltip;if(!i)return;let s=i(t);this.lastViewport=t.viewport,this.setTooltip(s,t.x,t.y)}setTooltip(t,r,i){let s=this.element;if(s){if(typeof t=="string")s.innerText=t;else if(t)t.text&&(s.innerText=t.text),t.html&&(s.innerHTML=t.html),t.className&&(s.className=t.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${r}px, ${i}px)`,t&&typeof t=="object"&&"style"in t&&Object.assign(s.style,t.style)}}};var Vs;(function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Vs||(Vs={}));var jl={[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},ee=(e,t,r)=>t?e.enable(r):e.disable(r),sw=(e,t,r)=>e.hint(r,t),rr=(e,t,r)=>e.pixelStorei(r,t),nw=(e,t,r)=>{let i=r===36006?36009:36008;return e.bindFramebuffer(i,t)},Wl=(e,t,r)=>{let s={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];e.bindBuffer(s,t)};function Kx(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var ow={[3042]:ee,[32773]:(e,t)=>e.blendColor(...t),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(e,t)=>e.clearColor(...t),[3107]:(e,t)=>e.colorMask(...t),[2884]:ee,[2885]:(e,t)=>e.cullFace(t),[2929]:ee,[2931]:(e,t)=>e.clearDepth(t),[2932]:(e,t)=>e.depthFunc(t),[2928]:(e,t)=>e.depthRange(...t),[2930]:(e,t)=>e.depthMask(t),[3024]:ee,[35723]:sw,[35725]:(e,t)=>e.useProgram(t),[36007]:(e,t)=>e.bindRenderbuffer(36161,t),[36389]:(e,t)=>e.bindTransformFeedback?.(36386,t),[34229]:(e,t)=>e.bindVertexArray(t),[36006]:nw,[36010]:nw,[34964]:Wl,[36662]:Wl,[36663]:Wl,[35053]:Wl,[35055]:Wl,[2886]:(e,t)=>e.frontFace(t),[33170]:sw,[2849]:(e,t)=>e.lineWidth(t),[32823]:ee,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:ee,[32926]:ee,[32928]:ee,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:ee,[3088]:(e,t)=>e.scissor(...t),[2960]:ee,[2961]:(e,t)=>e.clearStencil(t),[2968]:(e,t)=>e.stencilMaskSeparate(1028,t),[36005]:(e,t)=>e.stencilMaskSeparate(1029,t),[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]:(e,t)=>e.viewport(...t),[34383]:ee,[10754]:ee,[12288]:ee,[12289]:ee,[12290]:ee,[12291]:ee,[12292]:ee,[12293]:ee,[12294]:ee,[12295]:ee,[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:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Kx(t)?t:[t,t];let[r,i]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{t=Kx(t)&&t.length===3?[...t,...t]:t;let[r,i,s,n,o,a]=t;e.stencilFuncSeparate(1028,r,i,s),e.stencilFuncSeparate(1029,n,o,a)},stencilOp:(e,t)=>{t=Kx(t)&&t.length===3?[...t,...t]:t;let[r,i,s,n,o,a]=t;e.stencilOpSeparate(1028,r,i,s),e.stencilOpSeparate(1029,n,o,a)},viewport:(e,t)=>e.viewport(...t)};function zt(e,t,r){return t[e]!==void 0?t[e]:r[e]}var aw={blendEquation:(e,t,r)=>e.blendEquationSeparate(zt(32777,t,r),zt(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(zt(32969,t,r),zt(32968,t,r),zt(32971,t,r),zt(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(zt(32824,t,r),zt(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(zt(32938,t,r),zt(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,zt(2962,t,r),zt(2967,t,r),zt(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,zt(34816,t,r),zt(36003,t,r),zt(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,zt(2964,t,r),zt(2965,t,r),zt(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,zt(34817,t,r),zt(34818,t,r),zt(34819,t,r))},$x={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({[35725]:t}),bindRenderbuffer:(e,t,r)=>e({[36007]:r}),bindTransformFeedback:(e,t,r)=>e({[36389]:r}),bindVertexArray:(e,t)=>e({[34229]:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({[36006]:r,[36010]:r});case 36009:return e({[36006]:r});case 36008:return e({[36010]:r});default:return null}},bindBuffer:(e,t,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[t];return i?e({[i]:r}):{valueChanged:!0}},blendColor:(e,t,r,i,s)=>e({[32773]:new Float32Array([t,r,i,s])}),blendEquation:(e,t)=>e({[32777]:t,[34877]:t}),blendEquationSeparate:(e,t,r)=>e({[32777]:t,[34877]:r}),blendFunc:(e,t,r)=>e({[32969]:t,[32968]:r,[32971]:t,[32970]:r}),blendFuncSeparate:(e,t,r,i,s)=>e({[32969]:t,[32968]:r,[32971]:i,[32970]:s}),clearColor:(e,t,r,i,s)=>e({[3106]:new Float32Array([t,r,i,s])}),clearDepth:(e,t)=>e({[2931]:t}),clearStencil:(e,t)=>e({[2961]:t}),colorMask:(e,t,r,i,s)=>e({[3107]:[t,r,i,s]}),cullFace:(e,t)=>e({[2885]:t}),depthFunc:(e,t)=>e({[2932]:t}),depthRange:(e,t,r)=>e({[2928]:new Float32Array([t,r])}),depthMask:(e,t)=>e({[2930]:t}),frontFace:(e,t)=>e({[2886]:t}),lineWidth:(e,t)=>e({[2849]:t}),polygonOffset:(e,t,r)=>e({[32824]:t,[10752]:r}),sampleCoverage:(e,t,r)=>e({[32938]:t,[32939]:r}),scissor:(e,t,r,i,s)=>e({[3088]:new Int32Array([t,r,i,s])}),stencilMask:(e,t)=>e({[2968]:t,[36005]:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,i)=>e({[2962]:t,[2967]:r,[2963]:i,[34816]:t,[36003]:r,[36004]:i}),stencilFuncSeparate:(e,t,r,i,s)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:i,[t===1028?2963:36004]:s}),stencilOp:(e,t,r,i)=>e({[2964]:t,[2965]:r,[2966]:i,[34817]:t,[34818]:r,[34819]:i}),stencilOpSeparate:(e,t,r,i,s)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:i,[t===1028?2966:34819]:s}),viewport:(e,t,r,i,s)=>e({[2978]:[t,r,i,s]})},Ti=(e,t)=>e.isEnabled(t),Jx={[3042]:Ti,[2884]:Ti,[2929]:Ti,[3024]:Ti,[32823]:Ti,[32926]:Ti,[32928]:Ti,[3089]:Ti,[2960]:Ti,[35977]:Ti},cw=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 Wr(e,t){if(F8(t))return;let r={};for(let s in t){let n=Number(s),o=ow[s];o&&(typeof o=="string"?r[o]=!0:o(e,t[s],n))}let i=e.state&&e.state.cache;if(i)for(let s in r){let n=aw[s];n(e,t,i)}}function Ld(e,t=jl){if(typeof t=="number"){let s=t,n=Jx[s];return n?n(e,s):e.getParameter(s)}let r=Array.isArray(t)?t:Object.keys(t),i={};for(let s of r){let n=Jx[s];i[s]=n?n(e,Number(s)):e.getParameter(Number(s))}return i}function lw(e){Wr(e,jl)}function F8(e){for(let t in e)return!1;return!0}function uw(e,t){if(e===t)return!0;let r=Array.isArray(e)||ArrayBuffer.isView(e),i=Array.isArray(t)||ArrayBuffer.isView(t);if(r&&i&&e.length===t.length){for(let s=0;s<e.length;++s)if(e[s]!==t[s])return!1;return!0}return!1}var Zx=class{gl;program=null;stateStack=[];enable=!0;cache;log;constructor(t,{copyState:r=!1,log:i=()=>{}}={}){this.gl=t,this.cache=r?Ld(t):Object.assign({},jl),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(t={}){this.stateStack.push({})}pop(){tt(this.stateStack.length>0);let t=this.stateStack[this.stateStack.length-1];Wr(this.gl,t),this.stateStack.pop()}_updateCache(t){let r=!1,i,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in t){tt(n!==void 0);let o=t[n],a=this.cache[n];uw(o,a)||(r=!0,i=a,s&&!(n in s)&&(s[n]=a),this.cache[n]=o)}return{valueChanged:r,oldValue:i}}};function Un(e){return e.state}function Qx(e,t){let{enable:r=!0,copyState:i}=t;if(tt(i!==void 0),!e.state){e.state=new Zx(e,{copyState:i}),L8(e);for(let n in $x){let o=$x[n];N8(e,n,o)}fw(e,"getParameter"),fw(e,"isEnabled")}let s=Un(e);return s.enable=r,e}function zs(e){let t=Un(e);t||(Qx(e,{copyState:!1}),t=Un(e)),t.push()}function $i(e){let t=Un(e);tt(t),t.pop()}function fw(e,t){let r=e[t].bind(e);e[t]=function(s){if(s===void 0||cw.has(s))return r(s);let n=Un(e);return s in n.cache||(n.cache[s]=r(s)),n.enable?n.cache[s]:r(s)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function N8(e,t,r){if(!e[t])return;let i=e[t].bind(e);e[t]=function(...n){let o=Un(e),{valueChanged:a,oldValue:c}=r(o._updateCache,...n);return a&&i(...n),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function L8(e){let t=e.useProgram.bind(e);e.useProgram=function(i){let s=Un(e);s.program!==i&&(t(i),s.program=i)}}var D8={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function hw(e,t){t={...D8,...t};let r=null,i=n=>r=n.statusMessage||r;e.addEventListener("webglcontextcreationerror",i,!1);let s=null;if(s||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",i,!1),!s)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(t.onContextLost){let{onContextLost:n}=t;e.addEventListener("webglcontextlost",o=>n(o),!1)}if(t.onContextRestored){let{onContextRestored:n}=t;e.addEventListener("webglcontextrestored",o=>n(o),!1)}return s}function Er(e,t,r){return r[t]===void 0&&(r[t]=e.getExtension(t)||null),r[t]}function dw(e,t){let r=e.getParameter(7936),i=e.getParameter(7937);Er(e,"WEBGL_debug_renderer_info",t);let s=t.WEBGL_debug_renderer_info,n=e.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=o||i,l=e.getParameter(7938),u=pw(a,c),f=U8(a,c),h=k8(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function pw(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function U8(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function k8(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(pw(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function Dd(e){switch(e){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(e))}var ve="texture-compression-bc",Pt="texture-compression-astc",bi="texture-compression-etc2",V8="texture-compression-etc1-webgl",Ud="texture-compression-pvrtc-webgl",tA="texture-compression-atc-webgl",Xl="float32-renderable-webgl",eA="float16-renderable-webgl",z8="rgb9e5ufloat_renderable-webgl",rA="snorm8-renderable-webgl",Yl="norm16-renderable-webgl",iA="snorm16-renderable-webgl",kd="float32-filterable",gw="float16-filterable-webgl",ql="WEBGL_compressed_texture_s3tc",Kl="WEBGL_compressed_texture_s3tc_srgb",ga="EXT_texture_compression_rgtc",ma="EXT_texture_compression_bptc",H8="WEBGL_compressed_texture_etc",G8="WEBGL_compressed_texture_astc",W8="WEBGL_compressed_texture_etc1",j8="WEBGL_compressed_texture_pvrtc",X8="WEBGL_compressed_texture_atc",mw="EXT_texture_norm16",_w="EXT_render_snorm",Y8="EXT_color_buffer_float",Vd={"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":[_w],"norm16-renderable-webgl":[mw],"snorm16-renderable-webgl":[mw,_w],"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":[ql,Kl,ga,ma],"texture-compression-bc5-webgl":[ga],"texture-compression-bc7-webgl":[ma],"texture-compression-etc2":[H8],"texture-compression-astc":[G8],"texture-compression-etc1-webgl":[W8],"texture-compression-pvrtc-webgl":[j8],"texture-compression-atc-webgl":[X8]};function yw(e){return e in Vd}function xw(e,t,r){return(Vd[t]||[]).every(s=>Er(e,s,r))}var zd={"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:rA},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:rA},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:eA,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Yl,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:iA},"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:rA},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:eA,filter:gw,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Yl},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:iA},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:Xl,filter:kd},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:z8},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Xl,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:Yl},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Yl},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:Xl,filter:kd,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:eA,filter:gw},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Yl,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:iA},"rgb32float-webgl":{gl:34837,render:Xl,filter:kd,gl2ext:Y8,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:Xl,filter:kd,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:ql,f:ve},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Kl,f:ve},"bc1-rgba-unorm":{gl:33777,x:ql,f:ve},"bc1-rgba-unorm-srgb":{gl:35916,x:Kl,f:ve},"bc2-rgba-unorm":{gl:33778,x:ql,f:ve},"bc2-rgba-unorm-srgb":{gl:35918,x:Kl,f:ve},"bc3-rgba-unorm":{gl:33779,x:ql,f:ve},"bc3-rgba-unorm-srgb":{gl:35919,x:Kl,f:ve},"bc4-r-unorm":{gl:36283,x:ga,f:ve},"bc4-r-snorm":{gl:36284,x:ga,f:ve},"bc5-rg-unorm":{gl:36285,x:ga,f:ve},"bc5-rg-snorm":{gl:36286,x:ga,f:ve},"bc6h-rgb-ufloat":{gl:36495,x:ma,f:ve},"bc6h-rgb-float":{gl:36494,x:ma,f:ve},"bc7-rgba-unorm":{gl:36492,x:ma,f:ve},"bc7-rgba-unorm-srgb":{gl:36493,x:ma,f:ve},"etc2-rgb8unorm":{gl:37492,f:bi},"etc2-rgb8unorm-srgb":{gl:37494,f:bi},"etc2-rgb8a1unorm":{gl:37496,f:bi},"etc2-rgb8a1unorm-srgb":{gl:37497,f:bi},"etc2-rgba8unorm":{gl:37493,f:bi},"etc2-rgba8unorm-srgb":{gl:37495,f:bi},"eac-r11unorm":{gl:37488,f:bi},"eac-r11snorm":{gl:37489,f:bi},"eac-rg11unorm":{gl:37490,f:bi},"eac-rg11snorm":{gl:37491,f:bi},"astc-4x4-unorm":{gl:37808,f:Pt},"astc-4x4-unorm-srgb":{gl:37840,f:Pt},"astc-5x4-unorm":{gl:37809,f:Pt},"astc-5x4-unorm-srgb":{gl:37841,f:Pt},"astc-5x5-unorm":{gl:37810,f:Pt},"astc-5x5-unorm-srgb":{gl:37842,f:Pt},"astc-6x5-unorm":{gl:37811,f:Pt},"astc-6x5-unorm-srgb":{gl:37843,f:Pt},"astc-6x6-unorm":{gl:37812,f:Pt},"astc-6x6-unorm-srgb":{gl:37844,f:Pt},"astc-8x5-unorm":{gl:37813,f:Pt},"astc-8x5-unorm-srgb":{gl:37845,f:Pt},"astc-8x6-unorm":{gl:37814,f:Pt},"astc-8x6-unorm-srgb":{gl:37846,f:Pt},"astc-8x8-unorm":{gl:37815,f:Pt},"astc-8x8-unorm-srgb":{gl:37847,f:Pt},"astc-10x5-unorm":{gl:37819,f:Pt},"astc-10x5-unorm-srgb":{gl:37851,f:Pt},"astc-10x6-unorm":{gl:37817,f:Pt},"astc-10x6-unorm-srgb":{gl:37849,f:Pt},"astc-10x8-unorm":{gl:37818,f:Pt},"astc-10x8-unorm-srgb":{gl:37850,f:Pt},"astc-10x10-unorm":{gl:37819,f:Pt},"astc-10x10-unorm-srgb":{gl:37851,f:Pt},"astc-12x10-unorm":{gl:37820,f:Pt},"astc-12x10-unorm-srgb":{gl:37852,f:Pt},"astc-12x12-unorm":{gl:37821,f:Pt},"astc-12x12-unorm-srgb":{gl:37853,f:Pt},"pvrtc-rgb4unorm-webgl":{gl:35840,f:Ud},"pvrtc-rgba4unorm-webgl":{gl:35842,f:Ud},"pvrtc-rbg2unorm-webgl":{gl:35841,f:Ud},"pvrtc-rgba2unorm-webgl":{gl:35843,f:Ud},"etc1-rbg-unorm-webgl":{gl:36196,f:V8},"atc-rgb-unorm-webgl":{gl:35986,f:tA},"atc-rgba-unorm-webgl":{gl:35986,f:tA},"atc-rgbai-unorm-webgl":{gl:34798,f:tA}},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},K8={[5126]:4,[5125]:4,[5124]:4,[5123]:2,[5122]:2,[5131]:2,[5120]:1,[5121]:1};function Hd(e,t,r){let i=zd[t];if(!i||i.gl===void 0)return!1;let s=i.x||i.gl2ext;return s?Boolean(Er(e,s,r)):!0}function sA(e){let r=zd[e]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${e}`);return r}function Aw(e,t,r){if(!Hd(e,t,r)||t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if(Rh(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(Er(e,"OES_texture_float_linear, extensions",r)):t.endsWith("16float")?Boolean(Er(e,"OES_texture_half_float_linear, extensions",r)):!0}function Tw(e,t,r){return!(!Hd(e,t,r)||typeof t=="number")}function _a(e){let t=zd[e],r=sA(e),i=Rh(e);return{format:r,dataFormat:t?.dataFormat||$8(i.format,i.integer,i.normalized,r),type:i.dataType?Dd(i.dataType):t?.types?.[0]||5121,compressed:i.compressed}}function bw(e){let t=zd[e];if(!t?.attachment)throw new Error(`${e} is not a depth stencil format`);return t.attachment}function nA(e){let t=_a(e),r=q8[t.dataFormat]||4,i=K8[t.type]||1;return r*i}function $8(e,t,r,i){if(i===6408||i===6407)return i;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;default:return 6408}}var Ew={"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"},Gd=class extends Qc{gl;extensions;testedFeatures=new Set;constructor(t,r,i){super([],i),this.gl=t,this.extensions=r,Er(t,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let t=this.getFeatures();for(let r of t)this.has(r)&&(yield r);return[]}has(t){return this.disabledFeatures[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),yw(t)&&xw(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){let t=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of t)this.has(r)}getFeatures(){return[...Object.keys(Ew),...Object.keys(Vd)]}getWebGLFeature(t){let r=Ew[t];return Boolean(typeof r=="string"?Er(this.gl,r,this.extensions):r)}};var Wd=class extends Zc{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(t){super(),this.gl=t}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]}};function Sr(e,t,r){if(J8(t))return r(e);let{nocatch:i=!0}=t;zs(e),Wr(e,t);let s;if(i)s=r(e),$i(e);else try{s=r(e)}finally{$i(e)}return s}function J8(e){for(let t in e)return!1;return!0}function vw(e,t,r,i){if(Ss(t))return i(e);let s=e;zs(s.gl);try{return Z8(e,t),Wr(s.gl,r),i(e)}finally{$i(s.gl)}}function Z8(e,t){let r=e,{gl:i}=r;if(t.cullMode)switch(t.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(t.frontFace&&i.frontFace(kn("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&i.enable(34383),t.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){let n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=kn("provokingVertex",t.provokingVertex,{first:36429,last:36430});n?.provokingVertexWEBGL(o)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){let n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=kn("polygonMode",t.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,o),n?.polygonModeWEBGL(1029,o)}t.polygonOffsetLine&&i.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&i.enable(12288),t.clipDistance1&&i.enable(12289),t.clipDistance2&&i.enable(12290),t.clipDistance3&&i.enable(12291),t.clipDistance4&&i.enable(12292),t.clipDistance5&&i.enable(12293),t.clipDistance6&&i.enable(12294),t.clipDistance7&&i.enable(12295)),t.depthWriteEnabled!==void 0&&i.depthMask(tz("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(Xd("depthCompare",t.depthCompare))),t.stencilWriteMask){let s=t.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(t.stencilReadMask&&D.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let s=t.stencilReadMask||4294967295,n=Xd("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,s),i.stencilFuncSeparate(1029,n,0,s)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let s=oA("stencilPassOperation",t.stencilPassOperation),n=oA("stencilFailOperation",t.stencilFailOperation),o=oA("stencilDepthFailOperation",t.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,o,s),i.stencilOpSeparate(1029,n,o,s)}if(t.blendColorOperation||t.blendAlphaOperation){i.enable(3042);let s=Sw("blendColorOperation",t.blendColorOperation||"add"),n=Sw("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(s,n);let o=jd("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=jd("blendColorDstFactor",t.blendColorDstFactor||"zero"),c=jd("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=jd("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function Xd(e,t){return kn(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function oA(e,t){return kn(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Sw(e,t){return kn(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function jd(e,t){return kn(e,t,{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 Q8(e,t){return`Illegal parameter ${t} for ${e}`}function kn(e,t,r){if(!(t in r))throw new Error(Q8(e,t));return r[t]}function tz(e,t){return t}function Yd(e){let t={};return e.addressModeU&&(t[10242]=aA(e.addressModeU)),e.addressModeV&&(t[10243]=aA(e.addressModeV)),e.addressModeW&&(t[32882]=aA(e.addressModeW)),e.magFilter&&(t[10240]=Cw(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=ez(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=Xd("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function aA(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Cw(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function ez(e,t){if(!t)return Cw(e);switch(e){case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var Le=class extends Q{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(t,r={}){super(t,r),this.device=t,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),t.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=rz(this.props.usage),this.glUsage=iz(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(t,r=0,i=t.byteLength+r){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,i,this.glUsage),this.gl.bufferSubData(s,r,t),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(t,r,i),this.trackAllocatedMemory(i)}_initWithByteLength(t){tt(t>=0);let r=t;t===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(t,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,t),this.gl.bindBuffer(36663,null),this._setDebugData(t,r,t.byteLength)}async readAsync(t=0,r){return this.readSyncWebGL(t,r)}readSyncWebGL(t=0,r){r=r??this.byteLength-t;let i=new Uint8Array(r),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,i,s,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,t,r),i}};function rz(e){return e&Q.INDEX?34963:e&Q.VERTEX?34962:e&Q.UNIFORM?35345:34962}function iz(e){return e&Q.INDEX||e&Q.VERTEX?35044:e&Q.UNIFORM?35048:35044}var Vn=class extends Ps{device;handle;parameters;constructor(t,r){super(t,r),this.device=t,this.parameters=Yd(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(t){for(let[r,i]of Object.entries(t)){let s=Number(r);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,i);break;default:this.device.gl.samplerParameteri(this.handle,s,i);break}}}};var jr=class extends Cs{device;gl;handle;texture;constructor(t,r){super(t,{...xt.defaultProps,...r}),this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var sz={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},qd=class extends xt{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(t,r){super(t,{...sz,format:"rgba8unorm",...r}),this.device=t,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=nz(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Q0(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(t){return new jr(this.device,{...t,texture:this})}initialize(t={}){if(this.props.dimension==="cube")return this.initializeCube(t);let r=t.data;if(r instanceof Promise)return r.then(m=>this.initialize(Object.assign({},t,{pixels:m,data:m}))),this;let i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(i&&r.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,r.addEventListener("loadeddata",()=>this.initialize(t)),this;let{parameters:s={}}=t,{pixels:n=null,pixelStore:o={},textureUnit:a=void 0,mipmaps:c=!0}=t;r||(r=n);let{width:l,height:u,dataFormat:f,type:h,compressed:d=!1}=t,{depth:p=0}=t,g=sA(t.format);return{width:l,height:u,compressed:d,dataFormat:f,type:h}=this._deduceParameters({format:t.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:g,type:h,dataFormat:f,parameters:o,compressed:d}),this.setSampler(t.sampler),this._setSamplerParameters(s),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),c&&this.device.isTextureFormatFilterable(t.format)&&this.generateMipmap(),i&&(this._video={video:r,parameters:s,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(t){let{mipmaps:r=!0,parameters:i={}}=t;return this.setCubeMapImageData(t).then(()=>{this.loaded=!0,r&&this.generateMipmap(t),this.setSampler(t.sampler),this._setSamplerParameters(i)}),this}setSampler(t={}){let r;t instanceof Vn?(this.sampler=t,r=t.props):(this.sampler=new Vn(this.device,t),r=t);let i=Yd(r);return this._setSamplerParameters(i),this}resize(t){let{height:r,width:i,mipmaps:s=!1}=t;return i!==this.width||r!==this.height?this.initialize({width:i,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:s}):this}update(){if(this._video){let{video:t,parameters:r,lastTime:i}=this._video;if(i===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}generateMipmap(t={}){return this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Sr(this.gl,t,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(t){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(t);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:i=null,level:s=0,glFormat:n=this.glFormat,offset:o=0,parameters:a={}}=t,{data:c=null,type:l=this.type,width:u=this.width,height:f=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=t;c||(c=i),{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}),Sr(this.gl,a,()=>{switch(g){case"null":p.texImage2D(r,s,n,u,f,0,h,l,c);break;case"typed-array":p.texImage2D(r,s,n,u,f,0,h,l,c,o);break;case"buffer":this.device.gl.bindBuffer(35052,c.handle||c),this.device.gl.texImage2D(r,s,n,u,f,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"browser-object":p.texImage2D(r,s,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:tt(!1,"Unknown image data type")}}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let m=nA(this.props.format);this.trackAllocatedMemory(this.width*this.height*m,"Texture")}return this.loaded=!0,this}setSubImageData({target:t=this.target,pixels:r=null,data:i=null,x:s=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:i,width:o,height:a}),tt(this.depth===1,"texSubImage not supported for 3D textures"),i||(i=r),i&&i.data){let g=i;i=g.data,o=g.shape[0],a=g.shape[1]}i instanceof Le&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),Sr(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(t,c,s,n,o,a,l,i):i===null?this.gl.texSubImage2D(t,c,s,n,o,a,f,u,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(t,c,s,n,o,a,f,u,i,d):typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(t,c,s,n,o,a,f,u,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(t,c,s,n,o,a,f,u,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(t={}){return D.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(t=this.textureUnit){let{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,this.handle),t}unbind(t=this.textureUnit){let{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,null),t}_getDataType({data:t,compressed:r=!1}){return r?{data:t,dataType:"compressed"}:t===null?{data:t,dataType:"null"}:ArrayBuffer.isView(t)?{data:t,dataType:"typed-array"}:t instanceof Le?{data:t.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&t instanceof WebGLBuffer?{data:t,dataType:"buffer"}:{data:t,dataType:"browser-object"}}_deduceParameters(t){let{format:r,data:i}=t,{width:s,height:n,dataFormat:o,type:a,compressed:c}=t,l=_a(r);return o=o||l.dataFormat,a=a||l.type,c=c||l.compressed,{width:s,height:n}=this._deduceImageSize(i,s,n),{dataFormat:o,type:a,compressed:c,width:s,height:n,format:r,data:i}}_deduceImageSize(t,r,i){let s;return typeof ImageData<"u"&&t instanceof ImageData?s={width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?s={width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?s={width:t.width,height:t.height}:typeof ImageBitmap<"u"&&t instanceof ImageBitmap?s={width:t.width,height:t.height}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?s={width:t.videoWidth,height:t.videoHeight}:t?s={width:r,height:i}:s={width:r>=0?r:1,height:i>=0?i:1},tt(s,"Could not deduced texture size"),tt(r===void 0||s.width===r,"Deduced texture width does not match supplied width"),tt(i===void 0||s.height===i,"Deduced texture height does not match supplied height"),s}async setCubeMapImageData(t){let{gl:r}=this,{width:i,height:s,pixels:n,data:o,format:a=6408,type:c=5121}=t,l=n||o,u=await Promise.all(qd.FACES.map(f=>{let h=l[f];return Promise.all(Array.isArray(h)?h:[h])}));this.bind(),qd.FACES.forEach((f,h)=>{u[h].length>1&&this.props.mipmaps!==!1&&D.warn(`${this.id} has mipmap and multiple LODs.`)(),u[h].forEach((d,p)=>{i&&s?r.texImage2D(f,p,a,i,s,0,a,c,d):r.texImage2D(f,p,a,a,c,d)})}),this.unbind()}setImageDataForFace(t){let{face:r,width:i,height:s,pixels:n,data:o,format:a=6408,type:c=5121}=t,{gl:l}=this,u=n||o;return this.bind(),u instanceof Promise?u.then(f=>this.setImageDataForFace(Object.assign({},t,{face:r,data:f,pixels:f}))):this.width||this.height?l.texImage2D(r,0,a,i,s,0,a,c,u):l.texImage2D(r,0,a,a,c,u),this}setImageData3D(t){let{level:r=0,dataFormat:i,format:s,type:n,width:o,height:a,depth:c=1,offset:l=0,data:u,parameters:f={}}=t;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let h=_a(s);if(Sr(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 Le&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,r,i,o,a,c,0,s,n,l))}),u&&u.byteLength)this.trackAllocatedMemory(u.byteLength,"Texture");else{let d=nA(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*d,"Texture")}return this.loaded=!0,this}_setSamplerParameters(t){if(!Ss(t)){oz(t),this.gl.bindTexture(this.target,this.handle);for(let[r,i]of Object.entries(t)){let s=Number(r),n=i;switch(s){case 33082:case 33083:this.gl.texParameterf(this.target,s,n);break;default:this.gl.texParameteri(this.target,s,n);break}}this.gl.bindTexture(this.target,null)}}},De=qd;Y(De,"FACES",[34069,34070,34071,34072,34073,34074]);function nz(e){switch(e.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(e.dimension)}}function oz(e){D.log(1,"texture sampler parameters",e)()}var Ei=class extends mi{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(t,r){super(t,r);let i=r.handle===null;if(this.device=t,this.gl=t.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){t.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let s=this.gl.bindFramebuffer(36160,this.handle);for(let n=0;n<this.colorAttachments.length;++n){let o=this.colorAttachments[n],a=36064+n;o&&this._attachOne(a,o)}if(this.depthStencilAttachment&&this._attachOne(bw(this.depthStencilAttachment.props.format),this.depthStencilAttachment),r.check!==!1){let n=this.gl.checkFramebufferStatus(36160);if(n!==36053)throw new Error(`Framebuffer ${cz(n)}`)}this.gl.bindFramebuffer(36160,s)}}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}createDepthStencilTexture(t){return new De(this.device,{id:`${this.id}-depth-stencil`,format:t,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(t,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;t===void 0&&(t=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let i of this.colorAttachments)i.texture.resize({width:t,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.texture.resize({width:t,height:r}),this}_attachOne(t,r){if(Array.isArray(r)){let[i,s=0,n=0]=r;return this._attachTexture(t,i,s,n),i}if(r instanceof De)return this._attachTexture(t,r,0,0),r;if(r instanceof jr){let i=r;return this._attachTexture(t,i.texture,i.props.baseMipLevel,i.props.baseArrayLayer),r.texture}throw new Error("attach")}_attachTexture(t,r,i,s){let{gl:n}=this.device;switch(n.bindTexture(r.target,r.handle),r.target){case 35866:case 32879:n.framebufferTextureLayer(36160,t,r.target,s,i);break;case 34067:let o=az(i);n.framebufferTexture2D(36160,t,o,r.handle,s);break;case 3553:n.framebufferTexture2D(36160,t,3553,r.handle,s);break;default:tt(!1,"Illegal texture type")}n.bindTexture(r.target,null)}};function az(e){return e<34069?e+34069:e}function cz(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}var Kd=class extends vs{device;presentationSize;_framebuffer=null;constructor(t,r){super(r),this.device=t,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new Ei(this.device,{handle:null}),this._framebuffer}update(){let t=this.getPixelSize();(t[0]!==this.presentationSize[0]||t[1]!==this.presentationSize[1])&&(this.presentationSize=t,this.resize())}resize(t){if(this.device.gl&&this.canvas){let r=this.getDevicePixelRatio(t?.useDevicePixels);this.setDevicePixelRatio(r,t);return}}commit(){}};var lz={spector:D.get("spector")||D.get("spectorjs")},uz="https://cdn.jsdelivr.net/npm/[email protected]/dist/spector.bundle.js",fz=1,Ge=null,ww=!1;async function Pw(e){if(!globalThis.SPECTOR)try{await sl(uz)}catch(t){D.warn(String(t))}}function Mw(e){if(e={...lz,...e},!e?.spector||(!Ge&&globalThis.SPECTOR&&(D.probe(fz,"SPECTOR found and initialized")(),Ge=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=Ge)),!Ge))return null;if(ww||(ww=!0,Ge.spyCanvases(),Ge?.onCaptureStarted.add(t=>D.info("Spector capture started:",t)()),Ge?.onCapture.add(t=>{D.info("Spector capture complete:",t)(),Ge?.getResultUI(),Ge?.resultView.display(),Ge?.resultView.addCapture(t)})),e?.canvas){if(typeof e.spector=="string"&&e.spector!==e.canvas.id)return Ge;Ge?.startCapture(e?.canvas,500),new Promise(t=>setTimeout(t,2e3)).then(t=>{D.info("Spector capture stopped after 2 seconds")(),Ge?.stopCapture()})}return Ge}var hz="https://unpkg.com/[email protected]/index.js";function Rw(e){return e.luma=e.luma||{},e.luma}async function Iw(){be()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await sl(hz))}function Bw(e,t={}){return e?t.debug?pz(e,t):dz(e):null}function dz(e){let t=Rw(e);return t.realContext?t.realContext:e}function pz(e,t){if(!globalThis.WebGLDebugUtils)return D.warn("webgl-debug not loaded")(),e;let r=Rw(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Vs,...e});let i=globalThis.WebGLDebugUtils.makeDebugContext(e,gz.bind(null,t),mz.bind(null,t));for(let o in Vs)!(o in i)&&typeof Vs[o]=="number"&&(i[o]=Vs[o]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(e)),Object.setPrototypeOf(s,i);let n=Object.create(s);return r.realContext=e,r.debugContext=n,n.debug=!0,n}function cA(e,t){t=Array.from(t).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function gz(e,t,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(t),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),o=`${s} in gl.${r}(${n})`;D.error(o)();debugger;if(e.throwOnError)throw new Error(o)}function mz(e,t,r){let i="";if(D.level>=1&&(i=cA(t,r),D.log(1,i)()),e.break&&e.break.length>0&&(i=i||cA(t,r),e.break.every(n=>i.indexOf(n)!==-1)))debugger;for(let s of r)if(s===void 0){if(i=i||cA(t,r),e.throwOnError)throw new Error(`Undefined argument: ${i}`);D.error(`Undefined argument: ${i}`)();debugger}}function Fw(e){let t=e.split(/\r?\n/),r=[];for(let i of t){if(i.length<=1)continue;let s=i.split(":");if(s.length===2){let[f,h]=s;r.push({message:h.trim(),type:Ow(f),lineNum:0,linePos:0});continue}let[n,o,a,...c]=s,l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),r.push({message:c.join(":").trim(),type:Ow(n),lineNum:l,linePos:u})}return r}function Ow(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var $d=class extends ws{device;handle;constructor(t,r){switch(super(t,r),this.device=t,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 t=this.device.gl.getShaderInfoLog(this.handle);return Fw(t)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(t){t=(s=>s.startsWith("#version ")?s:`#version 100
${s}`)(t);let{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),D.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}D.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),D.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let t=async s=>await new Promise(n=>setTimeout(n,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var _z=256,yz=1024,xz=16384,lA=6144,Az=[1,2,4,8],Jd=class extends Ho{device;glParameters;constructor(t,r){super(t,r),this.device=t,zs(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){$i(this.device.gl)}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(t={}){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,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),t.scissorRect&&(r.scissorTest=!0,r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=t.stencilReference),t.colorMask&&(r.colorMask=Az.map(i=>Boolean(i&t.colorMask))),this.glParameters=r,Wr(this.device.gl,r)}beginOcclusionQuery(t){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let t={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=xz,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=_z,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=yz,t.clearStencil=this.props.clearStencil),r!==0&&Sr(this.device.gl,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(t=0,r=[0,0,0,0]){Sr(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(lA,t,r);break;case Uint32Array:this.device.gl.clearBufferuiv(lA,t,r);break;case Float32Array:default:this.device.gl.clearBufferfv(lA,t,r);break}})}};var Tz="Failed to deduce GL constant from typed array";function Nw(e){switch(ArrayBuffer.isView(e)?e.constructor:e){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(Tz)}}function $l(e,t){let{clamped:r=!0}=t||{};switch(e){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 bz={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},Ez={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},Hs=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(t){return $l(t.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(t){return tt(t.size),$l(t.type||5126).BYTES_PER_ELEMENT*t.size}static resolve(...t){return new Hs(bz,...t)}constructor(...t){t.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return Hs.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return Hs.getBytesPerVertex(this)}_assign(t={}){return t=Z0("Accessor",t,Ez),t.type!==void 0&&(this.type=t.type,(t.type===5124||t.type===5125)&&(this.integer=!0)),t.size!==void 0&&(this.size=t.size),t.offset!==void 0&&(this.offset=t.offset),t.stride!==void 0&&(this.stride=t.stride),t.normalize!==void 0&&(this.normalized=t.normalize),t.normalized!==void 0&&(this.normalized=t.normalized),t.integer!==void 0&&(this.integer=t.integer),t.divisor!==void 0&&(this.divisor=t.divisor),t.buffer!==void 0&&(this.buffer=t.buffer),t.index!==void 0&&(typeof t.index=="boolean"?this.index=t.index?1:0:this.index=t.index),t.instanced!==void 0&&(this.divisor=t.instanced?1:0),t.isInstanced!==void 0&&(this.divisor=t.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 Lw(e){return Sz.includes(e)}var Sz=[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<f32>","float32x2"],[35665]:[5126,3,"vec3","vec3<f32>","float32x3"],[35666]:[5126,4,"vec4","vec4<f32>","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2<i32>","sint32x2"],[35668]:[5124,3,"ivec3","vec3<i32>","sint32x3"],[35669]:[5124,4,"ivec4","vec4<i32>","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2<u32>","uint32x2"],[36295]:[5125,3,"uvec3","vec3<u32>","uint32x3"],[36296]:[5125,4,"uvec4","vec4<u32>","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2<f32>","float32x2"],[35672]:[5126,3,"bvec3","vec3<f32>","float32x3"],[35673]:[5126,4,"bvec4","vec4<f32>","float32x4"],[35674]:[5126,8,"mat2","mat2x2<f32>"],[35685]:[5126,8,"mat2x3","mat2x3<f32>"],[35686]:[5126,8,"mat2x4","mat2x4<f32>"],[35687]:[5126,12,"mat3x2","mat3x2<f32>"],[35675]:[5126,12,"mat3","mat3x3<f32>"],[35688]:[5126,12,"mat3x4","mat3x4<f32>"],[35689]:[5126,16,"mat4x2","mat4x2<f32>"],[35690]:[5126,16,"mat4x3","mat4x3<f32>"],[35676]:[5126,16,"mat4","mat4x4<f32>"]};function uA(e){let t=Dw[e];if(!t)throw new Error("uniform");let[r,i,,s]=t;return{format:s,components:i,glType:r}}function Uw(e){let t=Dw[e];if(!t)throw new Error("attribute");let[,r,,i,s]=t;return{attributeType:i,vertexFormat:s,components:r}}function kw(e,t){let r={attributes:[],bindings:[]};r.attributes=vz(e,t);let i=Pz(e,t);for(let a of i){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 s=wz(e,t),n=0;for(let a of s)if(Lw(a.type)){let{viewDimension:c,sampleType:l}=Rz(a.type);r.bindings.push({type:"texture",name:a.name,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}s.length&&(r.uniforms=s);let o=Cz(e,t);return o?.length&&(r.varyings=o),r}function vz(e,t){let r=[],i=e.getProgramParameter(t,35721);for(let s=0;s<i;s++){let n=e.getActiveAttrib(t,s);if(!n)throw new Error("activeInfo");let{name:o,type:a}=n,c=e.getAttribLocation(t,o);if(c>=0){let{attributeType:l}=Uw(a),u=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:u,type:l})}}return r.sort((s,n)=>s.location-n.location),r}function Cz(e,t){let r=[],i=e.getProgramParameter(t,35971);for(let s=0;s<i;s++){let n=e.getTransformFeedbackVarying(t,s);if(!n)throw new Error("activeInfo");let{name:o,type:a,size:c}=n,{glType:l,components:u}=uA(a),f=new Hs({type:l,size:c*u}),h={location:s,name:o,accessor:f};r.push(h)}return r.sort((s,n)=>s.location-n.location),r}function wz(e,t){let r=[],i=e.getProgramParameter(t,35718);for(let s=0;s<i;s++){let n=e.getActiveUniform(t,s);if(!n)throw new Error("activeInfo");let{name:o,size:a,type:c}=n,{name:l,isArray:u}=Iz(o),f=e.getUniformLocation(t,l),h={location:f,name:l,size:a,type:c,isArray:u};if(r.push(h),h.size>1)for(let d=0;d<h.size;d++){let p=`${l}[${d}]`;f=e.getUniformLocation(t,p);let g={...h,name:p,location:f};r.push(g)}}return r}function Pz(e,t){let r=(n,o)=>e.getActiveUniformBlockParameter(t,n,o),i=[],s=e.getProgramParameter(t,35382);for(let n=0;n<s;n++){let o={name:e.getActiveUniformBlockName(t,n)||"",location:r(n,35391),byteLength:r(n,35392),vertex:r(n,35396),fragment:r(n,35398),uniformCount:r(n,35394),uniforms:[]},a=r(n,35395)||[],c=e.getActiveUniforms(t,a,35383),l=e.getActiveUniforms(t,a,35384),u=e.getActiveUniforms(t,a,35387),f=e.getActiveUniforms(t,a,35388);for(let h=0;h<o.uniformCount;++h){let d=e.getActiveUniform(t,a[h]);if(!d)throw new Error("activeInfo");o.uniforms.push({name:d.name,format:uA(c[h]).format,type:c[h],arrayLength:l[h],byteOffset:u[h],byteStride:f[h]})}i.push(o)}return i.sort((n,o)=>n.location-o.location),i}var Mz={[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 Rz(e){let t=Mz[e];if(!t)throw new Error("sampler");let[r,i]=t;return{viewDimension:r,sampleType:i}}function Iz(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function Vw(e,t,r,i){let s=e,n=i;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 i!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,i);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return s.uniform1uiv(t,o,1);case 36294:return s.uniform2uiv(t,o,2);case 36295:return s.uniform3uiv(t,o,3);case 36296:return s.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return s.uniformMatrix2x3fv(t,!1,o);case 35686:return s.uniformMatrix2x4fv(t,!1,o);case 35687:return s.uniformMatrix3x2fv(t,!1,o);case 35688:return s.uniformMatrix3x4fv(t,!1,o);case 35689:return s.uniformMatrix4x2fv(t,!1,o);case 35690:return s.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}function zw(e){switch(e){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(e)}}function Hw(e){switch(e){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(e)}}var Gw=4,Zd=class extends Or{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(t,r){super(t,r),this.device=t,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:i,bufferMode:s=35981}=r;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,s)),this._linkShaders(),D.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=kw(this.device.gl,this.handle),D.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=j0(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":D.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(t,r){for(let[i,s]of Object.entries(t)){let n=this.shaderLayout.bindings.find(o=>o.name===i)||this.shaderLayout.bindings.find(o=>o.name===`${i}Uniforms`);if(!n){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||D.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(s||D.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(s instanceof Le)&&!(s.buffer instanceof Le))throw new Error("buffer value");break;case"texture":if(!(s instanceof jr||s instanceof De||s instanceof Ei))throw new Error("texture value");break;case"sampler":D.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(n.type)}this.bindings[i]=s}}draw(t){let{renderPass:r,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:n,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u}=t,f=zw(s),h=Boolean(n.indexBuffer),d=n.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return D.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||o===0)return D.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(o===0)return D.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 vw(this.device,i,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(t){let{bindings:r}=il(t);Object.keys(r).forEach(i=>{D.warn(`Unsupported value "${JSON.stringify(r[i])}" used in setUniforms() for key ${i}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,t)}async _linkShaders(){let{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),D.time(Gw,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),D.timeEnd(Gw,`linkProgram for ${this.id}`)(),D.level,!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}D.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),D.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(t){switch(t){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 ${t}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let t=async s=>await new Promise(n=>setTimeout(n,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(let[,r]of Object.entries(this.bindings))r instanceof De&&(r.update(),t=t&&r.loaded);return t}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:t}=this.device;t.useProgram(this.handle);let r=0,i=0;for(let s of this.shaderLayout.bindings){let n=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:o}=s,a=t.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);t.uniformBlockBinding(this.handle,i,a),n instanceof Le?t.bindBufferBase(35345,i,n.handle):t.bindBufferRange(35345,i,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),i+=1;break;case"texture":if(!(n instanceof jr||n instanceof De||n instanceof Ei))throw new Error("texture");let c;if(n instanceof jr)c=n.texture;else if(n instanceof De)c=n;else if(n instanceof Ei&&n.colorAttachments[0]instanceof jr)D.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");t.activeTexture(33984+r),t.bindTexture(c.target,c.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(let t of this.shaderLayout.uniforms||[]){let{name:r,location:i,type:s,textureUnit:n}=t,o=this.uniforms[r]??n;o!==void 0&&Vw(this.device.gl,i,s,o)}}};var Qd=class extends Wo{device;commands=[];constructor(t){super(t,{}),this.device=t}submitCommands(t=this.commands){for(let r of t)switch(r.name){case"copy-buffer-to-buffer":Bz(this.device,r.options);break;case"copy-buffer-to-texture":Oz(this.device,r.options);break;case"copy-texture-to-buffer":Fz(this.device,r.options);break;case"copy-texture-to-texture":Nz(this.device,r.options);break}}};function Bz(e,t){let r=t.source,i=t.destination;e.gl.bindBuffer(36662,r.handle),e.gl.bindBuffer(36663,i.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function Oz(e,t){throw new Error("Not implemented")}function Fz(e,t){let{source:r,mipLevel:i=0,aspect:s="all",width:n=t.source.width,height:o=t.source.height,depthOrArrayLayers:a=0,origin:c=[0,0],destination:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=t;if(s!=="all")throw new Error("not supported");if(i!==0||a!==0||f||h)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=Ww(r),g;try{let m=l,_=n||d.width,y=o||d.height,x=_a(d.texture.props.format),E=x.dataFormat,P=x.type;e.gl.bindBuffer(35051,m.handle),g=e.gl.bindFramebuffer(36160,d.handle),e.gl.readPixels(c[0],c[1],_,y,E,P,u)}finally{e.gl.bindBuffer(35051,null),g!==void 0&&e.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function Nz(e,t){let{source:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:n=[0,0],destination:o}=t,{width:a=t.destination.width,height:c=t.destination.height}=t,{framebuffer:l,destroyFramebuffer:u}=Ww(r),[f,h]=s,[d,p,g]=n,m=e.gl.bindFramebuffer(36160,l.handle),_=null,y;if(o instanceof De)_=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:e.gl.copyTexSubImage2D(y,i,d,p,f,h,a,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(y,i,d,p,g,f,h,a,c);break;default:}_&&_.unbind(),e.gl.bindFramebuffer(36160,m),u&&l.destroy()}function Ww(e){if(e instanceof xt){let{width:t,height:r,id:i}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var tp=class extends Go{device;commandBuffer;constructor(t,r){super(t,r),this.device=t,this.commandBuffer=new Qd(t)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,r,i){}};var ya=class extends jo{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(t){return L_()==="Chrome"}constructor(t,r){super(t,r),this.device=t,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(t){let r=t;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(t,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:n,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(t,s,n,o,a):this.device.gl.vertexAttribPointer(t,s,n,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,u||0),this.attributes[t]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){let r=this.attributes[t];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(t,r)}}_getAccessor(t){let r=this.attributeInfos[t];if(!r)throw new Error(`Unknown attribute location ${t}`);let i=Dd(r.bufferDataType);return{size:r.bufferComponents,type:i,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(t,r=!0){let s=ya.isConstantAttributeZeroSupported(this.device)||t!==0;(r||s)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,r){let i=Lz(r),s=i.byteLength*t,n=i.length*t;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),o=o||!Dz(i,this.bufferValue),o){let a=K0(r.constructor,n);$0({target:a,source:i,start:0,count:n}),this.buffer.write(a),this.bufferValue=r}return this.buffer}};function Lz(e){return Array.isArray(e)?new Float32Array(e):e}function Dz(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var ep=class extends Xo{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(t,r){super(t,r),this.device=t,this.gl=t.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Hw(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let r in t)this.setBuffer(r,t[r])})}setBuffer(t,r){let i=this._getVaryingIndex(t),{buffer:s,byteLength:n,byteOffset:o}=this._getBufferRange(r);if(i<0){this.unusedBuffers[t]=s,D.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[i]={buffer:s,byteLength:n,byteOffset:o},this.bindOnUse||this._bindBuffer(i,s,o,n)}getBuffer(t){if(jw(t))return this.buffers[t]||null;let r=this._getVaryingIndex(t);return r>=0?this.buffers[r]:null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let r;return this._bound?r=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof Le)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:i=0,byteLength:s=t.buffer.byteLength}=t;return{buffer:r,byteOffset:i,byteLength:s}}_getVaryingIndex(t){if(jw(t))return Number(t);for(let r of this.layout.varyings)if(t===r.name)return r.location;return-1}_bindBuffers(){for(let t in this.buffers){let{buffer:r,byteLength:i,byteOffset:s}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),r,s,i)}}_unbindBuffers(){for(let t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r,i=0,s){let n=r&&r.handle;!n||s===void 0?this.gl.bindBufferBase(35982,t,n):this.gl.bindBufferRange(35982,t,n,i,s)}};function jw(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var rp=class extends Yo{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(t,r){if(super(t,r),this.device=t,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(t){return this._begin(t?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(t){this._queryPending||(this.target=t,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 t=this.device.gl.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(t=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((i,s)=>{let n=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):r++>t?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}};function fA(e){switch(e){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 tt(!1),0}}function Xw(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return tt(!1),0}}function Yw(e,t){let{sourceX:r=0,sourceY:i=0,sourceFormat:s=6408,sourceAttachment:n=36064}=t||{},{target:o=null,sourceWidth:a,sourceHeight:c,sourceType:l}=t||{},{framebuffer:u,deleteFramebuffer:f}=Kw(e);tt(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=kz(o,l,s,a,c),l=l||Nw(o);let g=h.bindFramebuffer(36160,d);return h.readPixels(r,i,a,c,s,l,o),h.bindFramebuffer(36160,g||null),f&&u.destroy(),o}function qw(e,t){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:n=6408,targetByteOffset:o=0}=t||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=t||{},{framebuffer:u,deleteFramebuffer:f}=Kw(e);tt(u),a=a||u.width,c=c||u.height;let h=u;l=l||5121;let d=r;if(!d){let g=fA(n),m=Xw(l),_=o+a*c*g*m;d=h.device.createBuffer({byteLength:_})}let p=e.device.createCommandEncoder();return p.copyTextureToBuffer({source:e,width:a,height:c,origin:[i,s],destination:d,byteOffset:o}),p.destroy(),f&&u.destroy(),d}function Kw(e){return e instanceof mi?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Uz(e),deleteFramebuffer:!0}}function Uz(e,t){let{device:r,width:i,height:s,id:n}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${n}`,width:i,height:s,colorAttachments:[e]})}function kz(e,t,r,i,s){if(e)return e;t=t||5121;let n=$l(t,{clamped:!1}),o=fA(r);return new n(i*s*o)}var Vz=256,zz=1024,Hz=16384;var Gz="clear: bad arguments";function $w(e,t){let{framebuffer:r=null,color:i=null,depth:s=null,stencil:n=null}=t||{},o={};r&&(o.framebuffer=r);let a=0;i&&(a|=Hz,i!==!0&&(o.clearColor=i)),s&&(a|=Vz,s!==!0&&(o.clearDepth=s)),n&&(a|=zz,s!==!0&&(o.clearStencil=s)),tt(a!==0,Gz);let c=e.gl;Sr(c,o,()=>{c.clear(a)})}var Jl=1,xa=class extends Qe{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(t){if(t instanceof xa)return t;if(t?.device instanceof Qe)return t.device;if(!Wz(t))throw new Error("Invalid WebGL2RenderingContext");return new xa({gl:t})}static async create(t={}){D.groupCollapsed(Jl,"WebGLDevice created")();let r=[];t.debug&&r.push(Iw()),t.spector&&r.push(Pw()),typeof t.canvas=="string"&&r.push(vs.pageLoaded);let i=await Promise.allSettled(r);for(let o of i)o.status==="rejected"&&D.error(`Failed to initialize debug libraries ${o.reason}`)();if(D.probe(Jl+1,"DOM is loaded")(),t.gl?.device)return D.warn("reattaching existing device")(),xa.attach(t.gl);let s=new xa(t),n=`Created ${s.type}${s.debug?" debug":""} context: ${s.info.vendor}, ${s.info.renderer} for canvas: ${s.canvasContext.id}`;return D.probe(Jl,n)(),D.table(Jl,s.info)(),D.groupEnd(Jl)(),s}constructor(t){super({...t,id:t.id||Wt("webgl-device")});let r=t.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let i=t.gl?.canvas||t.canvas;this.canvasContext=new Kd(this,{...t,canvas:i}),this.lost=new Promise(a=>{this._resolveContextLost=a});let s=t.gl||null;if(s||=hw(this.canvasContext.canvas,{...t,onContextLost:a=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!s)throw new Error("WebGL context creation failed");this.handle=s,this.gl=s,this.gl.device=this,this.gl._version=2,t.spector&&(this.spectorJS=Mw({...this.props,canvas:this.handle.canvas})),this.info=dw(this.gl,this._extensions),this.limits=new Wd(this.gl),this.features=new Gd(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:n=!0,copyState:o=!1}=t;Qx(this.gl,{enable:n,copyState:o,log:(...a)=>D.log(1,...a)()}),t.debug&&(this.gl=Bw(this.gl,{...t,throwOnError:!0}),this.debug=!0,D.level=Math.max(D.level,1),D.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(t){return Hd(this.gl,t,this._extensions)}isTextureFormatFilterable(t){return Aw(this.gl,t,this._extensions)}isTextureFormatRenderable(t){return Tw(this.gl,t,this._extensions)}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){let r=this._getBufferProps(t);return new Le(this,r)}_createTexture(t){return new De(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Vn(this,t)}createShader(t){return new $d(this,t)}createFramebuffer(t){return new Ei(this,t)}createVertexArray(t){return new ya(this,t)}createTransformFeedback(t){return new ep(this,t)}createQuerySet(t){return new rp(this,t)}createRenderPipeline(t){return new Zd(this,t)}beginRenderPass(t){return new Jd(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(t){return new tp(this,t)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(t,r){return Yw(t,r)}readPixelsToBufferWebGL(t,r){return qw(t,r)}setParametersWebGL(t){Wr(this.gl,t)}getParametersWebGL(t){return Ld(this.gl,t)}withParametersWebGL(t,r){return Sr(this.gl,t,r)}clearWebGL(t){$w(this,t)}resetWebGL(){D.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),lw(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let t=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(t=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){zs(this.gl)}popState(){$i(this.gl)}setSpectorMetadata(t,r){t.__SPECTOR_Metadata=r}getGLKey(t,r){r=r||this.gl2||this.gl;let i=Number(t);for(let s in r)if(r[s]===i)return`GL.${s}`;return String(t)}_constants;setConstantAttributeWebGL(t,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let s=this._constants[t];switch(s&&qz(s,r)&&D.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:jz(this,t,r);break;case Int32Array:Xz(this,t,r);break;case Uint32Array:Yz(this,t,r);break;default:tt(!1)}}getExtension(t){return Er(this.gl,t,this._extensions),this._extensions}},Gs=xa;Y(Gs,"type","webgl");function Wz(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function jz(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:tt(!1)}}function Xz(e,t,r){e.gl.vertexAttribI4iv(t,r)}function Yz(e,t,r){e.gl.vertexAttribI4uiv(t,r)}function qz(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var zn=li(Jw());var Kz={mousedown:1,mousemove:2,mouseup:4};function $z(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return!0;return!1}function Zw(e){let t=e.prototype.handler;e.prototype.handler=function(i){let s=this.store;i.button>0&&i.type==="pointerdown"&&($z(s,n=>n.pointerId===i.pointerId)||s.push(i)),t.call(this,i)}}function Qw(e){e.prototype.handler=function(r){let i=Kz[r.type];i&1&&r.button>=0&&(this.pressed=!0),i&2&&r.which===0&&(i=4),this.pressed&&(i&4&&(this.pressed=!1),this.callback(this.manager,i,{pointers:[r],changedPointers:[r],pointerType:"mouse",srcEvent:r}))}}Zw(zn.PointerEventInput);Qw(zn.MouseInput);var tP=zn.Manager,Xr=zn;var Yr=class{constructor(t,r,i){this.element=t,this.callback=r,this.options={enable:!0,...i}}};var eP=Xr?[[Xr.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Xr.Rotate,{enable:!1}],[Xr.Pinch,{enable:!1}],[Xr.Swipe,{enable:!1}],[Xr.Pan,{threshold:0,enable:!1}],[Xr.Press,{enable:!1}],[Xr.Tap,{event:"doubletap",taps:2,enable:!1}],[Xr.Tap,{event:"anytap",enable:!1}],[Xr.Tap,{enable:!1}]]:null,hA={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},rP={doubletap:["tap"]},iP={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},Aa={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},sP={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"},dA={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var nP=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Hn=typeof window<"u"?window:global;var sp=!1;try{let e={get passive(){return sp=!0,!0}};Hn.addEventListener("test",null,e),Hn.removeEventListener("test",null)}catch{sp=!1}var Jz=nP.indexOf("firefox")!==-1,{WHEEL_EVENTS:Zz}=Aa,oP="wheel",aP=4.000244140625,Qz=40,t5=.25,Zl=class extends Yr{constructor(t,r,i){super(t,r,i),this.handleEvent=s=>{if(!this.options.enable)return;let n=s.deltaY;Hn.WheelEvent&&(Jz&&s.deltaMode===Hn.WheelEvent.DOM_DELTA_PIXEL&&(n/=Hn.devicePixelRatio),s.deltaMode===Hn.WheelEvent.DOM_DELTA_LINE&&(n*=Qz)),n!==0&&n%aP===0&&(n=Math.floor(n/aP)),s.shiftKey&&n&&(n=n*t5),this.callback({type:oP,center:{x:s.clientX,y:s.clientY},delta:-n,srcEvent:s,pointerType:"mouse",target:s.target})},this.events=(this.options.events||[]).concat(Zz),this.events.forEach(s=>t.addEventListener(s,this.handleEvent,sp?{passive:!1}:!1))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,r){t===oP&&(this.options.enable=r)}};var{MOUSE_EVENTS:e5}=Aa,cP="pointermove",lP="pointerover",uP="pointerout",fP="pointerenter",hP="pointerleave",Ql=class extends Yr{constructor(t,r,i){super(t,r,i),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,this.events=(this.options.events||[]).concat(e5),this.events.forEach(n=>t.addEventListener(n,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,r){t===cP&&(this.enableMoveEvent=r),t===lP&&(this.enableOverEvent=r),t===uP&&(this.enableOutEvent=r),t===fP&&(this.enableEnterEvent=r),t===hP&&(this.enableLeaveEvent=r)}handleOverEvent(t){this.enableOverEvent&&t.type==="mouseover"&&this._emit(lP,t)}handleOutEvent(t){this.enableOutEvent&&t.type==="mouseout"&&this._emit(uP,t)}handleEnterEvent(t){this.enableEnterEvent&&t.type==="mouseenter"&&this._emit(fP,t)}handleLeaveEvent(t){this.enableLeaveEvent&&t.type==="mouseleave"&&this._emit(hP,t)}handleMoveEvent(t){if(this.enableMoveEvent)switch(t.type){case"mousedown":t.button>=0&&(this.pressed=!0);break;case"mousemove":t.which===0&&(this.pressed=!1),this.pressed||this._emit(cP,t);break;case"mouseup":this.pressed=!1;break;default:}}_emit(t,r){this.callback({type:t,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var{KEY_EVENTS:r5}=Aa,dP="keydown",pP="keyup",tu=class extends Yr{constructor(t,r,i){super(t,r,i),this.handleEvent=s=>{let n=s.target||s.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:dP,srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:pP,srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(r5),t.tabIndex=this.options.tabIndex||0,t.style.outline="none",this.events.forEach(s=>t.addEventListener(s,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,r){t===dP&&(this.enableDownEvent=r),t===pP&&(this.enableUpEvent=r)}};var gP="contextmenu",eu=class extends Yr{constructor(t,r,i){super(t,r,i),this.handleEvent=s=>{this.options.enable&&this.callback({type:gP,center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,r){t===gP&&(this.options.enable=r)}};var i5={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},s5=1,n5=2,o5=3,a5=0,c5=1,l5=2,u5=1,f5=2,h5=4;function mP(e){let t=i5[e.srcEvent.type];if(!t)return null;let{buttons:r,button:i,which:s}=e.srcEvent,n=!1,o=!1,a=!1;return t===4||t===2&&!Number.isFinite(r)?(n=s===s5,o=s===n5,a=s===o5):t===2?(n=Boolean(r&u5),o=Boolean(r&h5),a=Boolean(r&f5)):t===1&&(n=i===a5,o=i===c5,a=i===l5),{leftButton:n,middleButton:o,rightButton:a}}function _P(e,t){let r=e.center;if(!r)return null;let i=t.getBoundingClientRect(),s=i.width/t.offsetWidth||1,n=i.height/t.offsetHeight||1,o={x:(r.x-i.left-t.clientLeft)/s,y:(r.y-i.top-t.clientTop)/n};return{center:r,offsetCenter:o}}var pA={srcElement:"root",priority:0},ru=class{constructor(t){this.handleEvent=r=>{if(this.isEmpty())return;let i=this._normalizeEvent(r),s=r.srcEvent.target;for(;s&&s!==i.rootElement;){if(this._emit(i,s),i.handled)return;s=s.parentNode}this._emit(i,"root")},this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(t,r,i,s=!1,n=!1){let{handlers:o,handlersByElement:a}=this,c=pA;typeof i=="string"||i&&i.addEventListener?c={...pA,srcElement:i}:i&&(c={...pA,...i});let l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:t,handler:r,srcElement:c.srcElement,priority:c.priority};s&&(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(t,r){let{handlers:i,handlersByElement:s}=this;for(let n=i.length-1;n>=0;n--){let o=i[n];if(o.type===t&&o.handler===r){i.splice(n,1);let a=s.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&s.delete(o.srcElement)}}this._active=i.some(n=>!n.passive)}_emit(t,r){let i=this.handlersByElement.get(r);if(i){let s=!1,n=()=>{t.handled=!0},o=()=>{t.handled=!0,s=!0},a=[];for(let c=0;c<i.length;c++){let{type:l,handler:u,once:f}=i[c];if(u({...t,type:l,stopPropagation:n,stopImmediatePropagation:o}),f&&a.push(i[c]),s)break}for(let c=0;c<a.length;c++){let{type:l,handler:u}=a[c];this.remove(l,u)}}}_normalizeEvent(t){let r=this.eventManager.getElement();return{...t,...mP(t),..._P(t,r),preventDefault:()=>{t.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};var d5={events:null,recognizers:null,recognizerOptions:{},Manager:tP,touchAction:"none",tabIndex:0},Ta=class{constructor(t=null,r){this._onBasicInput=s=>{let{srcEvent:n}=s,o=iP[n.type];o&&this.manager.emit(o,s)},this._onOtherEvent=s=>{this.manager.emit(s.type,s)},this.options={...d5,...r},this.events=new Map,this.setElement(t);let{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(t){if(this.element&&this.destroy(),this.element=t,!t)return;let{options:r}=this,i=r.Manager;this.manager=new i(t,{touchAction:r.touchAction,recognizers:r.recognizers||eP}).on("hammer.input",this._onBasicInput),r.recognizers||Object.keys(hA).forEach(s=>{let n=this.manager.get(s);n&&hA[s].forEach(o=>{n.recognizeWith(o)})});for(let s in r.recognizerOptions){let n=this.manager.get(s);if(n){let o=r.recognizerOptions[s];delete o.enable,n.set(o)}}this.wheelInput=new Zl(t,this._onOtherEvent,{enable:!1}),this.moveInput=new Ql(t,this._onOtherEvent,{enable:!1}),this.keyInput=new tu(t,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new eu(t,this._onOtherEvent,{enable:!1});for(let[s,n]of this.events)n.isEmpty()||(this._toggleRecognizer(n.recognizerName,!0),this.manager.on(s,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(t,r,i){this._addEventHandler(t,r,i,!1)}once(t,r,i){this._addEventHandler(t,r,i,!0)}watch(t,r,i){this._addEventHandler(t,r,i,!1,!0)}off(t,r){this._removeEventHandler(t,r)}_toggleRecognizer(t,r){let{manager:i}=this;if(!i)return;let s=i.get(t);if(s&&s.options.enable!==r){s.set({enable:r});let n=rP[t];n&&!this.options.recognizers&&n.forEach(o=>{let a=i.get(o);r?(a.requireFailure(t),s.dropRequireFailure(o)):a.dropRequireFailure(t)})}this.wheelInput.enableEventType(t,r),this.moveInput.enableEventType(t,r),this.keyInput.enableEventType(t,r),this.contextmenuInput.enableEventType(t,r)}_addEventHandler(t,r,i,s,n){if(typeof t!="string"){i=r;for(let u in t)this._addEventHandler(u,t[u],i,s,n);return}let{manager:o,events:a}=this,c=dA[t]||t,l=a.get(c);l||(l=new ru(this),a.set(c,l),l.recognizerName=sP[c]||c,o&&o.on(c,l.handleEvent)),l.add(t,r,i,s,n),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(t,r){if(typeof t!="string"){for(let o in t)this._removeEventHandler(o,t[o]);return}let{events:i}=this,s=dA[t]||t,n=i.get(s);if(n&&(n.remove(t,r),n.isEmpty())){let{recognizerName:o}=n,a=!1;for(let c of i.values())if(c.recognizerName===o&&!c.isEmpty()){a=!0;break}a||this._toggleRecognizer(o,!1)}}};function Ws(){}var p5=({isDragging:e})=>e?"grabbing":"grab",yP={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:Ws,onWebGLInitialized:Ws,onResize:Ws,onViewStateChange:Ws,onInteractionStateChange:Ws,onBeforeRender:Ws,onAfterRender:Ws,onLoad:Ws,onError:e=>k.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:p5,getTooltip:null,debug:!1,drawPickingColors:!1},np=class{constructor(t){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 Ee({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=i=>{let{_pickRequest:s}=this;if(i.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(i.leftButton||i.rightButton)return;{let n=i.offsetCenter;if(!n)return;s.x=n.x,s.y=n.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=i},this._onEvent=i=>{let s=_l[i.type],n=i.offsetCenter;if(!s||!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[s.handler]||c.props[s.handler]),u=this.props[s.handler],f=!1;l&&(f=l.call(c,a,i)),f||(u?.(a,i),this.widgetManager.onEvent(a,i))},this._onPointerDown=i=>{let s=i.offsetCenter,n=this._pick("pickObject","pickObject Time",{x:s.x,y:s.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=n.result[0]||n.emptyInfo},this.props={...yP,...t},t=this.props,t.viewState&&t.initialViewState&&k.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,t.device?this.device=t.device:t.gl&&(t.gl instanceof WebGLRenderingContext&&k.error("WebGL1 context not supported.")(),this.device=Gs.attach(t.gl));let r=this.device;r||(ze.registerDevices([Gs]),r=ze.createDevice({...t.deviceProps,canvas:this._createCanvas(t)})),this.animationLoop=this._createAnimationLoop(r,t),this.setProps(t),t._typedArrayManagerProps&&Ur.setOptions(t._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(t){this.stats.get("setProps Time").timeStart(),"onLayerHover"in t&&k.removed("onLayerHover","onHover")(),"onLayerClick"in t&&k.removed("onLayerClick","onClick")(),t.initialViewState&&!vt(this.props.initialViewState,t.initialViewState,3)&&(this.viewState=t.initialViewState),Object.assign(this.props,t),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(t={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;t.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(t),s=this.layerManager.needsRedraw(t),n=this.effectManager.needsRedraw(t),o=this.deckRenderer.needsRedraw(t);return r=r||i||s||n||o,r}redraw(t){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=t||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 At(this.viewManager),this.viewManager.views}getViewports(t){return At(this.viewManager),this.viewManager.getViewports(t)}getCanvas(){return this.canvas}pickObject(t){let r=this._pick("pickObject","pickObject Time",t).result;return r.length?r[0]:null}pickMultipleObjects(t){return t.depth=t.depth||10,this._pick("pickObject","pickMultipleObjects Time",t).result}pickObjects(t){return this._pick("pickObjects","pickObjects Time",t)}_addResources(t,r=!1){for(let i in t)this.layerManager.resourceManager.add({resourceId:i,data:t[i],forceUpdate:r})}_removeResources(t){for(let r of t)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(t){this.effectManager.addDefaultEffect(t)}_addDefaultShaderModule(t){this.layerManager.addDefaultShaderModule(t)}_removeDefaultShaderModule(t){this.layerManager?.removeDefaultShaderModule(t)}_pick(t,r,i){At(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(r).timeStart();let n=this.deckPicker[t]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return s.get(r).timeEnd(),n}_createCanvas(t){let r=t.canvas;return typeof r=="string"&&(r=document.getElementById(r),At(r)),r||(r=document.createElement("canvas"),r.id=t.id||"deckgl-overlay",(t.parent||document.body).appendChild(r)),Object.assign(r.style,t.style),r}_setCanvasSize(t){if(!this.canvas)return;let{width:r,height:i}=t;if(r||r===0){let s=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=s}if(i||i===0){let s=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=t.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:t}=this;if(!t)return;let r=t.clientWidth??t.width,i=t.clientHeight??t.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(t,r){let{gl:i,onError:s,useDevicePixels:n}=r;return new wl({device:t,useDevicePixels:n,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:s})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:t}=this.props,r=Array.isArray(t)?t:t?[t]:[new Gr({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:t}=this.props;this.animationLoop&&t&&t(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:t}=this;if(t.event){let{result:r,emptyInfo:i}=this._pick("pickObject","pickObject Time",t);this.cursorState.isHovering=r.length>0;let s=i,n=!1;for(let o of r)s=o,n=o.layer?.onHover(o,t.event)||n;n||(this.props.onHover?.(s,t.event),this.widgetManager.onHover(s,t.event)),t.event=null}}_updateCursor(){let t=this.props.parent||this.canvas;t&&(t.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(t){if(this.device=t,!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 Gs&&this.props.onWebGLInitialized(this.device.gl);let r=new On;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new Ta(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 s in _l)this.eventManager.on(s,this._onEvent);this.viewManager=new Ll({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 i=this.viewManager.getViewports()[0];this.layerManager=new Fn(this.device,{deck:this,stats:this.stats,viewport:i,timeline:r}),this.effectManager=new Vl({deck:this,device:this.device}),this.deckRenderer=new Dn(this.device),this.deckPicker=new Hl(this.device),this.widgetManager=new Nd({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Gl),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(t,r){let{device:i,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:s});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:i,gl:s})}_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(t){let r=this.props.onViewStateChange(t)||t.viewState;this.viewState&&(this.viewState={...this.viewState,[t.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(t){this.cursorState.isDragging=t.isDragging||!1,this.props.onInteractionStateChange(t)}_getFrameStats(){let{stats:t}=this;t.get("frameRate").timeEnd(),t.get("frameRate").timeStart();let r=this.animationLoop.stats;t.get("GPU Time").addTime(r.get("GPU Time").lastTiming),t.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:t,stats:r}=this;t.fps=r.get("frameRate").getHz(),t.setPropsTime=r.get("setProps Time").time,t.updateAttributesTime=r.get("Update Attributes").time,t.framesRedrawn=r.get("Redraw Count").count,t.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,t.pickCount=r.get("Pick Count").count,t.gpuTime=r.get("GPU Time").time,t.cpuTime=r.get("CPU Time").time,t.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),t.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=ze.stats.get("Memory Usage");t.bufferMemory=i.get("Buffer Memory").count,t.textureMemory=i.get("Texture Memory").count,t.renderbufferMemory=i.get("Renderbuffer Memory").count,t.gpuMemory=i.get("GPU Memory").count}},We=np;(()=>{np.defaultProps=yP})(),(()=>{np.VERSION=Ph})();function xP(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return rl(e)}}var AP=Dh;function iu(e,t){return{attribute:e,format:t.size>1?`${t.type}x${t.size}`:t.type,byteOffset:t.offset||0}}function js(e){return e.stride||e.size*e.bytesPerElement}function TP(e,t){return e.type===t.type&&e.size===t.size&&js(e)===js(t)&&(e.offset||0)===(t.offset||0)}function gA(e,t){t.offset&&k.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=js(e),i=t.vertexOffset!==void 0?t.vertexOffset:e.vertexOffset||0,s=t.elementOffset||0,n=i*r+s*e.bytesPerElement+(e.offset||0);return{...t,offset:n,stride:r}}function g5(e,t){let r=gA(e,t);return{high:r,low:{...r,offset:r.offset+e.size*4}}}var su=class{constructor(t,r,i){this._buffer=null,this.device=t,this.id=r.id||"",this.size=r.size||1;let s=r.logicalType||r.type,n=s==="float64",{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;n?a="float32":!s&&r.isIndexed?a="uint32":a=s||"float32";let c=xP(s||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,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 t=this.getAccessor();return t.vertexOffset?t.vertexOffset*js(t):0}get numInstances(){return this.state.numInstances}set numInstances(t){this.state.numInstances=t}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Ur.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(t=this.id,r=null){let i={};if(this.state.constant){let s=this.value;if(r){let n=gA(this.getAccessor(),r),o=n.offset/s.BYTES_PER_ELEMENT,a=n.size||this.size;i[t]=s.subarray(o,o+a)}else i[t]=s}else i[t]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${t}64Low`]=i[t]:i[`${t}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(t=this.id,r=null){let i=this.getAccessor(),s=[],n={name:this.id,byteStride:js(i),attributes:s};if(this.doublePrecision){let o=g5(i,r||{});s.push(iu(t,{...i,...o.high}),iu(`${t}64Low`,{...i,...o.low}))}else if(r){let o=gA(i,r);s.push(iu(t,{...i,...o}))}else s.push(iu(t,i));return n}setAccessor(t){this.state.bufferAccessor=t}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let t=null;if(this.state.constant&&this.value){let r=Array.from(this.value);t=[r,r]}else{let{value:r,numInstances:i,size:s}=this,n=i*s;if(r&&n&&r.length>=n){let o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;c<n;)for(let l=0;l<s;l++){let u=r[c++];u<o[l]&&(o[l]=u),u>a[l]&&(a[l]=u)}t=[o,a]}}return this.state.bounds=t,t}setData(t){let{state:r}=this,i;ArrayBuffer.isView(t)?i={value:t}:t instanceof Q?i={buffer:t}:i=t;let s={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)s.type="float32";else{let o=AP(i.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=i.value.BYTES_PER_ELEMENT,s.stride=js(s)}if(r.bounds=null,i.constant){let n=i.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(i.buffer){let n=i.buffer;r.externalBuffer=n,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let n=i.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:o}=this,a=js(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=vd(n,s)),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<l)&&(o=this._createBuffer(l)),o.write(n,c)}return this.setAccessor(s),!0}updateSubBuffer(t={}){this.state.bounds=null;let r=this.value,{startOffset:i=0,endOffset:s}=t;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?vd(r,{size:this.size,startIndex:i,endIndex:s}):r.subarray(i,s),i*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(t,r=!1){let{state:i}=this,s=i.allocatedValue,n=Ur.allocate(s,t+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=n;let{byteOffset:o}=this,{buffer:a}=this;return(!a||a.byteLength<n.byteLength+o)&&(a=this._createBuffer(n.byteLength+o),r&&s&&a.write(s instanceof Float64Array?vd(s,this):s,o)),i.allocatedValue=n,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(t){let{value:r}=t;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let i=this.settings.defaultType,s=!1;if(this.doublePrecision&&(s=r.BYTES_PER_ELEMENT<4),s)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof i)&&this.settings.normalized&&!("normalized"in t)&&k.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(t){switch(this.settings.type){case"snorm8":return new Float32Array(t).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(t).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(t).map(r=>r/255);case"unorm16":return new Float32Array(t).map(r=>r/65535);default:return t}}_normalizeValue(t,r,i){let{defaultValue:s,size:n}=this.settings;if(Number.isFinite(t))return r[i]=t,r;if(!t){let o=n;for(;--o>=0;)r[i+o]=s[o];return r}switch(n){case 4:r[i+3]=Number.isFinite(t[3])?t[3]:s[3];case 3:r[i+2]=Number.isFinite(t[2])?t[2]:s[2];case 2:r[i+1]=Number.isFinite(t[1])?t[1]:s[1];case 1:r[i+0]=Number.isFinite(t[0])?t[0]:s[0];break;default:let o=n;for(;--o>=0;)r[i+o]=Number.isFinite(t[o])?t[o]:s[o]}return r}_areValuesEqual(t,r){if(!t||!r)return!1;let{size:i}=this;for(let s=0;s<i;s++)if(t[s]!==r[s])return!1;return!0}_createBuffer(t){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:r?Q.INDEX:Q.VERTEX,indexType:r?i:void 0,byteLength:t}),this._buffer}};var bP=[],EP=[];function Ht(e,t=0,r=1/0){let i=bP,s={index:-1,data:e,target:[]};return e?typeof e[Symbol.iterator]=="function"?i=e:e.length>0&&(EP.length=e.length,i=EP):i=bP,(t>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(t,r),s.index=t-1),{iterable:i,objectInfo:s}}function op(e){return e&&e[Symbol.asyncIterator]}function ap(e,t){let{size:r,stride:i,offset:s,startIndices:n,nested:o}=t,a=e.BYTES_PER_ELEMENT,c=i?i/a:r,l=s?s/a:0,u=Math.floor((e.length-l)/c);return(f,{index:h,target:d})=>{if(!n){let _=h*c+l;for(let y=0;y<r;y++)d[y]=e[_+y];return d}let p=n[h],g=n[h+1]||u,m;if(o){m=new Array(g-p);for(let _=p;_<g;_++){let y=_*c+l;d=new Array(r);for(let x=0;x<r;x++)d[x]=e[y+x];m[_-p]=d}}else if(c===r)m=e.subarray(p*r+l,g*r+l);else{m=new e.constructor((g-p)*r);let _=0;for(let y=p;y<g;y++){let x=y*c+l;for(let E=0;E<r;E++)m[_++]=e[x+E]}}return m}}var SP=[],nu=[[0,1/0]];function vP(e,t){if(e===nu||(t[0]<0&&(t[0]=0),t[0]>=t[1]))return e;let r=[],i=e.length,s=0;for(let n=0;n<i;n++){let o=e[n];o[1]<t[0]?(r.push(o),s=n+1):o[0]>t[1]?r.push(o):t=[Math.min(o[0],t[0]),Math.max(o[1],t[1])]}return r.splice(s,0,t),r}var _5={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function cp(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});let r=e.type||"interpolation";return{..._5[r],...t,...e,type:r}}var Ji=class extends su{constructor(t,r){super(t,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:nu}),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(t){this.state.startIndices=t}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:t=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!t,r}layoutChanged(){return this.state.layoutChanged}setAccessor(t){this.state.layoutChanged||=!TP(t,this.getAccessor()),super.setAccessor(t)}getUpdateTriggers(){let{accessor:t}=this.settings;return[this.id].concat(typeof t!="function"&&t||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(t){if(!t||!this.supportsTransition())return null;let{accessor:r}=this.settings,i=this.settings.transition,s=Array.isArray(r)?t[r.find(n=>t[n])]:t[r];return cp(s,i)}setNeedsUpdate(t=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),r){let{startRow:i=0,endRow:s=1/0}=r;this.state.updateRanges=vP(this.state.updateRanges,[i,s])}else this.state.updateRanges=nu}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=SP}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(t,r.updateRanges!==nu),!0):!1}updateBuffer({numInstances:t,data:r,props:i,context:s}){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(s,this,{data:r,startRow:l,endRow:u,props:i,numInstances:t});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,u]of n){let f=Number.isFinite(l)?this.getVertexOffset(l):0,h=Number.isFinite(u)?this.getVertexOffset(u):a||!Number.isFinite(t)?this.value.length:t*this.size;super.updateSubBuffer({startOffset:f,endOffset:h})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(t){return t===void 0||typeof t=="function"?!1:(this.setData({constant:!0,value:t})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setExternalBuffer(t){let{state:r}=this;return t?(this.clearNeedsUpdate(),r.lastExternalBuffer===t||(r.lastExternalBuffer=t,this.setNeedsRedraw(),this.setData(t)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(t,r=null){let{state:i,settings:s}=this;if(!t)return i.binaryValue=null,i.binaryAccessor=null,!1;if(s.noAlloc)return!1;if(i.binaryValue===t)return this.clearNeedsUpdate(),!0;if(i.binaryValue=t,this.setNeedsRedraw(),s.transform||r!==this.startIndices){ArrayBuffer.isView(t)&&(t={value:t});let o=t;At(ArrayBuffer.isView(o.value),`invalid ${s.accessor}`);let a=Boolean(o.size)&&o.size!==this.size;return i.binaryAccessor=ap(o.value,{size:o.size||this.size,stride:o.stride,offset:o.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(t),!0}getVertexOffset(t){let{startIndices:r}=this;return(r?t<r.length?r[t]:this.numInstances:t)*this.size}getValue(){let t=this.settings.shaderAttributes,r=super.getValue();if(!t)return r;for(let i in t)Object.assign(r,super.getValue(i,t[i]));return r}getBufferLayout(t){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,i=super._getBufferLayout(),{stepMode:s}=this.settings;if(s==="dynamic"?i.stepMode=t?t.isInstanced?"instance":"vertex":"instance":i.stepMode=s??"vertex",!r)return i;for(let n in r){let o=super._getBufferLayout(n,r[n]);i.attributes.push(...o.attributes)}return i}_autoUpdater(t,{data:r,startRow:i,endRow:s,props:n,numInstances:o}){if(t.constant)return;let{settings:a,state:c,value:l,size:u,startIndices:f}=t,{accessor:h,transform:d}=a,p=c.binaryAccessor||(typeof h=="function"?h:n[h]);At(typeof p=="function",`accessor "${h}" is not a function`);let g=t.getVertexOffset(i),{iterable:m,objectInfo:_}=Ht(r,i,s);for(let y of m){_.index++;let x=p(y,_);if(d&&(x=d.call(this,x)),f){let E=(_.index<f.length-1?f[_.index+1]:o)-f[_.index];if(x&&Array.isArray(x[0])){let P=g;for(let B of x)t._normalizeValue(B,l,P),P+=u}else x&&x.length>u?l.set(x,g):(t._normalizeValue(x,_.target,0),Od({target:l,source:_.target,start:g,count:E}));g+=E*u}else t._normalizeValue(x,l,g),g+=u}}_validateAttributeUpdaters(){let{settings:t}=this;if(!(t.noAlloc||typeof t.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:t}=this,r=Math.min(4,this.size);if(t&&t.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(t[3]);case 3:i=i&&Number.isFinite(t[2]);case 2:i=i&&Number.isFinite(t[1]);case 1:i=i&&Number.isFinite(t[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function mA(e){let{source:t,target:r,start:i=0,size:s,getData:n}=e,o=e.end||r.length,a=t.length,c=o-i;if(a>c){r.set(t.subarray(0,c),i);return}if(r.set(t,i),!n)return;let l=a;for(;l<c;){let u=n(l,t);for(let f=0;f<s;f++)r[i+l]=u[f]||0,l++}}function CP({source:e,target:t,size:r,getData:i,sourceStartIndices:s,targetStartIndices:n}){if(!s||!n)return mA({source:e,target:t,size:r,getData:i}),t;let o=0,a=0,c=i&&((u,f)=>i(u+a,f)),l=Math.min(s.length,n.length);for(let u=1;u<l;u++){let f=s[u]*r,h=n[u]*r;mA({source:e.subarray(o,f),target:t,start:a,end:h,size:r,getData:c}),o=f,a=h}return a<t.length&&mA({source:[],target:t,start:a,size:r,getData:c}),t}function wP(e){let{device:t,settings:r,value:i}=e,s=new Ji(t,r);return s.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),s}function lp(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${e}"`)}}function up(e){switch(e){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function fp(e){e.push(e.shift())}function PP(e,t){let{doublePrecision:r,settings:i,value:s,size:n}=e,o=r&&s instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=e.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(i.noAlloc?s.length:(t+a)*n)*o}function hp({device:e,source:t,target:r}){return(!r||r.byteLength<t.byteLength)&&(r?.destroy(),r=e.createBuffer({byteLength:t.byteLength,usage:t.usage})),r}function dp({device:e,buffer:t,attribute:r,fromLength:i,toLength:s,fromStartIndices:n,getData:o=a=>a}){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&&t&&i>=s)return t;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let x=o;o=(E,P)=>r.normalizeConstant(x(E,P))}let m=d?(x,E)=>o(g,E):(x,E)=>o(g.subarray(x+l,x+l+c),E),_=t?new Float32Array(t.readSyncWebGL(u,i*4).buffer):new Float32Array(0),y=new Float32Array(s);return CP({source:_,target:y,sourceStartIndices:n,targetStartIndices:f,size:c,getData:m}),(!t||t.byteLength<y.byteLength+u)&&(t?.destroy(),t=e.createBuffer({byteLength:y.byteLength+u,usage:35050})),t.write(y,u),t}var ba=class{constructor({device:t,attribute:r,timeline:i}){this.buffers=[],this.currentLength=0,this.device=t,this.transition=new Hr(i),this.attribute=r,this.attributeInTransition=wP(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(t,r,i=1/0){this.settings=t,this.currentStartIndices=this.attribute.startIndices,this.currentLength=PP(this.attribute,r),this.transition.start({...t,duration:i})}update(){let t=this.transition.update();return t&&this.onUpdate(),t}setBuffer(t){this.attributeInTransition.setData({buffer:t,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let t of this.buffers)t.destroy();this.buffers.length=0}};var ou=class extends ba{constructor({device:t,attribute:r,timeline:i}){super({device:t,attribute:r,timeline:i}),this.type="interpolation",this.transform=A5(t,r)}start(t,r){let i=this.currentLength,s=this.currentStartIndices;if(super.start(t,r,t.duration),t.duration<=0){this.transition.cancel();return}let{buffers:n,attribute:o}=this;fp(n),n[0]=dp({device:this.device,buffer:n[0],attribute:o,fromLength:i,toLength:this.currentLength,fromStartIndices:s,getData:t.enter}),n[1]=hp({device:this.device,source:n[0],target:n[1]}),this.setBuffer(n[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/o.size);MP(o)&&(l/=2),c.setVertexCount(l),o.isConstant?(c.setAttributes({aFrom:n[0]}),c.setConstantAttributes({aTo:o.value})):c.setAttributes({aFrom:n[0],aTo:o.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:n[1]})}onUpdate(){let{duration:t,easing:r}=this.settings,{time:i}=this.transition,s=i/t;r&&(s=r(s));let{model:n}=this.transform;n.setUniforms({time:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},y5=`#version 300 es
#define SHADER_NAME interpolation-transition-vertex-shader
uniform float time;
in ATTRIBUTE_TYPE aFrom;
in ATTRIBUTE_TYPE aTo;
out ATTRIBUTE_TYPE vCurrent;
void main(void) {
vCurrent = mix(aFrom, aTo, time);
gl_Position = vec4(0.0);
}
`,x5=`#version 300 es
#define SHADER_NAME interpolation-transition-vertex-shader
uniform float time;
in ATTRIBUTE_TYPE aFrom;
in ATTRIBUTE_TYPE aFrom64Low;
in ATTRIBUTE_TYPE aTo;
in ATTRIBUTE_TYPE aTo64Low;
out ATTRIBUTE_TYPE vCurrent;
out ATTRIBUTE_TYPE vCurrent64Low;
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 main(void) {
for (int i=0; i<ATTRIBUTE_SIZE; i++) {
vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), time);
vCurrent[i] = value.x;
vCurrent64Low[i] = value.y;
}
gl_Position = vec4(0.0);
}
`;function MP(e){return e.doublePrecision&&e.value instanceof Float64Array}function A5(e,t){let r=t.size,i=lp(r),s=up(r),n=t.getBufferLayout();return MP(t)?new Ar(e,{vs:x5,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:s,byteOffset:0},{attribute:"aFrom64Low",format:s,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:s,byteOffset:0},{attribute:"aTo64Low",format:s,byteOffset:4*r}]}],modules:[Hi],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new Ar(e,{vs:y5,bufferLayout:[{name:"aFrom",format:s},{name:"aTo",format:n.attributes[0].format}],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}var au=class extends ba{constructor({device:t,attribute:r,timeline:i}){super({device:t,attribute:r,timeline:i}),this.type="spring",this.texture=S5(t),this.framebuffer=v5(t,this.texture),this.transform=E5(t,r)}start(t,r){let i=this.currentLength,s=this.currentStartIndices;super.start(t,r);let{buffers:n,attribute:o}=this;for(let c=0;c<2;c++)n[c]=dp({device:this.device,buffer:n[c],attribute:o,fromLength:i,toLength:this.currentLength,fromStartIndices:s,getData:t.enter});n[2]=hp({device:this.device,source:n[0],target:n[2]}),this.setBuffer(n[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){let{buffers:t,transform:r,framebuffer:i,transition:s}=this,n=this.settings;r.model.setAttributes({aPrev:t[0],aCur:t[1]}),r.transformFeedback.setBuffers({vNext:t[2]}),r.model.setUniforms({stiffness:n.stiffness,damping:n.damping}),r.run({framebuffer:i,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),fp(t),this.setBuffer(t[1]),this.device.readPixelsToArrayWebGL(i)[0]>0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},T5=`#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;
}
`,b5=`#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 E5(e,t){let r=lp(t.size),i=up(t.size);return new Ar(e,{vs:T5,fs:b5,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:t.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 S5(e){return e.createTexture({data:new Uint8Array(4),format:"rgba8unorm",mipmaps:!1,width:1,height:1})}function v5(e,t){return e.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[t]})}var C5={interpolation:ou,spring:au},cu=class{constructor(t,{id:r,timeline:i}){if(!t)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=t,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:r,numInstances:i}){this.numInstances=i||1;for(let s in t){let n=t[s],o=n.getTransitionSetting(r);o&&this._updateAttribute(s,n,o)}for(let s in this.transitions){let n=t[s];(!n||!n.getTransitionSetting(r))&&this._removeTransition(s)}}hasAttribute(t){let r=this.transitions[t];return r&&r.inProgress}getAttributes(){let t={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(t[r]=i.attributeInTransition)}return t}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let t=this.needsRedraw;return this.needsRedraw=!1,t}_removeTransition(t){this.transitions[t].delete(),delete this.transitions[t]}_updateAttribute(t,r,i){let s=this.transitions[t],n=!s||s.type!==i.type;if(n){s&&this._removeTransition(t);let o=C5[i.type];o?this.transitions[t]=new o({attribute:r,timeline:this.timeline,device:this.device}):(k.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[t].start(i,this.numInstances))}};var RP="attributeManager.invalidate",w5="attributeManager.updateStart",P5="attributeManager.updateEnd",M5="attribute.updateStart",R5="attribute.allocate",I5="attribute.updateEnd",qr=class{constructor(t,{id:r="attribute-manager",stats:i,timeline:s}={}){this.mergeBoundsMemoized=He(VC),this.id=r,this.device=t,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new cu(t,{id:`${r}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let t in this.attributes)this.attributes[t].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(t={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!t.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(t){this._add(t)}addInstanced(t){this._add(t,{stepMode:"instance"})}remove(t){for(let r of t)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(t,r){let i=this._invalidateTrigger(t,r);kt(RP,this,t,i)}invalidateAll(t){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,t);kt(RP,this,"all")}update({data:t,numInstances:r,startIndices:i=null,transitions:s,props:n={},buffers:o={},context:a={}}){let c=!1;kt(w5,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=i,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,t.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(n[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:r,data:t,props:n,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&kt(P5,this,r),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:s})}updateTransition(){let{attributeTransitionManager:t}=this,r=t.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(t){let r=t.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(t={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,s={...i.getAttributes()};for(let n in r){let o=r[n];o.needsRedraw(t)&&!i.hasAttribute(n)&&(s[n]=o)}return s}getBufferLayouts(t){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(t))}_add(t,r){for(let i in t){let s=t[i],n={...s,id:i,size:s.isIndexed&&1||s.size||1,...r};this.attributes[i]=new Ji(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let t={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(s=>{t[s]||(t[s]=[]),t[s].push(r)});this.updateTriggers=t}_invalidateTrigger(t,r){let{attributes:i,updateTriggers:s}=this,n=s[t];return n&&n.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(t){let{attribute:r,numInstances:i}=t;if(kt(M5,r),r.constant){r.setConstantValue(r.value);return}r.allocate(i)&&kt(R5,r,i),r.updateBuffer(t)&&(this.needsRedraw=!0,kt(I5,r,i))}};var lu=class extends Hr{get value(){return this._value}_onUpdate(){let{time:t,settings:{fromValue:r,toValue:i,duration:s,easing:n}}=this,o=n(t/s);this._value=se(r,i,o)}};var IP=1e-5;function BP(e,t,r,i,s){let n=t-e,a=(r-t)*s,c=-n*i;return a+c+n+t}function B5(e,t,r,i,s){if(Array.isArray(r)){let n=[];for(let o=0;o<r.length;o++)n[o]=BP(e[o],t[o],r[o],i,s);return n}return BP(e,t,r,i,s)}function OP(e,t){if(Array.isArray(e)){let r=0;for(let i=0;i<e.length;i++){let s=e[i]-t[i];r+=s*s}return Math.sqrt(r)}return Math.abs(e-t)}var uu=class extends Hr{get value(){return this._currValue}_onUpdate(){let{fromValue:t,toValue:r,damping:i,stiffness:s}=this.settings,{_prevValue:n=t,_currValue:o=t}=this,a=B5(n,o,r,i,s),c=OP(a,r),l=OP(a,o);c<IP&&l<IP&&(a=r,this.end()),this._prevValue=o,this._currValue=a}};var O5={interpolation:lu,spring:uu},fu=class{constructor(t){this.transitions=new Map,this.timeline=t}get active(){return this.transitions.size>0}add(t,r,i,s){let{transitions:n}=this;if(n.has(t)){let c=n.get(t),{value:l=c.settings.fromValue}=c;r=l,this.remove(t)}if(s=cp(s),!s)return;let o=O5[s.type];if(!o){k.error(`unsupported transition type '${s.type}'`)();return}let a=new o(this.timeline);a.start({...s,fromValue:r,toValue:i}),n.set(t,a)}remove(t){let{transitions:r}=this;r.has(t)&&(r.get(t).cancel(),r.delete(t))}update(){let t={};for(let[r,i]of this.transitions)i.update(),t[r]=i.value,i.inProgress||this.remove(r);return t}clear(){for(let t of this.transitions.keys())this.remove(t)}};function NP(e){let t=e[br];for(let r in t){let i=t[r],{validate:s}=i;if(s&&!s(e[r],i))throw new Error(`Invalid prop ${r}: ${e[r]}`)}}function LP(e,t){let r=Ea({newProps:e,oldProps:t,propTypes:e[br],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=N5(e,t),s=!1;return i||(s=L5(e,t)),{dataChanged:i,propsChanged:r,updateTriggersChanged:s,extensionsChanged:D5(e,t),transitionsChanged:F5(e,t)}}function F5(e,t){if(!e.transitions)return!1;let r={},i=e[br],s=!1;for(let n in e.transitions){let o=i[n],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&_A(e[n],t[n],o)&&(r[n]=!0,s=!0)}return s?r:!1}function Ea({newProps:e,oldProps:t,ignoreProps:r={},propTypes:i={},triggerName:s="props"}){if(t===e)return!1;if(typeof e!="object"||e===null)return`${s} changed shallowly`;if(typeof t!="object"||t===null)return`${s} changed shallowly`;for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${s}.${n} added`;let o=_A(e[n],t[n],i[n]);if(o)return`${s}.${n} ${o}`}for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${s}.${n} dropped`;if(!Object.hasOwnProperty.call(e,n)){let o=_A(e[n],t[n],i[n]);if(o)return`${s}.${n} ${o}`}}return!1}function _A(e,t,r){let i=r&&r.equal;return i&&!i(e,t,r)||!i&&(i=e&&t&&e.equals,i&&!i.call(e,t))?"changed deeply":!i&&t!==e?"changed shallowly":null}function N5(e,t){if(t===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:s}=e;return i?i(e.data,t.data)||(r="Data comparator detected a change"):e.data!==t.data&&(r="A new data container was supplied"),r&&s&&(r=s(e.data,t.data)||r),r}function L5(e,t){if(t===null)return{all:!0};if("all"in e.updateTriggers&&FP(e,t,"all"))return{all:!0};let r={},i=!1;for(let s in e.updateTriggers)s!=="all"&&FP(e,t,s)&&(r[s]=!0,i=!0);return i?r:!1}function D5(e,t){if(t===null)return!0;let r=t.extensions,{extensions:i}=e;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let s=0;s<i.length;s++)if(!i[s].equals(r[s]))return!0;return!1}function FP(e,t,r){let i=e.updateTriggers[r];i=i??{};let s=t.updateTriggers[r];return s=s??{},Ea({oldProps:s,newProps:i,triggerName:r})}var U5="count(): argument not an object",k5="count(): argument not a container";function pp(e){if(!z5(e))throw new Error(U5);if(typeof e.count=="function")return e.count();if(Number.isFinite(e.size))return e.size;if(Number.isFinite(e.length))return e.length;if(V5(e))return Object.keys(e).length;throw new Error(k5)}function V5(e){return e!==null&&typeof e=="object"&&e.constructor===Object}function z5(e){return e!==null&&typeof e=="object"}function Si(e,t){if(!t)return e;let r={...e,...t};if("defines"in t&&(r.defines={...e.defines,...t.defines}),"modules"in t&&(r.modules=(e.modules||[]).concat(t.modules),t.modules.some(i=>i.name==="project64"))){let i=r.modules.findIndex(s=>s.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in t)if(!e.inject)r.inject=t.inject;else{let i={...e.inject};for(let s in t.inject)i[s]=(i[s]||"")+t.inject[s];r.inject=i}return r}var H5={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},yA={};function DP(e,t,r,i){if(r instanceof xt)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let s=null;r.compressed&&(s={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let n=t.createTexture({...r,sampler:{...H5,...s,...i}});return yA[n.id]=e,n}function UP(e,t){!t||!(t instanceof xt)||yA[t.id]===e&&(t.delete(),delete yA[t.id])}var G5={boolean:{validate(e,t){return!0},equal(e,t,r){return Boolean(e)===Boolean(t)}},number:{validate(e,t){return Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)}},color:{validate(e,t){return t.optional&&!e||xA(e)&&(e.length===3||e.length===4)},equal(e,t,r){return vt(e,t,1)}},accessor:{validate(e,t){let r=gp(e);return r==="function"||r===gp(t.value)},equal(e,t,r){return typeof t=="function"?!0:vt(e,t,1)}},array:{validate(e,t){return t.optional&&!e||xA(e)},equal(e,t,r){let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?vt(e,t,s):e===t}},object:{equal(e,t,r){if(r.ignore)return!0;let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?vt(e,t,s):e===t}},function:{validate(e,t){return t.optional&&!e||typeof e=="function"},equal(e,t,r){return!r.compare&&r.ignore!==!1||e===t}},data:{transform:(e,t,r)=>{if(!e)return e;let{dataTransform:i}=r.props;return i?i(e):typeof e.shape=="string"&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,r)=>{let i=r.context;return!i||!i.device?null:DP(r.id,i.device,e,{...t.parameters,...r.props.textureParameters})},release:(e,t,r)=>{UP(r.id,e)}}};function kP(e){let t={},r={},i={};for(let[s,n]of Object.entries(e)){let o=n?.deprecatedFor;if(o)i[s]=Array.isArray(o)?o:[o];else{let a=W5(s,n);t[s]=a,r[s]=a.value}}return{propTypes:t,defaultProps:r,deprecatedProps:i}}function W5(e,t){switch(gp(t)){case"object":return hu(e,t);case"array":return hu(e,{type:"array",value:t,compare:!1});case"boolean":return hu(e,{type:"boolean",value:t});case"number":return hu(e,{type:"number",value:t});case"function":return hu(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function hu(e,t){return"type"in t?{name:e,...G5[t.type],...t}:"value"in t?{name:e,type:gp(t.value),...t}:{name:e,type:"object",value:t}}function xA(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function gp(e){return xA(e)?"array":e===null?"null":typeof e}function VP(e,t){let r;for(let n=t.length-1;n>=0;n--){let o=t[n];"extensions"in o&&(r=o.extensions)}let i=AA(e.constructor,r),s=Object.create(i);s[da]=e,s[Ai]={},s[zr]={};for(let n=0;n<t.length;++n){let o=t[n];for(let a in o)s[a]=o[a]}return Object.freeze(s),s}var j5="_mergedDefaultProps";function AA(e,t){let r=j5;if(t)for(let s of t){let n=s.constructor;n&&(r+=`:${n.extensionName||n.name}`)}let i=zP(e,r);return i||(e[r]=X5(e,t||[]))}function X5(e,t){if(!e.prototype)return null;let i=Object.getPrototypeOf(e),s=AA(i),n=zP(e,"defaultProps")||{},o=kP(n),a=Object.assign(Object.create(null),s,o.defaultProps),c=Object.assign(Object.create(null),s?.[br],o.propTypes),l=Object.assign(Object.create(null),s?.[Bd],o.deprecatedProps);for(let u of t){let f=AA(u.constructor);f&&(Object.assign(a,f),Object.assign(c,f[br]),Object.assign(l,f[Bd]))}return Y5(a,e),K5(a,c),q5(a,l),a[br]=c,a[Bd]=l,t.length===0&&!TA(e,"_propTypes")&&(e._propTypes=c),a}function Y5(e,t){let r=J5(t);Object.defineProperties(e,{id:{writable:!0,value:r}})}function q5(e,t){for(let r in t)Object.defineProperty(e,r,{enumerable:!1,set(i){let s=`${this.id}: ${r}`;for(let n of t[r])TA(this,n)||(this[n]=i);k.deprecated(s,t[r].join("/"))()}})}function K5(e,t){let r={},i={};for(let s in t){let n=t[s],{name:o,value:a}=n;n.async&&(r[o]=a,i[o]=$5(o))}e[ji]=r,e[Ai]={},Object.defineProperties(e,i)}function $5(e){return{enumerable:!0,set(t){typeof t=="string"||t instanceof Promise||op(t)?this[Ai][e]=t:this[zr][e]=t},get(){if(this[zr]){if(e in this[zr])return this[zr][e]||this[ji][e];if(e in this[Ai]){let t=this[da]&&this[da].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[ji][e]}}return this[ji][e]}}}function TA(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function zP(e,t){return TA(e,t)&&e[t]}function J5(e){let t=e.componentName;return t||k.warn(`${e.name}.componentName not specified`)(),t||e.name}var Z5=0,mp=class{constructor(...t){this.props=VP(this,t),this.id=this.props.id,this.count=Z5++}clone(t){let{props:r}=this,i={};for(let s in r[ji])s in r[zr]?i[s]=r[zr][s]:s in r[Ai]&&(i[s]=r[Ai][s]);return new this.constructor({...r,...i,...t})}},Gn=mp;(()=>{mp.componentName="Component"})(),(()=>{mp.defaultProps={}})();var Q5=Object.freeze({}),Wn=class{constructor(t){this.component=t,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let t in this.asyncProps){let r=this.asyncProps[t];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||Q5}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(t){return t in this.asyncProps}getAsyncProp(t){let r=this.asyncProps[t];return r&&r.resolvedValue}isAsyncPropLoading(t){if(t){let r=this.asyncProps[t];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(t,r){this._watchPromise(t,Promise.resolve(r))}setAsyncProps(t){this.component=t[da]||this.component;let r=t[zr]||{},i=t[Ai]||t,s=t[ji]||{};for(let n in r){let o=r[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o),r[n]=this.getAsyncProp(n)}for(let n in i){let o=i[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o)}}_fetch(t,r){return null}_onResolve(t,r){}_onError(t,r){}_updateAsyncProp(t,r){if(this._didAsyncInputValueChange(t,r)){if(typeof r=="string"&&(r=this._fetch(t,r)),r instanceof Promise){this._watchPromise(t,r);return}if(op(r)){this._resolveAsyncIterable(t,r);return}this._setPropValue(t,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let t in this.asyncProps)Object.defineProperty(this.oldAsyncProps,t,{enumerable:!0,value:this.oldProps[t]})}}_didAsyncInputValueChange(t,r){let i=this.asyncProps[t];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(t,r){this._freezeAsyncOldProps();let i=this.asyncProps[t];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(t,r,i){let s=this.asyncProps[t];s&&i>=s.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=r,s.resolvedLoadCount=i,this.onAsyncPropUpdated(t,r))}_watchPromise(t,r){let i=this.asyncProps[t];if(i){i.pendingLoadCount++;let s=i.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(i,n),this._setAsyncPropValue(t,n,s),this._onResolve(t,n))}).catch(n=>{this._onError(t,n)})}}async _resolveAsyncIterable(t,r){if(t!=="data"){this._setPropValue(t,r);return}let i=this.asyncProps[t];if(!i)return;i.pendingLoadCount++;let s=i.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(t,n,s)}this._onResolve(t,n)}_postProcessValue(t,r){let i=t.type;return i&&this.component&&(i.release&&i.release(t.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(t,r){if(!this.asyncProps[t]){let s=this.component&&this.component.props[br];this.asyncProps[t]={type:s&&s[t],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var du=class extends Wn{constructor({attributeManager:t,layer:r}){super(r),this.attributeManager=t,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(t,r){let i=this.layer,s=i?.props.fetch;return s?s(r,{propName:t,layer:i}):super._fetch(t,r)}_onResolve(t,r){let i=this.layer;if(i){let s=i.props.onDataLoad;t==="data"&&s&&s(r,{propName:t,layer:i})}}_onError(t,r){let i=this.layer;i&&i.raiseError(r,`loading ${t} of ${this.layer}`)}};var tH="layer.changeFlag",eH="layer.initialize",rH="layer.update",iH="layer.finalize",sH="layer.matched",HP=2**24-1,nH=Object.freeze([]),oH=He(({oldViewport:e,viewport:t})=>e.equals(t)),vi=new Uint8ClampedArray(0),aH={data:{type:"data",value:nH,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__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:(e,{propName:t,layer:r,loaders:i,loadOptions:s,signal:n})=>{let{resourceManager:o}=r.context;s=s||r.getLoadOptions(),i=i||r.props.loaders,n&&(s={...s,fetch:{...s?.fetch,signal:n}});let a=o.contains(e);return!a&&!s&&(o.add({resourceId:e,data:Jt(e,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:c=>r.internalState?.reloadAsyncProp(t,c),consumerId:r.id,requestId:t}):Jt(e,i,s)}},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:e})=>[0,-e*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},_p=class extends Gn{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Us.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let t=this;for(;t.parent;)t=t.parent;return t}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(t){At(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=zx(t,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,n,o]=na(i,r.pixelProjectionMatrix);return t.length===2?[s,n]:[s,n,o]}unproject(t){return At(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(t)}projectPosition(t,r){At(this.internalState);let i=this.internalState.viewport||this.context.viewport;return wd(t,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}setState(t){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,t),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 t=this.state;return t&&(t.models||t.model&&[t.model])||[]}setModuleParameters(t){for(let r of this.getModels())r.updateModuleSettings(t)}setShaderModuleProps(...t){for(let r of this.getModels())r.shaderInputs.setProps(...t)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:t}=this.props;return t===X.DEFAULT||t===X.LNGLAT||t===X.CARTESIAN}onHover(t,r){return this.props.onHover&&this.props.onHover(t,r)||!1}onClick(t,r){return this.props.onClick&&this.props.onClick(t,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(t,r=[]){return r[0]=t+1&255,r[1]=t+1>>8&255,r[2]=t+1>>8>>8&255,r}decodePickingColor(t){At(t instanceof Uint8Array);let[r,i,s]=t;return r+i*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:pp(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(t){t=Si(t,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)t=Si(t,r.getShaders.call(this,r));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){let r=this.getAttributeManager(),{dataChanged:i}=t.changeFlags;if(i&&r)if(Array.isArray(i))for(let s of i)r.invalidateAll(s);else r.invalidateAll();if(r){let{props:s}=t,n=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||s.pickable||s.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(t){for(let i of this.getModels())i.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(t){for(let r of this.getModels())r.draw(t)}getPickingInfo({info:t,mode:r,sourceLayer:i}){let{index:s}=t;return s>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[s]),t}raiseError(t,r){r&&(t=new Error(`${r}: ${t.message}`,{cause:t})),this.props.onError?.(t)||this.context?.onError?.(t,this)}getNeedsRedraw(t={clearRedrawFlags:!1}){return this._getNeedsRedraw(t)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(t){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=t,(!r||!oH({oldViewport:r,viewport:t}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(t="all"){let r=this.getAttributeManager();r&&(t==="all"?r.invalidateAll():r.invalidate(t))}updateAttributes(t){let r=!1;for(let i in t)t[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,t,r)}_updateAttributes(){let t=this.getAttributeManager();if(!t)return;let r=this.props,i=this.getNumInstances(),s=this.getStartIndices();t.update({data:r.data,numInstances:i,startIndices:s,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let n=t.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){let t=this.getAttributeManager();t&&t.updateTransition()}_updateUniformTransition(){let{uniformTransitions:t}=this.internalState;if(t.active){let r=t.update(),i=Object.create(this.props);for(let s in r)Object.defineProperty(i,s,{value:r[s]});return i}return this.props}calculateInstancePickingColors(t,{numInstances:r}){if(t.constant)return;let i=Math.floor(vi.length/4);if(this.internalState.usesPickingColorCache=!0,i<r){r>HP&&k.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),vi=Ur.allocate(vi,r,{size:4,copy:!0,maxCount:Math.max(r,HP)});let s=Math.floor(vi.length/4),n=[];for(let o=i;o<s;o++)this.encodePickingColor(o,n),vi[o*4+0]=n[0],vi[o*4+1]=n[1],vi[o*4+2]=n[2]}t.value=vi.subarray(0,r*4)}_setModelAttributes(t,r,i=!1){if(!Object.keys(r).length)return;if(i){let a=this.getAttributeManager();t.setBufferLayout(a.getBufferLayouts(t)),r=a.getAttributes()}let s=t.userData?.excludeAttributes||{},n={},o={};for(let a in r){if(s[a])continue;let c=r[a].getValue();for(let l in c){let u=c[l];u instanceof Q?r[a].settings.isIndexed?t.setIndexBuffer(u):n[l]=u:u&&(o[l]=u)}}t.setAttributes(n),t.setConstantAttributes(o)}disablePickingIndex(t){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(t);return}let{pickingColors:i,instancePickingColors:s}=this.getAttributeManager().attributes,n=i||s,o=n&&r.attributes&&r.attributes[n.id];if(o&&o.value){let a=o.value,c=this.encodePickingColor(t);for(let l=0;l<r.length;l++){let u=n.getVertexOffset(l);a[u]===c[0]&&a[u+1]===c[1]&&a[u+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(t)}_disablePickingIndex(t){let{pickingColors:r,instancePickingColors:i}=this.getAttributeManager().attributes,s=r||i;if(!s)return;let n=s.getVertexOffset(t),o=s.getVertexOffset(t+1);s.buffer.write(new Uint8Array(o-n),n)}restorePickingColors(){let{pickingColors:t,instancePickingColors:r}=this.getAttributeManager().attributes,i=t||r;i&&(this.internalState.usesPickingColorCache&&i.value.buffer!==vi.buffer&&(i.value=vi.subarray(0,i.value.length)),i.updateSubBuffer({startOffset:0}))}_initialize(){At(!this.internalState),At(Number.isFinite(this.props.coordinateSystem)),kt(eH,this);let t=this._getAttributeManager();t&&t.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new du({attributeManager:t,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(k.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),t)}),this.internalState.uniformTransitions=new fu(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(t){kt(sH,this,this===t);let{state:r,internalState:i}=t;this!==t&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let t=this.needsUpdate();if(kt(rH,this,t),!t)return;let r=this.props,i=this.context,s=this.internalState,n=i.viewport,o=this._updateUniformTransition();s.propsInTransition=o,i.viewport=s.viewport||n,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.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{i.viewport=n,this.props=r,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){kt(iH,this),this.finalizeState(this.context);for(let t of this.props.extensions)t.finalizeState.call(this,this.context,t)}_drawLayer({renderPass:t,moduleParameters:r=null,uniforms:i={},parameters:s={}}){this._updateAttributeTransition();let n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;let a=this.props.opacity;i.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(i)||[0,0];o.device.setParametersWebGL({polygonOffset:l});for(let u of this.getModels())u.setParameters(s);o.device.withParametersWebGL(s,()=>{let u={renderPass:t,moduleParameters:r,uniforms:i,parameters:s,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(t){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let s in t)if(t[s]){let n=!1;switch(s){case"dataChanged":let o=t[s],a=r[s];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,n=!0);default:r[s]||(r[s]=t[s],n=!0)}n&&kt(tH,this,s,t)}let i=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||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(t,r){let i=LP(t,r);if(i.updateTriggersChanged)for(let s in i.updateTriggersChanged)i.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(i.transitionsChanged)for(let s in i.transitionsChanged)this.internalState.uniformTransitions.add(s,r[s],t[s],t.transitions?.[s]);return this.setChangeFlags(i)}validateProps(){NP(this.props)}updateAutoHighlight(t){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(t)}_updateAutoHighlight(t){let r={highlightedObjectColor:t.picked?t.color:null},{highlightColor:i}=this.props;t.picked&&typeof i=="function"&&(r.highlightColor=i(t)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let t=this.context;return new qr(t.device,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,r){let{props:i,oldProps:s}=t;this.setNeedsRedraw(),this._updateAttributes();let n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(r||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};o||(l.highlightedObjectColor=null),Array.isArray(c)&&(l.highlightColor=c),(r||a!==s.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(t){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),s=i?i.getNeedsRedraw(t):!1;if(r=r||s,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}},lt=_p;(()=>{_p.defaultProps=aH})(),(()=>{_p.layerName="Layer"})();var cH="compositeLayer.renderLayers",bA=class extends lt{get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(t=>t.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(t){}setState(t){super.setState(t),this.setNeedsUpdate()}getPickingInfo({info:t}){let{object:r}=t;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(t.object=r.__source.object,t.index=r.__source.index),t}filterSubLayer(t){return!0}shouldRenderSubLayer(t,r){return r&&r.length}getSubLayerClass(t,r){let{_subLayerProps:i}=this.props;return i&&i[t]&&i[t].type||r}getSubLayerRow(t,r,i){return t.__source={parent:this,object:r,index:i},t}getSubLayerAccessor(t){if(typeof t=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,s)=>i&&i.__source?(r.index=i.__source.index,t(i.__source.object,r)):t(i,s)}return t}getSubLayerProps(t={}){let{opacity:r,pickable:i,visible:s,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:i,visible:s,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:_},E=y&&t.id&&y[t.id],P=E&&E.updateTriggers,B=t.id||"sublayer";if(E){let F=this.props[br],M=t.type?t.type._propTypes:{};for(let v in E){let T=M[v]||F[v];T&&T.type==="accessor"&&(E[v]=this.getSubLayerAccessor(E[v]))}}Object.assign(x,t,E),x.id=`${this.props.id}-${B}`,x.updateTriggers={all:this.props.updateTriggers?.all,...t.updateTriggers,...P};for(let F of g){let M=F.getSubLayerProps.call(this,F);M&&Object.assign(x,M,{updateTriggers:Object.assign(x.updateTriggers,M.updateTriggers)})}return x}_updateAutoHighlight(t){for(let r of this.getSubLayers())r.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(t,r){let i=this.internalState.subLayers,s=!i||this.needsUpdate();if(s){let n=this.renderLayers();i=Oe(n,Boolean),this.internalState.subLayers=i}kt(cH,this,s,i);for(let n of i)n.parent=this}},It=bA;(()=>{bA.layerName="CompositeLayer"})();var yp=Math.PI/180,GP=180/Math.PI,xp=6370972,Sa=256;function lH(){let e=Sa/xp,t=Math.PI/180*Sa;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[1/e,1/e,1/e],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,1/e]}}var Kr=class extends xe{constructor(t={}){let{latitude:r=0,longitude:i=0,zoom:s=0,nearZMultiplier:n=.1,farZMultiplier:o=2,resolution:a=10}=t,{height:c,altitude:l=1.5}=t;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,s);u.rotateX(r*yp),u.rotateZ(-i*yp),u.scale(f/c);let h=Math.atan(.5/l),d=Sa*2*f/c;super({...t,height:c,viewMatrix:u,longitude:i,latitude:r,zoom:s,distanceScales:lH(),fovyRadians:h*2,focalDistance:l,near:n,far:Math.min(2,1/d+1)*l*o}),this.latitude=r,this.longitude=i,this.resolution=a}get projectionMode(){return Se.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(t={}){let r={targetZ:t.z||0},i=this.unproject([0,this.height/2],r),s=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&&(n[0]+=360),i[0]>this.longitude&&(i[0]-=360),[Math.min(i[0],n[0],s[0],o[0]),Math.min(i[1],n[1],s[1],o[1]),Math.max(i[0],n[0],s[0],o[0]),Math.max(i[1],n[1],s[1],o[1])]}unproject(t,{topLeft:r=!0,targetZ:i}={}){let[s,n,o]=t,a=r?n:this.height-n,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(o))l=EA(c,[s,a,o,1]);else{let d=EA(c,[s,a,-1,1]),p=EA(c,[s,a,1,1]),g=((i||0)/xp+1)*Sa,m=jt.sqrLen(jt.sub([],d,p)),_=jt.sqrLen(d),y=jt.sqrLen(p),E=4*((4*_*y-(m-_-y)**2)/16)/m,P=Math.sqrt(_-E),B=Math.sqrt(Math.max(0,g*g-E)),F=(P-B)/Math.sqrt(m);l=jt.lerp([],d,p,F)}let[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(i)?[u,f,i]:[u,f]}projectPosition(t){let[r,i,s=0]=t,n=r*yp,o=i*yp,a=Math.cos(o),c=(s/xp+1)*Sa;return[Math.sin(n)*a*c,-Math.cos(n)*a*c,Math.sin(o)*c]}unprojectPosition(t){let[r,i,s]=t,n=jt.len(t),o=Math.asin(s/n),c=Math.atan2(r,-i)*GP,l=o*GP,u=(n/Sa-1)*xp;return[c,l,u]}projectFlat(t){return t}unprojectFlat(t){return t}panByPosition(t,r){let i=this.unproject(r);return{longitude:t[0]-i[0]+this.longitude,latitude:t[1]-i[1]+this.latitude}}};function EA(e,t){let r=Be.transformMat4([],t,e);return Be.scale(r,r,1/r[3]),r}var SA=Math.PI/180;function uH({height:e,focalDistance:t,orbitAxis:r,rotationX:i,rotationOrbit:s,zoom:n}){let o=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-t,0]:[0,0,t],c=new q().lookAt({eye:a,up:o});c.rotateX(i*SA),r==="Z"?c.rotateZ(s*SA):c.rotateY(s*SA);let l=Math.pow(2,n)/e;return c.scale(l),c}var jn=class extends xe{constructor(t){let{height:r,projectionMatrix:i,fovy:s=50,orbitAxis:n="Z",target:o=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=t,u=i?i[5]/2:Mn(s);super({...t,longitude:void 0,viewMatrix:uH({height:r||1,focalDistance:u,orbitAxis:n,rotationX:a,rotationOrbit:c,zoom:l}),fovy:s,focalDistance:u,position:o,zoom:l}),this.projectedCenter=this.project(this.center)}unproject(t,{topLeft:r=!0}={}){let[i,s,n=this.projectedCenter[2]]=t,o=r?s:this.height-s,[a,c,l]=xr([i,o,n],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(t,r){let i=this.project(t),s=[this.width/2+i[0]-r[0],this.height/2+i[1]-r[1],this.projectedCenter[2]];return{target:this.unproject(s)}}};var fH=new q().lookAt({eye:[0,0,1]});function hH({width:e,height:t,near:r,far:i,padding:s}){let n=-e/2,o=e/2,a=-t/2,c=t/2;if(s){let{left:l=0,right:u=0,top:f=0,bottom:h=0}=s,d=ht((l+e-u)/2,0,e)-e/2,p=ht((f+t-h)/2,0,t)-t/2;n-=d,o-=d,a+=p,c+=p}return new q().ortho({left:n,right:o,bottom:a,top:c,near:r,far:i})}var Zi=class extends xe{constructor(t){let{width:r,height:i,near:s=.1,far:n=1e3,zoom:o=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=t,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({...t,longitude:void 0,position:a,viewMatrix:fH.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:hH({width:r||1,height:i||1,padding:c,near:s,far:n}),zoom:h,distanceScales:p})}projectFlat([t,r]){let{unitsPerMeter:i}=this.distanceScales;return[t*i[0],r*i[1]]}unprojectFlat([t,r]){let{metersPerUnit:i}=this.distanceScales;return[t*i[0],r*i[1]]}panByPosition(t,r){let i=xr(r,this.pixelUnprojectionMatrix),s=this.projectFlat(t),n=Qt.add([],s,Qt.negate([],i)),o=Qt.add([],this.center,n);return{target:this.unprojectFlat(o)}}};var Xn=class extends xe{constructor(t){let{longitude:r,latitude:i,modelMatrix:s,bearing:n=0,pitch:o=0,up:a=[0,0,1]}=t,l=new Nr({bearing:n,pitch:o===-90?1e-4:90+o}).toVector3().normalize(),u=s?new q(s).transformAsVector(l):l,f=Number.isFinite(i)?Al({latitude:i}):0,h=Math.pow(2,f),d=new q().lookAt({eye:[0,0,0],center:u,up:a}).scale(h);super({...t,zoom:f,viewMatrix:d}),this.latitude=i,this.longitude=r}};var Yn=20,WP=500,pu=class extends Ki{constructor(t){let{width:r,height:i,position:s=[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}=t;super({width:r,height:i,position:s,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=t.makeViewport}panStart({pos:t}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:t,startPanPosition:r})}pan({pos:t}){if(!t)return this;let{startPanPos:r=[0,0],startPanPosition:i=[0,0]}=this.getState(),{width:s,height:n,bearing:o,pitch:a}=this.getViewportProps(),c=WP*(t[0]-r[0])/s,l=WP*(t[1]-r[1])/n,u=new Nr({bearing:o,pitch:a}),f=new Nr({bearing:o,pitch:-90}),h=u.toVector3().normalize(),d=f.toVector3().cross(h).normalize();return this._getUpdatedState({position:new w(i).add(d.scale(c)).add(h.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startBearing:n,startPitch:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||n===void 0||o===void 0)return this;let l;if(t){let u=(t[0]-s[0])/a,f=(t[1]-s[1])/c;l={bearing:n-u*180,pitch:o-f*90}}else l={bearing:n-r,pitch:o-i};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:t,scale:r}){let i=this.getViewportProps(),s=this.getState().startZoomPosition||i.position,n=this.makeViewport(i),{projectionMatrix:o,width:a}=n,l=2*Math.atan(1/o[0])*(t[0]/a-.5),u=this.getDirection(!0);return this._move(u.rotateZ({radians:-l}),Math.log2(r)*Yn,s)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(t=Yn){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),t)}moveRight(t=Yn){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),t)}moveUp(t=Yn){let r=this.getDirection(!0);return this._move(r,t)}moveDown(t=Yn){let r=this.getDirection(!0);return this._move(r.negate(),t)}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}zoomIn(t=Yn){return this._move(new w(0,0,1),t)}zoomOut(t=Yn){return this._move(new w(0,0,-1),t)}shortestPathFrom(t){let r=t.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:n}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),n!==null&&r.longitude!==null&&Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}_move(t,r,i=this.getViewportProps().position){let s=t.scale(r);return this._getUpdatedState({position:new w(i).add(s)})}getDirection(t=!1){return new Nr({bearing:this.getViewportProps().bearing,pitch:t?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(t){return new pu({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}applyConstraints(t){let{pitch:r,maxPitch:i,minPitch:s,longitude:n,bearing:o}=t;return t.pitch=ht(r,s,i),n!==null&&(n<-180||n>180)&&(t.longitude=In(n+180,360)-180),(o<-180||o>180)&&(t.bearing=In(o+180,360)-180),t}},qn=class extends Ne{constructor(){super(...arguments),this.ControllerState=pu,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["position","pitch","bearing"])}}};var vA=class extends Fe{constructor(t={}){super(t)}get ViewportType(){return Xn}get ControllerType(){return qn}},gu=vA;(()=>{vA.displayName="FirstPersonView"})();var mu=class extends Ki{constructor(t){let{width:r,height:i,rotationX:s=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:_}=t;super({width:r,height:i,rotationX:s,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=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanPosition:this._unproject(t)})}pan({pos:t,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:t}){return this._getUpdatedState({startRotatePos:t,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:t,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startRotationX:n,startRotationOrbit:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||n===void 0||o===void 0)return this;let l;if(t){let u=(t[0]-s[0])/a,f=(t[1]-s[1])/c;(n<-90||n>90)&&(u*=-1),l={rotationX:n+f*180,rotationOrbit:o+u*180}}else l={rotationX:n+i,rotationOrbit:o+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(t){let r=t.getViewportProps(),i={...this.getViewportProps()},{rotationOrbit:s}=i;return Math.abs(s-r.rotationOrbit)>180&&(i.rotationOrbit=s<0?s+360:s-360),i}zoomStart({pos:t}){return this._getUpdatedState({startZoomPosition:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:r,scale:i}){let{startZoom:s,startZoomPosition:n}=this.getState();if(n||(s=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(t)),!n)return this;let o=this._calculateNewZoom({scale:i,startZoom:s}),a=this.makeViewport({...this.getViewportProps(),zoom:o});return this._getUpdatedState({zoom:o,...a.panByPosition(n,t)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(t=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:t})})}zoomOut(t=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/t})})}moveLeft(t=50){return this._panFromCenter([-t,0])}moveRight(t=50){return this._panFromCenter([t,0])}moveUp(t=50){return this._panFromCenter([0,-t])}moveDown(t=50){return this._panFromCenter([0,t])}rotateLeft(t=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-t})}rotateRight(t=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+t})}rotateUp(t=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-t})}rotateDown(t=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+t})}_unproject(t){let r=this.makeViewport(this.getViewportProps());return t&&r.unproject(t)}_calculateNewZoom({scale:t,startZoom:r}){let{maxZoom:i,minZoom:s}=this.getViewportProps();r===void 0&&(r=this.getViewportProps().zoom);let n=r+Math.log2(t);return ht(n,s,i)}_panFromCenter(t){let{width:r,height:i,target:s}=this.getViewportProps();return this.pan({startPosition:s,pos:[r/2+t[0],i/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}applyConstraints(t){let{maxZoom:r,minZoom:i,zoom:s,maxRotationX:n,minRotationX:o,rotationOrbit:a}=t;return t.zoom=Array.isArray(s)?[ht(s[0],i,r),ht(s[1],i,r)]:ht(s,i,r),t.rotationX=ht(t.rotationX,o,n),(a<-180||a>180)&&(t.rotationOrbit=In(a+180,360)-180),t}},Kn=class extends Ne{constructor(){super(...arguments),this.ControllerState=mu,this.transition={transitionDuration:300,transitionInterpolator:new Ae({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})}}};var CA=class extends Fe{constructor(t={}){super(t),this.props.orbitAxis=t.orbitAxis||"Z"}get ViewportType(){return jn}get ControllerType(){return Kn}},_u=CA;(()=>{CA.displayName="OrbitView"})();var wA=class extends mu{constructor(t){super(t),this.zoomAxis=t.zoomAxis||"all"}_calculateNewZoom({scale:t,startZoom:r}){let{maxZoom:i,minZoom:s}=this.getViewportProps();r===void 0&&(r=this.getViewportProps().zoom);let n=Math.log2(t);if(Array.isArray(r)){let[o,a]=r;switch(this.zoomAxis){case"X":o=ht(o+n,s,i);break;case"Y":a=ht(a+n,s,i);break;default:let c=Math.min(o+n,a+n);c<s&&(n+=s-c),c=Math.max(o+n,a+n),c>i&&(n+=i-c),o+=n,a+=n}return[o,a]}return ht(r+n,s,i)}},$n=class extends Ne{constructor(){super(...arguments),this.ControllerState=wA,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["target","zoom"])},this.dragMode="pan"}_onPanRotate(){return!1}};var PA=class extends Fe{constructor(t={}){super(t)}get ViewportType(){return Zi}get ControllerType(){return $n}},yu=PA;(()=>{PA.displayName="OrthographicView"})();var MA=class extends kl{applyConstraints(t){let{maxZoom:r,minZoom:i,zoom:s}=t;t.zoom=ht(s,i,r);let{longitude:n,latitude:o}=t;return(n<-180||n>180)&&(t.longitude=In(n+180,360)-180),t.latitude=ht(o,-89,89),t}},Jn=class extends Ne{constructor(){super(...arguments),this.ControllerState=MA,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(t){super.setProps(t),this.dragRotate=!1,this.touchRotate=!1}};var RA=class extends Fe{constructor(t={}){super(t)}get ViewportType(){return Kr}get ControllerType(){return Jn}},xu=RA;(()=>{RA.displayName="GlobeView"})();var Ap=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(t){t&&(this.opts=t)}equals(t){return this===t?!0:this.constructor===t.constructor&&vt(this.opts,t.opts,1)}getShaders(t){return null}getSubLayerProps(t){let{defaultProps:r}=t.constructor,i={updateTriggers:{}};for(let s in r)if(s in this.props){let n=r[s],o=this.props[s];i[s]=o,n&&n.type==="accessor"&&(i.updateTriggers[s]=this.props.updateTriggers[s],typeof o=="function"&&(i[s]=this.getSubLayerAccessor(o)))}return i}initializeState(t,r){}updateState(t,r){}onNeedsRedraw(t){}getNeedsPickingBuffer(t){return!1}draw(t,r){}finalizeState(t,r){}},Lt=Ap;(()=>{Ap.defaultProps={}})(),(()=>{Ap.extensionName="LayerExtension"})();var IA={bearing:0,pitch:0,position:[0,0,0]},dH={speed:1.2,curve:1.414},Qi=class extends qi{constructor(t={}){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={...dH,...t}}interpolateProps(t,r,i){let s=Dx(t,r,i,this.opts);for(let n in IA)s[n]=se(t[n]||IA[n],r[n]||IA[n],i);return s}getDuration(t,r){let{transitionDuration:i}=r;return i==="auto"&&(i=Ux(t,r,this.opts)),i}};var ts=class{constructor(t){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=t;this.typedArrayManager=Ur,this.attributes={},this._attributeDefs=r,this.opts=t,this.updateGeometry(t)}updateGeometry(t){Object.assign(this.opts,t);let{data:r,buffers:i={},getGeometry:s,geometryBuffer:n,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=s,this.positionSize=n&&n.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,n&&(At(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(i.vertexPositions=n)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:t,endRow:r}){this._rebuildGeometry({startRow:t,endRow:r})}getGeometryFromBuffer(t){let r=t.value||t;return ArrayBuffer.isView(r)?ap(r,{size:this.positionSize,offset:t.offset,stride:t.stride,startIndices:this.data.startIndices}):null}_allocate(t,r){let{attributes:i,buffers:s,_attributeDefs:n,typedArrayManager:o}=this;for(let a in n)if(a in s)o.release(i[a]),i[a]=null;else{let c=n[a];c.copy=r,i[a]=o.allocate(i[a],t,c)}}_forEachGeometry(t,r,i){let{data:s,getGeometry:n}=this,{iterable:o,objectInfo:a}=Ht(s,r,i);for(let c of o){a.index++;let l=n?n(c,a):null;t(l,a.index)}}_rebuildGeometry(t){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:s}=this,{data:n,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=t||{},l={};if(t||(r=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,h)=>{let d=f&&this.normalizeGeometry(f);l[h]=d,i[h+1]=i[h]+(d?this.getGeometrySize(d):0)},a,c),s=i[i.length-1];else if(i=n.startIndices,s=i[n.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof Q){let f=this.positionSize*4;s=s||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/f}else if(o.value){let f=o.value,h=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;s=s||f.length/h}this._allocate(s,Boolean(t)),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=s;let u={};this._forEachGeometry((f,h)=>{let d=l[h]||f;u.vertexStart=i[h],u.indexStart=r[h];let p=h<i.length-1?i[h+1]:s;u.geometrySize=p-i[h],u.geometryIndex=h,this.updateGeometryAttributes(d,u)},a,c),this.vertexCount=r[r.length-1]}};var jP=`#version 300 es
#define SHADER_NAME arc-layer-vertex-shader
in vec3 positions;
in vec4 instanceSourceColors;
in vec4 instanceTargetColors;
in vec3 instanceSourcePositions;
in vec3 instanceSourcePositions64Low;
in vec3 instanceTargetPositions;
in vec3 instanceTargetPositions64Low;
in vec3 instancePickingColors;
in float instanceWidths;
in float instanceHeights;
in float instanceTilts;
uniform bool greatCircle;
uniform bool useShortestPath;
uniform float numSegments;
uniform float opacity;
uniform float widthScale;
uniform float widthMinPixels;
uniform float widthMaxPixels;
uniform int widthUnits;
out vec4 vColor;
out vec2 uv;
out float isValid;
float paraboloid(float distance, float sourceZ, float targetZ, float ratio) {
float deltaZ = targetZ - sourceZ;
float dh = distance * instanceHeights;
if (dh == 0.0) {
return sourceZ + deltaZ * ratio;
}
float unitZ = deltaZ / dh;
float p2 = unitZ * unitZ + 1.0;
float dir = step(deltaZ, 0.0);
float z0 = mix(sourceZ, targetZ, dir);
float r = mix(ratio, 1.0 - ratio, dir);
return sqrt(r * (p2 - r)) * dh + z0;
}
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;
}
float getSegmentRatio(float index) {
return smoothstep(0.0, 1.0, index / (numSegments - 1.0));
}
vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {
float distance = length(source.xy - target.xy);
float z = paraboloid(distance, source.z, target.z, segmentRatio);
float tiltAngle = radians(instanceTilts);
vec2 tiltDirection = normalize(target.xy - source.xy);
vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);
return vec3(
mix(source.xy, target.xy, segmentRatio) + tilt,
z * cos(tiltAngle)
);
}
float getAngularDist (vec2 source, vec2 target) {
vec2 sourceRadians = radians(source);
vec2 targetRadians = radians(target);
vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);
vec2 shd_sq = sin_half_delta * sin_half_delta;
float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;
return 2.0 * asin(sqrt(a));
}
vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {
vec2 lngLat;
if(abs(angularDist - PI) < 0.001) {
lngLat = (1.0 - t) * source.xy + t * target.xy;
} else {
float a = sin((1.0 - t) * angularDist);
float b = sin(t * angularDist);
vec3 p = source3D.yxz * a + target3D.yxz * b;
lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));
}
float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);
return vec3(lngLat, z);
}
void main(void) {
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
float segmentIndex = positions.x;
float segmentRatio = getSegmentRatio(segmentIndex);
float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));
float nextSegmentRatio = getSegmentRatio(min(numSegments - 1.0, segmentIndex + 1.0));
float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
isValid = 1.0;
uv = vec2(segmentRatio, positions.y);
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
vec4 curr;
vec4 next;
vec3 source;
vec3 target;
if ((greatCircle || project_uProjectionMode == PROJECTION_MODE_GLOBE) && project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
source = project_globe_(vec3(instanceSourcePositions.xy, 0.0));
target = project_globe_(vec3(instanceTargetPositions.xy, 0.0));
float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);
vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);
vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);
vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);
if (abs(currPos.x - prevPos.x) > 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 XP=`#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 Tp=[0,0,0,255],pH={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getSourceColor:{type:"accessor",value:Tp},getTargetColor:{type:"accessor",value:Tp},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}},bp=class extends lt{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:jP,fs:XP,modules:[dt,_t]})}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:Tp},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:Tp},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(t){super.updateState(t);let{props:r,oldProps:i,changeFlags:s}=t;(s.extensionsChanged||r.numSegments!==i.numSegments)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{widthUnits:r,widthScale:i,widthMinPixels:s,widthMaxPixels:n,greatCircle:o,wrapLongitude:a}=this.props,c=this.state.model;c.setUniforms(t),c.setUniforms({greatCircle:o,widthUnits:Ft[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n,useShortestPath:a}),c.draw(this.context.renderPass)}_getModel(){let{numSegments:t}=this.props,r=[];for(let s=0;s<t;s++)r=r.concat([s,1,0,s,-1,0]);let i=new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new it({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(r)}}}),isInstanced:!0});return i.setUniforms({numSegments:t}),i}},Zn=bp;(()=>{bp.layerName="ArcLayer"})(),(()=>{bp.defaultProps=pH})();var gH=new Uint32Array([0,2,1,0,3,2]),mH=new Float32Array([0,1,0,0,1,0,1,1]);function BA(e,t){if(!t)return _H(e);let r=Math.max(Math.abs(e[0][0]-e[3][0]),Math.abs(e[1][0]-e[2][0])),i=Math.max(Math.abs(e[1][1]-e[0][1]),Math.abs(e[2][1]-e[3][1])),s=Math.ceil(r/t)+1,n=Math.ceil(i/t)+1,o=(s-1)*(n-1)*6,a=new Uint32Array(o),c=new Float32Array(s*n*2),l=new Float64Array(s*n*3),u=0,f=0;for(let h=0;h<s;h++){let d=h/(s-1);for(let p=0;p<n;p++){let g=p/(n-1),m=yH(e,d,g);l[u*3+0]=m[0],l[u*3+1]=m[1],l[u*3+2]=m[2]||0,c[u*2+0]=d,c[u*2+1]=1-g,h>0&&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 _H(e){let t=new Float64Array(12);for(let r=0;r<e.length;r++)t[r*3+0]=e[r][0],t[r*3+1]=e[r][1],t[r*3+2]=e[r][2]||0;return{vertexCount:6,positions:t,indices:gH,texCoords:mH}}function yH(e,t,r){return se(se(e[0],e[1],r),se(e[3],e[2],r),t)}var YP=`#version 300 es
#define SHADER_NAME bitmap-layer-vertex-shader
in vec2 texCoords;
in vec3 positions;
in vec3 positions64Low;
out vec2 vTexCoord;
out vec2 vTexPos;
uniform float coordinateConversion;
const vec3 pickingColor = vec3(1.0, 0.0, 0.0);
void main(void) {
geometry.worldPosition = positions;
geometry.uv = texCoords;
geometry.pickingColor = pickingColor;
gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vTexCoord = texCoords;
if (coordinateConversion < -0.5) {
vTexPos = geometry.position.xy + project_uCommonOrigin.xy;
} else if (coordinateConversion > 0.5) {
vTexPos = geometry.worldPosition.xy;
}
vec4 color = vec4(0.0);
DECKGL_FILTER_COLOR(color, geometry);
}
`;var xH=`
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.;
}
`,qP=`#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])
);
}
${xH}
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 AH={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}},Ep=class extends lt{getShaders(){return super.getShaders({vs:YP,fs:qP,modules:[dt,_t]})}initializeState(){let t=this.getAttributeManager();t.remove(["instancePickingColors"]);let r=!0;t.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:t,oldProps:r,changeFlags:i}){let s=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll()),t.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]&&s.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else t._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(t){let{image:r}=this.props,i=t.info;if(!i.color||!r)return i.bitmap=null,i;let{width:s,height:n}=r;i.index=0;let o=TH(i.color);return i.bitmap={size:{width:s,height:n},uv:o,pixel:[Math.floor(o[0]*s),Math.floor(o[1]*n)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(t){super._updateAutoHighlight({...t,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:t}=this.props,r=t;return KP(t)&&(r=[[t[0],t[1]],[t[0],t[3]],[t[2],t[3]],[t[2],t[1]]]),BA(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(t){let{uniforms:r,moduleParameters:i}=t,{model:s,coordinateConversion:n,bounds:o,disablePicking:a}=this.state,{image:c,desaturate:l,transparentColor:u,tintColor:f}=this.props;i.picking.isActive&&a||c&&s&&(s.setUniforms(r),s.setBindings({bitmapTexture:c}),s.setUniforms({desaturate:l,transparentColor:u.map(h=>h/255),tintColor:f.slice(0,3).map(h=>h/255),coordinateConversion:n,bounds:o}),s.draw(this.context.renderPass))}_getCoordinateUniforms(){let{LNGLAT:t,CARTESIAN:r,DEFAULT:i}=X,{_imageCoordinateSystem:s}=this.props;if(s!==i){let{bounds:n}=this.props;if(!KP(n))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?t:r;if(s=s===t?t:r,s===t&&o===r)return{coordinateConversion:-1,bounds:n};if(s===r&&o===t){let a=Xt([n[0],n[1]]),c=Xt([n[2],n[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],c[0],c[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}},Qn=Ep;(()=>{Ep.layerName="BitmapLayer"})(),(()=>{Ep.defaultProps=AH})();function TH(e){let[t,r,i]=e,s=(i&240)/256,n=(i&15)/16;return[(t+n)/256,(r+s)/256]}function KP(e){return Number.isFinite(e[0])}var $P=`#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 JP=`#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 bH=1024,EH=4,ZP=()=>{},QP={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},SH={x:0,y:0,width:0,height:0};function vH(e){return Math.pow(2,Math.ceil(Math.log2(e)))}function CH(e,t,r,i){let s=Math.min(r/t.width,i/t.height),n=Math.floor(t.width*s),o=Math.floor(t.height*s);return s===1?{data:t,width:n,height:o}:(e.canvas.height=o,e.canvas.width=n,e.clearRect(0,0,n,o),e.drawImage(t,0,0,t.width,t.height,0,0,n,o),{data:e.canvas,width:n,height:o})}function Au(e){return e&&(e.id||e.url)}function wH(e,t,r,i){let{width:s,height:n,device:o}=e,a=o.createTexture({format:"rgba8unorm",width:t,height:r,sampler:i}),c=o.createCommandEncoder();return c.copyTextureToTexture({source:e,destination:a,width:s,height:n}),c.finish(),e.destroy(),a}function tM(e,t,r){for(let i=0;i<t.length;i++){let{icon:s,xOffset:n}=t[i],o=Au(s);e[o]={...s,x:n,y:r}}}function PH({icons:e,buffer:t,mapping:r={},xOffset:i=0,yOffset:s=0,rowHeight:n=0,canvasWidth:o}){let a=[];for(let c=0;c<e.length;c++){let l=e[c],u=Au(l);if(!r[u]){let{height:f,width:h}=l;i+h+t>o&&(tM(r,a,s),i=0,s=n+s+t,n=0,a=[]),a.push({icon:l,xOffset:i}),i=i+h+t,n=Math.max(n,f)}}return a.length>0&&tM(r,a,s),{mapping:r,rowHeight:n,xOffset:i,yOffset:s,canvasWidth:o,canvasHeight:vH(n+s+t)}}function MH(e,t,r){if(!e||!t)return null;r=r||{};let i={},{iterable:s,objectInfo:n}=Ht(e);for(let o of s){n.index++;let a=t(o,n),c=Au(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!i[c]&&(!r[c]||a.url!==r[c].url)&&(i[c]={...a,source:o,sourceIndex:n.index})}return i}var Tu=class{constructor(t,{onUpdate:r=ZP,onError:i=ZP}){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=EH,this._canvasWidth=bH,this._canvasHeight=0,this._canvas=null,this.device=t,this.onUpdate=r,this.onError=i}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(t){let r=this._autoPacking?Au(t):t;return this._mapping[r]||SH}setProps({loadOptions:t,autoPacking:r,iconAtlas:i,iconMapping:s,textureParameters:n}){t&&(this._loadOptions=t),r!==void 0&&(this._autoPacking=r),s&&(this._mapping=s),i&&(this._texture?.delete(),this._texture=null,this._externalTexture=i),n&&(this._textureParameters=n)}get isLoaded(){return this._pendingCount===0}packIcons(t,r){if(!this._autoPacking||typeof document>"u")return;let i=Object.values(MH(t,r,this._mapping)||{});if(i.length>0){let{mapping:s,xOffset:n,yOffset:o,rowHeight:a,canvasHeight:c}=PH({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=s,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||QP})),this._texture.height!==this._canvasHeight&&(this._texture=wH(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||QP)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(t){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let i of t)this._pendingCount++,Jt(i.url,this._loadOptions).then(s=>{let n=Au(i),o=this._mapping[n],{x:a,y:c,width:l,height:u}=o,{data:f,width:h,height:d}=CH(r,s,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(s=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:s})}).finally(()=>{this._pendingCount--})}};var eM=[0,0,0,255],RH={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:e=>e.position},getIcon:{type:"accessor",value:e=>e.icon},getColor:{type:"accessor",value:eM},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}},Sp=class extends lt{getShaders(){return super.getShaders({vs:$P,fs:JP,modules:[dt,_t]})}initializeState(){this.state={iconManager:new Tu(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:eM},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(t){super.updateState(t);let{props:r,oldProps:i,changeFlags:s}=t,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?i.iconMapping!==r.iconMapping&&n.invalidate("getIcon"):(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getIcon))&&f.packIcons(c,l),s.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(t){super.finalizeState(t),this.state.iconManager.finalize()}draw({uniforms:t}){let{sizeScale:r,sizeMinPixels:i,sizeMaxPixels:s,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(t),u.setUniforms({iconsTextureDim:[l.width,l.height],sizeUnits:Ft[n],sizeScale:r,sizeMinPixels:i,sizeMaxPixels:s,billboard:o,alphaCutoff:a}),u.draw(this.context.renderPass)}}_getModel(){let t=[-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 it({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(t)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(t){let r=this.getCurrentLayer()?.props.onIconError;r?r(t):k.error(t.error.message)()}getInstanceOffset(t){let{width:r,height:i,anchorX:s=r/2,anchorY:n=i/2}=this.state.iconManager.getIconMapping(t);return[r/2-s,i/2-n]}getInstanceColorMode(t){return this.state.iconManager.getIconMapping(t).mask?1:0}getInstanceIconFrame(t){let{x:r,y:i,width:s,height:n}=this.state.iconManager.getIconMapping(t);return[r,i,s,n]}},es=Sp;(()=>{Sp.defaultProps=RH})(),(()=>{Sp.layerName="IconLayer"})();var rM=`#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 iM=`#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 IH=[0,0,0,255],BH={getSourcePosition:{type:"accessor",value:e=>e.sourcePosition},getTargetPosition:{type:"accessor",value:e=>e.targetPosition},getColor:{type:"accessor",value:IH},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}},vp=class extends lt{getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:rM,fs:iM,modules:[dt,_t]})}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(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{widthUnits:r,widthScale:i,widthMinPixels:s,widthMaxPixels:n,wrapLongitude:o}=this.props,a=this.state.model;a.setUniforms(t),a.setUniforms({widthUnits:Ft[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n,useShortestPath:o?1:0}),a.draw(this.context.renderPass),o&&(a.setUniforms({useShortestPath:-1}),a.draw(this.context.renderPass))}_getModel(){let t=[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 it({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(t)}}}),isInstanced:!0})}},to=vp;(()=>{vp.layerName="LineLayer"})(),(()=>{vp.defaultProps=BH})();var sM=`#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 nM=`#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 oM=[0,0,0,255],aM=[0,0,1],OH={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:e=>e.position},getNormal:{type:"accessor",value:aM},getColor:{type:"accessor",value:oM},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function FH(e){let{header:t,attributes:r}=e;if(!(!t||!r)&&(e.length=t.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:i,value:s}=r.COLOR_0;r.instanceColors={size:i,type:"unorm8",value:s}}}var Cp=class extends lt{getShaders(){return super.getShaders({vs:sM,fs:nM,modules:[dt,_r,_t]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:aM},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:oM}})}updateState(t){let{changeFlags:r,props:i}=t;super.updateState(t),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&FH(i.data)}draw({uniforms:t}){let{pointSize:r,sizeUnits:i}=this.props,s=this.state.model;s.setUniforms(t),s.setUniforms({sizeUnits:Ft[i],radiusPixels:r}),s.draw(this.context.renderPass)}_getModel(){let t=[];for(let r=0;r<3;r++){let i=r/3*Math.PI*2;t.push(Math.cos(i)*2,Math.sin(i)*2,0)}return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new it({topology:"triangle-list",attributes:{positions:new Float32Array(t)}}),isInstanced:!0})}},eo=Cp;(()=>{Cp.layerName="PointCloudLayer"})(),(()=>{Cp.defaultProps=OH})();var cM=`#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 lM=`#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 uM=[0,0,0,255],NH={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:e=>e.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:uM},getLineColor:{type:"accessor",value:uM},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},wp=class extends lt{getShaders(){return super.getShaders({vs:cM,fs:lM,modules:[dt,_t]})}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(t){super.updateState(t),t.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{radiusUnits:r,radiusScale:i,radiusMinPixels:s,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(t),p.setUniforms({stroked:o?1:0,filled:a,billboard:c,antialiasing:l,radiusUnits:Ft[r],radiusScale:i,radiusMinPixels:s,radiusMaxPixels:n,lineWidthUnits:Ft[u],lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}),p.draw(this.context.renderPass)}_getModel(){let t=[-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 it({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(t)}}}),isInstanced:!0})}},ro=wp;(()=>{wp.defaultProps=NH})(),(()=>{wp.layerName="ScatterplotLayer"})();var va={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function io(e,t,r={}){return fM(e,r)!==t?(LH(e,r),!0):!1}function fM(e,t={}){return Math.sign(Xs(e,t))}var bu={x:0,y:1,z:2};function Xs(e,t={}){let{start:r=0,end:i=e.length,plane:s="xy"}=t,n=t.size||2,o=0,a=bu[s[0]],c=bu[s[1]];for(let l=r,u=i-n;l<i;l+=n)o+=(e[l+a]-e[u+a])*(e[l+c]+e[u+c]),u=l;return o/2}function LH(e,t){let{start:r=0,end:i=e.length,size:s=2}=t,n=(i-r)/s,o=Math.floor(n/2);for(let a=0;a<o;++a){let c=r+a*s,l=r+(n-1-a)*s;for(let u=0;u<s;++u){let f=e[c+u];e[c+u]=e[l+u],e[l+u]=f}}}function FA(e,t,r=2,i,s="xy"){let n=t&&t.length,o=n?t[0]*r:e.length,a=dM(e,0,o,r,!0,i&&i[0],s),c=[];if(!a||a.next===a.prev)return c;let l,u,f,h,d,p,g;if(n&&(a=HH(e,t,a,r,i,s)),e.length>80*r){h=u=e[0],d=f=e[1];for(let m=r;m<o;m+=r)p=e[m],g=e[m+1],p<h&&(h=p),g<d&&(d=g),p>u&&(u=p),g>f&&(f=g);l=Math.max(u-h,f-d),l=l!==0?32767/l:0}return Eu(a,c,r,h,d,l,0),c}function dM(e,t,r,i,s,n,o){let a,c;n===void 0&&(n=Xs(e,{start:t,end:r,size:i,plane:o}));let l=bu[o[0]],u=bu[o[1]];if(s===n<0)for(a=t;a<r;a+=i)c=hM(a,e[a+l],e[a+u],c);else for(a=r-i;a>=t;a-=i)c=hM(a,e[a+l],e[a+u],c);return c&&Rp(c,c.next)&&(vu(c),c=c.next),c}function so(e,t){if(!e)return e;t||(t=e);let r=e,i;do if(i=!1,!r.steiner&&(Rp(r,r.next)||Dt(r.prev,r,r.next)===0)){if(vu(r),r=t=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==t);return t}function Eu(e,t,r,i,s,n,o){if(!e)return;!o&&n&&YH(e,i,s,n);let a=e,c,l;for(;e.prev!==e.next;){if(c=e.prev,l=e.next,n?kH(e,i,s,n):UH(e)){t.push(c.i/r|0),t.push(e.i/r|0),t.push(l.i/r|0),vu(e),e=l.next,a=l.next;continue}if(e=l,e===a){o?o===1?(e=VH(so(e),t,r),Eu(e,t,r,i,s,n,2)):o===2&&zH(e,t,r,i,s,n):Eu(so(e),t,r,i,s,n,1);break}}}function UH(e){let t=e.prev,r=e,i=e.next;if(Dt(t,r,i)>=0)return!1;let s=t.x,n=r.x,o=i.x,a=t.y,c=r.y,l=i.y,u=s<n?s<o?s:o:n<o?n:o,f=a<c?a<l?a:l:c<l?c:l,h=s>n?s>o?s:o:n>o?n:o,d=a>c?a>l?a:l:c>l?c:l,p=i.next;for(;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&Ca(s,a,n,c,o,l,p.x,p.y)&&Dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function kH(e,t,r,i){let s=e.prev,n=e,o=e.next;if(Dt(s,n,o)>=0)return!1;let a=s.x,c=n.x,l=o.x,u=s.y,f=n.y,h=o.y,d=a<c?a<l?a:l:c<l?c:l,p=u<f?u<h?u:h:f<h?f:h,g=a>c?a>l?a:l:c>l?c:l,m=u>f?u>h?u:h:f>h?f:h,_=OA(d,p,t,r,i),y=OA(g,m,t,r,i),x=e.prevZ,E=e.nextZ;for(;x&&x.z>=_&&E&&E.z<=y;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==s&&x!==o&&Ca(a,u,c,f,l,h,x.x,x.y)&&Dt(x.prev,x,x.next)>=0||(x=x.prevZ,E.x>=d&&E.x<=g&&E.y>=p&&E.y<=m&&E!==s&&E!==o&&Ca(a,u,c,f,l,h,E.x,E.y)&&Dt(E.prev,E,E.next)>=0))return!1;E=E.nextZ}for(;x&&x.z>=_;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==s&&x!==o&&Ca(a,u,c,f,l,h,x.x,x.y)&&Dt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;E&&E.z<=y;){if(E.x>=d&&E.x<=g&&E.y>=p&&E.y<=m&&E!==s&&E!==o&&Ca(a,u,c,f,l,h,E.x,E.y)&&Dt(E.prev,E,E.next)>=0)return!1;E=E.nextZ}return!0}function VH(e,t,r){let i=e;do{let s=i.prev,n=i.next.next;!Rp(s,n)&&pM(s,i,i.next,n)&&Su(s,n)&&Su(n,s)&&(t.push(s.i/r|0),t.push(i.i/r|0),t.push(n.i/r|0),vu(i),vu(i.next),i=e=n),i=i.next}while(i!==e);return so(i)}function zH(e,t,r,i,s,n){let o=e;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&$H(o,a)){let c=gM(o,a);o=so(o,o.next),c=so(c,c.next),Eu(o,t,r,i,s,n,0),Eu(c,t,r,i,s,n,0);return}a=a.next}o=o.next}while(o!==e)}function HH(e,t,r,i,s,n){let o=[],a,c,l,u,f;for(a=0,c=t.length;a<c;a++)l=t[a]*i,u=a<c-1?t[a+1]*i:e.length,f=dM(e,l,u,i,!1,s&&s[a+1],n),f===f.next&&(f.steiner=!0),o.push(KH(f));for(o.sort(GH),a=0;a<o.length;a++)r=WH(o[a],r);return r}function GH(e,t){return e.x-t.x}function WH(e,t){let r=jH(e,t);if(!r)return t;let i=gM(r,e);return so(i,i.next),so(r,r.next)}function jH(e,t){let r=t,i=e.x,s=e.y,n=-1/0,o;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){let h=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=i&&h>n&&(n=h,o=r.x<r.next.x?r:r.next,h===i))return o}r=r.next}while(r!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0,f;r=o;do i>=r.x&&r.x>=c&&i!==r.x&&Ca(s<l?i:n,s,c,l,s<l?n:i,s,r.x,r.y)&&(f=Math.abs(s-r.y)/(i-r.x),Su(r,e)&&(f<u||f===u&&(r.x>o.x||r.x===o.x&&XH(o,r)))&&(o=r,u=f)),r=r.next;while(r!==a);return o}function XH(e,t){return Dt(e.prev,e,t.prev)<0&&Dt(t.next,e,e.next)<0}function YH(e,t,r,i){let s=e;do s.z===0&&(s.z=OA(s.x,s.y,t,r,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,qH(s)}function qH(e){let t,r,i=1,s,n,o,a,c,l;do{for(n=e,e=null,l=null,s=0;n;){for(s++,a=n,o=0,r=0;r<i&&(o++,a=a.nextZ,!!a);r++);for(c=i;o>0||c>0&&a;)o!==0&&(c===0||!a||n.z<=a.z)?(t=n,n=n.nextZ,o--):(t=a,a=a.nextZ,c--),l?l.nextZ=t:e=t,t.prevZ=l,l=t;n=a}l.nextZ=null,i*=2}while(s>1);return e}function OA(e,t,r,i,s){return e=(e-r)*s|0,t=(t-i)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function KH(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function Ca(e,t,r,i,s,n,o,a){return(s-o)*(t-a)>=(e-o)*(n-a)&&(e-o)*(i-a)>=(r-o)*(t-a)&&(r-o)*(n-a)>=(s-o)*(i-a)}function $H(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!JH(e,t)&&(Su(e,t)&&Su(t,e)&&ZH(e,t)&&(Dt(e.prev,e,t.prev)||Dt(e,t.prev,t))||Rp(e,t)&&Dt(e.prev,e,e.next)>0&&Dt(t.prev,t,t.next)>0)}function Dt(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Rp(e,t){return e.x===t.x&&e.y===t.y}function pM(e,t,r,i){let s=Mp(Dt(e,t,r)),n=Mp(Dt(e,t,i)),o=Mp(Dt(r,i,e)),a=Mp(Dt(r,i,t));return!!(s!==n&&o!==a||s===0&&Pp(e,r,t)||n===0&&Pp(e,i,t)||o===0&&Pp(r,e,i)||a===0&&Pp(r,t,i))}function Pp(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Mp(e){return e>0?1:e<0?-1:0}function JH(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&pM(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function Su(e,t){return Dt(e.prev,e,e.next)<0?Dt(e,t,e.next)>=0&&Dt(e,e.prev,t)>=0:Dt(e,t,e.prev)<0||Dt(e,e.next,t)<0}function ZH(e,t){let r=e,i=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do r.y>n!=r.next.y>n&&r.next.y!==r.y&&s<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==e);return i}function gM(e,t){let r=new Cu(e.i,e.x,e.y),i=new Cu(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,r.next=s,s.prev=r,i.next=r,r.prev=i,n.next=i,i.prev=n,i}function hM(e,t,r,i){let s=new Cu(e,t,r);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function vu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var Cu=class{constructor(t,r,i){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=r,this.y=i}};function je(e,t){let r=t.length,i=e.length;if(i>0){let s=!0;for(let n=0;n<r;n++)if(e[i-r+n]!==t[n]){s=!1;break}if(s)return!1}for(let s=0;s<r;s++)e[i+s]=t[s];return!0}function wu(e,t){let r=t.length;for(let i=0;i<r;i++)e[i]=t[i]}function Ys(e,t,r,i,s=[]){let n=i+t*r;for(let o=0;o<r;o++)s[o]=e[n+o];return s}function Ip(e,t,r,i,s=[]){let n,o;if(r&8)n=(i[3]-e[1])/(t[1]-e[1]),o=3;else if(r&4)n=(i[1]-e[1])/(t[1]-e[1]),o=1;else if(r&2)n=(i[2]-e[0])/(t[0]-e[0]),o=2;else if(r&1)n=(i[0]-e[0])/(t[0]-e[0]),o=0;else return null;for(let a=0;a<e.length;a++)s[a]=(o&1)===a?i[o]:n*(t[a]-e[a])+e[a];return s}function Pu(e,t){let r=0;return e[0]<t[0]?r|=1:e[0]>t[2]&&(r|=2),e[1]<t[1]?r|=4:e[1]>t[3]&&(r|=8),r}function Mu(e,t){let{size:r=2,broken:i=!1,gridResolution:s=10,gridOffset:n=[0,0],startIndex:o=0,endIndex:a=e.length}=t||{},c=(a-o)/r,l=[],u=[l],f=Ys(e,0,r,o),h,d,p=yM(f,s,n,[]),g=[];je(l,f);for(let m=1;m<c;m++){for(h=Ys(e,m,r,o,h),d=Pu(h,p);d;){Ip(f,h,d,p,g);let _=Pu(g,p);_&&(Ip(f,g,_,p,g),d=_),je(l,g),wu(f,g),t9(p,s,d),i&&l.length>r&&(l=[],u.push(l),je(l,f)),d=Pu(h,p)}je(l,h),wu(f,h)}return i?u:u[0]}var mM=0,QH=1;function Ru(e,t=null,r){if(!e.length)return[];let{size:i=2,gridResolution:s=10,gridOffset:n=[0,0],edgeTypes:o=!1}=r||{},a=[],c=[{pos:e,types:o?new Array(e.length/i).fill(QH):null,holes:t||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:h,holes:d}=c.shift();e9(f,i,d[0]||f.length,l),u=yM(l[0],s,n,u);let p=Pu(l[1],u);if(p){let g=_M(f,h,i,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<d.length;y++)g=_M(f,h,i,d[y],d[y+1]||f.length,u,p),g[0]&&(m.holes.push(m.pos.length),m.pos=Bp(m.pos,g[0].pos),o&&(m.types=Bp(m.types,g[0].types))),g[1]&&(_.holes.push(_.pos.length),_.pos=Bp(_.pos,g[1].pos),o&&(_.types=Bp(_.types,g[1].types)))}else{let g={positions:f};o&&(g.edgeTypes=h),d.length&&(g.holeIndices=d),a.push(g)}}return a}function _M(e,t,r,i,s,n,o){let a=(s-i)/r,c=[],l=[],u=[],f=[],h=[],d,p,g,m=Ys(e,a-1,r,i),_=Math.sign(o&8?m[1]-n[3]:m[0]-n[2]),y=t&&t[a-1],x=0,E=0;for(let P=0;P<a;P++)d=Ys(e,P,r,i,d),p=Math.sign(o&8?d[1]-n[3]:d[0]-n[2]),g=t&&t[i/r+P],p&&_&&_!==p&&(Ip(m,d,o,n,h),je(c,h)&&u.push(y),je(l,h)&&f.push(y)),p<=0?(je(c,d)&&u.push(g),x-=p):u.length&&(u[u.length-1]=mM),p>=0?(je(l,d)&&f.push(g),E+=p):f.length&&(f[f.length-1]=mM),wu(m,d),_=p,y=g;return[x?{pos:c,types:t&&u}:null,E?{pos:l,types:t&&f}:null]}function yM(e,t,r,i){let s=Math.floor((e[0]-r[0])/t)*t+r[0],n=Math.floor((e[1]-r[1])/t)*t+r[1];return i[0]=s,i[1]=n,i[2]=s+t,i[3]=n+t,i}function t9(e,t,r){r&8?(e[1]+=t,e[3]+=t):r&4?(e[1]-=t,e[3]-=t):r&2?(e[0]+=t,e[2]+=t):r&1&&(e[0]-=t,e[2]-=t)}function e9(e,t,r,i){let s=1/0,n=-1/0,o=1/0,a=-1/0;for(let c=0;c<r;c+=t){let l=e[c],u=e[c+1];s=l<s?l:s,n=l>n?l:n,o=u<o?u:o,a=u>a?u:a}return i[0][0]=s,i[0][1]=o,i[1][0]=n,i[1][1]=a,i}function Bp(e,t){for(let r=0;r<t.length;r++)e.push(t[r]);return e}var r9=85.051129;function NA(e,t){let{size:r=2,startIndex:i=0,endIndex:s=e.length,normalize:n=!0}=t||{},o=e.slice(i,s);xM(o,r,0,s-i);let a=Mu(o,{size:r,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(n)for(let c of a)AM(c,r);return a}function LA(e,t=null,r){let{size:i=2,normalize:s=!0,edgeTypes:n=!1}=r||{};t=t||[];let o=[],a=[],c=0,l=0;for(let f=0;f<=t.length;f++){let h=t[f]||e.length,d=l,p=i9(e,i,c,h);for(let g=p;g<h;g++)o[l++]=e[g];for(let g=c;g<p;g++)o[l++]=e[g];xM(o,i,d,l),s9(o,i,d,l,r?.maxLatitude),c=h,a[f]=l}a.pop();let u=Ru(o,a,{size:i,gridResolution:360,gridOffset:[-180,-180],edgeTypes:n});if(s)for(let f of u)AM(f.positions,i);return u}function i9(e,t,r,i){let s=-1,n=-1;for(let o=r+1;o<i;o+=t){let a=Math.abs(e[o]);a>s&&(s=a,n=o-1)}return n}function s9(e,t,r,i,s=r9){let n=e[r],o=e[i-t];if(Math.abs(n-o)>180){let a=Ys(e,0,t,r);a[0]+=Math.round((o-n)/360)*360,je(e,a),a[1]=Math.sign(a[1])*s,je(e,a),a[0]=n,je(e,a)}}function xM(e,t,r,i){let s=e[0],n;for(let o=r;o<i;o+=t){n=e[o];let a=n-s;(a>180||a<-180)&&(n-=Math.round(a/360)*360),e[o]=s=n}}function AM(e,t){let r,i=e.length/t;for(let n=0;n<i&&(r=e[n*t],(r+180)%360===0);n++);let s=-Math.round(r/360)*360;if(s!==0)for(let n=0;n<i;n++)e[n*t]+=s}var Iu=class extends it{constructor(t){let{indices:r,attributes:i}=o9(t);super({...t,indices:r,attributes:i})}};function o9(e){let{radius:t,height:r=1,nradial:i=10}=e,{vertices:s}=e;s&&(k.assert(s.length>=i),s=s.flatMap(d=>[d[0],d[1]]),io(s,va.COUNTER_CLOCKWISE));let n=r>0,o=i+1,a=n?o*3+1:i,c=Math.PI*2/i,l=new Uint16Array(n?i*3*2:0),u=new Float32Array(a*3),f=new Float32Array(a*3),h=0;if(n){for(let d=0;d<o;d++){let p=d*c,g=d%i,m=Math.sin(p),_=Math.cos(p);for(let y=0;y<2;y++)u[h+0]=s?s[g*2]:_*t,u[h+1]=s?s[g*2+1]:m*t,u[h+2]=(1/2-y)*r,f[h+0]=s?s[g*2]:_,f[h+1]=s?s[g*2+1]:m,h+=3}u[h+0]=u[h-3],u[h+1]=u[h-2],u[h+2]=u[h-1],h+=3}for(let d=n?0:1;d<o;d++){let p=Math.floor(d/2)*Math.sign(.5-d%2),g=p*c,m=(p+i)%i,_=Math.sin(g),y=Math.cos(g);u[h+0]=s?s[m*2]:y*t,u[h+1]=s?s[m*2+1]:_*t,u[h+2]=r/2,f[h+2]=1,h+=3}if(n){let d=0;for(let p=0;p<i;p++)l[d++]=p*2+0,l[d++]=p*2+2,l[d++]=p*2+0,l[d++]=p*2+1,l[d++]=p*2+1,l[d++]=p*2+3}return{indices:l,attributes:{POSITION:{size:3,value:u},NORMAL:{size:3,value:f}}}}var TM=`#version 300 es
#define SHADER_NAME column-layer-vertex-shader
in vec3 positions;
in vec3 normals;
in vec3 instancePositions;
in float instanceElevations;
in vec3 instancePositions64Low;
in vec4 instanceFillColors;
in vec4 instanceLineColors;
in float instanceStrokeWidths;
in vec3 instancePickingColors;
uniform float opacity;
uniform float radius;
uniform float angle;
uniform vec2 offset;
uniform bool extruded;
uniform bool stroked;
uniform bool isStroke;
uniform float coverage;
uniform float elevationScale;
uniform float edgeDistance;
uniform float widthScale;
uniform float widthMinPixels;
uniform float widthMaxPixels;
uniform int radiusUnits;
uniform int widthUnits;
out vec4 vColor;
#ifdef FLAT_SHADING
out vec4 position_commonspace;
#endif
void main(void) {
geometry.worldPosition = instancePositions;
vec4 color = isStroke ? instanceLineColors : instanceFillColors;
mat2 rotationMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));
float elevation = 0.0;
float strokeOffsetRatio = 1.0;
if (extruded) {
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * elevationScale;
} else if (stroked) {
float widthPixels = clamp(
project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels) / 2.0;
float halfOffset = project_pixel_size(widthPixels) / project_size(edgeDistance * coverage * radius);
if (isStroke) {
strokeOffsetRatio -= sign(positions.z) * halfOffset;
} else {
strokeOffsetRatio -= halfOffset;
}
}
float shouldRender = float(color.a > 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 bM=`#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 Op=[0,0,0,255],a9={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:e=>e.position},getFillColor:{type:"accessor",value:Op},getLineColor:{type:"accessor",value:Op},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},Fp=class extends lt{getShaders(){let t={},{flatShading:r}=this.props;return r&&(t.FLAT_SHADING=1),super.getShaders({vs:TM,fs:bM,defines:t,modules:[dt,r?Ns:_r,_t]})}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:Op},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:Op},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(t){super.updateState(t);let{props:r,oldProps:i,changeFlags:s}=t,n=s.extensionsChanged||r.flatShading!==i.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!==i.diskResolution||r.vertices!==i.vertices||(r.extruded||r.stroked)!==(i.extruded||i.stroked))&&this._updateGeometry(r)}getGeometry(t,r,i){let s=new Iu({radius:1,height:i?2:0,vertices:r,nradial:t}),n=0;if(r)for(let o=0;o<t;o++){let a=r[o],c=Math.sqrt(a[0]*a[0]+a[1]*a[1]);n+=c/t}else n=1;return this.setState({edgeDistance:Math.cos(Math.PI/t)*n}),s}_getModels(){let t=this.getShaders(),r=this.getAttributeManager().getBufferLayouts(),i=new J(this.context.device,{...t,id:`${this.props.id}-fill`,bufferLayout:r,isInstanced:!0}),s=new J(this.context.device,{...t,id:`${this.props.id}-wireframe`,bufferLayout:r,isInstanced:!0});return{fillModel:i,wireframeModel:s,models:[s,i]}}_updateGeometry({diskResolution:t,vertices:r,extruded:i,stroked:s}){let n=this.getGeometry(t,r,i||s);this.setState({fillVertexCount:n.attributes.POSITION.value.length/3});let o=this.state.fillModel,a=this.state.wireframeModel;o.setGeometry(n),o.setTopology("triangle-strip"),o.setIndexBuffer(null),a.setGeometry(n),a.setTopology("line-list")}draw({uniforms:t}){let{lineWidthUnits:r,lineWidthScale:i,lineWidthMinPixels:s,lineWidthMaxPixels:n,radiusUnits:o,elevationScale:a,extruded:c,filled:l,stroked:u,wireframe:f,offset:h,coverage:d,radius:p,angle:g}=this.props,m=this.state.fillModel,_=this.state.wireframeModel,{fillVertexCount:y,edgeDistance:x}=this.state,E={...t,radius:p,angle:g/180*Math.PI,offset:h,extruded:c,stroked:u,coverage:d,elevationScale:a,edgeDistance:x,radiusUnits:Ft[o],widthUnits:Ft[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n};c&&f&&(_.setUniforms(E),_.setUniforms({isStroke:!0}),_.draw(this.context.renderPass)),m.setUniforms(E),l&&(m.setVertexCount(y),m.setUniforms({isStroke:!1}),m.draw(this.context.renderPass)),!c&&u&&(m.setVertexCount(y*2/3),m.setUniforms({isStroke:!0}),m.draw(this.context.renderPass))}},$r=Fp;(()=>{Fp.layerName="ColumnLayer"})(),(()=>{Fp.defaultProps=a9})();var c9={cellSize:{type:"number",min:0,value:1e3},offset:{type:"array",value:[1,1]}},Np=class extends $r{_updateGeometry(){let t=new Wi;this.state.fillModel.setGeometry(t)}draw({uniforms:t}){let{elevationScale:r,extruded:i,offset:s,coverage:n,cellSize:o,angle:a,radiusUnits:c}=this.props,l=this.state.fillModel;l.setUniforms(t),l.setUniforms({radius:o/2,radiusUnits:Ft[c],angle:a,offset:s,extruded:i,coverage:n,elevationScale:r,edgeDistance:1,isStroke:!1}),l.draw(this.context.renderPass)}},no=Np;(()=>{Np.layerName="GridCellLayer"})(),(()=>{Np.defaultProps=c9})();function EM(e,t,r,i){let s;if(Array.isArray(e[0])){let n=e.length*t;s=new Array(n);for(let o=0;o<e.length;o++)for(let a=0;a<t;a++)s[o*t+a]=e[o][a]||0}else s=e;return r?Mu(s,{size:t,gridResolution:r}):i?NA(s,{size:t}):s}var l9=1,u9=2,DA=4,Bu=class extends ts{constructor(t){super({...t,attributes:{positions:{size:3,padding:18,initialize:!0,type:t.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(t){return this.attributes[t]}getGeometryFromBuffer(t){return this.normalize?super.getGeometryFromBuffer(t):null}normalizeGeometry(t){return this.normalize?EM(t,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):t}getGeometrySize(t){if(SM(t)){let i=0;for(let s of t)i+=this.getGeometrySize(s);return i}let r=this.getPathLength(t);return r<2?0:this.isClosed(t)?r<3?0:r+2:r}updateGeometryAttributes(t,r){if(r.geometrySize!==0)if(t&&SM(t))for(let i of t){let s=this.getGeometrySize(i);r.geometrySize=s,this.updateGeometryAttributes(i,r),r.vertexStart+=s}else this._updateSegmentTypes(t,r),this._updatePositions(t,r)}_updateSegmentTypes(t,r){let i=this.attributes.segmentTypes,s=t?this.isClosed(t):!1,{vertexStart:n,geometrySize:o}=r;i.fill(0,n,n+o),s?(i[n]=DA,i[n+o-2]=DA):(i[n]+=l9,i[n+o-2]+=u9),i[n+o-1]=DA}_updatePositions(t,r){let{positions:i}=this.attributes;if(!i||!t)return;let{vertexStart:s,geometrySize:n}=r,o=new Array(3);for(let a=s,c=0;c<n;a++,c++)this.getPointOnPath(t,c,o),i[a*3]=o[0],i[a*3+1]=o[1],i[a*3+2]=o[2]}getPathLength(t){return t.length/this.positionSize}getPointOnPath(t,r,i=[]){let{positionSize:s}=this;r*s>=t.length&&(r+=1-t.length/s);let n=r*s;return i[0]=t[n],i[1]=t[n+1],i[2]=s===3&&t[n+2]||0,i}isClosed(t){if(!this.normalize)return Boolean(this.opts.loop);let{positionSize:r}=this,i=t.length-r;return t[0]===t[i]&&t[1]===t[i+1]&&(r===2||t[2]===t[i+2])}};function SM(e){return Array.isArray(e[0])}var vM=`#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 CM=`#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 wM=[0,0,0,255],f9={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:e=>e.path},getColor:{type:"accessor",value:wM},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},UA={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e},Lp=class extends lt{getShaders(){return super.getShaders({vs:vM,fs:CM,modules:[dt,_t]})}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:UA,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:UA,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:UA,defaultValue:wM},instancePickingColors:{size:4,type:"uint8",accessor:(i,{index:s,target:n})=>this.encodePickingColor(i&&i.__source?i.__source.index:s,n)}}),this.setState({pathTesselator:new Bu({fp64:this.use64bitPositions()})})}updateState(t){super.updateState(t);let{props:r,changeFlags:i}=t,s=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.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:i.dataChanged}),this.setState({numInstances:o.instanceCount,startIndices:o.vertexStarts}),i.dataChanged||s.invalidateAll()}i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(t){let r=super.getPickingInfo(t),{index:i}=r,s=this.props.data;return s[0]&&s[0].__source&&(r.object=s.find(n=>n.__source.index===i)),r}disablePickingIndex(t){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;i<r.length;i++)r[i].__source.index===t&&this._disablePickingIndex(i);else super.disablePickingIndex(t)}draw({uniforms:t}){let{jointRounded:r,capRounded:i,billboard:s,miterLimit:n,widthUnits:o,widthScale:a,widthMinPixels:c,widthMaxPixels:l}=this.props,u=this.state.model;u.setUniforms(t),u.setUniforms({jointType:Number(r),capType:Number(i),billboard:s,widthUnits:Ft[o],widthScale:a,miterLimit:n,widthMinPixels:c,widthMaxPixels:l}),u.draw(this.context.renderPass)}_getModel(){let t=[0,1,2,1,4,2,1,3,4,3,5,4],r=[0,0,0,-1,0,1,1,-1,1,1,1,0];return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new it({topology:"triangle-list",attributes:{indices:new Uint16Array(t),positions:{value:new Float32Array(r),size:2}}}),isInstanced:!0})}calculatePositions(t){let{pathTesselator:r}=this.state;t.startIndices=r.vertexStarts,t.value=r.get("positions")}calculateSegmentTypes(t){let{pathTesselator:r}=this.state;t.startIndices=r.vertexStarts,t.value=r.get("segmentTypes")}},Jr=Lp;(()=>{Lp.defaultProps=f9})(),(()=>{Lp.layerName="PathLayer"})();var DM=li(BM(),1);var zp=va.CLOCKWISE,OM=va.COUNTER_CLOCKWISE,qs={isClosed:!0};function w9(e){if(e=e&&e.positions||e,!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error("invalid polygon")}function Pa(e){return"positions"in e?e.positions:e}function Lu(e){return"holeIndices"in e?e.holeIndices:null}function P9(e){return Array.isArray(e[0])}function M9(e){return e.length>=1&&e[0].length>=2&&Number.isFinite(e[0][0])}function R9(e){let t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]&&t[2]===r[2]}function I9(e,t,r,i){for(let s=0;s<t;s++)if(e[r+s]!==e[i-t+s])return!1;return!0}function FM(e,t,r,i,s){let n=t,o=r.length;for(let a=0;a<o;a++)for(let c=0;c<i;c++)e[n++]=r[a][c]||0;if(!R9(r))for(let a=0;a<i;a++)e[n++]=r[0][a]||0;return qs.start=t,qs.end=n,qs.size=i,io(e,s,qs),n}function NM(e,t,r,i,s=0,n,o){n=n||r.length;let a=n-s;if(a<=0)return t;let c=t;for(let l=0;l<a;l++)e[c++]=r[s+l];if(!I9(r,i,s,n))for(let l=0;l<i;l++)e[c++]=r[s+l];return qs.start=t,qs.end=c,qs.size=i,io(e,o,qs),c}function Hp(e,t){w9(e);let r=[],i=[];if("positions"in e){let{positions:s,holeIndices:n}=e;if(n){let o=0;for(let a=0;a<=n.length;a++)o=NM(r,o,s,t,n[a-1],n[a],a===0?zp:OM),i.push(o);return i.pop(),{positions:r,holeIndices:i}}e=s}if(!P9(e))return NM(r,0,e,t,0,r.length,zp),r;if(!M9(e)){let s=0;for(let[n,o]of e.entries())s=FM(r,s,o,t,n===0?zp:OM),i.push(s);return i.pop(),{positions:r,holeIndices:i}}return FM(r,0,e,t,zp),r}function GA(e,t,r){let i=e.length/3,s=0;for(let n=0;n<i;n++){let o=(n+1)%i;s+=e[n*3+t]*e[o*3+r],s-=e[o*3+t]*e[n*3+r]}return Math.abs(s/2)}function LM(e,t,r,i){let s=e.length/3;for(let n=0;n<s;n++){let o=n*3,a=e[o+0],c=e[o+1],l=e[o+2];e[o+t]=a,e[o+r]=c,e[o+i]=l}}function UM(e,t,r,i){let s=Lu(e);s&&(s=s.map(a=>a/t));let n=Pa(e),o=i&&t===3;if(r){let a=n.length;n=n.slice();let c=[];for(let l=0;l<a;l+=t){c[0]=n[l],c[1]=n[l+1],o&&(c[2]=n[l+2]);let u=r(c);n[l]=u[0],n[l+1]=u[1],o&&(n[l+2]=u[2])}}if(o){let a=GA(n,0,1),c=GA(n,0,2),l=GA(n,1,2);if(!a&&!c&&!l)return[];a>c&&a>l||(c>l?(r||(n=n.slice()),LM(n,0,2,1)):(r||(n=n.slice()),LM(n,2,0,1)))}return(0,DM.default)(n,s,t)}var Du=class extends ts{constructor(t){let{fp64:r,IndexType:i=Uint32Array}=t;super({...t,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(t){let{attributes:r}=this;return t==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[t]}updateGeometry(t){super.updateGeometry(t);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(t){if(this.normalize){let r=Hp(t,this.positionSize);return this.opts.resolution?Ru(Pa(r),Lu(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?LA(Pa(r),Lu(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return t}getGeometrySize(t){if(VM(t)){let r=0;for(let i of t)r+=this.getGeometrySize(i);return r}return Pa(t).length/this.positionSize}getGeometryFromBuffer(t){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(t):null}updateGeometryAttributes(t,r){if(t&&VM(t))for(let i of t){let s=this.getGeometrySize(i);r.geometrySize=s,this.updateGeometryAttributes(i,r),r.vertexStart+=s,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let i=t;this._updateIndices(i,r),this._updatePositions(i,r),this._updateVertexValid(i,r)}}_updateIndices(t,{geometryIndex:r,vertexStart:i,indexStart:s}){let{attributes:n,indexStarts:o,typedArrayManager:a}=this,c=n.indices;if(!c||!t)return;let l=s,u=UM(t,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,s+u.length,{copy:!0});for(let f=0;f<u.length;f++)c[l++]=u[f]+i;o[r+1]=s+u.length,n.indices=c}_updatePositions(t,{vertexStart:r,geometrySize:i}){let{attributes:{positions:s},positionSize:n}=this;if(!s||!t)return;let o=Pa(t);for(let a=r,c=0;c<i;a++,c++){let l=o[c*n],u=o[c*n+1],f=n>2?o[c*n+2]:0;s[a*3]=l,s[a*3+1]=u,s[a*3+2]=f}}_updateVertexValid(t,{vertexStart:r,geometrySize:i}){let{positionSize:s}=this,n=this.attributes.vertexValid,o=t&&Lu(t);if(t&&t.edgeTypes?n.set(t.edgeTypes,r):n.fill(1,r,r+i),o)for(let a=0;a<o.length;a++)n[r+o[a]/s-1]=0;n[r+i-1]=0}};function VM(e){return Array.isArray(e)&&e.length>0&&!Number.isFinite(e[0])}var Gp=`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 zM=`#version 300 es
#define SHADER_NAME solid-polygon-layer-vertex-shader
in vec3 vertexPositions;
in vec3 vertexPositions64Low;
in float elevations;
${Gp}
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 HM=`#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;
${Gp}
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 GM=`#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 jp=[0,0,0,255],B9={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:e=>e.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:jp},getLineColor:{type:"accessor",value:jp},material:!0},Wp={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e},Xp=class extends lt{getShaders(t){return super.getShaders({vs:t==="top"?zM:HM,fs:GM,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[dt,_r,_t]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:t}=this.context,{coordinateSystem:r}=this.props,{_full3d:i}=this.props;t.isGeospatial&&r===X.DEFAULT&&(r=X.LNGLAT);let s;r===X.LNGLAT&&(i?s=t.projectPosition.bind(t):s=t.projectFlat.bind(t)),this.setState({numInstances:0,polygonTesselator:new Du({preproject:s,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:Wp,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:Wp,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Wp,accessor:"getFillColor",defaultValue:jp},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Wp,accessor:"getLineColor",defaultValue:jp},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(t){let r=super.getPickingInfo(t),{index:i}=r,s=this.props.data;return s[0]&&s[0].__source&&(r.object=s.find(n=>n.__source.index===i)),r}disablePickingIndex(t){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;i<r.length;i++)r[i].__source.index===t&&this._disablePickingIndex(i);else super.disablePickingIndex(t)}draw({uniforms:t}){let{extruded:r,filled:i,wireframe:s,elevationScale:n}=this.props,{topModel:o,sideModel:a,wireframeModel:c,polygonTesselator:l}=this.state,u={...t,extruded:Boolean(r),elevationScale:n};c&&s&&(c.setInstanceCount(l.instanceCount-1),c.setUniforms(u),c.draw(this.context.renderPass)),a&&i&&(a.setInstanceCount(l.instanceCount-1),a.setUniforms(u),a.draw(this.context.renderPass)),o&&i&&(o.setVertexCount(l.vertexCount),o.setUniforms(u),o.draw(this.context.renderPass))}updateState(t){super.updateState(t),this.updateGeometry(t);let{props:r,oldProps:i,changeFlags:s}=t,n=this.getAttributeManager();(s.extensionsChanged||r.filled!==i.filled||r.extruded!==i.extruded)&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),n.invalidateAll())}updateGeometry({props:t,oldProps:r,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:n}=this.state,o=t.data.attributes||{};n.updateGeometry({data:t.data,normalize:t._normalize,geometryBuffer:o.getPolygon,buffers:o,getGeometry:t.getPolygon,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:t._full3d}),this.setState({numInstances:n.instanceCount,startIndices:n.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:t,filled:r,extruded:i}=this.props,s,n,o;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});s=new J(this.context.device,{...a,id:`${t}-top`,topology:"triangle-list",uniforms:{isWireframe:!1},bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});n=new J(this.context.device,{...this.getShaders("side"),id:`${t}-side`,bufferLayout:a,uniforms:{isWireframe:!1},geometry:new it({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:`${t}-wireframe`,bufferLayout:a,uniforms:{isWireframe:!0},geometry:new it({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,s].filter(Boolean),topModel:s,sideModel:n,wireframeModel:o}}calculateIndices(t){let{polygonTesselator:r}=this.state;t.startIndices=r.indexStarts,t.value=r.get("indices")}calculatePositions(t){let{polygonTesselator:r}=this.state;t.startIndices=r.vertexStarts,t.value=r.get("positions")}calculateVertexValid(t){t.value=this.state.polygonTesselator.get("vertexValid")}},Zr=Xp;(()=>{Xp.defaultProps=B9})(),(()=>{Xp.layerName="SolidPolygonLayer"})();function Yp({data:e,getIndex:t,dataRange:r,replace:i}){let{startRow:s=0,endRow:n=1/0}=r,o=e.length,a=o,c=o;for(let h=0;h<o;h++){let d=t(e[h]);if(a>h&&d>=s&&(a=h),d>=n){c=h;break}}let l=a,f=c-a!==i.length?e.slice(c):void 0;for(let h=0;h<i.length;h++)e[l++]=i[h];if(f){for(let h=0;h<f.length;h++)e[l++]=f[h];e.length=l}return{startRow:a,endRow:a+i.length}}var WM=[0,0,0,255],O9=[0,0,0,255],F9={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:e=>e.polygon},getFillColor:{type:"accessor",value:O9},getLineColor:{type:"accessor",value:WM},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},qp=class extends It{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&k.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:t}){let r=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getPolygon);if(r&&Array.isArray(t.dataChanged)){let i=this.state.paths.slice(),s=t.dataChanged.map(n=>Yp({data:i,getIndex:o=>o.__source.index,dataRange:n,replace:this._getPaths(n)}));this.setState({paths:i,pathsDiff:s})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(t={}){let{data:r,getPolygon:i,positionFormat:s,_normalize:n}=this.props,o=[],a=s==="XY"?2:3,{startRow:c,endRow:l}=t,{iterable:u,objectInfo:f}=Ht(r,c,l);for(let h of u){f.index++;let d=i(h,f);n&&(d=Hp(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:t,_dataDiff:r,stroked:i,filled:s,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:E,getLineWidth:P,getLineDashArray:B,getElevation:F,getPolygon:M,updateTriggers:v,material:T}=this.props,{paths:L,pathsDiff:V}=this.state,z=this.getSubLayerClass("fill",Zr),W=this.getSubLayerClass("stroke",Jr),Z=this.shouldRenderSubLayer("fill",L)&&new z({_dataDiff:r,extruded:n,elevationScale:l,filled:s,wireframe:o,_normalize:a,_windingOrder:c,getElevation:F,getFillColor:x,getLineColor:n&&o?E:WM,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:t,positionFormat:f,getPolygon:M}),ut=!n&&i&&this.shouldRenderSubLayer("stroke",L)&&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(E),getWidth:this.getSubLayerAccessor(P),getDashArray:this.getSubLayerAccessor(B)},this.getSubLayerProps({id:"stroke",updateTriggers:v&&{getWidth:v.getLineWidth,getColor:v.getLineColor,getDashArray:v.getLineDashArray}}),{data:L,positionFormat:f,getPath:st=>st.path});return[!n&&Z,ut,n&&Z]}},Qr=qp;(()=>{qp.layerName="PolygonLayer"})(),(()=>{qp.defaultProps=F9})();function jM(e,t){if(!e)return null;let r="startIndices"in e?e.startIndices[t]:t,i=e.featureIds.value[r];return r!==-1?N9(e,i,r):null}function N9(e,t,r){let i={properties:{...e.properties[t]}};for(let s in e.numericProps)i.properties[s]=e.numericProps[s].value[r];return i}function XM(e,t){let r={points:null,lines:null,polygons:null};for(let i in r){let s=e[i].globalFeatureIds.value;r[i]=new Uint8ClampedArray(s.length*3);let n=[];for(let o=0;o<s.length;o++)t(s[o],n),r[i][o*3+0]=n[0],r[i][o*3+1]=n[1],r[i][o*3+2]=n[2]}return r}var YM=`#version 300 es
#define SHADER_NAME multi-icon-layer-fragment-shader
precision highp float;
uniform float opacity;
uniform sampler2D iconsTexture;
uniform float gamma;
uniform bool sdf;
uniform float alphaCutoff;
uniform float sdfBuffer;
uniform float outlineBuffer;
uniform vec4 outlineColor;
in vec4 vColor;
in vec2 vTextureCoords;
in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
if (!bool(picking.isActive)) {
float alpha = texture(iconsTexture, vTextureCoords).a;
vec4 color = vColor;
if (sdf) {
float distance = alpha;
alpha = smoothstep(sdfBuffer - gamma, sdfBuffer + gamma, distance);
if (outlineBuffer > 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 WA=192/256,qM=[],L9={getIconOffsets:{type:"accessor",value:e=>e.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},Kp=class extends es{getShaders(){return{...super.getShaders(),fs:YM}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(r,{index:i,target:s})=>this.encodePickingColor(i,s)}})}updateState(t){super.updateState(t);let{props:r,oldProps:i}=t,{outlineColor:s}=r;s!==i.outlineColor&&(s=s.map(n=>n/255),s[3]=Number.isFinite(s[3])?s[3]:1,this.setState({outlineColor:s})),!r.sdf&&r.outlineWidth&&k.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(t){let{sdf:r,smoothing:i,outlineWidth:s}=this.props,{outlineColor:n}=this.state,o=s?Math.max(i,WA*(1-s)):-1;if(t.uniforms={...t.uniforms,sdfBuffer:WA,outlineBuffer:o,gamma:i,sdf:Boolean(r),outlineColor:n},super.draw(t),r&&s){let{iconManager:a}=this.state,c=a.getTexture(),l=this.state.model;c&&(l.setUniforms({outlineBuffer:WA}),l.draw(this.context.renderPass))}}getInstanceOffset(t){return t?Array.from(t).flatMap(r=>super.getInstanceOffset(r)):qM}getInstanceColorMode(t){return 1}getInstanceIconFrame(t){return t?Array.from(t).flatMap(r=>super.getInstanceIconFrame(r)):qM}},ao=Kp;(()=>{Kp.defaultProps=L9})(),(()=>{Kp.layerName="MultiIconLayer"})();var Uu=class{constructor({fontSize:t=24,buffer:r=3,radius:i=8,cutoff:s=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=s,this.radius=i;let c=this.size=t+r*4,l=this._createCanvas(c),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${t}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(t){let r=document.createElement("canvas");return r.width=r.height=t,r}draw(t){let{width:r,actualBoundingBoxAscent:i,actualBoundingBoxDescent:s,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(t),a=Math.ceil(i),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(s)),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(t,_,_+a);let E=m.getImageData(_,_,l,u);x.fill(1e20,0,d),y.fill(0,0,d);for(let P=0;P<u;P++)for(let B=0;B<l;B++){let F=E.data[4*(P*l+B)+3]/255;if(F===0)continue;let M=(P+_)*f+B+_;if(F===1)x[M]=0,y[M]=1e20;else{let v=.5-F;x[M]=v>0?v*v:0,y[M]=v<0?v*v:0}}KM(x,0,0,f,h,f,this.f,this.v,this.z),KM(y,_,_,l,u,f,this.f,this.v,this.z);for(let P=0;P<d;P++){let B=Math.sqrt(x[P])-Math.sqrt(y[P]);p[P]=Math.round(255-255*(B/this.radius+this.cutoff))}return g}};function KM(e,t,r,i,s,n,o,a,c){for(let l=t;l<t+i;l++)$M(e,r*n+l,n,s,o,a,c);for(let l=r;l<r+s;l++)$M(e,l*n+t,1,i,o,a,c)}function $M(e,t,r,i,s,n,o){n[0]=0,o[0]=-1e20,o[1]=1e20,s[0]=e[t];for(let a=1,c=0,l=0;a<i;a++){s[a]=e[t+a*r];let u=a*a;do{let f=n[c];l=(s[a]-s[f]+u-f*f)/(a-f)/2}while(l<=o[c]&&--c>-1);c++,n[c]=a,o[c]=l,o[c+1]=1e20}for(let a=0,c=0;a<i;a++){for(;o[c+1]<a;)c++;let l=n[c],u=a-l;e[t+a*r]=s[l]+u*u}}var D9=32,U9=[];function k9(e){return Math.pow(2,Math.ceil(Math.log2(e)))}function JM({characterSet:e,getFontWidth:t,fontHeight:r,buffer:i,maxCanvasWidth:s,mapping:n={},xOffset:o=0,yOffset:a=0}){let c=0,l=o,u=r+i*2;for(let f of e)if(!n[f]){let h=t(f);l+h+i*2>s&&(l=0,c++),n[f]={x:l+i,y:a+c*u+i,width:h,height:u,layoutWidth:h,layoutHeight:r},l+=h+i*2}return{mapping:n,xOffset:l,yOffset:a+c*u,canvasHeight:k9(a+(c+1)*u)}}function ZM(e,t,r,i){let s=0;for(let n=t;n<r;n++){let o=e[n];s+=i[o]?.layoutWidth||0}return s}function QM(e,t,r,i,s,n){let o=t,a=0;for(let c=t;c<r;c++){let l=ZM(e,c,c+1,s);a+l>i&&(o<c&&n.push(c),o=c,a=0),a+=l}return a}function V9(e,t,r,i,s,n){let o=t,a=t,c=t,l=0;for(let u=t;u<r;u++)if((e[u]===" "||e[u+1]===" "||u+1===r)&&(c=u+1),c>a){let f=ZM(e,a,c,s);l+f>i&&(o<a&&(n.push(a),o=a,l=0),f>i&&(f=QM(e,a,c,i,s,n),o=n[n.length-1])),a=c,l+=f}return l}function z9(e,t,r,i,s=0,n){n===void 0&&(n=e.length);let o=[];return t==="break-all"?QM(e,s,n,r,i,o):V9(e,s,n,r,i,o),o}function H9(e,t,r,i,s,n){let o=0,a=0;for(let c=t;c<r;c++){let l=e[c],u=i[l];u?(a||(a=u.layoutHeight),s[c]=o+u.layoutWidth/2,o+=u.layoutWidth):(k.warn(`Missing character: ${l} (${l.codePointAt(0)})`)(),s[c]=o,o+=D9)}n[0]=o,n[1]=a}function tR(e,t,r,i,s){let n=Array.from(e),o=n.length,a=new Array(o),c=new Array(o),l=new Array(o),u=(r==="break-word"||r==="break-all")&&isFinite(i)&&i>0,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?z9(n,r,i,s,p,g):U9;for(let x=0;x<=y.length;x++){let E=x===0?p:y[x-1],P=x<y.length?y[x]:g;H9(n,E,P,s,a,h);for(let B=E;B<P;B++){let F=n[B],M=s[F]?.layoutOffsetY||0;c[B]=d+h[1]/2+M,l[B]=h[0]}d=d+h[1]*t,f[0]=Math.max(f[0],h[0])}p=g}_===`
`&&(a[p]=0,c[p]=0,l[p]=0,p++)}return f[1]=d,{x:a,y:c,rowWidth:l,size:f}}function eR({value:e,length:t,stride:r,offset:i,startIndices:s,characterSet:n}){let o=e.BYTES_PER_ELEMENT,a=r?r/o:1,c=i?i/o:0,l=s[t]||Math.ceil((e.length-c)/a),u=n&&new Set,f=new Array(t),h=e;if(a>1||c>0){let d=e.constructor;h=new d(l);for(let p=0;p<l;p++)h[p]=e[p*a+c]}for(let d=0;d<t;d++){let p=s[d],g=s[d+1]||l,m=h.subarray(p,g);f[d]=String.fromCodePoint.apply(null,m),u&&m.forEach(u.add,u)}if(u)for(let d of u)n.add(String.fromCodePoint(d));return{texts:f,characterCount:l}}var Ma=class{constructor(t=5){this._cache={},this._order=[],this.limit=t}get(t){let r=this._cache[t];return r&&(this._deleteOrder(t),this._appendOrder(t)),r}set(t,r){this._cache[t]?(this.delete(t),this._cache[t]=r,this._appendOrder(t)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[t]=r,this._appendOrder(t))}delete(t){this._cache[t]&&(delete this._cache[t],this._deleteOrder(t))}_deleteOrder(t){let r=this._order.indexOf(t);r>=0&&this._order.splice(r,1)}_appendOrder(t){this._order.push(t)}};function G9(){let e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}var co={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:G9(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},rR=1024,iR=.9,sR=1.2,oR=3,$p=new Ma(oR);function W9(e,t){let r;typeof t=="string"?r=new Set(Array.from(t)):r=new Set(t);let i=$p.get(e);if(!i)return r;for(let s in i.mapping)r.has(s)&&r.delete(s);return r}function j9(e,t){for(let r=0;r<e.length;r++)t.data[4*r+3]=e[r]}function nR(e,t,r,i){e.font=`${i} ${r}px ${t}`,e.fillStyle="#000",e.textBaseline="alphabetic",e.textAlign="left"}function aR(e){k.assert(Number.isFinite(e)&&e>=oR,"Invalid cache limit"),$p=new Ma(e)}var ku=class{constructor(){this.props={...co}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){let{fontSize:t,buffer:r}=this.props;return(t*sR+r*2)/t}setProps(t={}){Object.assign(this.props,t),this._key=this._getKey();let r=W9(this._key,this.props.characterSet),i=$p.get(this._key);if(i&&r.size===0){this._atlas!==i&&(this._atlas=i);return}let s=this._generateFontAtlas(r,i);this._atlas=s,$p.set(this._key,s)}_generateFontAtlas(t,r){let{fontFamily:i,fontWeight:s,fontSize:n,buffer:o,sdf:a,radius:c,cutoff:l}=this.props,u=r&&r.data;u||(u=document.createElement("canvas"),u.width=rR);let f=u.getContext("2d",{willReadFrequently:!0});nR(f,i,n,s);let{mapping:h,canvasHeight:d,xOffset:p,yOffset:g}=JM({getFontWidth:m=>f.measureText(m).width,fontHeight:n*sR,buffer:o,characterSet:t,maxCanvasWidth:rR,...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(nR(f,i,n,s),a){let m=new Uu({fontSize:n,buffer:o,radius:c,cutoff:l,fontFamily:i,fontWeight:`${s}`});for(let _ of t){let{data:y,width:x,height:E,glyphTop:P}=m.draw(_);h[_].width=x,h[_].layoutOffsetY=n*iR-P;let B=f.createImageData(x,E);j9(y,B),f.putImageData(B,h[_].x,h[_].y)}}else for(let m of t)f.fillText(m,h[m].x,h[m].y+o+n*iR);return{xOffset:p,yOffset:g,mapping:h,data:u,width:u.width,height:u.height}}_getKey(){let{fontFamily:t,fontWeight:r,fontSize:i,buffer:s,sdf:n,radius:o,cutoff:a}=this.props;return n?`${t} ${r} ${i} ${s} ${o} ${a}`:`${t} ${r} ${i} ${s}`}};var cR=`#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 lR=`#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 X9={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:e=>e.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}},Jp=class extends lt{getShaders(){return super.getShaders({vs:cR,fs:lR,modules:[dt,_t]})}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(t){super.updateState(t);let{changeFlags:r}=t;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:t}){let{billboard:r,sizeScale:i,sizeUnits:s,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(t),l.setUniforms({billboard:r,stroked:Boolean(a),padding:c,sizeUnits:Ft[s],sizeScale:i,sizeMinPixels:n,sizeMaxPixels:o}),l.draw(this.context.renderPass)}_getModel(){let t=[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 it({topology:"triangle-fan-webgl",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(t)}}}),isInstanced:!0})}},lo=Jp;(()=>{Jp.defaultProps=X9})(),(()=>{Jp.layerName="TextBackgroundLayer"})();var uR={start:1,middle:0,end:-1},fR={top:1,center:0,bottom:-1},jA=[0,0,0,255],Y9=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:jA},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:co.characterSet},fontFamily:co.fontFamily,fontWeight:co.fontWeight,lineHeight:Y9,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:jA},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:e=>e.text},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:jA},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"]}},Zp=class extends It{constructor(){super(...arguments),this.getBoundingRect=(t,r)=>{let{size:[i,s]}=this.transformParagraph(t,r),{fontSize:n}=this.state.fontAtlasManager.props;i/=n,s/=n;let{getTextAnchor:o,getAlignmentBaseline:a}=this.props,c=uR[typeof o=="function"?o(t,r):o],l=fR[typeof a=="function"?a(t,r):a];return[(c-1)*i/2,(l-1)*s/2,i,s]},this.getIconOffsets=(t,r)=>{let{getTextAnchor:i,getAlignmentBaseline:s}=this.props,{x:n,y:o,rowWidth:a,size:[c,l]}=this.transformParagraph(t,r),u=uR[typeof i=="function"?i(t,r):i],f=fR[typeof s=="function"?s(t,r):s],h=n.length,d=new Array(h*2),p=0;for(let g=0;g<h;g++){let m=(1-u)*(c-a[g])/2;d[p++]=(u-1)*c/2+m+n[g],d[p++]=(f-1)*l/2+o[g]}return d}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new ku},this.props.maxWidth>0&&k.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(t){let{props:r,oldProps:i,changeFlags:s}=t;(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==i.lineHeight||r.wordBreak!==i.wordBreak||r.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:t}){return t.object=t.index>=0?this.props.data[t.index]:null,t}_updateFontAtlas(){let{fontSettings:t,fontFamily:r,fontWeight:i}=this.props,{fontAtlasManager:s,characterSet:n}=this.state,o={...t,characterSet:n,fontFamily:r,fontWeight:i};if(!s.mapping)return s.setProps(o),!0;for(let a in o)if(o[a]!==s.props[a])return s.setProps(o),!0;return!1}_updateText(){let{data:t,characterSet:r}=this.props,i=t.attributes?.getText,{getText:s}=this.props,n=t.startIndices,o,a=r==="auto"&&new Set;if(i&&n){let{texts:c,characterCount:l}=eR({...ArrayBuffer.isView(i)?{value:i}:i,length:t.length,startIndices:n,characterSet:a});o=l,s=(u,{index:f})=>c[f]}else{let{iterable:c,objectInfo:l}=Ht(t);n=[0],o=0;for(let u of c){l.index++;let f=Array.from(s(u,l)||"");a&&f.forEach(a.add,a),o+=f.length,n.push(o)}}this.setState({getText:s,startIndices:n,numInstances:o,characterSet:a||r})}transformParagraph(t,r){let{fontAtlasManager:i}=this.state,s=i.mapping,n=this.state.getText,{wordBreak:o,lineHeight:a,maxWidth:c}=this.props,l=n(t,r)||"";return tR(l,a,o,c*i.props.fontSize,s)}renderLayers(){let{startIndices:t,numInstances:r,getText:i,fontAtlasManager:{scale:s,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:E,fontSettings:P,outlineWidth:B,outlineColor:F,sizeScale:M,sizeUnits:v,sizeMinPixels:T,sizeMaxPixels:L,transitions:V,updateTriggers:z}=this.props,W=this.getSubLayerClass("characters",ao),Z=this.getSubLayerClass("background",lo);return[x&&new Z({getFillColor:g,getLineColor:m,getLineWidth:_,padding:y,getPosition:u,getSize:h,getAngle:d,getPixelOffset:p,billboard:E,sizeScale:M,sizeUnits:v,sizeMinPixels:T,sizeMaxPixels:L,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:co.smoothing,outlineWidth:B/(P.radius||co.radius),outlineColor:F,iconAtlas:n,iconMapping:o,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,billboard:E,sizeScale:M*s,sizeUnits:v,sizeMinPixels:T*s,sizeMaxPixels:L*s,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:t,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(t){aR(t)}},uo=Zp;(()=>{Zp.defaultProps=q9})(),(()=>{Zp.layerName="TextLayer"})();var Vu={circle:{type:ro,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:es,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:uo,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"}}},zu={type:Jr,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},Qp={type:Zr,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Ra({type:e,props:t}){let r={};for(let i in t)r[i]=e.defaultProps[t[i]];return r}function tg(e,t){let{transitions:r,updateTriggers:i}=e.props,s={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let n in t){let o=t[n],a=e.props[n];n.startsWith("get")&&(a=e.getSubLayerAccessor(a),s.updateTriggers[o]=i[n],r&&(s.transitions[o]=r[n])),s[o]=a}return s}function dR(e){if(Array.isArray(e))return e;switch(k.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return k.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}function XA(e,t,r={}){let i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:s=0,endRow:n=e.length}=r;for(let o=s;o<n;o++){let a=e[o],{geometry:c}=a;if(c)if(c.type==="GeometryCollection"){k.assert(Array.isArray(c.geometries),"GeoJSON does not have geometries array");let{geometries:l}=c;for(let u=0;u<l.length;u++){let f=l[u];hR(f,i,t,a,o)}}else hR(c,i,t,a,o)}return i}function hR(e,t,r,i,s){let{type:n,coordinates:o}=e,{pointFeatures:a,lineFeatures:c,polygonFeatures:l,polygonOutlineFeatures:u}=t;if(!$9(n,o)){k.warn(`${n} coordinates are malformed`)();return}switch(n){case"Point":a.push(r({geometry:e},i,s));break;case"MultiPoint":o.forEach(f=>{a.push(r({geometry:{type:"Point",coordinates:f}},i,s))});break;case"LineString":c.push(r({geometry:e},i,s));break;case"MultiLineString":o.forEach(f=>{c.push(r({geometry:{type:"LineString",coordinates:f}},i,s))});break;case"Polygon":l.push(r({geometry:e},i,s)),o.forEach(f=>{u.push(r({geometry:{type:"LineString",coordinates:f}},i,s))});break;case"MultiPolygon":o.forEach(f=>{l.push(r({geometry:{type:"Polygon",coordinates:f}},i,s)),f.forEach(h=>{u.push(r({geometry:{type:"LineString",coordinates:h}},i,s))})});break;default:}}var K9={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function $9(e,t){let r=K9[e];for(k.assert(r,`Unknown GeoJSON type ${e}`);t&&--r>0;)t=t[0];return t&&Number.isFinite(t[0])}function pR(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function eg(e){return e.geometry.coordinates}function gR(e,t){let r=pR(),{pointFeatures:i,lineFeatures:s,polygonFeatures:n,polygonOutlineFeatures:o}=e;return r.points.data=i,r.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),r.points.getPosition=eg,r.lines.data=s,r.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),r.lines.getPath=eg,r.polygons.data=n,r.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),r.polygons.getPolygon=eg,r.polygonsOutline.data=o,r.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),r.polygonsOutline.getPath=eg,r}function mR(e,t){let r=pR(),{points:i,lines:s,polygons:n}=e,o=XM(e,t);return r.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:3,value:o.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.lines.data={length:s.pathIndices.value.length-1,startIndices:s.pathIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:3,value:o.lines}},properties:s.properties,numericProps:s.numericProps,featureIds:s.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 J9=["points","linestrings","polygons"],Z9={...Ra(Vu.circle),...Ra(Vu.icon),...Ra(Vu.text),...Ra(zu),...Ra(Qp),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:e=>e.properties.icon},getText:{type:"accessor",value:e=>e.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},rg=class extends It{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:t,changeFlags:r}){if(!r.dataChanged)return;let{data:i}=this.props,s=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:s}),s?this._updateStateBinary({props:t,changeFlags:r}):this._updateStateJSON({props:t,changeFlags:r})}_updateStateBinary({props:t,changeFlags:r}){let i=mR(t.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:t,changeFlags:r}){let i=dR(t.data),s=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=XA(i,s,l);for(let f in c)o[f].push(Yp({data:n[f],getIndex:h=>h.__source.index,dataRange:l,replace:u[f]}))}}else n=XA(i,s);let a=gR(n,o);this.setState({features:n,featuresDiff:o,layerProps:a})}getPickingInfo(t){let r=super.getPickingInfo(t),{index:i,sourceLayer:s}=r;return r.featureType=J9.find(n=>s.id.startsWith(`${this.id}-${n}-`)),i>=0&&s.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[i]),r}_updateAutoHighlight(t){let r=`${this.id}-points-`,i=t.featureType==="points";for(let s of this.getSubLayers())s.id.startsWith(r)===i&&s.updateAutoHighlight(t)}_renderPolygonLayer(){let{extruded:t,wireframe:r}=this.props,{layerProps:i}=this.state,s="polygons-fill",n=this.shouldRenderSubLayer(s,i.polygons?.data)&&this.getSubLayerClass(s,Qp.type);if(n){let o=tg(this,Qp.props),a=t&&r;return a||delete o.getLineColor,o.updateTriggers.lineColors=a,new n(o,this.getSubLayerProps({id:s,updateTriggers:o.updateTriggers}),i.polygons)}return null}_renderLineLayers(){let{extruded:t,stroked:r}=this.props,{layerProps:i}=this.state,s="polygons-stroke",n="linestrings",o=!t&&r&&this.shouldRenderSubLayer(s,i.polygonsOutline?.data)&&this.getSubLayerClass(s,zu.type),a=this.shouldRenderSubLayer(n,i.lines?.data)&&this.getSubLayerClass(n,zu.type);if(o||a){let c=tg(this,zu.props);return[o&&new o(c,this.getSubLayerProps({id:s,updateTriggers:c.updateTriggers}),i.polygonsOutline),a&&new a(c,this.getSubLayerProps({id:n,updateTriggers:c.updateTriggers}),i.lines)]}return null}_renderPointLayers(){let{pointType:t}=this.props,{layerProps:r,binary:i}=this.state,{highlightedObjectIndex:s}=this.props;!i&&Number.isFinite(s)&&(s=r.points.data.findIndex(a=>a.__source.index===s));let n=new Set(t.split("+")),o=[];for(let a of n){let c=`points-${a}`,l=Vu[a],u=l&&this.shouldRenderSubLayer(c,r.points?.data)&&this.getSubLayerClass(c,l.type);if(u){let f=tg(this,l.props),h=r.points;if(a==="text"&&i){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:s}),h))}}return o}renderLayers(){let{extruded:t}=this.props,r=this._renderPolygonLayer(),i=this._renderLineLayers(),s=this._renderPointLayers();return[!t&&r,i,s,t&&r]}getSubLayerAccessor(t){let{binary:r}=this.state;return!r||typeof t!="function"?super.getSubLayerAccessor(t):(i,s)=>{let{data:n,index:o}=s,a=jM(n,o);return t(a,s)}}},Ci=rg;(()=>{rg.layerName="GeoJsonLayer"})(),(()=>{rg.defaultProps=Z9})();function Q9(e){return typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e}function ig(e){if(Array.isArray(e))return e.map(t=>ig(t));if(e&&typeof e=="object"){let t={};for(let[r,i]of Object.entries(e))t[Q9(r)]=ig(i);return t}return e}var KR=li(qR(),1);function eT(e,t){if(t?._parser&&t._parser!=="fast-xml-parser")throw new Error(t?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(s,n,o,a)=>Boolean(t?.arrayPaths?.some(l=>n===l)),...t?._fastXML},i=cW(e,r);return t?.uncapitalizeKeys?ig(i):i}function cW(e,t){return new KR.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}var lW="4.2.0-beta.2",ti={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:lW,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:uW,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(e,t)=>eT(new TextDecoder().decode(e),{...ti.options.xml,...t?.xml}),parseTextSync:(e,t)=>eT(e,{...ti.options.xml,...t?.xml})};function uW(e){return e.startsWith("<?xml")}function $R(e,t){let r=ti.parseTextSync?.(e,t),i=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof i=="string"?i:i.value||i.code||"Unknown error"}var fW="4.2.0-beta.2",Wu={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:fW,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:hW,options:{wms:{throwOnError:!1}},parse:async(e,t)=>rT(new TextDecoder().decode(e),t),parseSync:(e,t)=>rT(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>rT(e,t)};function hW(e){return e.startsWith("<?xml")}function rT(e,t){let r={...Wu.options.wms,...t?.wms},i=$R(e,r),s=r.minimalErrors?i:`WMS Service error: ${i}`;if(r.throwOnError)throw new Error(s);return s}function ho(e){return Array.isArray(e)?e:e?[e]:[]}function ju(e){let t=ho(e);return t.length>0&&t.every(r=>typeof r=="string")?t:[]}function Xu(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseFloat(e);default:return}}function ng(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseInt(e,10);default:return}}function po(e){switch(e){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function iT(e,t){let r=ti.parseTextSync?.(e,t),i=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,s=dW(i);if(t?.inheritedLayerProps)for(let n of s.layers)ZR(n,null);return t?.includeRawJSON&&(s.json=i),t?.includeXMLText&&(s.xml=e),s}function dW(e){let t={version:String(e.version||""),name:String(e.Service?.Name||"unnamed"),title:e.Service?.Title?String(e.Service?.Title):void 0,abstract:e.Service?.Abstract?String(e.Service?.Abstract):void 0,keywords:ju(e.Service?.KeywordList?.Keyword),fees:e.Service?.Fees?JSON.stringify(e.Service?.Fees):void 0,accessConstraints:e.Service?.AccessConstraints?JSON.stringify(e.Service?.AccessConstraints):void 0,layerLimit:ng(e.Service?.LayerLimit),maxWidth:ng(e.Service?.maxWidth),maxHeight:ng(e.Service?.maxHeight),layers:[],requests:pW(e.Capability?.Request),exceptions:gW(e.Exception)},r=ho(e.Capability?.Layer);for(let i of r)t.layers.push(JR(i));for(let[i,s]of Object.entries(t))s===void 0&&delete t[i];return t}function pW(e){let t={};for(let[r,i]of Object.entries(e||{})){let s=ju(i?.Format);t[r]={mimeTypes:s}}return t}function gW(e){if(ho(e?.Format).length>0)return{mimeTypes:ju(e)}}function JR(e){let t={title:String(e?.Title||""),name:e?.Name&&String(e?.Name),abstract:e?.Name&&String(e?.Abstract),keywords:ju(e.KeywordList?.Keyword)},r=e?.CRS||e?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(t.crs=r);let i=e?.EX_GeographicBoundingBox&&mW(e?.EX_GeographicBoundingBox);i&&(t.geographicBoundingBox=i),i=e?.LatLonBoundingBox&&_W(e?.LatLonBoundingBox),i&&(t.geographicBoundingBox=i);let s=e?.BoundingBox&&yW(e?.BoundingBox);s&&s.length>0&&(t.boundingBoxes=s);let o=ho(e?.Dimension).map(l=>AW(l));o.length&&(t.dimensions=o),e?.opaque&&(t.opaque=po(e?.opaque)),e?.cascaded&&(t.cascaded=po(e?.cascaded)),e?.queryable&&(t.queryable=po(e?.queryable));let a=ho(e?.Layer),c=[];for(let l of a)c.push(JR(l));c.length>0&&(t.layers=c);for(let[l,u]of Object.entries(t))u===void 0&&delete t[l];return t}function mW(e){let{westBoundLongitude:t,northBoundLatitude:r,eastBoundLongitude:i,southBoundLatitude:s}=e;return[[t,s],[i,r]]}function _W(e){let{minx:t,miny:r,maxx:i,maxy:s}=e;return[[t,r],[i,s]]}function yW(e){return ho(e).map(r=>xW(r))}function xW(e){let{CRS:t,SRS:r,minx:i,miny:s,maxx:n,maxy:o,resx:a,resy:c}=e,l={crs:t||r,boundingBox:[[Xu(i),Xu(s)],[Xu(n),Xu(o)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function AW(e){let{name:t,units:r,value:i}=e,s={name:t,units:r,extent:i};return e.unitSymbol&&(s.unitSymbol=e.unitSymbol),e.default&&(s.defaultValue=e.default),e.multipleValues&&(s.multipleValues=po(e.multipleValues)),e.nearestValue&&(s.nearestValue=po(e.nearestValue)),e.current&&(s.current=po(e.current)),s}function ZR(e,t){t?.geographicBoundingBox&&!e.geographicBoundingBox&&(e.geographicBoundingBox=[...t.geographicBoundingBox]),t?.crs&&!e.crs&&(e.crs=[...t.crs]),t?.boundingBoxes&&!e.boundingBoxes&&(e.boundingBoxes=[...t.boundingBoxes]),t?.dimensions&&!e.dimensions&&(e.dimensions=[...t.dimensions]);for(let r of e.layers||[])ZR(r,e)}var TW="4.2.0-beta.2",Ia={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:TW,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:bW,options:{wms:{}},parse:async(e,t)=>iT(new TextDecoder().decode(e),t?.wms),parseTextSync:(e,t)=>iT(e,t?.wms)};function bW(e){return e.startsWith("<?xml")}function sT(e,t){let i=(ti.parseTextSync?.(e,t)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(i)?i:[i]).map(n=>EW(n))}}function EW(e){return{attributes:e||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var QR={...Ia,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(e,t)=>sT(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>sT(e,t)};function nT(e,t){return ti.parseTextSync?.(e,t)}var tI={...Ia,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(e,t)=>nT(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>nT(e,t)};function eI(e,t){let{type:r="auto"}=e,i=r==="auto"?vW(e.url,t):SW(r,t);if(!i)throw new Error("Not a valid image source type");return i.create(e)}function SW(e,t){for(let r of t)if(r.type===e)return r;return null}function vW(e,t){for(let r of t)if(r.testURL&&r.testURL(e))return r;return null}var rI={type:"wms",testURL:e=>e.toLowerCase().includes("wms"),create:e=>new oT(e)},oT=class extends cr{url;data;substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(t){super(t),this.url=t.url,this.data=t.url,this.substituteCRS84=t.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,...t.wmsParameters},this.vendorParameters=t.vendorParameters||{}}async getMetadata(){let t=await this.getCapabilities();return this.normalizeMetadata(t)}async getImage(t){let{boundingBox:r,bbox:i,...s}=t,n={bbox:r?[...r[0],...r[1]]:i,...s};return await this.getMap(n)}normalizeMetadata(t){return t}async getCapabilities(t,r){let i=this.getCapabilitiesURL(t,r),s=await this.fetch(i),n=await s.arrayBuffer();this._checkResponse(s,n);let o=await Ia.parse(n,this.loadOptions);return this.capabilities=o,o}async getMap(t,r){let i=this.getMapURL(t,r),s=await this.fetch(i),n=await s.arrayBuffer();this._checkResponse(s,n);try{return await pi.parse(n,this.loadOptions)}catch{throw this._parseError(n)}}async getFeatureInfo(t,r){let i=this.getFeatureInfoURL(t,r),s=await this.fetch(i),n=await s.arrayBuffer();return this._checkResponse(s,n),await QR.parse(n,this.loadOptions)}async getFeatureInfoText(t,r){let i=this.getFeatureInfoURL(t,r),s=await this.fetch(i),n=await s.arrayBuffer();return this._checkResponse(s,n),new TextDecoder().decode(n)}async describeLayer(t,r){let i=this.describeLayerURL(t,r),s=await this.fetch(i),n=await s.arrayBuffer();return this._checkResponse(s,n),await tI.parse(n,this.loadOptions)}async getLegendGraphic(t,r){let i=this.getLegendGraphicURL(t,r),s=await this.fetch(i),n=await s.arrayBuffer();this._checkResponse(s,n);try{return await pi.parse(n,this.loadOptions)}catch{throw this._parseError(n)}}getCapabilitiesURL(t,r){let i={version:this.wmsParameters.version,...t};return this._getWMSUrl("GetCapabilities",i,r)}getMapURL(t,r){t=this._getWMS130Parameters(t);let i={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,...t};return this._getWMSUrl("GetMap",i,r)}getFeatureInfoURL(t,r){t=this._getWMS130Parameters(t);let{boundingBox:i,bbox:s}=t;t.bbox=i?[...i[0],...i[1]]:s;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,...t};return this._getWMSUrl("GetFeatureInfo",n,r)}describeLayerURL(t,r){let i={version:this.wmsParameters.version,...t};return this._getWMSUrl("DescribeLayer",i,r)}getLegendGraphicURL(t,r){let i={version:this.wmsParameters.version,...t};return this._getWMSUrl("GetLegendGraphic",i,r)}_parseWMSUrl(t){let[r,i]=t.split("?"),s=i.split("&"),n={};for(let o of s){let[a,c]=o.split("=");n[a]=c}return{url:r,parameters:n}}_getWMSUrl(t,r,i){let s=this.url,n=!0,o={service:"WMS",version:r.version,request:t,...r,...this.vendorParameters,...i},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(o))(!a.includes(c)||l)&&(s+=n?"?":"&",n=!1,s+=this._getURLParameter(c,l,r));return encodeURI(s)}_getWMS130Parameters(t){let r={...t};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(t,r,i){switch(t){case"crs":i.version!=="1.3.0"?t="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":i.version==="1.3.0"&&(t="crs");break;case"bbox":let s=this._flipBoundingBox(r,i);s&&(r=s);break;case"x":i.version==="1.3.0"&&(t="i");break;case"y":i.version==="1.3.0"&&(t="j");break;default:}return t=t.toUpperCase(),Array.isArray(r)?`${t}=${r.join(",")}`:`${t}=${r?String(r):""}`}_flipBoundingBox(t,r){if(!Array.isArray(t)||t.length!==4)return null;let i=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),s=t;return i?[s[1],s[0],s[3],s[2]]:s}async _fetchArrayBuffer(t){let r=await this.fetch(t),i=await r.arrayBuffer();return this._checkResponse(r,i),i}_checkResponse(t,r){let i=t.headers["content-type"];if(!t.ok||Wu.mimeTypes.includes(i)){let s=Bc(this.loadOptions,{wms:{throwOnError:!0}}),n=Wu.parseSync?.(r,s);throw new Error(n)}}_parseError(t){let r=Wu.parseSync?.(t,this.loadOptions);return new Error(r)}};var Ba=class extends cr{constructor(t){super(t)}async getMetadata(){throw new Error("ImageSource.getMetadata not implemented")}async getImage(t){let r=this.getGranularParameters(t),i=this.getURLFromTemplate(r),n=await(await this.fetch(i)).arrayBuffer();return await pi.parse(n)}getGranularParameters(t){let[[r,i],[s,n]]=t.boundingBox;return{...t,east:r,north:i,south:n,west:s}}getURLFromTemplate(t){let r=this.props.url;for(let[i,s]of Object.entries(t))r=r.replace(`\${${i}}`,String(s)),r=r.replace(`{${i}}`,String(s));return r}};Y(Ba,"type","template"),Y(Ba,"testURL",t=>t.toLowerCase().includes("{"));var aT=class extends Ba{data;constructor(t){super(t),this.data=t.url}async getMetadata(){return await this.metadata()}async getImage(t){throw new Error("not implemented")}async metadata(){throw new Error("not implemented")}exportImage(t){throw new Error("not implemented")}metadataURL(t){return`${this.props.url}?f=pjson`}exportImageURL(t){let r=`bbox=${t.bbox[0]},${t.bbox[1]},${t.bbox[2]},${t.bbox[3]}`,i=`size=${t.width},${t.height}`,s={...t,bbox:r,size:i};return delete s.width,delete s.height,this.getUrl("exportImage",s)}getUrl(t,r,i){let s=`${this.props.url}/${t}`,n=!0;for(let[o,a]of Object.entries(r))s+=n?"?":"&",n=!1,Array.isArray(a)?s+=`${o.toUpperCase()}=${a.join(",")}`:s+=`${o.toUpperCase()}=${a?String(a):""}`;return s}async checkResponse(t){if(!t.ok)throw new Error("error")}},iI={type:"arcgis-image-server",testURL:e=>e.toLowerCase().includes("ImageServer"),create:e=>new aT(e)};var CW=[rI,iI];function cT(e){return eI(e,CW)}var sI=6378137*Math.PI;function lT(e){let t=Xt(e);return t[0]=(t[0]/256-1)*sI,t[1]=(t[1]/256-1)*sI,t}var wW={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:(e,t)=>console.error(t,e)}},ag=class extends It{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:t,props:r,oldProps:i}){let{viewport:s}=this.context;t.dataChanged||r.serviceType!==i.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(s,"image source changed"),0)):vt(r.layers,i.layers,1)?t.viewportChanged&&this.debounce(()=>this.loadImage(s,"viewport changed")):this.debounce(()=>this.loadImage(s,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:t,image:r,lastRequestParameters:i}=this.state;return r&&new Qn({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:i.srs==="EPSG:4326"?X.LNGLAT:X.CARTESIAN,bounds:t,image:r})}async getFeatureInfoText(t,r){let{lastRequestParameters:i}=this.state;return i?await this.state.imageSource.getFeatureInfoText?.({...i,query_layers:i.layers,x:t,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(t){if(t.data instanceof cr)return t.data;if(typeof t.data=="string")return cT({url:t.data,loadOptions:t.loadOptions,type:t.serviceType});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:t}=this.state;try{this.state.loadCounter++;let r=await t.getMetadata();this.state.imageSource===t&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(t,r){let{layers:i,serviceType:s}=this.props;if(s==="wms"&&i.length===0)return;let n=t.getBounds(),{width:o,height:a}=t,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=t.resolution?"EPSG:4326":"EPSG:3857");let u={width:o,height:a,boundingBox:[[n[0],n[1]],[n[2],n[3]]],layers:i,crs:l};if(l==="EPSG:3857"){let f=lT([n[0],n[1]]),h=lT([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.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:f,bounds:n,lastRequestParameters:u,lastRequestId:c}))}catch(f){this.raiseError(f,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,f)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(t,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>t(),r)}},og=ag;(()=>{ag.layerName="WMSLayer"})(),(()=>{ag.defaultProps=wW})();var PW={getHeight:{type:"accessor",value:0},greatCircle:!0},cg=class extends Zn{},Yu=cg;(()=>{cg.layerName="GreatCircleLayer"})(),(()=>{cg.defaultProps=PW})();var MW={...Qr.defaultProps},lg=class extends It{indexToBounds(){return null}renderLayers(){let{elevationScale:t,extruded:r,wireframe:i,filled:s,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,E=this.getSubLayerClass("cell",Qr),{updateTriggers:P,...B}=this.indexToBounds()||{};return new E({filled:s,wireframe:i,extruded:r,elevationScale:t,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)}},ir=lg;(()=>{lg.layerName="GeoCellLayer"})(),(()=>{lg.defaultProps=MW})();var ug=li(uT(),1),RW=3,IW=30,BW=2*IW+1,oI=180/Math.PI;function cI(e,t,r){let i=1<<t;return[(e[0]+r[0])/i,(e[1]+r[1])/i]}function aI(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function lI(e){return[aI(e[0]),aI(e[1])]}function uI(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function fI([e,t,r]){let i=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*oI,i*oI]}function hI(e){let t=ug.default.fromString(e,!0,10).toString(2);for(;t.length<RW+BW;)t="0"+t;let r=t.lastIndexOf("1"),i=t.substring(0,3),s=t.substring(3,r),n=s.length/2,o=ug.default.fromString(i,!0,2).toString(10),a=ug.default.fromString(s,!0,2).toString(4);for(;a.length<n;)a="0"+a;return`${o}/${a}`}function OW(e,t,r,i){if(i===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function dI(e){let t=e.split("/"),r=parseInt(t[0],10),i=t[1],s=i.length,n=[0,0],o;for(let a=s-1;a>=0;a--){o=s-a;let c=i[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);OW(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 pI=li(uT(),1);function FW(e){let t=e.padEnd(16,"0");return pI.default.fromString(t,16)}var NW=100;function LW({face:e,ij:t,level:r}){let i=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(NW*Math.pow(2,-r))),n=new Float64Array(4*s*2+2),o=0,a=0;for(let c=0;c<4;c++){let l=i[c].slice(0),u=i[c+1],f=(u[0]-l[0])/s,h=(u[1]-l[1])/s;for(let d=0;d<s;d++){l[0]+=f,l[1]+=h;let p=cI(t,r,l),g=lI(p),m=uI(e,g),_=fI(m);Math.abs(_[1])>89.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 DW(e){if(typeof e=="string"){if(e.indexOf("/")>0)return e;e=FW(e)}return hI(e.toString())}function gI(e){let t=DW(e),r=dI(t);return LW(r)}var UW={getS2Token:{type:"accessor",value:e=>e.token}},fg=class extends ir{indexToBounds(){let{data:t,getS2Token:r}=this.props;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(i,s)=>gI(r(i,s))}}},Ku=fg;(()=>{fg.layerName="S2Layer"})(),(()=>{fg.defaultProps=UW})();var fT=512;function kW(e,t){let r=0,i=0,s=1<<e.length,n=s/fT;for(let o=0;o<e.length;o++){s>>=1;let a=parseInt(e[o]);a%2&&(r|=s),a>1&&(i|=s)}return[[r/n,fT-i/n],[(r+t)/n,fT-(i+t)/n]]}function mI(e,t=1){let[r,i]=kW(e,t),[s,n]=_e(r),[o,a]=_e(i);return[o,n,o,a,s,a,s,n,o,n]}var VW={getQuadkey:{type:"accessor",value:e=>e.quadkey}},hg=class extends ir{indexToBounds(){let{data:t,extruded:r,getQuadkey:i}=this.props,s=r?.99:1;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(n,o)=>mI(i(n,o),s),updateTriggers:{getPolygon:s}}}},$u=hg;(()=>{hg.layerName="QuadkeyLayer"})(),(()=>{hg.defaultProps=VW})();var go=class{constructor(t){this.index=t,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(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.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 t=this.content?this.content.byteLength:0;return Number.isFinite(t)||console.error("byteLength not defined in tile data"),t}async _loadData({getData:t,requestScheduler:r,onLoad:i,onError:s}){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 t({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?s(p,this):i(this)}}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};var Yt={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var _I=new w,zW=new w,$s=class{constructor(t=[0,0,0],r=[0,0,0],i){i=i||_I.copy(t).add(r).scale(.5),this.center=new w(i),this.halfDiagonal=new w(r).subtract(this.center),this.minimum=new w(t),this.maximum=new w(r)}clone(){return new $s(this.minimum,this.maximum,this.center)}equals(t){return this===t||Boolean(t)&&this.minimum.equals(t.minimum)&&this.maximum.equals(t.maximum)}transform(t){return this.center.transformAsPoint(t),this.halfDiagonal.transform(t),this.minimum.transform(t),this.maximum.transform(t),this}intersectPlane(t){let{halfDiagonal:r}=this,i=zW.from(t.normal),s=r.x*Math.abs(i.x)+r.y*Math.abs(i.y)+r.z*Math.abs(i.z),n=this.center.dot(i)+t.distance;return n-s>0?Yt.INSIDE:n+s<0?Yt.OUTSIDE:Yt.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let r=_I.from(t).subtract(this.center),{halfDiagonal:i}=this,s=0,n;return n=Math.abs(r.x)-i.x,n>0&&(s+=n*n),n=Math.abs(r.y)-i.y,n>0&&(s+=n*n),n=Math.abs(r.z)-i.z,n>0&&(s+=n*n),s}};var Ju=new w,yI=new w,vr=class{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new w,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=Ju.from(r),this.center=new w().from(t).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new vr(this.center,this.radius)}union(t){let r=this.center,i=this.radius,s=t.center,n=t.radius,o=Ju.copy(s).subtract(r),a=o.magnitude();if(i>=a+n)return this.clone();if(n>=a+i)return t.clone();let c=(i+a+n)*.5;return yI.copy(o).scale((-i+c)/a).add(r),this.center.copy(yI),this.radius=c,this}expand(t){let i=Ju.from(t).subtract(this.center).magnitude();return i>this.radius&&(this.radius=i),this}transform(t){this.center.transform(t);let r=Vt.getScaling(Ju,t);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(t){let r=this.distanceTo(t);return r*r}distanceTo(t){let i=Ju.from(t).subtract(this.center);return Math.max(0,i.len()-this.radius)}intersectPlane(t){let r=this.center,i=this.radius,n=t.normal.dot(r)+t.distance;return n<-i?Yt.OUTSIDE:n<i?Yt.INTERSECTING:Yt.INSIDE}};var HW=new w,GW=new w,dg=new w,pg=new w,gg=new w,WW=new w,jW=new w,is={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},ei=class{constructor(t=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new w().from(t),this.halfAxes=new mt(r)}get halfSize(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2);return[new w(t).len(),new w(r).len(),new w(i).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),s=new w(t).normalize(),n=new w(r).normalize(),o=new w(i).normalize();return new gr().fromMatrix3(new mt([...s,...n,...o]))}fromCenterHalfSizeQuaternion(t,r,i){let s=new gr(i),n=new mt().fromQuaternion(s);return n[0]=n[0]*r[0],n[1]=n[1]*r[0],n[2]=n[2]*r[0],n[3]=n[3]*r[1],n[4]=n[4]*r[1],n[5]=n[5]*r[1],n[6]=n[6]*r[2],n[7]=n[7]*r[2],n[8]=n[8]*r[2],this.center=new w().from(t),this.halfAxes=n,this}clone(){return new ei(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new vr){let r=this.halfAxes,i=r.getColumn(0,dg),s=r.getColumn(1,pg),n=r.getColumn(2,gg),o=HW.copy(i).add(s).add(n);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let r=this.center,i=t.normal,s=this.halfAxes,n=i.x,o=i.y,a=i.z,c=Math.abs(n*s[is.COLUMN0ROW0]+o*s[is.COLUMN0ROW1]+a*s[is.COLUMN0ROW2])+Math.abs(n*s[is.COLUMN1ROW0]+o*s[is.COLUMN1ROW1]+a*s[is.COLUMN1ROW2])+Math.abs(n*s[is.COLUMN2ROW0]+o*s[is.COLUMN2ROW1]+a*s[is.COLUMN2ROW2]),l=i.dot(r)+t.distance;return l<=-c?Yt.OUTSIDE:l>=c?Yt.INSIDE:Yt.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let r=GW.from(t).subtract(this.center),i=this.halfAxes,s=i.getColumn(0,dg),n=i.getColumn(1,pg),o=i.getColumn(2,gg),a=s.magnitude(),c=n.magnitude(),l=o.magnitude();s.normalize(),n.normalize(),o.normalize();let u=0,f;return f=Math.abs(r.dot(s))-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(t,r,i=[-0,-0]){let s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,c=a.getColumn(0,dg),l=a.getColumn(1,pg),u=a.getColumn(2,gg),f=WW.copy(c).add(l).add(u).add(o),h=jW.copy(f).subtract(t),d=r.dot(h);return s=Math.min(d,s),n=Math.max(d,n),f.copy(o).add(c).add(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),f.copy(o).add(c).subtract(l).add(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),f.copy(o).add(c).subtract(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),o.copy(f).subtract(c).add(l).add(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),o.copy(f).subtract(c).add(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),o.copy(f).subtract(c).subtract(l).add(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),o.copy(f).subtract(c).subtract(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),n=Math.max(d,n),i[0]=s,i[1]=n,i}transform(t){this.center.transformAsPoint(t);let r=this.halfAxes.getColumn(0,dg);r.transformAsPoint(t);let i=this.halfAxes.getColumn(1,pg);i.transformAsPoint(t);let s=this.halfAxes.getColumn(2,gg);return s.transformAsPoint(t),this.halfAxes=new mt([...r,...i,...s]),this}getTransform(){throw new Error("not implemented")}};var xI=new w,AI=new w,de=class{constructor(t=[0,0,1],r=0){this.normal=new w,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return fe(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=xI.from(t),this.normal.from(r).normalize();let i=-this.normal.dot(t);return this.distance=i,this}fromCoefficients(t,r,i,s){return this.normal.set(t,r,i),fe(Ct(this.normal.len(),1)),this.distance=s,this}clone(){return new de(this.normal,this.distance)}equals(t){return Ct(this.distance,t.distance)&&Ct(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=AI.copy(this.normal).transformAsVector(t).normalize(),i=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(i,r)}projectPointOntoPlane(t,r=[0,0,0]){let i=xI.from(t),s=this.getPointDistance(i),n=AI.copy(this.normal).scale(s);return i.subtract(n).to(r)}};var TI=[new w([1,0,0]),new w([0,1,0]),new w([0,0,1])],bI=new w,XW=new w,ie=class{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*TI.length;let r=t.center,i=t.radius,s=0;for(let n of TI){let o=this.planes[s],a=this.planes[s+1];o||(o=this.planes[s]=new de),a||(a=this.planes[s+1]=new de);let c=bI.copy(n).scale(-i).add(r);o.fromPointNormal(c,n);let l=bI.copy(n).scale(i).add(r),u=XW.copy(n).negate();a.fromPointNormal(l,u),s+=2}return this}computeVisibility(t){let r=Yt.INSIDE;for(let i of this.planes)switch(t.intersectPlane(i)){case Yt.OUTSIDE:return Yt.OUTSIDE;case Yt.INTERSECTING:r=Yt.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(fe(Number.isFinite(r),"parentPlaneMask is required."),r===ie.MASK_OUTSIDE||r===ie.MASK_INSIDE)return r;let i=ie.MASK_INSIDE,s=this.planes;for(let n=0;n<this.planes.length;++n){let o=n<31?1<<n:0;if(n<31&&!(r&o))continue;let a=s[n],c=t.intersectPlane(a);if(c===Yt.OUTSIDE)return ie.MASK_OUTSIDE;c===Yt.INTERSECTING&&(i|=o)}return i}};ie.MASK_OUTSIDE=4294967295;ie.MASK_INSIDE=0;ie.MASK_INDETERMINATE=2147483647;var CCt=new w,wCt=new w,PCt=new w,MCt=new w,RCt=new w;var LCt=new w,DCt=new w,UCt=new w,kCt=new w,VCt=new w,zCt=new w,HCt=new w,GCt=new w,WCt=new w,jCt=new w,XCt=new w,YCt=new w;var wi=new mt,qW=new mt,KW=new mt,mg=new mt,EI=new mt;function pT(e,t={}){let r=mr.EPSILON20,i=10,s=0,n=0,o=qW,a=KW;o.identity(),a.copy(e);let c=r*$W(a);for(;n<i&&JW(a)>c;)ZW(a,mg),EI.copy(mg).transpose(),a.multiplyRight(mg),a.multiplyLeft(EI),o.multiplyRight(mg),++s>2&&(++n,s=0);return t.unitary=o.toTarget(t.unitary),t.diagonal=a.toTarget(t.diagonal),t}function $W(e){let t=0;for(let r=0;r<9;++r){let i=e[r];t+=i*i}return Math.sqrt(t)}var hT=[1,0,0],dT=[2,2,1];function JW(e){let t=0;for(let r=0;r<3;++r){let i=e[wi.getElementIndex(dT[r],hT[r])];t+=2*i*i}return Math.sqrt(t)}function ZW(e,t){let r=mr.EPSILON15,i=0,s=1;for(let l=0;l<3;++l){let u=Math.abs(e[wi.getElementIndex(dT[l],hT[l])]);u>i&&(s=l,i=u)}let n=hT[s],o=dT[s],a=1,c=0;if(Math.abs(e[wi.getElementIndex(o,n)])>r){let l=e[wi.getElementIndex(o,o)],u=e[wi.getElementIndex(n,n)],f=e[wi.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 mt.IDENTITY.to(t),t[wi.getElementIndex(n,n)]=t[wi.getElementIndex(o,o)]=a,t[wi.getElementIndex(o,n)]=c,t[wi.getElementIndex(n,o)]=-c,t}var Js=new w,QW=new w,tj=new w,ej=new w,rj=new w,ij=new mt,sj={diagonal:new mt,unitary:new mt};function Zu(e,t=new ei){if(!e||e.length===0)return t.halfAxes=new mt([0,0,0,0,0,0,0,0,0]),t.center=new w,t;let r=e.length,i=new w(0,0,0);for(let v of e)i.add(v);let s=1/r;i.multiplyByScalar(s);let n=0,o=0,a=0,c=0,l=0,u=0;for(let v of e){let T=Js.copy(v).subtract(i);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*=s,o*=s,a*=s,c*=s,l*=s,u*=s;let f=ij;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}=pT(f,sj),d=t.halfAxes.copy(h),p=d.getColumn(0,tj),g=d.getColumn(1,ej),m=d.getColumn(2,rj),_=-Number.MAX_VALUE,y=-Number.MAX_VALUE,x=-Number.MAX_VALUE,E=Number.MAX_VALUE,P=Number.MAX_VALUE,B=Number.MAX_VALUE;for(let v of e)Js.copy(v),_=Math.max(Js.dot(p),_),y=Math.max(Js.dot(g),y),x=Math.max(Js.dot(m),x),E=Math.min(Js.dot(p),E),P=Math.min(Js.dot(g),P),B=Math.min(Js.dot(m),B);p=p.multiplyByScalar(.5*(E+_)),g=g.multiplyByScalar(.5*(P+y)),m=m.multiplyByScalar(.5*(B+x)),t.center.copy(p).add(g).add(m);let F=QW.set(_-E,y-P,x-B).multiplyByScalar(.5),M=new mt([F[0],0,0,0,F[1],0,0,0,F[2]]);return t.halfAxes.multiplyRight(M),t}var Oa=512,SI=3,vI=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],CI=vI.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),nj=CI.concat([[.25,.5],[.75,.5]]),Zs=class{constructor(t,r,i){this.x=t,this.y=r,this.z=i}get children(){if(!this._children){let t=this.x*2,r=this.y*2,i=this.z+1;this._children=[new Zs(t,r,i),new Zs(t,r+1,i),new Zs(t+1,r,i),new Zs(t+1,r+1,i)]}return this._children}update(t){let{viewport:r,cullingVolume:i,elevationBounds:s,minZ:n,maxZ:o,bounds:a,offset:c,project:l}=t,u=this.getBoundingVolume(s,c,l);if(a&&!this.insideBounds(a)||i.computeVisibility(u)<0)return!1;if(!this.childVisible){let{z:h}=this;if(h<o&&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(t);return!0}getSelected(t=[]){if(this.selected&&t.push(this),this._children)for(let r of this._children)r.getSelected(t);return t}insideBounds([t,r,i,s]){let n=Math.pow(2,this.z),o=Oa/n;return this.x*o<i&&this.y*o<s&&(this.x+1)*o>t&&(this.y+1)*o>r}getBoundingVolume(t,r,i){if(i){let c=this.z<1?nj:this.z<2?CI:vI,l=[];for(let u of c){let f=_g(this.x+u[0],this.y+u[1],this.z);f[2]=t[0],l.push(i(f)),t[0]!==t[1]&&(f[2]=t[1],l.push(i(f)))}return Zu(l)}let s=Math.pow(2,this.z),n=Oa/s,o=this.x*n+r*Oa,a=Oa-(this.y+1)*n;return new $s([o,a,t[0]],[o+n,a+n,t[1]])}};function wI(e,t,r,i){let s=e instanceof Kr&&e.resolution?e.projectPosition:null,n=Object.values(e.getFrustumPlanes()).map(({normal:d,distance:p})=>new de(d.clone().negate(),p)),o=new ie(n),a=e.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,u=e instanceof ne&&e.pitch<=60?t:0;if(i){let[d,p,g,m]=i,_=Xt([d,m]),y=Xt([g,p]);i=[_[0],Oa-_[1],y[0],Oa-y[1]]}let f=new Zs(0,0,0),h={viewport:e,project:s,cullingVolume:o,elevationBounds:[c,l],minZ:u,maxZ:t,bounds:i,offset:0};if(f.update(h),e instanceof ne&&e.subViewports&&e.subViewports.length>1){for(h.offset=-1;f.update(h)&&!(--h.offset<-SI););for(h.offset=1;f.update(h)&&!(++h.offset>SI););}return f.getSelected()}var ss=512,oj=[-1/0,-1/0,1/0,1/0],Qs={type:"object",value:null,validate:(e,t)=>t.optional&&e===null||typeof e=="string"||Array.isArray(e)&&e.every(r=>typeof r=="string"),equal:(e,t)=>{if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let i=0;i<r;i++)if(e[i]!==t[i])return!1;return!0}};function MI(e,t){let r=[t.transformAsPoint([e[0],e[1]]),t.transformAsPoint([e[2],e[1]]),t.transformAsPoint([e[0],e[3]]),t.transformAsPoint([e[2],e[3]])];return[Math.min(...r.map(s=>s[0])),Math.min(...r.map(s=>s[1])),Math.max(...r.map(s=>s[0])),Math.max(...r.map(s=>s[1]))]}function aj(e){return Math.abs(e.split("").reduce((t,r)=>(t<<5)-t+r.charCodeAt(0)|0,0))}function Pi(e,t){if(!e||!e.length)return null;let{index:r,id:i}=t;if(Array.isArray(e)){let n=aj(i)%e.length;e=e[n]}let s=e;for(let n of Object.keys(r)){let o=new RegExp(`{${n}}`,"g");s=s.replace(o,String(r[n]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(s=s.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),s}function cj(e,t,r){let i;if(t&&t.length===2){let[s,n]=t,o=e.getBounds({z:s}),a=e.getBounds({z:n});i=[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 i=e.getBounds();return e.isGeospatial?[Math.max(i[0],r[0]),Math.max(i[1],r[1]),Math.min(i[2],r[2]),Math.min(i[3],r[3])]:[Math.max(Math.min(i[0],r[2]),r[0]),Math.max(Math.min(i[1],r[3]),r[1]),Math.min(Math.max(i[2],r[0]),r[2]),Math.min(Math.max(i[3],r[1]),r[3])]}function RI({viewport:e,z:t,cullRect:r}){return(e.subViewports||[e]).map(s=>gT(s,t||0,r))}function gT(e,t,r){if(!Array.isArray(t)){let n=r.x-e.x,o=r.y-e.y,{width:a,height:c}=r,l={targetZ:t},u=e.unproject([n,o],l),f=e.unproject([n+a,o],l),h=e.unproject([n,o+c],l),d=e.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 i=gT(e,t[0],r),s=gT(e,t[1],r);return[Math.min(i[0],s[0]),Math.min(i[1],s[1]),Math.max(i[2],s[2]),Math.max(i[3],s[3])]}function lj(e,t,r){return r?MI(e,r).map(s=>s*t/ss):e.map(i=>i*t/ss)}function mT(e,t){return Math.pow(2,e)*ss/t}function _g(e,t,r){let i=mT(r,ss),s=e/i*360-180,n=Math.PI-2*Math.PI*t/i,o=180/Math.PI*Math.atan(.5*(Math.exp(n)-Math.exp(-n)));return[s,o]}function PI(e,t,r,i){let s=mT(r,i);return[e/s*ss,t/s*ss]}function _T(e,t,r,i,s=ss){if(e.isGeospatial){let[l,u]=_g(t,r,i),[f,h]=_g(t+1,r+1,i);return{west:l,north:u,east:f,south:h}}let[n,o]=PI(t,r,i,s),[a,c]=PI(t+1,r+1,i,s);return{left:n,top:o,right:a,bottom:c}}function uj(e,t,r,i,s){let n=cj(e,null,i),o=mT(t,r),[a,c,l,u]=lj(n,o,s),f=[];for(let h=Math.floor(a);h<l;h++)for(let d=Math.floor(c);d<u;d++)f.push({x:h,y:d,z:t});return f}function yT({viewport:e,maxZoom:t,minZoom:r,zRange:i,extent:s,tileSize:n=ss,modelMatrix:o,modelMatrixInverse:a,zoomOffset:c=0}){let l=e.isGeospatial?Math.round(e.zoom+Math.log2(ss/n))+c:Math.ceil(e.zoom)+c;if(typeof r=="number"&&Number.isFinite(r)&&l<r){if(!s)return[];l=r}typeof t=="number"&&Number.isFinite(t)&&l>t&&(l=t);let u=s;return o&&a&&s&&!e.isGeospatial&&(u=MI(s,o)),e.isGeospatial?wI(e,l,i,s):uj(e,l,n,u||oj,a)}function xT(e){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(e)}function AT(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}function II(e){let t={},r;return i=>{for(let s in i)if(!fj(i[s],t[s])){r=e(i),t=i;break}return r}}function fj(e,t){if(e===t)return!0;if(Array.isArray(e)){let r=e.length;if(!t||t.length!==r)return!1;for(let i=0;i<r;i++)if(e[i]!==t[i])return!1;return!0}return!1}var BI=1,yg=2,hj="never",dj="no-overlap",Qu="best-available",pj=5,gj={[Qu]:_j,[dj]:yj,[hj]:()=>{}},mj={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:()=>{}},mo=class{constructor(t){this._getCullBounds=II(RI),this.opts={...mj,...t},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new As({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(t=>t.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(t=>t.needsReload)}setOptions(t){Object.assign(this.opts,t),Number.isFinite(t.maxZoom)&&(this._maxZoom=Math.floor(t.maxZoom)),Number.isFinite(t.minZoom)&&(this._minZoom=Math.ceil(t.minZoom))}finalize(){for(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let t of this._cache.keys()){let r=this._cache.get(t);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(t):r.setNeedsReload()}}update(t,{zRange:r,modelMatrix:i}={zRange:null,modelMatrix:null}){let s=i?new q(i):new q,n=!s.equals(this._modelMatrix);if(!this._viewport||!t.equals(this._viewport)||!Ct(this._zRange,r)||n){n&&(this._modelMatrixInverse=s.clone().invert(),this._modelMatrix=s),this._viewport=t,this._zRange=r;let a=this.getTileIndices({viewport:t,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(t,r){if(!t.isVisible)return!1;if(r&&this._viewport){let i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:s}=t;for(let[n,o,a,c]of i){let l;if("west"in s)l=s.west<a&&s.east>n&&s.south<c&&s.north>o;else{let u=Math.min(s.top,s.bottom),f=Math.max(s.top,s.bottom);l=s.left<a&&s.right>n&&u<c&&f>o}if(l)return!0}return!1}return!0}getTileIndices({viewport:t,maxZoom:r,minZoom:i,zRange:s,modelMatrix:n,modelMatrixInverse:o}){let{tileSize:a,extent:c,zoomOffset:l}=this.opts;return yT({viewport:t,maxZoom:r,minZoom:i,zRange:s,tileSize:a,extent:c,modelMatrix:n,modelMatrixInverse:o,zoomOffset:l})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){let{tileSize:r}=this.opts;return{bbox:_T(this._viewport,t.x,t.y,t.z,r)}}getParentIndex(t){let r=Math.floor(t.x/2),i=Math.floor(t.y/2),s=t.z-1;return{x:r,y:i,z:s}}updateTileStates(){let t=this.opts.refinementStrategy||Qu,r=new Array(this._cache.size),i=0;for(let s of this._cache.values())r[i++]=s.isVisible,s.isSelected=!1,s.isVisible=!1;for(let s of this._selectedTiles)s.isSelected=!0,s.isVisible=!0;(typeof t=="function"?t:gj[t])(Array.from(this._cache.values())),i=0;for(let s of this._cache.values())if(r[i++]!==s.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:t=0}=this.opts,r=[],i=0;for(let s of this._cache.values())s.isLoading&&(i++,!s.isSelected&&!s.isVisible&&r.push(s));for(;t>0&&i>t&&r.length>0;)r.shift().abort(),i--}_rebuildTree(){let{_cache:t}=this;for(let r of t.values())r.parent=null,r.children&&(r.children.length=0);for(let r of t.values()){let i=this._getNearestAncestor(r);r.parent=i,i?.children&&i.children.push(r)}}_resizeCache(){let{_cache:t,opts:r}=this,i=r.maxCacheSize||(r.maxCacheByteSize?1/0:pj*this.selectedTiles.length),s=r.maxCacheByteSize||1/0;if(t.size>i||this._cacheByteSize>s){for(let[o,a]of t)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize?a.byteLength:0,t.delete(o),this.opts.onTileUnload?.(a)),t.size<=i&&this._cacheByteSize<=s)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(t,r){let i=this.getTileId(t),s=this._cache.get(i),n=!1;return!s&&r?(s=new go(t),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:i,zoom:this.getTileZoom(s.index)}),n=!0,this._cache.set(i,s),this._dirty=!0):s&&s.needsReload&&(n=!0),s&&n&&s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),s}_getNearestAncestor(t){let{_minZoom:r=0}=this,i=t.index;for(;this.getTileZoom(i)>r;){i=this.getParentIndex(i);let s=this._getTile(i);if(s)return s}return null}};function _j(e){for(let t of e)t.state=0;for(let t of e)t.isSelected&&!OI(t)&&TT(t);for(let t of e)t.isVisible=Boolean(t.state&yg)}function yj(e){for(let r of e)r.state=0;for(let r of e)r.isSelected&&OI(r);let t=Array.from(e).sort((r,i)=>r.zoom-i.zoom);for(let r of t)if(r.isVisible=Boolean(r.state&yg),r.children&&(r.isVisible||r.state&BI))for(let i of r.children)i.state=BI;else r.isSelected&&TT(r)}function OI(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=yg,!0;t=t.parent}return!1}function TT(e){for(let t of e.children)t.isLoaded||t.content?t.state|=yg:TT(t)}var xj={TilesetClass:mo,data:{type:"data",value:[]},dataComparator:Qs.equal,renderSubLayers:{type:"function",value:e=>new Ci(e)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:e=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:Qu,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},xg=class extends It{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(t=>t.isLoaded&&t.layers&&t.layers.every(r=>r.isLoaded)))}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({changeFlags:t}){let{tileset:r}=this.state,i=t.propsOrDataChanged||t.updateTriggersChanged,s=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getTileData);r?i&&(r.setOptions(this._getTilesetOptions()),s?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:t,maxCacheSize:r,maxCacheByteSize:i,refinementStrategy:s,extent:n,maxZoom:o,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:u}=this.props;return{maxCacheSize:r,maxCacheByteSize:i,maxZoom:o,minZoom:a,tileSize:t,refinementStrategy:s,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 t=this.state.tileset,{zRange:r,modelMatrix:i}=this.props,s=t.update(this.context.viewport,{zRange:r,modelMatrix:i}),{isLoaded:n}=t,o=this.state.isLoaded!==n,a=this.state.frameNumber!==s;n&&(o||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:s}),this.state.isLoaded=n}_onViewportLoad(){let{tileset:t}=this.state,{onViewportLoad:r}=this.props;r&&r(t.selectedTiles)}_onTileLoad(t){this.props.onTileLoad(t),t.layers=null,this.setNeedsUpdate()}_onTileError(t,r){this.props.onTileError(t),r.layers=null,this.setNeedsUpdate()}_onTileUnload(t){this.props.onTileUnload(t)}getTileData(t){let{data:r,getTileData:i,fetch:s}=this.props,{signal:n}=t;return t.url=typeof r=="string"||Array.isArray(r)?Pi(r,t):null,i?i(t):s&&t.url?s(t.url,{propName:"data",layer:this,signal:n}):null}renderSubLayers(t){return this.props.renderSubLayers(t)}getSubLayerPropsByTile(t){return null}getPickingInfo(t){let r=t.sourceLayer,i=r.props.tile,s=t.info;return s.picked&&(s.tile=i),s.sourceTile=i,s.sourceTileSubLayer=r,s}_updateAutoHighlight(t){t.sourceTileSubLayer.updateAutoHighlight(t)}renderLayers(){return this.state.tileset.tiles.map(t=>{let r=this.getSubLayerPropsByTile(t);if(!(!t.isLoaded&&!t.content))if(t.layers)r&&t.layers[0]&&Object.keys(r).some(i=>t.layers[0].props[i]!==r[i])&&(t.layers=t.layers.map(i=>i.clone(r)));else{let i=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:t.id,updateTriggers:this.props.updateTriggers}),data:t.content,_offset:0,tile:t});t.layers=Oe(i,Boolean).map(s=>s.clone({tile:t,...r}))}return t.layers})}filterSubLayer({layer:t,cullRect:r}){let{tile:i}=t.props;return this.state.tileset.isTileVisible(i,r)}},Mi=xg;(()=>{xg.defaultProps=xj})(),(()=>{xg.layerName="TileLayer"})();var Aj={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}},Ag=class extends Jr{getShaders(){let t=super.getShaders();return t.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;
}
`},t}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(t){let{fadeTrail:r,trailLength:i,currentTime:s}=this.props;t.uniforms={...t.uniforms,fadeTrail:r,trailLength:i,currentTime:s},super.draw(t)}},tf=Ag;(()=>{Ag.layerName="TripsLayer"})(),(()=>{Ag.defaultProps=Aj})();var DI=li(ef(),1);var Cr=li(ef(),1);var rf=li(ef(),1);function Tg(e,t){t=t===void 0?e[0][0]:t;for(let r of e){let i=r[0]-t;i>180?r[0]-=360:i<-180&&(r[0]+=360)}}function Tj(e,t,r){let[i,s]=(0,rf.cellToLatLng)(e),n=t.length;Tg(t,s);let o=t[0]===t[n-1]?n-1:n;for(let a=0;a<o;a++)t[a][0]=se(s,t[a][0],r),t[a][1]=se(i,t[a][1],r)}function NI(e,t,r){let i=e(t,r),[s,n]=(0,rf.cellToLatLng)(i);return[n,s]}function bT(e,t=1){let r=(0,rf.cellToBoundary)(e,!0);return t!==1?Tj(e,r,t):Tg(r),r}function LI(e){let t=new Float64Array(e.length*2),r=0;for(let i of e)t[r++]=i[0],t[r++]=i[1];return t}var bj=10;function Ej(e,t){let r;return e==null?r=t:typeof e=="object"?r={...e,coverage:t}:r={getHexagon:e,coverage:t},r}var Sj={...Qr.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0},Fa=class extends It{initializeState(){Fa._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:t}){return this._shouldUseHighPrecision()?t.propsOrDataChanged:t.somethingChanged}updateState({props:t,changeFlags:r}){if(t.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let i=this._calculateH3DataProps();this.setState(i)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let t=-1,r=!1,i=!1,{iterable:s,objectInfo:n}=Ht(this.props.data);for(let o of s){n.index++;let a=this.props.getHexagon(o,n),c=(0,Cr.getResolution)(a);if(t<0){if(t=c,!this.props.highPrecision)break}else if(t!==c){i=!0;break}if((0,Cr.isPentagon)(a)){r=!0;break}}return{resolution:t,edgeLengthKM:t>=0?(0,Cr.getHexagonEdgeLengthAvg)(t,"km"):0,hasMultipleRes:i,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:t,hasPentagon:r,hasMultipleRes:i}=this.state,{viewport:s}=this.context;return Boolean(s?.resolution)||i||r||t>=0&&t<=5}return this.props.highPrecision}_updateVertices(t){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:i,centerHex:s}=this.state;if(r<0)return;let n=this.props.centerHexagon||(0,Cr.latLngToCell)(t.latitude,t.longitude,r);if(s===n)return;if(s)try{if((0,Cr.gridDistance)(s,n)*i<bj)return}catch{}let{unitsPerMeter:o}=t.distanceScales,a=bT(n),[c,l]=(0,Cr.cellToLatLng)(n),[u,f]=t.projectFlat([l,c]);a=a.map(h=>{let d=t.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:t,material:r,coverage:i,extruded:s,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:t,extruded:s,coverage:i,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:t,getHexagon:r,updateTriggers:i,coverage:s}=this.props,n=this.getSubLayerClass("hexagon-cell-hifi",Qr),o=this._getForwardProps();return o.updateTriggers.getPolygon=Ej(i.getHexagon,s),new n(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:t,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return LI(bT(l,s))}})}_renderColumnLayer(){let{data:t,getHexagon:r,updateTriggers:i}=this.props,s=this.getSubLayerClass("hexagon-cell",$r),n=this._getForwardProps();return n.updateTriggers.getPosition=i.getHexagon,new s(n,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:n.updateTriggers}),{data:t,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:NI.bind(null,r)})}},ns=Fa;(()=>{Fa.defaultProps=Sj})(),(()=>{Fa.layerName="H3HexagonLayer"})(),(()=>{Fa._checkH3Lib=()=>{}})();var vj={getHexagons:{type:"accessor",value:e=>e.hexagons}},bg=class extends ir{initializeState(){ns._checkH3Lib()}updateState({props:t,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:i,getHexagons:s}=t,n=[],{iterable:o,objectInfo:a}=Ht(i);for(let c of o){a.index++;let l=s(c,a),u=(0,DI.cellsToMultiPolygon)(l,!0);for(let f of u){for(let h of f)Tg(h);n.push(this.getSubLayerRow({polygon:f},c,a.index))}}this.setState({polygons:n})}}indexToBounds(){let{getElevation:t,getFillColor:r,getLineColor:i,getLineWidth:s}=this.props;return{data:this.state.polygons,getPolygon:n=>n.polygon,getElevation:this.getSubLayerAccessor(t),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(i),getLineWidth:this.getSubLayerAccessor(s)}}},sf=bg;(()=>{bg.layerName="H3ClusterLayer"})(),(()=>{bg.defaultProps=vj})();var ET=Math.PI/180,Eg=new Float32Array(16),UI=new Float32Array(12);function kI(e,t,r){let i=t[0]*ET,s=t[1]*ET,n=t[2]*ET,o=Math.sin(n),a=Math.sin(i),c=Math.sin(s),l=Math.cos(n),u=Math.cos(i),f=Math.cos(s),h=r[0],d=r[1],p=r[2];e[0]=h*f*u,e[1]=h*c*u,e[2]=h*-a,e[3]=d*(-c*l+f*a*o),e[4]=d*(f*l+c*a*o),e[5]=d*u*o,e[6]=p*(c*o+f*a*l),e[7]=p*(-f*o+c*a*l),e[8]=p*u*l}function VI(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}var Sg={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(e,{startRow:t,endRow:r}){let{data:i,getOrientation:s,getScale:n,getTranslation:o,getTransformMatrix:a}=this.props,c=Array.isArray(a),l=c&&a.length===16,u=Array.isArray(n),f=Array.isArray(s),h=Array.isArray(o),d=l||!c&&Boolean(a(i[0]));d?e.constant=l:e.constant=f&&u&&h;let p=e.value;if(e.constant){let g;d?(Eg.set(a),g=VI(Eg)):(g=UI,kI(g,s,n),g.set(o,9)),e.value=new Float32Array(g)}else{let g=t*e.size,{iterable:m,objectInfo:_}=Ht(i,t,r);for(let y of m){_.index++;let x;if(d)Eg.set(l?a:a(y,_)),x=VI(Eg);else{x=UI;let E=f?s:s(y,_),P=u?n:n(y,_);kI(x,E,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 vg(e,t){return t===X.CARTESIAN||t===X.METER_OFFSETS||t===X.DEFAULT&&!e.isGeospatial}var zI=`#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 HI=`#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(e){let t=e.positions||e.POSITION;k.assert(t,'no "postions" or "POSITION" attribute in mesh');let r=t.value.length/t.size,i=e.COLOR_0||e.colors;i||(i={size:3,value:new Float32Array(r*3).fill(1)});let s=e.NORMAL||e.normals;s||(s={size:3,value:new Float32Array(r*3).fill(0)});let n=e.TEXCOORD_0||e.texCoords;return n||(n={size:2,value:new Float32Array(r*2).fill(0)}),{positions:t,colors:i,normals:s,texCoords:n}}function GI(e){return e instanceof it?(e.attributes=ST(e.attributes),e):e.attributes?new it({...e,topology:"triangle-list",attributes:ST(e.attributes)}):new it({topology:"triangle-list",attributes:ST(e)})}var Cj=[0,0,0,255],wj={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:e=>e.position},getColor:{type:"accessor",value:Cj},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}},Cg=class extends lt{getShaders(){return super.getShaders({vs:zI,fs:HI,modules:[dt,Ns,_t]})}getBounds(){if(this.props._instanced)return super.getBounds();let t=this.state.positionBounds;if(t)return t;let{mesh:r}=this.props;if(!r)return null;if(t=r.header?.boundingBox,!t){let{attributes:i}=GI(r);i.POSITION=i.POSITION||i.positions,t=Ui(i)}return this.state.positionBounds=t,t}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:Sg}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(t){super.updateState(t);let{props:r,oldProps:i,changeFlags:s}=t;if(r.mesh!==i.mesh||s.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!==i.texture&&r.texture instanceof xt&&this.setTexture(r.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(t){super.finalizeState(t),this.state.emptyTexture.delete()}draw({uniforms:t}){let{model:r}=this.state;if(!r)return;let{viewport:i,renderPass:s}=this.context,{sizeScale:n,coordinateSystem:o,_instanced:a}=this.props;r.setUniforms(t),r.setUniforms({sizeScale:n,composeModelMatrix:!a||vg(i,o),flatShading:!this.state.hasNormals}),r.draw(s)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(t){let r=new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:GI(t),isInstanced:!0}),{texture:i}=this.props,{emptyTexture:s}=this.state;return r.setBindings({sampler:i||s}),r.setUniforms({hasTexture:Boolean(i)}),r}setTexture(t){let{emptyTexture:r,model:i}=this.state;i&&(i.setBindings({sampler:t||r}),i.setUniforms({hasTexture:Boolean(t)}))}},Ri=Cg;(()=>{Cg.defaultProps=wj})(),(()=>{Cg.layerName="SimpleMeshLayer"})();var ri;(function(e){e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.LINEAR=9729]="LINEAR",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(ri||(ri={}));function of(e,t,r,i){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:n}=i;return n&&(s.bindings.u_DiffuseEnvSampler=n.diffuseEnvSampler,s.bindings.u_SpecularEnvSampler=n.specularEnvSampler,s.bindings.u_brdfLUT=n.brdfLutTexture,s.uniforms.u_ScaleIBLAmbient=[1,1]),i?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],s.uniforms.u_ScaleFGDSpec=[0,0,0,0]),r.NORMAL&&(s.defines.HAS_NORMALS=1),r.TANGENT&&i?.useTangents&&(s.defines.HAS_TANGENTS=1),r.TEXCOORD_0&&(s.defines.HAS_UV=1),i?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=1),i?.lights&&(s.defines.USE_LIGHTS=1),t&&Pj(e,t,s),s}function Pj(e,t,r){if(r.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Mj(e,t.pbrMetallicRoughness,r),t.normalTexture){nf(e,t.normalTexture,"u_NormalSampler","HAS_NORMALMAP",r);let{scale:i=1}=t.normalTexture;r.uniforms.u_NormalScale=i}if(t.occlusionTexture){nf(e,t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",r);let{strength:i=1}=t.occlusionTexture;r.uniforms.u_OcclusionStrength=i}switch(t.emissiveTexture&&(nf(e,t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",r),r.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:i=.5}=t;r.defines.ALPHA_CUTOFF=1,r.uniforms.u_AlphaCutoff=i;break;case"BLEND":D.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=ri.FUNC_ADD,r.glParameters.blendFunc=[ri.SRC_ALPHA,ri.ONE_MINUS_SRC_ALPHA,ri.ONE,ri.ONE_MINUS_SRC_ALPHA];break}}function Mj(e,t,r){t.baseColorTexture&&nf(e,t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",r),r.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&nf(e,t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",r);let{metallicFactor:i=1,roughnessFactor:s=1}=t;r.uniforms.u_MetallicRoughnessValues=[i,s]}function nf(e,t,r,i=null,s){let n=t?.texture?.sampler?.parameters||{},o=t.texture.source.image,a,c={};o.compressed?(a=o,c={[ri.TEXTURE_MIN_FILTER]:o.data.length>1?ri.LINEAR_MIPMAP_NEAREST:ri.LINEAR}):a={data:o};let l=e.createTexture({id:t.uniformName||t.id,parameters:{...n,...c},pixelStore:{[ri.UNPACK_FLIP_Y_WEBGL]:!1},...a});s.bindings[r]=l,i&&(s.defines[i]=1),s.generatedTextures.push(l)}var WI="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"},jI;async function CT(e){k_(e.modules);let t=V_("basis");return t||(jI||=Rj(e),await jI)}async function Rj(e){let t=null,r=null;return[t,r]=await Promise.all([await hi(wg.TRANSCODER,"textures",e),await hi(wg.TRANSCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await Ij(t,r)}function Ij(e,t){let r={};return t&&(r.wasmBinary=t),new Promise(i=>{e(r).then(s=>{let{BasisFile:n,initializeBasis:o}=s;o(),i({BasisFile:n})})})}var vT;async function wT(e){let t=e.modules||{};return t.basisEncoder?t.basisEncoder:(vT=vT||Bj(e),await vT)}async function Bj(e){let t=null,r=null;return[t,r]=await Promise.all([await hi(wg.ENCODER,"textures",e),await hi(wg.ENCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await Oj(t,r)}function Oj(e,t){let r={};return t&&(r.wasmBinary=t),new Promise(i=>{e(r).then(s=>{let{BasisFile:n,KTX2File:o,initializeBasis:a,BasisEncoder:c}=s;a(),i({BasisFile:n,KTX2File:o,BasisEncoder:c})})})}var _o={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 Fj=["","WEBKIT_","MOZ_"],XI={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 YI(e){if(!Pg){e=e||Nj()||void 0,Pg=new Set;for(let t of Fj)for(let r in XI)if(e&&e.getExtension(`${t}${r}`)){let i=XI[r];Pg.add(i)}}return Pg}function Nj(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var APt=new Uint8Array([0]);var qI,KI,$I,JI,ZI,QI,t2,e2;(function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"})(qI||(qI={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(KI||(KI={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}($I||($I={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(JI||(JI={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(ZI||(ZI={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(QI||(QI={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(t2||(t2={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(e2||(e2={}));var sr=[171,75,84,88,32,50,48,187,13,10,26,10];function r2(e){let t=new Uint8Array(e);return!(t.byteLength<sr.length||t[0]!==sr[0]||t[1]!==sr[1]||t[2]!==sr[2]||t[3]!==sr[3]||t[4]!==sr[4]||t[5]!==sr[5]||t[6]!==sr[6]||t[7]!==sr[7]||t[8]!==sr[8]||t[9]!==sr[9]||t[10]!==sr[10]||t[11]!==sr[11])}var Lj={etc1:{basisFormat:0,compressed:!0,format:_o.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:_o.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:_o.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:_o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:_o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:_o.COMPRESSED_RGBA_ASTC_4X4_KHR},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};async function MT(e,t){if(t.basis.containerFormat==="auto"){if(r2(e)){let i=await wT(t);return i2(i.KTX2File,e,t)}let{BasisFile:r}=await CT(t);return PT(r,e,t)}switch(t.basis.module){case"encoder":let r=await wT(t);switch(t.basis.containerFormat){case"ktx2":return i2(r.KTX2File,e,t);case"basis":default:return PT(r.BasisFile,e,t)}case"transcoder":default:let{BasisFile:i}=await CT(t);return PT(i,e,t)}}function PT(e,t,r){let i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("Failed to start basis transcoding");let s=i.getNumImages(),n=[];for(let o=0;o<s;o++){let a=i.getNumLevels(o),c=[];for(let l=0;l<a;l++)c.push(Dj(i,o,l,r));n.push(c)}return n}finally{i.close(),i.delete()}}function Dj(e,t,r,i){let s=e.getImageWidth(t,r),n=e.getImageHeight(t,r),o=e.getHasAlpha(),{compressed:a,format:c,basisFormat:l}=s2(i,o),u=e.getImageTranscodedSizeInBytes(t,r,l),f=new Uint8Array(u);if(!e.transcodeImage(f,t,r,l,0,0))throw new Error("failed to start Basis transcoding");return{width:s,height:n,data:f,compressed:a,format:c,hasAlpha:o}}function i2(e,t,r){let i=new e(new Uint8Array(t));try{if(!i.startTranscoding())throw new Error("failed to start KTX2 transcoding");let s=i.getLevels(),n=[];for(let o=0;o<s;o++){n.push(Uj(i,o,r));break}return[n]}finally{i.close(),i.delete()}}function Uj(e,t,r){let{alphaFlag:i,height:s,width:n}=e.getImageLevelInfo(t,0,0),{compressed:o,format:a,basisFormat:c}=s2(r,i),l=e.getImageTranscodedSizeInBytes(t,0,0,c),u=new Uint8Array(l);if(!e.transcodeImage(u,t,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:n,height:s,data:u,compressed:o,levelSize:l,hasAlpha:i,format:a}}function s2(e,t){let r=e&&e.basis&&e.basis.format;return r==="auto"&&(r=Mg()),typeof r=="object"&&(r=t?r.alpha:r.noAlpha),r=r.toLowerCase(),Lj[r]}function Mg(){let e=YI();return e.has("astc")?"astc-4x4":e.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:e.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:e.has("etc1")?"etc1":e.has("etc2")?"etc2":"rgb565"}var n2={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:WI,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},RT={...n2,parse:MT};var kj={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vj={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},BT=class{name;startTime=0;playing=!0;speed=1;channels=[];constructor(t){Object.assign(this,t)}animate(t){if(!this.playing)return;let i=(t/1e3-this.startTime)*this.speed;this.channels.forEach(({sampler:s,target:n,path:o})=>{Xj(i,s,n,o),Hj(n,n._node)})}},Rg=class{animations;constructor(t){this.animations=t.animations.map((r,i)=>{let s=r.name||`Animation-${i}`,n=r.samplers.map(({input:a,interpolation:c="LINEAR",output:l})=>({input:o2(t.accessors[a]),interpolation:c,output:o2(t.accessors[l])})),o=r.channels.map(({sampler:a,target:c})=>({sampler:n[a],target:t.nodes[c.node],path:c.path}));return new BT({name:s,channels:o})})}animate(t){this.setTime(t)}setTime(t){this.animations.forEach(r=>r.animate(t))}getAnimations(){return this.animations}};function o2(e){if(!e._animation){let t=Vj[e.componentType],r=kj[e.type],i=r*e.count,{buffer:s,byteOffset:n}=e.bufferView.data,o=new t(s,n+(e.byteOffset||0),i);if(r===1)e._animation=Array.from(o);else{let a=[];for(let c=0;c<o.length;c+=r)a.push(Array.from(o.slice(c,c+r)));e._animation=a}}return e._animation}var zj=new q;function Hj(e,t){if(t.matrix.identity(),e.translation&&t.matrix.translate(e.translation),e.rotation){let r=zj.fromQuaternion(e.rotation);t.matrix.multiplyRight(r)}e.scale&&t.matrix.scale(e.scale)}var IT=new gr;function Gj(e,t,r,i,s){if(t==="rotation"){IT.slerp({start:r,target:i,ratio:s});for(let n=0;n<IT.length;n++)e[t][n]=IT[n]}else for(let n=0;n<r.length;n++)e[t][n]=s*i[n]+(1-s)*r[n]}function Wj(e,t,{p0:r,outTangent0:i,inTangent1:s,p1:n,tDiff:o,ratio:a}){for(let c=0;c<e[t].length;c++){let l=i[c]*o,u=s[c]*o;e[t][c]=(2*Math.pow(a,3)-3*Math.pow(a,2)+1)*r[c]+(Math.pow(a,3)-2*Math.pow(a,2)+a)*l+(-2*Math.pow(a,3)+3*Math.pow(a,2))*n[c]+(Math.pow(a,3)-Math.pow(a,2))*u}}function jj(e,t,r){for(let i=0;i<r.length;i++)e[t][i]=r[i]}function Xj(e,{input:t,interpolation:r,output:i},s,n){let o=t[t.length-1],a=e%o,c=t.findIndex(h=>h>=a),l=Math.max(0,c-1);if(!Array.isArray(s[n]))switch(n){case"translation":s[n]=[0,0,0];break;case"rotation":s[n]=[0,0,0,1];break;case"scale":s[n]=[1,1,1];break;default:D.warn(`Bad animation path ${n}`)()}tt(s[n].length===i[l].length);let u=t[l],f=t[c];switch(r){case"STEP":jj(s,n,i[l]);break;case"LINEAR":if(f>u){let h=(a-u)/(f-u);Gj(s,n,i[l],i[c],h)}break;case"CUBICSPLINE":if(f>u){let h=(a-u)/(f-u),d=f-u,p=i[3*l+1],g=i[3*l+2],m=i[3*c+0],_=i[3*c+1];Wj(s,n,{p0:p,outTangent0:g,inTangent1:m,p1:_,tDiff:d,ratio:h})}break;default:D.warn(`Interpolation ${r} not supported`)();break}}var Yj=`
#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 c2(e,t){let{id:r,geometry:i,material:s,vertexCount:n,materialOptions:o,modelOptions:a}=t,c=of(e,s,i.attributes,o);D.info(4,"createGLTFModel defines: ",c.defines)();let l=[],u={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},f={id:r,geometry:i,topology:i.topology,vertexCount:n,modules:[Cn],vs:a2(e,Yj),fs:a2(e,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(e,f);return new xi({managedResources:l,model:h})}function a2(e,t){return`#version 300 es
${t}`}var Kj={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},Ig=class{device;options;gltf;constructor(t,r={}){this.device=t,this.options={...Kj,...r}}instantiate(t){return this.gltf=t,(t.scenes||[]).map(i=>this.createScene(i))}createAnimator(){return Array.isArray(this.gltf.animations)?new Rg(this.gltf):null}createScene(t){let i=(t.nodes||[]).map(n=>this.createNode(n));return new er({id:t.name||t.id,children:i})}createNode(t){if(!t._node){let i=(t.children||[]).map(n=>this.createNode(n));t.mesh&&i.push(this.createMesh(t.mesh));let s=new er({id:t.name||t.id,children:i});if(t.matrix)s.setMatrix(t.matrix);else{if(s.matrix.identity(),t.translation&&s.matrix.translate(t.translation),t.rotation){let n=new q().fromQuaternion(t.rotation);s.matrix.multiplyRight(n)}t.scale&&s.matrix.scale(t.scale)}t._node=s}return t._node}createMesh(t){if(!t._mesh){let i=(t.primitives||[]).map((n,o)=>this.createPrimitive(n,o,t)),s=new er({id:t.name||t.id,children:i});t._mesh=s}return t._mesh}createPrimitive(t,r,i){let s=t.name||`${i.name||i.id}-primitive-${r}`,n=$j(t.mode||4),o=t.indices?t.indices.count:this.getVertexCount(t.attributes),a=c2(this.device,{id:s,geometry:this.createGeometry(s,t,n),material:t.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});return a.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],a}getVertexCount(t){throw new Error("getVertexCount not implemented")}createGeometry(t,r,i){let s={};for(let[n,o]of Object.entries(r.attributes)){let{components:a,size:c,value:l}=o;s[n]={size:c??a,value:l}}return new it({id:t,topology:i,indices:r.indices.value,attributes:s})}createBuffer(t,r){t.bufferView||(t.bufferView={});let{bufferView:i}=t;return i.lumaBuffers||(i.lumaBuffers={}),i.lumaBuffers[r]||(i.lumaBuffers[r]=this.device.createBuffer({id:`from-${i.id}`,data:i.data||t.value})),i.lumaBuffers[r]}createSampler(t){return t}needsPOT(){return!1}},os;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(os||(os={}));function $j(e){switch(e){case os.POINTS:return"point-list";case os.LINES:return"line-list";case os.LINE_STRIP:return"line-strip";case os.LINE_LOOP:return"line-loop-webgl";case os.TRIANGLES:return"triangle-list";case os.TRIANGLE_STRIP:return"triangle-strip";case os.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(e)}}function OT(e,t,r){let i=new Ig(e,r),s=i.instantiate(t),n=i.createAnimator();return{scenes:s,animator:n}}var FT={};$t(FT,{decode:()=>cX,name:()=>aX});function oe(e,t){if(!e)throw new Error(t||"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 Jj=1.33,l2=["SCALAR","VEC2","VEC3","VEC4"],Zj=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Qj=new Map(Zj),tX={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eX={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},rX={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Fg(e){return l2[e-1]||l2[0]}function Na(e){let t=Qj.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function La(e,t){let r=rX[e.componentType],i=tX[e.type],s=eX[e.componentType],n=e.count*i,o=e.count*i*s;oe(o>=0&&o<=t.byteLength);let a=Og[e.componentType],c=Bg[e.type];return{ArrayType:r,length:n,byteLength:o,componentByteSize:a,numberOfComponentsInElement:c}}function af(e){let{images:t,bufferViews:r}=e;t=t||[],r=r||[];let i=t.map(o=>o.bufferView);r=r.filter(o=>!i.includes(o));let s=r.reduce((o,a)=>o+a.byteLength,0),n=t.reduce((o,a)=>{let{width:c,height:l}=a.image;return o+c*l},0);return s+Math.ceil(4*n*Jj)}function u2(e,t,r){let i=e.bufferViews[r];oe(i);let s=i.buffer,n=t[s];oe(n);let o=(i.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,i.byteLength)}function f2(e,t,r){let i=typeof r=="number"?e.accessors?.[r]:r;if(!i)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let s=e.bufferViews?.[i.bufferView||0];if(!s)throw new Error(`No gltf buffer view for accessor ${s}`);let{arrayBuffer:n,byteOffset:o}=t[s.buffer],a=(o||0)+(i.byteOffset||0)+(s.byteOffset||0),{ArrayType:c,length:l,componentByteSize:u,numberOfComponentsInElement:f}=La(i,s),h=u*f,d=s.byteStride||h;if(typeof s.byteStride>"u"||s.byteStride===h)return new c(n,a,l);let p=new c(l);for(let g=0;g<i.count;g++){let m=new c(n,a+g*d,f);p.set(m,g*f)}return p}function iX(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var Tt=class{gltf;sourceBuffers;byteLength;constructor(t){this.gltf={json:t?.json||iX(),buffers:t?.buffers||[],images:t?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(t){return this.json[t]}getExtraData(t){return(this.json.extras||{})[t]}hasExtension(t){let r=this.getUsedExtensions().find(s=>s===t),i=this.getRequiredExtensions().find(s=>s===t);return typeof r=="string"||typeof i=="string"}getExtension(t){let r=this.getUsedExtensions().find(s=>s===t),i=this.json.extensions||{};return r?i[t]:null}getRequiredExtension(t){return this.getRequiredExtensions().find(i=>i===t)?this.getExtension(t):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(t,r){return(t.extensions||{})[r]}getScene(t){return this.getObject("scenes",t)}getNode(t){return this.getObject("nodes",t)}getSkin(t){return this.getObject("skins",t)}getMesh(t){return this.getObject("meshes",t)}getMaterial(t){return this.getObject("materials",t)}getAccessor(t){return this.getObject("accessors",t)}getTexture(t){return this.getObject("textures",t)}getSampler(t){return this.getObject("samplers",t)}getImage(t){return this.getObject("images",t)}getBufferView(t){return this.getObject("bufferViews",t)}getBuffer(t){return this.getObject("buffers",t)}getObject(t,r){if(typeof r=="object")return r;let i=this.json[t]&&this.json[t][r];if(!i)throw new Error(`glTF file error: Could not find ${t}[${r}]`);return i}getTypedArrayForBufferView(t){t=this.getBufferView(t);let r=t.buffer,i=this.gltf.buffers[r];oe(i);let s=(t.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,t.byteLength)}getTypedArrayForAccessor(t){let r=this.getAccessor(t);return f2(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(t){t=this.getAccessor(t);let r=this.getBufferView(t.bufferView),s=this.getBuffer(r.buffer).data,n=r.byteOffset||0;return new Uint8Array(s,n,r.byteLength)}addApplicationData(t,r){return this.json[t]=r,this}addExtraData(t,r){return this.json.extras=this.json.extras||{},this.json.extras[t]=r,this}addObjectExtension(t,r,i){return t.extensions=t.extensions||{},t.extensions[r]=i,this.registerUsedExtension(r),this}setObjectExtension(t,r,i){let s=t.extensions||{};s[r]=i}removeObjectExtension(t,r){let i=t?.extensions||{};if(i[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let s=this.json.extensionsRemoved;s.includes(r)||s.push(r)}delete i[r]}addExtension(t,r={}){return oe(r),this.json.extensions=this.json.extensions||{},this.json.extensions[t]=r,this.registerUsedExtension(t),r}addRequiredExtension(t,r={}){return oe(r),this.addExtension(t,r),this.registerRequiredExtension(t),r}registerUsedExtension(t){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===t)||this.json.extensionsUsed.push(t)}registerRequiredExtension(t){this.registerUsedExtension(t),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===t)||this.json.extensionsRequired.push(t)}removeExtension(t){if(this.json.extensions?.[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(t)||r.push(t)}this.json.extensions&&delete this.json.extensions[t],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,t),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,t)}setDefaultScene(t){this.json.scene=t}addScene(t){let{nodeIndices:r}=t;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(t){let{meshIndex:r,matrix:i}=t;this.json.nodes=this.json.nodes||[];let s={mesh:r};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(t){let{attributes:r,indices:i,material:s,mode:n=4}=t,a={primitives:[{attributes:this._addAttributes(r),mode:n}]};if(i){let c=this._addIndices(i);a.primitives[0].indices=c}return Number.isFinite(s)&&(a.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(t){let i={primitives:[{attributes:this._addAttributes(t),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(i),this.json.meshes.length-1}addImage(t,r){let i=yn(t),s=r||i?.mimeType,o={bufferView:this.addBufferView(t),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(o),this.json.images.length-1}addBufferView(t,r=0,i=this.byteLength){let s=t.byteLength;oe(Number.isFinite(s)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(t);let n={buffer:r,byteOffset:i,byteLength:s};return this.byteLength+=xs(s,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(t,r){let i={bufferView:t,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(i),this.json.accessors.length-1}addBinaryBuffer(t,r={size:3}){let i=this.addBufferView(t),s={min:r.min,max:r.max};(!s.min||!s.max)&&(s=this._getAccessorMinMax(t,r.size));let n={size:r.size,componentType:Na(t),count:Math.round(t.length/r.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(n,r))}addTexture(t){let{imageIndex:r}=t,i={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(t){return this.json.materials=this.json.materials||[],this.json.materials.push(t),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];let t=this.byteLength,r=new ArrayBuffer(t),i=new Uint8Array(r),s=0;for(let n of this.sourceBuffers||[])s=Z_(n,i,s);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=t:this.json.buffers=[{byteLength:t}],this.gltf.binary=r,this.sourceBuffers=[r]}_removeStringFromArray(t,r){let i=!0;for(;i;){let s=t.indexOf(r);s>-1?t.splice(s,1):i=!1}}_addAttributes(t={}){let r={};for(let i in t){let s=t[i],n=this._getGltfAttributeName(i),o=this.addBinaryBuffer(s.value,s);r[n]=o}return r}_addIndices(t){return this.addBinaryBuffer(t,{size:1})}_getGltfAttributeName(t){switch(t.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 t}}_getAccessorMinMax(t,r){let i={min:null,max:null};if(t.length<r)return i;i.min=[],i.max=[];let s=t.subarray(0,r);for(let n of s)i.min.push(n),i.max.push(n);for(let n=r;n<t.length;n+=r)for(let o=0;o<r;o++)i.min[0+o]=Math.min(i.min[0+o],t[n+o]),i.max[0+o]=Math.max(i.max[0+o],t[n+o]);return i}};function h2(e){return(e%1+1)%1}var d2={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},sX={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},p2={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function cf(e,t){return p2[t]*d2[e]}function Da(e,t,r,i){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let s=e.getTypedArrayForBufferView(t),n=Ua(s,"SCALAR",r,i+1);return n instanceof BigInt64Array||n instanceof BigUint64Array?null:n}function Ua(e,t,r,i=1){let s=d2[t],n=sX[r],o=p2[r],a=i*s,c=a*o,l=e.buffer,u=e.byteOffset;return u%o!==0&&(l=new Uint8Array(l).slice(u,u+c).buffer,u=0),new n(l,u,a)}function ka(e,t,r){let i=`TEXCOORD_${t.texCoord||0}`,s=r.attributes[i],n=e.getTypedArrayForAccessor(s),o=e.gltf.json,a=t.index,c=o.textures?.[a]?.source;if(typeof c<"u"){let l=o.images?.[c]?.mimeType,u=e.gltf.images?.[c];if(u&&typeof u.width<"u"){let f=[];for(let h=0;h<n.length;h+=2){let d=nX(u,l,n,h,t.channels);f.push(d)}return f}}return[]}function Ng(e,t,r,i,s){if(!r?.length)return;let n=[];for(let u of r){let f=i.findIndex(h=>h===u);f===-1&&(f=i.push(u)-1),n.push(f)}let o=new Uint32Array(n),a=e.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,c=e.addBufferView(o,a,0),l=e.addAccessor(c,{size:1,componentType:Na(o),count:o.length});s.attributes[t]=l}function nX(e,t,r,i,s=[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[i],a=r[i+1],c=1;t&&(t.indexOf("image/jpeg")!==-1||t.indexOf("image/png")!==-1)&&(c=4);let l=oX(o,a,e,c),u=0;for(let f of s){let h=typeof f=="number"?Object.values(n)[f]:n[f],d=l+h.offset,p=jc(e);if(p.data.length<=d)throw new Error(`${p.data.length} <= ${d}`);let g=p.data[d];u|=g<<h.shift}return u}function oX(e,t,r,i=1){let s=r.width,n=h2(e)*(s-1),o=Math.round(n),a=r.height,c=h2(t)*(a-1),l=Math.round(c),u=r.components?r.components:i;return(l*s+o)*u}function Lg(e,t,r,i,s){let n=[];for(let o=0;o<t;o++){let a=r[o],c=r[o+1]-r[o];if(c+a>i)break;let l=a/s,u=c/s;n.push(e.slice(l,l+u))}return n}function Dg(e,t,r){let i=[];for(let s=0;s<t;s++){let n=s*r;i.push(e.slice(n,n+r))}return i}function Ug(e,t,r,i){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(i){let s=[],n=new TextDecoder("utf8"),o=0;for(let a=0;a<e;a++){let c=i[a+1]-i[a];if(c+o<=t.length){let l=t.subarray(o,c+o),u=n.decode(l);s.push(u),o+=c}}return s}return[]}var g2="EXT_mesh_features",aX=g2;async function cX(e,t){let r=new Tt(e);lX(r,t)}function lX(e,t){let r=e.gltf.json;if(r.meshes)for(let i of r.meshes)for(let s of i.primitives)uX(e,s,t)}function uX(e,t,r){if(!r?.gltf?.loadBuffers)return;let s=t.extensions?.[g2]?.featureIds;if(s)for(let n of s){let o;if(typeof n.attribute<"u"){let a=`_FEATURE_ID_${n.attribute}`,c=t.attributes[a];o=e.getTypedArrayForAccessor(c)}else typeof n.texture<"u"&&r?.gltf?.loadImages?o=ka(e,n.texture,t):o=[];n.data=o}}var DT={};$t(DT,{decode:()=>hX,name:()=>fX});var NT="EXT_structural_metadata",fX=NT;async function hX(e,t){let r=new Tt(e);dX(r,t)}function dX(e,t){if(!t.gltf?.loadBuffers)return;let r=e.getExtension(NT);r&&(t.gltf?.loadImages&&pX(e,r),gX(e,r))}function pX(e,t){let r=t.propertyTextures,i=e.gltf.json;if(r&&i.meshes)for(let s of i.meshes)for(let n of s.primitives)_X(e,r,n,t)}function gX(e,t){let r=t.schema;if(!r)return;let i=r.classes,s=t.propertyTables;if(i&&s)for(let n in i){let o=mX(s,n);o&&xX(e,r,o)}}function mX(e,t){for(let r of e)if(r.class===t)return r;return null}function _X(e,t,r,i){if(!t)return;let n=r.extensions?.[NT]?.propertyTextures;if(n)for(let o of n){let a=t[o];yX(e,a,r,i)}}function yX(e,t,r,i){if(!t.properties)return;i.dataAttributeNames||(i.dataAttributeNames=[]);let s=t.class;for(let n in t.properties){let o=`${s}_${n}`,a=t.properties?.[n];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=ka(e,a,r);l!==null&&(Ng(e,o,l,c,r),a.data=c,i.dataAttributeNames.push(o))}}function xX(e,t,r){let i=t.classes?.[r.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let s=r.count;for(let n in i.properties){let o=i.properties[n],a=r.properties?.[n];if(a){let c=AX(e,t,o,s,a);a.data=c}}}function AX(e,t,r,i,s){let n=[],o=s.values,a=e.getTypedArrayForBufferView(o),c=TX(e,r,s,i),l=bX(e,s,i);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{n=EX(r,i,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{n=Ug(i,a,c,l);break}case"ENUM":{n=SX(t,r,i,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return n}function TX(e,t,r,i){return t.array&&typeof t.count>"u"&&typeof r.arrayOffsets<"u"?Da(e,r.arrayOffsets,r.arrayOffsetType||"UINT32",i):null}function bX(e,t,r){return typeof t.stringOffsets<"u"?Da(e,t.stringOffsets,t.stringOffsetType||"UINT32",r):null}function EX(e,t,r,i){let s=e.array,n=e.count,o=cf(e.type,e.componentType),a=r.byteLength/o,c;return e.componentType?c=Ua(r,e.type,e.componentType,a):c=r,s?i?Lg(c,t,i,r.length,o):n?Dg(c,t,n):[]:c}function SX(e,t,r,i,s){let n=t.enumType;if(!n)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let o=e.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=cf(t.type,a),l=i.byteLength/c,u=Ua(i,t.type,a,l);if(u||(u=i),t.array){if(s)return vX({valuesData:u,numberOfElements:r,arrayOffsets:s,valuesDataBytesLength:i.length,elementSize:c,enumEntry:o});let f=t.count;return f?CX(u,r,f,o):[]}return LT(u,0,r,o)}function vX(e){let{valuesData:t,numberOfElements:r,arrayOffsets:i,valuesDataBytesLength:s,elementSize:n,enumEntry:o}=e,a=[];for(let c=0;c<r;c++){let l=i[c],u=i[c+1]-i[c];if(u+l>s)break;let f=l/n,h=u/n,d=LT(t,f,h,o);a.push(d)}return a}function CX(e,t,r,i){let s=[];for(let n=0;n<t;n++){let o=r*n,a=LT(e,o,r,i);s.push(a)}return s}function LT(e,t,r,i){let s=[];for(let n=0;n<r;n++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)s.push("");else{let o=e[t+n],a=wX(i,o);a?s.push(a.name):s.push("")}return s}function wX(e,t){for(let r of e.values)if(r.value===t)return r;return null}var UT={};$t(UT,{decode:()=>MX,name:()=>PX});var m2="EXT_feature_metadata",PX=m2;async function MX(e,t){let r=new Tt(e);RX(r,t)}function RX(e,t){if(!t.gltf?.loadBuffers)return;let r=e.getExtension(m2);r&&(t.gltf?.loadImages&&IX(e,r),BX(e,r))}function IX(e,t){let r=t.schema;if(!r)return;let i=r.classes,{featureTextures:s}=t;if(i&&s)for(let n in i){let o=i[n],a=FX(s,n);a&&LX(e,a,o)}}function BX(e,t){let r=t.schema;if(!r)return;let i=r.classes,s=t.featureTables;if(i&&s)for(let n in i){let o=OX(s,n);o&&NX(e,r,o)}}function OX(e,t){for(let r in e){let i=e[r];if(i.class===t)return i}return null}function FX(e,t){for(let r in e){let i=e[r];if(i.class===t)return i}return null}function NX(e,t,r){if(!r.class)return;let i=t.classes?.[r.class];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let s=r.count;for(let n in i.properties){let o=i.properties[n],a=r.properties?.[n];if(a){let c=DX(e,t,o,s,a);a.data=c}}}function LX(e,t,r){let i=t.class;for(let s in r.properties){let n=t?.properties?.[s];if(n){let o=HX(e,n,i);n.data=o}}}function DX(e,t,r,i,s){let n=[],o=s.bufferView,a=e.getTypedArrayForBufferView(o),c=UX(e,r,s,i),l=kX(e,r,s,i);return r.type==="STRING"||r.componentType==="STRING"?n=Ug(i,a,c,l):VX(r)&&(n=zX(r,i,a,c)),n}function UX(e,t,r,i){return t.type==="ARRAY"&&typeof t.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Da(e,r.arrayOffsetBufferView,r.offsetType||"UINT32",i):null}function kX(e,t,r,i){return typeof r.stringOffsetBufferView<"u"?Da(e,r.stringOffsetBufferView,r.offsetType||"UINT32",i):null}function VX(e){let t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||typeof e.componentType<"u"&&t.includes(e.componentType)}function zX(e,t,r,i){let s=e.type==="ARRAY",n=e.componentCount,o="SCALAR",a=e.componentType||e.type,c=cf(o,a),l=r.byteLength/c,u=Ua(r,o,a,l);return s?i?Lg(u,t,i,r.length,c):n?Dg(u,t,n):[]:u}function HX(e,t,r){let i=e.gltf.json;if(!i.meshes)return[];let s=[];for(let n of i.meshes)for(let o of n.primitives)GX(e,r,t,s,o);return s}function GX(e,t,r,i,s){let n={channels:r.channels,...r.texture},o=ka(e,n,s);o&&Ng(e,t,o,i,s)}var _2="4.2.0-beta.2";var Va=!0,y2=1735152710,zT=12,kg=8,WX=1313821514,jX=5130562,XX=0,YX=0,qX=1;function KX(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}function x2(e,t=0,r={}){let i=new DataView(e),{magic:s=y2}=r,n=i.getUint32(t,!1);return n===s||n===y2}function A2(e,t,r=0,i={}){let s=new DataView(t),n=KX(s,r+0),o=s.getUint32(r+4,Va),a=s.getUint32(r+8,Va);switch(Object.assign(e,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:n,version:o,json:{},binChunks:[]}),r+=zT,e.version){case 1:return $X(e,s,r);case 2:return JX(e,s,r,i={});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function $X(e,t,r){nt(e.header.byteLength>zT+kg);let i=t.getUint32(r+0,Va),s=t.getUint32(r+4,Va);return r+=kg,nt(s===XX),kT(e,t,r,i),r+=i,r+=VT(e,t,r,e.header.byteLength),r}function JX(e,t,r,i){return nt(e.header.byteLength>zT+kg),ZX(e,t,r,i),r+e.header.byteLength}function ZX(e,t,r,i){for(;r+8<=e.header.byteLength;){let s=t.getUint32(r+0,Va),n=t.getUint32(r+4,Va);switch(r+=kg,n){case WX:kT(e,t,r,s);break;case jX:VT(e,t,r,s);break;case YX:i.strict||kT(e,t,r,s);break;case qX:i.strict||VT(e,t,r,s);break;default:break}r+=xs(s,4)}return r}function kT(e,t,r,i){let s=new Uint8Array(t.buffer,r,i),o=new TextDecoder("utf8").decode(s);return e.json=JSON.parse(o),xs(i,4)}function VT(e,t,r,i){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:i,arrayBuffer:t.buffer}),xs(i,4)}function HT(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;let i=t.baseUri||t.uri;if(!i)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return i.substr(0,i.lastIndexOf("/")+1)+e}var WT={};$t(WT,{decode:()=>u7,name:()=>l7});var QX="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",t7="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",e7=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]),r7=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]),i7={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s7={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function T2(e,t,r,i,s,n="NONE"){let o=await n7();c7(o,o.exports[s7[s]],e,t,r,i,o.exports[i7[n||"NONE"]])}var GT;async function n7(){return GT||(GT=o7()),GT}async function o7(){let e=QX;WebAssembly.validate(e7)&&(e=t7,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let t=await WebAssembly.instantiate(a7(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}function a7(e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;++i){let s=e.charCodeAt(i);t[i]=s>96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let r=0;for(let i=0;i<e.length;++i)t[r++]=t[i]<60?r7[t[i]]:(t[i]-60)*64+t[++i];return t.buffer.slice(0,r)}function c7(e,t,r,i,s,n,o){let a=e.exports.sbrk,c=i+3&-4,l=a(c*s),u=a(n.length),f=new Uint8Array(e.exports.memory.buffer);f.set(n,u);let h=t(l,i,s,u,n.length);if(h===0&&o&&o(l,c,s),r.set(f.subarray(l,l+i*s)),a(l-a(0)),h!==0)throw new Error(`Malformed buffer data: ${h}`)}var Vg="EXT_meshopt_compression",l7=Vg;async function u7(e,t){let r=new Tt(e);if(!t?.gltf?.decompressMeshes||!t.gltf?.loadBuffers)return;let i=[];for(let s of e.json.bufferViews||[])i.push(f7(r,s));await Promise.all(i),r.removeExtension(Vg)}async function f7(e,t){let r=e.getObjectExtension(t,Vg);if(r){let{byteOffset:i=0,byteLength:s=0,byteStride:n,count:o,mode:a,filter:c="NONE",buffer:l}=r,u=e.gltf.buffers[l],f=new Uint8Array(u.arrayBuffer,u.byteOffset+i,s),h=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);await T2(h,o,n,f,a,c),e.removeObjectExtension(t,Vg)}}var jT={};$t(jT,{name:()=>h7,preprocess:()=>d7});var za="EXT_texture_webp",h7=za;function d7(e,t){let r=new Tt(e);if(!y0("image/webp")){if(r.getRequiredExtensions().includes(za))throw new Error(`gltf: Required extension ${za} not supported by browser`);return}let{json:i}=r;for(let s of i.textures||[]){let n=r.getObjectExtension(s,za);n&&(s.source=n.source),r.removeObjectExtension(s,za)}r.removeExtension(za)}var XT={};$t(XT,{name:()=>p7,preprocess:()=>g7});var zg="KHR_texture_basisu",p7=zg;function g7(e,t){let r=new Tt(e),{json:i}=r;for(let s of i.textures||[]){let n=r.getObjectExtension(s,zg);n&&(s.source=n.source,r.removeObjectExtension(s,zg))}r.removeExtension(zg)}var JT={};$t(JT,{decode:()=>I7,encode:()=>B7,name:()=>M7,preprocess:()=>R7});var b2="4.2.0-beta.2";var E2={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:b2,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 v2(e,t,r){let i=C2(t.metadata),s=[],n=m7(t.attributes);for(let o in e){let a=e[o],c=S2(o,a,n[o]);s.push(c)}if(r){let o=S2("indices",r);s.push(o)}return{fields:s,metadata:i}}function m7(e){let t={};for(let r in e){let i=e[r];t[i.name||"undefined"]=i}return t}function S2(e,t,r){let i=r?C2(r.metadata):void 0;return h0(e,t,i)}function C2(e){Object.entries(e);let t={};for(let r in e)t[`${r}.string`]=JSON.stringify(e[r]);return t}var w2={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},_7={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},y7=4,lf=class{draco;decoder;metadataQuerier;constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,r={}){let i=new this.draco.DecoderBuffer;i.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(r);let s=this.decoder.GetEncodedGeometryType(i),n=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let o;switch(s){case this.draco.TRIANGULAR_MESH:o=this.decoder.DecodeBufferToMesh(i,n);break;case this.draco.POINT_CLOUD:o=this.decoder.DecodeBufferToPointCloud(i,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,s,r),c=this._getMeshData(n,a,r),l=Ui(c.attributes),u=v2(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:n.num_points(),boundingBox:l},...c,schema:u}}finally{this.draco.destroy(i),n&&this.draco.destroy(n)}}_getDracoLoaderData(t,r,i){let s=this._getTopLevelMetadata(t),n=this._getDracoAttributes(t,i);return{geometry_type:r,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:s,attributes:n}}_getDracoAttributes(t,r){let i={};for(let s=0;s<t.num_attributes();s++){let n=this.decoder.GetAttribute(t,s),o=this._getAttributeMetadata(t,s);i[n.unique_id()]={unique_id:n.unique_id(),attribute_type:n.attribute_type(),data_type:n.data_type(),num_components:n.num_components(),byte_offset:n.byte_offset(),byte_stride:n.byte_stride(),normalized:n.normalized(),attribute_index:s,metadata:o};let a=this._getQuantizationTransform(n,r);a&&(i[n.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(n,r);c&&(i[n.unique_id()].octahedron_transform=c)}return i}_getMeshData(t,r,i){let s=this._getMeshAttributes(r,t,i);if(!s.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(i.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:s,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:s,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:s}}_getMeshAttributes(t,r,i){let s={};for(let n of Object.values(t.attributes)){let o=this._deduceAttributeName(n,i);n.name=o;let a=this._getAttributeValues(r,n);if(a){let{value:c,size:l}=a;s[o]={value:c,size:l,byteOffset:n.byte_offset,byteStride:n.byte_stride,normalized:n.normalized}}}return s}_getTriangleListIndices(t){let i=t.num_faces()*3,s=i*y7,n=this.draco._malloc(s);try{return this.decoder.GetTrianglesUInt32Array(t,s,n),new Uint32Array(this.draco.HEAPF32.buffer,n,i).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(t){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,r),T7(r)}finally{this.draco.destroy(r)}}_getAttributeValues(t,r){let i=_7[r.data_type];if(!i)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let s=r.num_components,o=t.num_points()*s,a=o*i.BYTES_PER_ELEMENT,c=x7(this.draco,i),l,u=this.draco._malloc(a);try{let f=this.decoder.GetAttribute(t,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,f,c,a,u),l=new i(this.draco.HEAPF32.buffer,u,o).slice()}finally{this.draco._free(u)}return{value:l,size:s}}_deduceAttributeName(t,r){let i=t.unique_id;for(let[o,a]of Object.entries(r.extraAttributes||{}))if(a===i)return o;let s=t.attribute_type;for(let o in w2)if(this.draco[o]===s)return w2[o];let n=r.attributeNameEntry||"name";return t.metadata[n]?t.metadata[n].string:`CUSTOM_ATTRIBUTE_${i}`}_getTopLevelMetadata(t){let r=this.decoder.GetMetadata(t);return this._getDracoMetadata(r)}_getAttributeMetadata(t,r){let i=this.decoder.GetAttributeMetadata(t,r);return this._getDracoMetadata(i)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let r={},i=this.metadataQuerier.NumEntries(t);for(let s=0;s<i;s++){let n=this.metadataQuerier.GetEntryName(t,s);r[n]=this._getDracoMetadataField(t,n)}return r}_getDracoMetadataField(t,r){let i=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,r,i);let s=A7(i);return{int:this.metadataQuerier.GetIntEntry(t,r),string:this.metadataQuerier.GetStringEntry(t,r),double:this.metadataQuerier.GetDoubleEntry(t,r),intArray:s}}finally{this.draco.destroy(i)}}_disableAttributeTransforms(t){let{quantizedAttributes:r=[],octahedronAttributes:i=[]}=t,s=[...r,...i];for(let n of s)this.decoder.SkipAttributeTransform(this.draco[n])}_getQuantizationTransform(t,r){let{quantizedAttributes:i=[]}=r,s=t.attribute_type();if(i.map(o=>this.decoder[o]).includes(s)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(t))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(t,r){let{octahedronAttributes:i=[]}=r,s=t.attribute_type();if(i.map(o=>this.decoder[o]).includes(s)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(t))return{quantization_bits:o.quantization_bits()}}finally{this.draco.destroy(o)}}return null}};function x7(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}function A7(e){let t=e.size(),r=new Int32Array(t);for(let i=0;i<t;i++)r[i]=e.GetValue(i);return r}function T7(e){let t=e.size(),r=new Int32Array(t);for(let i=0;i<t;i++)r[i]=e.GetValue(i);return r}var b7="1.5.6",E7="1.4.1",YT=`https://www.gstatic.com/draco/versioned/decoders/${b7}`,Ye={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},qT={[Ye.DECODER]:`${YT}/${Ye.DECODER}`,[Ye.DECODER_WASM]:`${YT}/${Ye.DECODER_WASM}`,[Ye.FALLBACK_DECODER]:`${YT}/${Ye.FALLBACK_DECODER}`,[Ye.ENCODER]:`https://raw.githubusercontent.com/google/draco/${E7}/javascript/${Ye.ENCODER}`},KT;async function P2(e){let t=e.modules||{};return t.draco3d?KT||=t.draco3d.createDecoderModule({}).then(r=>({draco:r})):KT||=S7(e),await KT}async function S7(e){let t,r;switch(e.draco&&e.draco.decoderType){case"js":t=await hi(qT[Ye.FALLBACK_DECODER],"draco",e,Ye.FALLBACK_DECODER);break;case"wasm":default:[t,r]=await Promise.all([await hi(qT[Ye.DECODER],"draco",e,Ye.DECODER),await hi(qT[Ye.DECODER_WASM],"draco",e,Ye.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await v7(t,r)}function v7(e,t){let r={};return t&&(r.wasmBinary=t),new Promise(i=>{e({...r,onModuleLoaded:s=>i({draco:s})})})}var Hg={...E2,parse:C7};async function C7(e,t){let{draco:r}=await P2(t),i=new lf(r);try{return i.parseSync(e,t?.draco)}finally{i.destroy()}}function M2(e){let t={};for(let r in e){let i=e[r];if(r!=="indices"){let s=$T(i);t[r]=s}}return t}function $T(e){let{buffer:t,size:r,count:i}=w7(e);return{value:t,size:r,byteOffset:0,count:i,type:Fg(r),componentType:Na(t)}}function w7(e){let t=e,r=1,i=0;return e&&e.value&&(t=e.value,r=e.size||1),t&&(ArrayBuffer.isView(t)||(t=P7(t,Float32Array)),i=t.length/r),{buffer:t,size:r,count:i}}function P7(e,t,r=!1){return e?Array.isArray(e)?new t(e):r&&!(e instanceof t)?new t(e):e:null}var tn="KHR_draco_mesh_compression",M7=tn;function R7(e,t,r){let i=new Tt(e);for(let s of R2(i))i.getObjectExtension(s,tn)}async function I7(e,t,r){if(!t?.gltf?.decompressMeshes)return;let i=new Tt(e),s=[];for(let n of R2(i))i.getObjectExtension(n,tn)&&s.push(O7(i,n,t,r));await Promise.all(s),i.removeExtension(tn)}function B7(e,t={}){let r=new Tt(e);for(let i of r.json.meshes||[])F7(i,t),r.addRequiredExtension(tn)}async function O7(e,t,r,i){let s=e.getObjectExtension(t,tn);if(!s)return;let n=e.getTypedArrayForBufferView(s.bufferView),o=pn(n.buffer,n.byteOffset),a={...r};delete a["3d-tiles"];let c=await $e(o,Hg,a,i),l=M2(c.attributes);for(let[u,f]of Object.entries(l))if(u in t.attributes){let h=t.attributes[u],d=e.getAccessor(h);d?.min&&d?.max&&(f.min=d.min,f.max=d.max)}t.attributes=l,c.indices&&(t.indices=$T(c.indices)),e.removeObjectExtension(t,tn),N7(t)}function F7(e,t,r=4,i,s){if(!i.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let n=i.DracoWriter.encodeSync({attributes:e}),o=s?.parseSync?.({attributes:e}),a=i._addFauxAttributes(o.attributes),c=i.addBufferView(n);return{primitives:[{attributes:a,mode:r,extensions:{[tn]:{bufferView:c,attributes:a}}}]}}function N7(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*R2(e){for(let t of e.json.meshes||[])for(let r of t.primitives)yield r}var ZT={};$t(ZT,{decode:()=>k7,name:()=>L7});var Wg="KHR_texture_transform",L7=Wg,Gg=new w,D7=new mt,U7=new mt;async function k7(e,t){if(!new Tt(e).hasExtension(Wg)||!t.gltf?.loadBuffers)return;let s=e.json.materials||[];for(let n=0;n<s.length;n++)V7(n,e)}function V7(e,t){let r=t.json.materials?.[e],i=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],s=[];for(let n of i)n&&n?.extensions?.[Wg]&&z7(t,e,n,s)}function z7(e,t,r,i){let s=H7(r,i);if(!s)return;let n=e.json.meshes||[];for(let o of n)for(let a of o.primitives){let c=a.material;Number.isFinite(c)&&t===c&&G7(e,a,s)}}function H7(e,t){let r=e.extensions?.[Wg],{texCoord:i=0}=e,{texCoord:s=i}=r;if(!(t.findIndex(([o,a])=>o===i&&a===s)!==-1)){let o=X7(r);return i!==s&&(e.texCoord=s),t.push([i,s]),{originalTexCoord:i,texCoord:s,matrix:o}}return null}function G7(e,t,r){let{originalTexCoord:i,texCoord:s,matrix:n}=r,o=t.attributes[`TEXCOORD_${i}`];if(Number.isFinite(o)){let a=e.json.accessors?.[o];if(a&&a.bufferView){let c=e.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:u}=e.buffers[c.buffer],f=(u||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:d}=La(a,c),p=Og[a.componentType],g=Bg[a.type],m=c.byteStride||p*g,_=new Float32Array(d);for(let y=0;y<a.count;y++){let x=new h(l,f+y*m,2);Gg.set(x[0],x[1],1),Gg.transformByMatrix3(n),_.set([Gg[0],Gg[1]],y*g)}i===s?W7(a,c,e.buffers,_):j7(s,a,t,e,_)}}}}function W7(e,t,r,i){e.componentType=5126,r.push({arrayBuffer:i.buffer,byteOffset:0,byteLength:i.buffer.byteLength}),t.buffer=r.length-1,t.byteLength=i.buffer.byteLength,t.byteOffset=0,delete t.byteStride}function j7(e,t,r,i,s){i.buffers.push({arrayBuffer:s.buffer,byteOffset:0,byteLength:s.buffer.byteLength});let n=i.json.bufferViews;if(!n)return;n.push({buffer:i.buffers.length-1,byteLength:s.buffer.byteLength,byteOffset:0});let o=i.json.accessors;o&&(o.push({bufferView:n?.length-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),r.attributes[`TEXCOORD_${e}`]=o.length-1)}function X7(e){let{offset:t=[0,0],rotation:r=0,scale:i=[1,1]}=e,s=new mt().set(1,0,0,0,1,0,t[0],t[1],1),n=D7.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),o=U7.set(i[0],0,0,0,i[1],0,0,0,1);return s.multiplyRight(n).multiplyRight(o)}var QT={};$t(QT,{decode:()=>q7,encode:()=>K7,name:()=>Y7});var yo="KHR_lights_punctual",Y7=yo;async function q7(e){let t=new Tt(e),{json:r}=t,i=t.getExtension(yo);i&&(t.json.lights=i.lights,t.removeExtension(yo));for(let s of r.nodes||[]){let n=t.getObjectExtension(s,yo);n&&(s.light=n.light),t.removeObjectExtension(s,yo)}}async function K7(e){let t=new Tt(e),{json:r}=t;if(r.lights){let i=t.addExtension(yo);oe(!i.lights),i.lights=r.lights,delete r.lights}if(t.json.lights){for(let i of t.json.lights){let s=i.node;t.addObjectExtension(s,yo,i)}delete t.json.lights}}var tb={};$t(tb,{decode:()=>J7,encode:()=>Z7,name:()=>$7});var uf="KHR_materials_unlit",$7=uf;async function J7(e){let t=new Tt(e),{json:r}=t;for(let i of r.materials||[])i.extensions&&i.extensions.KHR_materials_unlit&&(i.unlit=!0),t.removeObjectExtension(i,uf);t.removeExtension(uf)}function Z7(e){let t=new Tt(e),{json:r}=t;if(t.materials)for(let i of r.materials||[])i.unlit&&(delete i.unlit,t.addObjectExtension(i,uf,{}),t.addExtension(uf))}var eb={};$t(eb,{decode:()=>tY,encode:()=>eY,name:()=>Q7});var ff="KHR_techniques_webgl",Q7=ff;async function tY(e){let t=new Tt(e),{json:r}=t,i=t.getExtension(ff);if(i){let s=rY(i,t);for(let n of r.materials||[]){let o=t.getObjectExtension(n,ff);o&&(n.technique=Object.assign({},o,s[o.technique]),n.technique.values=iY(n.technique,t)),t.removeObjectExtension(n,ff)}t.removeExtension(ff)}}async function eY(e,t){}function rY(e,t){let{programs:r=[],shaders:i=[],techniques:s=[]}=e,n=new TextDecoder;return i.forEach(o=>{if(Number.isFinite(o.bufferView))o.code=n.decode(t.getTypedArrayForBufferView(o.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(o=>{o.fragmentShader=i[o.fragmentShader],o.vertexShader=i[o.vertexShader]}),s.forEach(o=>{o.program=r[o.program]}),s}function iY(e,t){let r=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(i=>{e.uniforms[i].value&&!(i in r)&&(r[i]=e.uniforms[i].value)}),Object.keys(r).forEach(i=>{typeof r[i]=="object"&&r[i].index!==void 0&&(r[i].texture=t.getTexture(r[i].index))}),r}var I2=[DT,FT,WT,jT,XT,JT,QT,tb,eb,ZT,UT];function B2(e,t={},r){let i=I2.filter(s=>F2(s.name,t));for(let s of i)s.preprocess?.(e,t,r)}async function O2(e,t={},r){let i=I2.filter(s=>F2(s.name,t));for(let s of i)await s.decode?.(e,t,r)}function F2(e,t){let r=t?.gltf?.excludeExtensions||{};return!(e in r&&!r[e])}var rb="KHR_binary_glTF";function N2(e){let t=new Tt(e),{json:r}=t;for(let i of r.images||[]){let s=t.getObjectExtension(i,rb);s&&Object.assign(i,s),t.removeObjectExtension(i,rb)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,t.removeExtension(rb)}var L2={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},nY={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},ib=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(t,r){this.json=t.json;let i=t.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${i.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(i),this._convertTopLevelObjectsToArrays(i),N2(t),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(t){t.asset=t.asset||{},t.asset.version="2.0",t.asset.generator=t.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(t){for(let r in L2)this._convertTopLevelObjectToArray(t,r)}_convertTopLevelObjectToArray(t,r){let i=t[r];if(!(!i||Array.isArray(i))){t[r]=[];for(let s in i){let n=i[s];n.id=n.id||s;let o=t[r].length;t[r].push(n),this.idToIndexMap[r][s]=o}}}_convertObjectIdsToArrayIndices(t){for(let r in L2)this._convertIdsToIndices(t,r);"scene"in t&&(t.scene=this._convertIdToIndex(t.scene,"scene"));for(let r of t.textures)this._convertTextureIds(r);for(let r of t.meshes)this._convertMeshIds(r);for(let r of t.nodes)this._convertNodeIds(r);for(let r of t.scenes)this._convertSceneIds(r)}_convertTextureIds(t){t.source&&(t.source=this._convertIdToIndex(t.source,"image"))}_convertMeshIds(t){for(let r of t.primitives){let{attributes:i,indices:s,material:n}=r;for(let o in i)i[o]=this._convertIdToIndex(i[o],"accessor");s&&(r.indices=this._convertIdToIndex(s,"accessor")),n&&(r.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(t){t.children&&(t.children=t.children.map(r=>this._convertIdToIndex(r,"node"))),t.meshes&&(t.meshes=t.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(t){t.nodes&&(t.nodes=t.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(t,r){t[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),t[r]=[]);for(let i of t[r])for(let s in i){let n=i[s],o=this._convertIdToIndex(n,s);i[s]=o}}_convertIdToIndex(t,r){let i=nY[r];if(i in this.idToIndexMap){let s=this.idToIndexMap[i][t];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${r} with id ${t}`);return s}return t}_updateObjects(t){for(let r of this.json.buffers)delete r.type}_updateMaterial(t){for(let r of t.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let i=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,s=t.textures.findIndex(n=>n.id===i);s!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:s})}}};function D2(e,t={}){return new ib().normalize(e,t)}async function U2(e,t,r=0,i,s){return oY(e,t,r,i),D2(e,{normalize:i?.gltf?.normalize}),B2(e,i,s),i?.gltf?.loadBuffers&&e.json.buffers&&await aY(e,i,s),i?.gltf?.loadImages&&await cY(e,i,s),await O2(e,i,s),e}function oY(e,t,r,i){if(i.uri&&(e.baseUri=i.uri),t instanceof ArrayBuffer&&!x2(t,r,i)&&(t=new TextDecoder().decode(t)),typeof t=="string")e.json=K_(t);else if(t instanceof ArrayBuffer){let o={};r=A2(o,t,r,i.glb),oe(o.type==="glTF",`Invalid GLB magic string ${o.type}`),e._glb=o,e.json=o.json}else oe(!1,"GLTF: must be ArrayBuffer or string");let s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){let{binChunks:o}=e._glb;e.buffers[0]={arrayBuffer:o[0].arrayBuffer,byteOffset:o[0].byteOffset,byteLength:o[0].byteLength}}let n=e.json.images||[];e.images=new Array(n.length).fill({})}async function aY(e,t,r){let i=e.json.buffers||[];for(let s=0;s<i.length;++s){let n=i[s];if(n.uri){let{fetch:o}=r;oe(o);let a=HT(n.uri,t),l=await(await r?.fetch?.(a))?.arrayBuffer?.();e.buffers[s]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete n.uri}else e.buffers[s]===null&&(e.buffers[s]={arrayBuffer:new ArrayBuffer(n.byteLength),byteOffset:0,byteLength:n.byteLength})}}async function cY(e,t,r){let i=lY(e),s=e.json.images||[],n=[];for(let o of i)n.push(uY(e,s[o],o,t,r));return await Promise.all(n)}function lY(e){let t=new Set,r=e.json.textures||[];for(let i of r)i.source!==void 0&&t.add(i.source);return Array.from(t).sort()}async function uY(e,t,r,i,s){let n;if(t.uri&&!t.hasOwnProperty("bufferView")){let a=HT(t.uri,i),{fetch:c}=s;n=await(await c(a)).arrayBuffer(),t.bufferView={data:n}}if(Number.isFinite(t.bufferView)){let a=u2(e.json,e.buffers,t.bufferView);n=pn(a.buffer,a.byteOffset,a.byteLength)}oe(n,"glTF image has no data");let o=await $e(n,[pi,RT],{...i,mimeType:t.mimeType,basis:i.basis||{format:Mg()}},s);o&&o[0]&&(o={compressed:!0,mipmaps:!1,width:o[0].width,height:o[0].height,data:o[0]}),e.images=e.images||[],e.images[r]=o}var as={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:_2,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:fY,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};async function fY(e,t={},r){t={...as.options,...t},t.gltf={...as.options.gltf,...t.gltf};let{byteOffset:i=0}=t;return await U2({},e,i,t,r)}var hY={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},dY={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},wr={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},pY={magFilter:wr.TEXTURE_MAG_FILTER,minFilter:wr.TEXTURE_MIN_FILTER,wrapS:wr.TEXTURE_WRAP_S,wrapT:wr.TEXTURE_WRAP_T},gY={[wr.TEXTURE_MAG_FILTER]:wr.LINEAR,[wr.TEXTURE_MIN_FILTER]:wr.NEAREST_MIPMAP_LINEAR,[wr.TEXTURE_WRAP_S]:wr.REPEAT,[wr.TEXTURE_WRAP_T]:wr.REPEAT};function mY(){return{id:"default-sampler",parameters:gY}}function _Y(e){return dY[e]}function yY(e){return hY[e]}var sb=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(t,r={}){let{json:i,buffers:s=[],images:n=[]}=t,{baseUri:o=""}=t;return oe(i),this.baseUri=o,this.buffers=s,this.images=n,this.jsonUnprocessed=i,this.json=this._resolveTree(t.json,r),this.json}_resolveTree(t,r={}){let i={...t};return this.json=i,t.bufferViews&&(i.bufferViews=t.bufferViews.map((s,n)=>this._resolveBufferView(s,n))),t.images&&(i.images=t.images.map((s,n)=>this._resolveImage(s,n))),t.samplers&&(i.samplers=t.samplers.map((s,n)=>this._resolveSampler(s,n))),t.textures&&(i.textures=t.textures.map((s,n)=>this._resolveTexture(s,n))),t.accessors&&(i.accessors=t.accessors.map((s,n)=>this._resolveAccessor(s,n))),t.materials&&(i.materials=t.materials.map((s,n)=>this._resolveMaterial(s,n))),t.meshes&&(i.meshes=t.meshes.map((s,n)=>this._resolveMesh(s,n))),t.nodes&&(i.nodes=t.nodes.map((s,n)=>this._resolveNode(s,n)),i.nodes=i.nodes.map((s,n)=>this._resolveNodeChildren(s))),t.skins&&(i.skins=t.skins.map((s,n)=>this._resolveSkin(s,n))),t.scenes&&(i.scenes=t.scenes.map((s,n)=>this._resolveScene(s,n))),typeof this.json.scene=="number"&&i.scenes&&(i.scene=i.scenes[this.json.scene]),i}getScene(t){return this._get(this.json.scenes,t)}getNode(t){return this._get(this.json.nodes,t)}getSkin(t){return this._get(this.json.skins,t)}getMesh(t){return this._get(this.json.meshes,t)}getMaterial(t){return this._get(this.json.materials,t)}getAccessor(t){return this._get(this.json.accessors,t)}getCamera(t){return this._get(this.json.cameras,t)}getTexture(t){return this._get(this.json.textures,t)}getSampler(t){return this._get(this.json.samplers,t)}getImage(t){return this._get(this.json.images,t)}getBufferView(t){return this._get(this.json.bufferViews,t)}getBuffer(t){return this._get(this.json.buffers,t)}_get(t,r){if(typeof r=="object")return r;let i=t&&t[r];return i||console.warn(`glTF file error: Could not find ${t}[${r}]`),i}_resolveScene(t,r){return{...t,id:t.id||`scene-${r}`,nodes:(t.nodes||[]).map(i=>this.getNode(i))}}_resolveNode(t,r){let i={...t,id:t?.id||`node-${r}`};return t.mesh!==void 0&&(i.mesh=this.getMesh(t.mesh)),t.camera!==void 0&&(i.camera=this.getCamera(t.camera)),t.skin!==void 0&&(i.skin=this.getSkin(t.skin)),t.meshes!==void 0&&t.meshes.length&&(i.mesh=t.meshes.reduce((s,n)=>{let o=this.getMesh(n);return s.id=o.id,s.primitives=s.primitives.concat(o.primitives),s},{primitives:[]})),i}_resolveNodeChildren(t){return t.children&&(t.children=t.children.map(r=>this.getNode(r))),t}_resolveSkin(t,r){let i=typeof t.inverseBindMatrices=="number"?this.getAccessor(t.inverseBindMatrices):void 0;return{...t,id:t.id||`skin-${r}`,inverseBindMatrices:i}}_resolveMesh(t,r){let i={...t,id:t.id||`mesh-${r}`,primitives:[]};return t.primitives&&(i.primitives=t.primitives.map(s=>{let n={...s,attributes:{},indices:void 0,material:void 0},o=s.attributes;for(let a in o)n.attributes[a]=this.getAccessor(o[a]);return s.indices!==void 0&&(n.indices=this.getAccessor(s.indices)),s.material!==void 0&&(n.material=this.getMaterial(s.material)),n})),i}_resolveMaterial(t,r){let i={...t,id:t.id||`material-${r}`};if(i.normalTexture&&(i.normalTexture={...i.normalTexture},i.normalTexture.texture=this.getTexture(i.normalTexture.index)),i.occlusionTexture&&(i.occlusionTexture={...i.occlusionTexture},i.occlusionTexture.texture=this.getTexture(i.occlusionTexture.index)),i.emissiveTexture&&(i.emissiveTexture={...i.emissiveTexture},i.emissiveTexture.texture=this.getTexture(i.emissiveTexture.index)),i.emissiveFactor||(i.emissiveFactor=i.emissiveTexture?[1,1,1]:[0,0,0]),i.pbrMetallicRoughness){i.pbrMetallicRoughness={...i.pbrMetallicRoughness};let s=i.pbrMetallicRoughness;s.baseColorTexture&&(s.baseColorTexture={...s.baseColorTexture},s.baseColorTexture.texture=this.getTexture(s.baseColorTexture.index)),s.metallicRoughnessTexture&&(s.metallicRoughnessTexture={...s.metallicRoughnessTexture},s.metallicRoughnessTexture.texture=this.getTexture(s.metallicRoughnessTexture.index))}return i}_resolveAccessor(t,r){let i=_Y(t.componentType),s=yY(t.type),n=i*s,o={...t,id:t.id||`accessor-${r}`,bytesPerComponent:i,components:s,bytesPerElement:n,value:void 0,bufferView:void 0,sparse:void 0};if(t.bufferView!==void 0&&(o.bufferView=this.getBufferView(t.bufferView)),o.bufferView){let a=o.bufferView.buffer,{ArrayType:c,byteLength:l}=La(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(t,r,i,s,n){let o=new Uint8Array(n*s);for(let a=0;a<n;a++){let c=r+a*i;o.set(new Uint8Array(t.arrayBuffer.slice(c,c+s)),a*s)}return o.buffer}_resolveTexture(t,r){return{...t,id:t.id||`texture-${r}`,sampler:typeof t.sampler=="number"?this.getSampler(t.sampler):mY(),source:typeof t.source=="number"?this.getImage(t.source):void 0}}_resolveSampler(t,r){let i={id:t.id||`sampler-${r}`,...t,parameters:{}};for(let s in i){let n=this._enumSamplerParameter(s);n!==void 0&&(i.parameters[n]=i[s])}return i}_enumSamplerParameter(t){return pY[t]}_resolveImage(t,r){let i={...t,id:t.id||`image-${r}`,image:null,bufferView:t.bufferView!==void 0?this.getBufferView(t.bufferView):void 0},s=this.images[r];return s&&(i.image=s),i}_resolveBufferView(t,r){let i=t.buffer,s=this.buffers[i].arrayBuffer,n=this.buffers[i].byteOffset||0;return t.byteOffset&&(n+=t.byteOffset),{id:`bufferView-${r}`,...t,buffer:this.buffers[i],data:new Uint8Array(s,n,t.byteLength)}}_resolveCamera(t,r){let i={...t,id:t.id||`camera-${r}`};return i.perspective,i.orthographic,i}};function xo(e,t){return new sb().postProcess(e,t)}async function k2(e){let t=[];return e.scenes.forEach(r=>{r.traverse(i=>{Object.values(i.model.uniforms).forEach(s=>{s.loaded===!1&&t.push(s)})})}),await xY(()=>t.some(r=>!r.loaded))}async function xY(e){for(;e();)await new Promise(t=>requestAnimationFrame(t))}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 z2=`#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 H2=[255,255,255,255],AY={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?typeof e.scene=="object"?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.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:e=>e.position},getColor:{type:"accessor",value:H2},_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:[as]},jg=class extends lt{getShaders(){let t=[dt,_t];return this.props._lighting==="pbr"&&t.push(Cn),super.getShaders({vs:V2,fs:z2,modules:t})}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:H2,transition:!0},instanceModelMatrix:Sg})}updateState(t){super.updateState(t);let{props:r,oldProps:i}=t;r.scenegraph!==i.scenegraph?this._updateScenegraph():r._animations!==i._animations&&this._applyAnimationsProp(this.state.animator,r._animations)}finalizeState(t){super.finalizeState(t),this.state.scenegraph?.destroy()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){let t=this.props,{device:r}=this.context,i=null;if(t.scenegraph instanceof Tr)i={scenes:[t.scenegraph]};else if(t.scenegraph&&typeof t.scenegraph=="object"){let a=t.scenegraph,c=a.json?xo(a):a,l=OT(r,c,this._getModelOptions());i={gltf:c,...l},k2(l).then(()=>{this.setNeedsRedraw()}).catch(u=>{this.raiseError(u,"loading glTF")})}let s={layer:this,device:this.context.device},n=t.getScene(i,s),o=t.getAnimator(i,s);if(n instanceof er){this.state.scenegraph?.destroy(),this._applyAnimationsProp(o,t._animations);let a=[];n.traverse(c=>{c instanceof xi&&a.push(c.model)}),this.setState({scenegraph:n,animator:o,models:a}),this.getAttributeManager().invalidateAll()}else n!==null&&k.warn("invalid scenegraph:",n)()}_applyAnimationsProp(t,r){if(!t||!r)return;let i=t.getAnimations();Object.keys(r).sort().forEach(s=>{let n=r[s];if(s==="*")i.forEach(o=>{Object.assign(o,n)});else if(Number.isFinite(Number(s))){let o=Number(s);o>=0&&o<i.length?Object.assign(i[o],n):k.warn(`animation ${s} not found`)()}else{let o=i.find(({name:a})=>a===s);o?Object.assign(o,n):k.warn(`animation ${s} not found`)()}})}_getModelOptions(){let{_imageBasedLightingEnvironment:t}=this.props,r;return t&&(typeof t=="function"?r=t({gl:this.context.gl,layer:this}):r=t),{imageBasedLightingEnvironment:r,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:t}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(t.timeline.getTime()),this.setNeedsRedraw());let{viewport:r,renderPass:i}=this.context,{sizeScale:s,sizeMinPixels:n,sizeMaxPixels:o,opacity:a,coordinateSystem:c}=this.props,l=this.getNumInstances();this.state.scenegraph.traverse((u,{worldMatrix:f})=>{if(u instanceof xi){let{model:h}=u;h.setInstanceCount(l),h.setUniforms({sizeScale:s,opacity:a,sizeMinPixels:n,sizeMaxPixels:o,composeModelMatrix:vg(r,c),sceneModelMatrix:f,u_Camera:h.uniforms.project_uCameraPosition}),h.draw(i)}})}},Ao=jg;(()=>{jg.defaultProps=AY})(),(()=>{jg.layerName="ScenegraphLayer"})();var G2=`#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 W2=`#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 TY(e){let t=e.positions||e.POSITION,r=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var bY={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},Xg=class extends Ri{getShaders(){let t=super.getShaders();return t.modules.push(Cn),{...t,vs:G2,fs:W2}}initializeState(){let{featureIds:t}=this.props;super.initializeState();let r=this.getAttributeManager();t&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(t){super.updateState(t);let{props:r,oldProps:i}=t;r.pbrMaterial!==i.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(t){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(t))}getModel(t){let{id:r,pbrMaterial:i}=this.props,s=this.parseMaterial(i,t);this.setState({parsedPBRMaterial:s});let n=this.getShaders();return TY(t.attributes),new J(this.context.device,{...this.getShaders(),id:r,geometry:t,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...n.defines,...s?.defines,HAS_UV_REGIONS:t.attributes.uvRegions?1:0},parameters:s?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(t){let{model:r}=this.state;if(r){let{mesh:i}=this.props,s=this.parseMaterial(t,i);this.setState({parsedPBRMaterial:s}),r.setBindings(s.bindings),r.setUniforms(s.uniforms)}}parseMaterial(t,r){let i=Boolean(t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture);return of(this.context.device,{unlit:i,...t},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(t){let r=this.props.featureIds,i=new Uint8ClampedArray(r.length*t.size),s=[];for(let n=0;n<r.length;n++)this.encodePickingColor(r[n],s),i[n*3]=s[0],i[n*3+1]=s[1],i[n*3+2]=s[2];t.value=i}finalizeState(t){super.finalizeState(t),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}},hf=Xg;(()=>{Xg.layerName="MeshLayer"})(),(()=>{Xg.defaultProps=bY})();var cs=6356752314245179e-9,EY={radii:[6378137,6378137,cs],radiiSquared:[6378137*6378137,6378137*6378137,cs*cs],oneOverRadii:[1/6378137,1/6378137,1/cs],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(cs*cs)],maximumRadius:Math.max(6378137,6378137,cs),centerToleranceSquared:.1};function Yg(e){return e}var sIt=new w;function SY(e,t=[],r=Yg){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function j2(e,t=[]){return SY(e,t,St._cartographicRadians?Yg:Vy)}function vY(e,t,r=Yg){return"longitude"in t?(t.longitude=r(e[0]),t.latitude=r(e[1]),t.height=e[2]):"x"in t?(t.x=r(e[0]),t.y=r(e[1]),t.z=e[2]):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function X2(e,t){return vY(e,t,St._cartographicRadians?Yg:zy)}var Y2=1e-14,CY=new w,q2={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"}},nb={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},df={east:new w,north:new w,up:new w,west:new w,south:new w,down:new w},wY=new w,PY=new w,MY=new w;function ob(e,t,r,i,s,n){let o=q2[t]&&q2[t][r];fe(o&&(!i||i===o));let a,c,l,u=CY.copy(s);if(Ct(u.x,0,Y2)&&Ct(u.y,0,Y2)){let h=Math.sign(u.z);a=wY.fromArray(nb[t]),t!=="east"&&t!=="west"&&a.scale(h),c=PY.fromArray(nb[r]),r!=="east"&&r!=="west"&&c.scale(h),l=MY.fromArray(nb[i]),i!=="east"&&i!=="west"&&l.scale(h)}else{let{up:h,east:d,north:p}=df;d.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,h),p.copy(h).cross(d);let{down:g,west:m,south:_}=df;g.copy(h).scale(-1),m.copy(d).scale(-1),_.copy(p).scale(-1),a=df[t],c=df[r],l=df[i]}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 Ha=new w,RY=new w,IY=new w;function K2(e,t,r=[]){let{oneOverRadii:i,oneOverRadiiSquared:s,centerToleranceSquared:n}=t;Ha.from(e);let o=Ha.x,a=Ha.y,c=Ha.z,l=i.x,u=i.y,f=i.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 _=RY;if(_.copy(e).scale(m),g<n)return _.to(r);let y=s.x,x=s.y,E=s.z,P=IY;P.set(_.x*y*2,_.y*x*2,_.z*E*2);let B=(1-m)*Ha.len()/(.5*P.len()),F=0,M,v,T,L;do{B-=F,M=1/(1+B*y),v=1/(1+B*x),T=1/(1+B*E);let V=M*M,z=v*v,W=T*T,Z=V*M,ut=z*v,st=W*T;L=h*V+d*z+p*W-1;let gt=-2*(h*Z*y+d*ut*x+p*st*E);F=L/gt}while(Math.abs(L)>mr.EPSILON12);return Ha.scale([M,v,T]).to(r)}var qg=new w,$2=new w,FY=new w,ii=new w,NY=new w,Kg=new w,ot=class{constructor(t=0,r=0,i=0){this.centerToleranceSquared=mr.EPSILON1,fe(t>=0),fe(r>=0),fe(i>=0),this.radii=new w(t,r,i),this.radiiSquared=new w(t*t,r*r,i*i),this.radiiToTheFourth=new w(t*t*t*t,r*r*r*r,i*i*i*i),this.oneOverRadii=new w(t===0?0:1/t,r===0?0:1/r,i===0?0:1/i),this.oneOverRadiiSquared=new w(t===0?0:1/(t*t),r===0?0:1/(r*r),i===0?0:1/(i*i)),this.minimumRadius=Math.min(t,r,i),this.maximumRadius=Math.max(t,r,i),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){let i=$2,s=FY,[,,n]=t;this.geodeticSurfaceNormalCartographic(t,i),s.copy(this.radiiSquared).scale(i);let o=Math.sqrt(i.dot(s));return s.scale(1/o),i.scale(n),s.add(i),s.to(r)}cartesianToCartographic(t,r=[0,0,0]){Kg.from(t);let i=this.scaleToGeodeticSurface(Kg,ii);if(!i)return;let s=this.geodeticSurfaceNormal(i,$2),n=NY;n.copy(Kg).subtract(i);let o=Math.atan2(s.y,s.x),a=Math.asin(s.z),c=Math.sign(jt.dot(n,Kg))*jt.length(n);return X2([o,a,c],r)}eastNorthUpToFixedFrame(t,r=new q){return ob(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,i,s,n=new q){return ob(this,t,r,i,s,n)}geocentricSurfaceNormal(t,r=[0,0,0]){return qg.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let i=j2(t),s=i[0],n=i[1],o=Math.cos(n);return qg.set(o*Math.cos(s),o*Math.sin(s),Math.sin(n)).normalize(),qg.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return qg.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return K2(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){ii.from(t);let i=ii.x,s=ii.y,n=ii.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(i*i*o.x+s*s*o.y+n*n*o.z);return ii.multiplyScalar(a).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return ii.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return ii.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,i=[0,0,0]){fe(Ct(this.radii.x,this.radii.y,mr.EPSILON15)),fe(this.radii.z>0),ii.from(t);let s=ii.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-r))return ii.set(0,0,s).to(i)}};ot.WGS84=new ot(6378137,6378137,cs);var $g=class{item;previous;next;constructor(t,r,i){this.item=t,this.previous=r,this.next=i}};var Jg=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new $g(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){let i=t.next;t.next=r,this.tail===t?this.tail=r:i.previous=r,r.next=i,r.previous=t,++this._length}};var Zg=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Jg,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,i){r._cacheNode||(r._cacheNode=this._list.add(r),i&&i(t,r))}unloadTile(t,r,i){let s=r._cacheNode;s&&(this._list.remove(s),r._cacheNode=null,i&&i(t,r))}unloadTiles(t,r){let i=this._trimTiles;this._trimTiles=!1;let s=this._list,n=t.maximumMemoryUsage*1024*1024,o=this._sentinel,a=s.head;for(;a!==o&&(t.gpuMemoryUsageInBytes>n||i);){let c=a.item;a=a.next,this.unloadTile(t,c,r)}}trim(){this._trimTiles=!0}};function J2(e,t){nt(e),nt(t);let{rtcCenter:r,gltfUpAxis:i}=t,{computedTransform:s,boundingVolume:{center:n}}=e,o=new q(s);switch(r&&o.translate(r),i){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}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new w(n);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let c=ot.WGS84.cartesianToCartographic(a,new w),u=ot.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=u.multiplyRight(o),t.cartographicOrigin=c,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Z2=new w,ab=new w,cb=new ie([new de,new de,new de,new de,new de,new de]);function t3(e,t){let{cameraDirection:r,cameraUp:i,height:s}=e,{metersPerUnit:n}=e.distanceScales,o=Qg(e,e.center),a=ot.WGS84.eastNorthUpToFixedFrame(o),c=e.unprojectPosition(e.cameraPosition),l=ot.WGS84.cartographicToCartesian(c,new w),u=new w(a.transformAsVector(new w(r).scale(n))).normalize(),f=new w(a.transformAsVector(new w(i).scale(n))).normalize();LY(e);let h=e.constructor,{longitude:d,latitude:p,width:g,bearing:m,zoom:_}=e,y=new h({longitude:d,latitude:p,height:s,width:g,bearing:m,zoom:_,pitch:0});return{camera:{position:l,direction:u,up:f},viewport:e,topDownViewport:y,height:s,cullingVolume:cb,frameNumber:t,sseDenominator:1.15}}function e3(e,t,r){if(r===0||e.length<=r)return[e,[]];let i=[],{longitude:s,latitude:n}=t.viewport;for(let[l,u]of e.entries()){let[f,h]=u.header.mbs,d=Math.abs(s-f),p=Math.abs(n-h),g=Math.sqrt(p*p+d*d);i.push([l,g])}let o=i.sort((l,u)=>l[1]-u[1]),a=[];for(let l=0;l<r;l++)a.push(e[o[l][0]]);let c=[];for(let l=r;l<o.length;l++)c.push(e[o[l][0]]);return[a,c]}function LY(e){let t=e.getFrustumPlanes(),r=Q2(t.near,e.cameraPosition),i=Qg(e,r),s=Qg(e,e.cameraPosition,ab),n=0;cb.planes[n++].fromPointNormal(i,Z2.copy(i).subtract(s));for(let o in t){if(o==="near")continue;let a=t[o],c=Q2(a,r,ab),l=Qg(e,c,ab);cb.planes[n++].fromPointNormal(l,Z2.copy(i).subtract(l))}}function Q2(e,t,r=new w){let i=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-i).add(t),r}function Qg(e,t,r=new w){let i=e.unprojectPosition(t);return ot.WGS84.cartographicToCartesian(i,r)}var DY=6378137,UY=6378137,lb=6356752314245179e-9,Ga=new w;function r3(e,t){if(e instanceof ei){let{halfAxes:r}=e,i=kY(r);return Math.log2(lb/(i+t[2]))}else if(e instanceof vr){let{radius:r}=e;return Math.log2(lb/(r+t[2]))}else if(e.width&&e.height){let{width:r,height:i}=e,s=Math.log2(DY/r),n=Math.log2(UY/i);return(s+n)/2}return 1}function ub(e,t,r){ot.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Ga);let i=Math.sqrt(Math.pow(Ga[0]-r[0],2)+Math.pow(Ga[1]-r[1],2)+Math.pow(Ga[2]-r[2],2));return Math.log2(lb/(i+t[2]))}function i3(e,t,r){let[i,s,n,o]=e;return ub({xmin:i,xmax:n,ymin:s,ymax:o,zmin:0,zmax:0},t,r)}function kY(e){e.getColumn(0,Ga);let t=e.getColumn(1),r=e.getColumn(2);return Ga.add(t).add(r).len()}var Ue={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},Ce;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(Ce||(Ce={}));var Pr;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Pr||(Pr={}));var pe;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(pe||(pe={}));var ls;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(ls||(ls={}));var s3={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function c3(e){return e!=null}var we=new w,tm=new w,VY=new w,zY=new w,To=new w,n3=new w,o3=new w,a3=new w;function em(e,t,r){if(nt(e,"3D Tile: boundingVolume must be defined"),e.box)return u3(e.box,t,r);if(e.region)return GY(e.region);if(e.sphere)return HY(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function l3(e,t){if(e.box)return WY(t);if(e.region){let[r,i,s,n,o,a]=e.region;return[[Zt(r),Zt(i),o],[Zt(s),Zt(n),a]]}if(e.sphere)return jY(t);throw new Error("Unkown boundingVolume type")}function u3(e,t,r){let i=new w(e[0],e[1],e[2]);t.transform(i,i);let s=[];if(e.length===10){let l=e.slice(3,6),u=new gr;u.fromArray(e,6);let f=new w([1,0,0]),h=new w([0,1,0]),d=new w([0,0,1]);f.transformByQuaternion(u),f.scale(l[0]),h.transformByQuaternion(u),h.scale(l[1]),d.transformByQuaternion(u),d.scale(l[2]),s=[...f.toArray(),...h.toArray(),...d.toArray()]}else s=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let n=t.transformAsVector(s.slice(0,3)),o=t.transformAsVector(s.slice(3,6)),a=t.transformAsVector(s.slice(6,9)),c=new mt([n[0],n[1],n[2],o[0],o[1],o[2],a[0],a[1],a[2]]);return c3(r)?(r.center=i,r.halfAxes=c,r):new ei(i,c)}function HY(e,t,r){let i=new w(e[0],e[1],e[2]);t.transform(i,i);let s=t.getScale(tm),n=Math.max(Math.max(s[0],s[1]),s[2]),o=e[3]*n;return c3(r)?(r.center=i,r.radius=o,r):new vr(i,o)}function GY(e){let[t,r,i,s,n,o]=e,a=ot.WGS84.cartographicToCartesian([Zt(t),Zt(s),n],VY),c=ot.WGS84.cartographicToCartesian([Zt(i),Zt(r),o],zY),l=new w().addVectors(a,c).multiplyByScalar(.5);return ot.WGS84.cartesianToCartographic(l,To),ot.WGS84.cartographicToCartesian([Zt(i),To[1],To[2]],n3),ot.WGS84.cartographicToCartesian([To[0],Zt(s),To[2]],o3),ot.WGS84.cartographicToCartesian([To[0],To[1],o],a3),u3([...l,...n3.subtract(l),...o3.subtract(l),...a3.subtract(l)],new q)}function WY(e){let t=f3(),{halfAxes:r}=e,i=new w(r.getColumn(0)),s=new w(r.getColumn(1)),n=new w(r.getColumn(2));for(let o=0;o<2;o++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)we.copy(e.center),we.add(i),we.add(s),we.add(n),h3(t,we),n.negate();s.negate()}i.negate()}return t}function jY(e){let t=f3(),{center:r,radius:i}=e,s=ot.WGS84.scaleToGeodeticSurface(r,we),n;s?n=ot.WGS84.geodeticSurfaceNormal(s):n=new w(0,0,1);let o=new w(n[2],-n[1],0);o.len()>0?o.normalize():o=new w(0,1,0);let a=o.clone().cross(n);for(let c of[o,a,n]){tm.copy(c).scale(i);for(let l=0;l<2;l++)we.copy(r),we.add(tm),h3(t,we),tm.negate()}return t}function f3(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function h3(e,t){ot.WGS84.cartesianToCartographic(t,we),e[0][0]=Math.min(e[0][0],we[0]),e[0][1]=Math.min(e[0][1],we[1]),e[0][2]=Math.min(e[0][2],we[2]),e[1][0]=Math.max(e[1][0],we[0]),e[1][1]=Math.max(e[1][1],we[1]),e[1][2]=Math.max(e[1][2],we[2])}var WIt=new w,jIt=new w,XIt=new q,YIt=new w,qIt=new w,KIt=new w;function XY(e,t){let r=e*t;return 1-Math.exp(-(r*r))}function YY(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){let r=e.dynamicScreenSpaceErrorComputedDensity,i=e.dynamicScreenSpaceErrorFactor;return XY(t,r)*i}return 0}function d3(e,t,r){let i=e.tileset,s=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,n=r?s:e.lodMetricValue;if(n===0)return 0;let o=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:c}=t,{viewDistanceScale:l}=i.options,u=n*a*(l||1)/(o*c);return u-=YY(i,o),u}var fb=new w,p3=new w,en=new w,g3=new w,qY=new w,hb=new q,m3=new q;function _3(e,t){if(e.lodMetricValue===0||isNaN(e.lodMetricValue))return"DIG";let r=2*db(e,t);return r<2?"OUT":!e.header.children||r<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function db(e,t){let{topDownViewport:r}=t,i=e.header.mbs[1],s=e.header.mbs[0],n=e.header.mbs[2],o=e.header.mbs[3],a=[...e.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);ot.WGS84.cartographicToCartesian(c,fb),p3.copy(fb).subtract(a).normalize(),ot.WGS84.eastNorthUpToFixedFrame(a,hb),m3.copy(hb).invert(),en.copy(fb).transform(m3);let l=Math.sqrt(en[0]*en[0]+en[1]*en[1]),u=l*l/en[2];g3.copy([en[0],en[1],u]);let h=g3.transform(hb).subtract(a).normalize(),p=p3.cross(h).normalize().scale(o).add(a),g=ot.WGS84.cartesianToCartographic(p),m=r.project([s,i,n]),_=r.project(g);return qY.copy(m).subtract(_).magnitude()}function y3(e){return{assetGltfUpAxis:e.asset&&e.asset.gltfUpAxis||"Y"}}var pf=class{_map=new Map;_array;_length;constructor(t=0){this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return nt(t<this._array.length),this._array[t]}set(t,r){nt(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=r,this._map.set(r,t)}delete(t){let r=this._map.get(t);r>=0&&(this._array.splice(r,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let r=this.length++;this._array[r]=t,this._map.set(t,r)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){nt(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){nt(t>=0),this.length=t}trim(t){t==null&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}};var KY={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Ii=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new pf;_emptyTraversalStack=new pf;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...KY,...t}}traverse(t,r,i){this.root=t,this.options={...this.options,...i},this.reset(),this.updateTile(t,r),this._frameNumber=r.frameNumber,this.executeTraversal(t,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,r){let i=this._traversalStack;for(t._selectionDepth=1,i.push(t);i.length>0;){let n=i.pop(),o=!1;this.canTraverse(n,r)&&(this.updateChildTiles(n,r),o=this.updateAndPushChildren(n,r,i,n.hasRenderContent?n._selectionDepth+1:n._selectionDepth));let a=n.parent,c=Boolean(!a||a._shouldRefine),l=!o;n.hasRenderContent?n.refine===Ce.ADD?(this.loadTile(n,r),this.selectTile(n,r)):n.refine===Ce.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 s=new Date().getTime();(this.traversalFinished(r)||s-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=s,this.options.onTraversalEnd(r))}updateChildTiles(t,r){let i=t.children;for(let s of i)this.updateTile(s,r)}updateAndPushChildren(t,r,i,s){let{loadSiblings:n,skipLevelOfDetail:o}=this.options,a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let c=t.refine===Ce.REPLACE&&t.hasRenderContent&&!o,l=!1,u=!0;for(let f of a)if(f._selectionDepth=s,f.isVisibleAndInRequestVolume?(i.find(f)&&i.delete(f),i.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(t,r){this.updateTileVisibility(t,r)}selectTile(t,r){this.shouldSelectTile(t)&&(t._selectedFrame=r.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,r){this.shouldLoadTile(t)&&(t._requestedFrame=r.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,r){t.tileset._cache.touch(t),t._touchedFrame=r.frameNumber}canTraverse(t,r,i=!1,s=!1){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:!s&&!t.isVisibleAndInRequestVolume?!1:this.shouldRefine(t,r,i):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,r,i=!1){let s=t._screenSpaceError;return i&&(s=t.getScreenSpaceError(r,!0)),s>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,r){let i=[];if(this.options.viewportTraversersMap)for(let s in this.options.viewportTraversersMap)this.options.viewportTraversersMap[s]===r.viewport.id&&i.push(s);else i.push(r.viewport.id);t.updateVisibility(r,i)}compareDistanceToCamera(t,r){return t._distanceToCamera-r._distanceToCamera}anyChildrenVisible(t,r){let i=!1;for(let s of t.children)s.updateVisibility(r),i=i||s.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(t,r){let i=!0,s=this._emptyTraversalStack;for(s.push(t);s.length>0;){let n=s.pop(),o=!n.hasRenderContent&&this.canTraverse(n,r,!1,!1),a=!n.hasRenderContent&&n.children.length===0;if(!o&&!n.contentAvailable&&!a&&(i=!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)s.push(l)}}return i}};var x3=new w;function $Y(e){return e!=null}var bo=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Ue.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new q;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Ii({});_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(t,r,i,s=""){this.header=r,this.tileset=t,this.id=s||r.id,this.url=r.url,this.parent=i,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===Ue.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===Ue.UNLOADED}get contentExpired(){return this.contentState===Ue.EXPIRED}get contentFailed(){return this.contentState===Ue.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=l3(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,r){switch(this.tileset.type){case pe.I3S:return db(this,t);case pe.TILES3D:return d3(this,t,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let t=this.tileset._traverser,{skipLevelOfDetail:r}=t.options,i=this.refine===Ce.ADD||r;if(i&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Ue.UNLOADED)return-1;let s=this.parent,o=s&&(!i||this._screenSpaceError===0||s.hasTilesetContent)?s._screenSpaceError:this._screenSpaceError,a=t.root?t.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=Ue.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=Ue.UNLOADED,!1;try{let i=this.tileset.getTileUrl(this.contentUrl),s=this.tileset.loader,n={...this.tileset.loadOptions,[s.id]:{...this.tileset.loadOptions[s.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(s.id)}};return this.content=await Jt(i,s,n),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Ue.READY,this._onContentLoaded(),!0}catch(i){throw this.contentState=Ue.FAILED,i}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=Ue.UNLOADED,!0}updateVisibility(t,r){if(this._frameNumber===t.frameNumber)return;let i=this.parent,s=i?i._visibilityPlaneMask:ie.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let n=i?i.computedTransform:this.tileset.modelMatrix;this._updateTransform(n)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,s),this._visible=this._visibilityPlaneMask!==ie.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=r}visibility(t,r){let{cullingVolume:i}=t,{boundingVolume:s}=this;return i.computeVisibilityWithPlaneMask(s,r)}contentVisibility(){return!0}distanceToTile(t){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let r=this.boundingVolume;return x3.subVectors(r.center,t.position),t.direction.dot(x3)}insideViewerRequestVolume(t){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if($Y(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Ue.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new q(t.transform):new q;let r=this.parent,i=this.tileset,s=r&&r.computedTransform?r.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new q(s).multiplyRight(this.transform);let n=r&&r._initialTransform?r._initialTransform.clone():new q;this._initialTransform=new q(n).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Ue.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=ie.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(t){return t||this.parent&&this.parent.refine||Ce.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(t){this.boundingVolume=em(t.boundingVolume,this.computedTransform,this.boundingVolume);let r=t.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=em(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=em(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new q){let r=t.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return y3(this.tileset.tileset)}}};var rm=class extends Ii{compareDistanceToCamera(t,r){return r._distanceToCamera===0&&t._distanceToCamera===0?r._centerZDepth-t._centerZDepth:r._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,r){if(super.updateTileVisibility(t,r),!t.isVisibleAndInRequestVolume)return;let i=t.children.length>0;if(t.hasTilesetContent&&i){let o=t.children[0];this.updateTileVisibility(o,r),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,r)){t._visible=!1;return}let s=t.refine===Ce.REPLACE,n=t._optimChildrenWithinParent===s3.USE_OPTIMIZATION;if(s&&n&&i&&!this.anyChildrenVisible(t,r)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,r){let{parent:i}=t;return!i||i.hasTilesetContent||i.refine!==Ce.ADD?!1:!this.shouldRefine(t,r,!0)}};var im=class{frameNumberMap=new Map;register(t,r){let i=this.frameNumberMap.get(t)||new Map,s=i.get(r)||0;i.set(r,s+1),this.frameNumberMap.set(t,i)}deregister(t,r){let i=this.frameNumberMap.get(t);if(!i)return;let s=i.get(r)||1;i.set(r,s-1)}isZero(t,r){return(this.frameNumberMap.get(t)?.get(r)||0)===0}};var pb={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},sm=class{_statusMap;pendingTilesRegister=new im;constructor(){this._statusMap={}}add(t,r,i,s){if(!this._statusMap[r]){let{frameNumber:n,viewport:{id:o}}=s;this._statusMap[r]={request:t,callback:i,key:r,frameState:s,status:pb.REQUESTED},this.pendingTilesRegister.register(o,n),t().then(a=>{this._statusMap[r].status=pb.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,s)}).catch(a=>{this._statusMap[r].status=pb.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),i(a)})}}update(t,r){if(this._statusMap[t]){let{frameNumber:i,viewport:{id:s}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(s,i);let{frameNumber:n,viewport:{id:o}}=r;this.pendingTilesRegister.register(o,n),this._statusMap[t].frameState=r}}find(t){return this._statusMap[t]}hasPendingTiles(t,r){return!this.pendingTilesRegister.isZero(t,r)}};var nm=class extends Ii{_tileManager;constructor(t){super(t),this._tileManager=new sm}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,r){return t._lodJudge=_3(t,r),t._lodJudge==="DIG"}updateChildTiles(t,r){let i=t.header.children||[],s=t.children,n=t.tileset;for(let o of i){let a=`${o.id}-${r.viewport.id}`,c=s&&s.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,t,a),r))}}return!1}async _loadTile(t,r){let{loader:i}=r,s=r.getTileUrl(`${r.url}/nodes/${t}`),n={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await Jt(s,i,n)}_onTileLoad(t,r,i){let s=new bo(r.tileset,t,r,i);r.children.push(s);let n=this._tileManager.find(s.id).frameState;this.updateTile(s,n),this._frameNumber===n.frameNumber&&(this.traversalFinished(n)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(s,n)}};var JY={description:"",ellipsoid:ot.WGS84,modelMatrix:new q,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},om="Tiles In Tileset(s)",gb="Tiles In Memory",A3="Tiles In View",T3="Tiles To Render",b3="Tiles Loaded",mb="Tiles Loading",E3="Tiles Unloaded",S3="Failed Tile Loads",v3="Points/Vertices",_b="Tile Memory Use",C3="Maximum Screen Space Error",gf=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 Zg;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(t,r){this.options={...JY,...r},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||Je.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new As({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 Ee({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(t){this.options={...this.options,...t}}getTileUrl(t){if(t.startsWith("data:"))return t;let i=t;return this.queryParams.length&&(i=`${t}${t.includes("?")?"&":"?"}${this.queryParams}`),i}hasExtension(t){return Boolean(this._extensionsUsed.indexOf(t)>-1)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let i=[];for(let s of r){let n=s.id;this._needTraverse(n)?i.push(n):this.traverseCounter--}for(let s of r){let n=s.id;if(this.roots[n]||(this.roots[n]=this._initializeTileHeaders(this.tileset,null)),!i.includes(n))continue;let o=t3(s,this._frameNumber);this._traverser.traverse(this.roots[n],o,this.options)}}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){let r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let i=this.frameStateData[r],s=Object.values(this._traverser.selectedTiles),[n,o]=e3(s,t,this.options.maximumTilesSelected);i.selectedTiles=n;for(let a of o)a.unselect();i._requestedTiles=Object.values(this._traverser.requestedTiles),i._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let t in this.frameStateData){let r=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(r.selectedTiles),this._requestedTiles=this._requestedTiles.concat(r._requestedTiles),this._emptyTiles=this._emptyTiles.concat(r._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(let t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,r){if(t.length!==r.length)return!0;let i=new Set(t.map(o=>o.id)),s=new Set(r.map(o=>o.id)),n=t.filter(o=>!s.has(o.id)).length>0;return n=n||r.filter(o=>!i.has(o.id)).length>0,n}_loadTiles(){for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r))}_updateStats(){let t=0,r=0;for(let i of this.selectedTiles)i.contentAvailable&&i.content&&(t++,i.content.pointCount?r+=i.content.pointCount:r+=i.content.vertexCount);this.stats.get(A3).count=this.selectedTiles.length,this.stats.get(T3).count=t,this.stats.get(v3).count=r,this.stats.get(C3).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(t){this.type===pe.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===pe.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===pe.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let t=this.tileset.fullExtent;if(t){let{xmin:i,xmax:s,ymin:n,ymax:o,zmin:a,zmax:c}=t;this.cartographicCenter=new w(i+(s-i)/2,n+(o-n)/2,a+(c-a)/2),this.cartesianCenter=new w,ot.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=ub(t,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[i,s,n,o]=r;this.cartographicCenter=new w(i+(n-i)/2,s+(o-s)/2,0),this.cartesianCenter=new w,ot.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=i3(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 t=this.root,{center:r}=t.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,ot.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new w(0,0,-ot.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=r3(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(om),this.stats.get(mb),this.stats.get(gb),this.stats.get(A3),this.stats.get(T3),this.stats.get(b3),this.stats.get(E3),this.stats.get(S3),this.stats.get(v3),this.stats.get(_b,"memory"),this.stats.get(C3)}_initializeTileHeaders(t,r){let i=new bo(this,t.root,r);if(r&&(r.children.push(i),i.depth=r.depth+1),this.type===pe.TILES3D){let s=[];for(s.push(i);s.length>0;){let n=s.pop();this.stats.get(om).incrementCount();let o=n.header.children||[];for(let a of o){let c=new bo(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,s.push(c)}}}return i}_initializeTraverser(){let t;switch(this.type){case pe.TILES3D:t=rm;break;case pe.I3S:t=nm;break;default:t=Ii}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r;try{this._onStartTileLoading(),r=await t.loadContent()}catch(i){this._onTileLoadError(t,i instanceof Error?i:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}_onTileLoadError(t,r){this.stats.get(S3).incrementCount();let i=r.message||r.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${i}`),this.options.onTileError(t,i,s)}_onTileLoad(t,r){if(r){if(this.type===pe.I3S){let i=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(om).reset(),this.stats.get(om).addCount(i)}t&&t.content&&J2(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===pe.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===pe.TILES3D){let{extensionsRemoved:r=[]}=t.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(mb).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(mb).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(b3).incrementCount(),this.stats.get(gb).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(_b).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(gb).decrementCount(),this.stats.get(E3).incrementCount(),this.stats.get(_b).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let r=t.pop();for(let i of r.children)t.push(i);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,i=[];for(i.push(r);i.length>0;){t=i.pop();for(let s of t.children)i.push(s);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){let r=new URLSearchParams(t.queryString),i=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...i}}if(this.asset=t.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}};var am="4.2.0-beta.2";var Eo={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},X2t=Object.keys(Eo);function yb(e,t,r){nt(e instanceof ArrayBuffer);let i=new TextDecoder("utf8"),s=new Uint8Array(e,t,r);return i.decode(s)}function w3(e,t=0){let r=new DataView(e);return`${String.fromCharCode(r.getUint8(t+0))}${String.fromCharCode(r.getUint8(t+1))}${String.fromCharCode(r.getUint8(t+2))}${String.fromCharCode(r.getUint8(t+3))}`}var ZY={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},qt={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},rt={...ZY,...qt};var xb={[qt.DOUBLE]:Float64Array,[qt.FLOAT]:Float32Array,[qt.UNSIGNED_SHORT]:Uint16Array,[qt.UNSIGNED_INT]:Uint32Array,[qt.UNSIGNED_BYTE]:Uint8Array,[qt.BYTE]:Int8Array,[qt.SHORT]:Int16Array,[qt.INT]:Int32Array},QY={DOUBLE:qt.DOUBLE,FLOAT:qt.FLOAT,UNSIGNED_SHORT:qt.UNSIGNED_SHORT,UNSIGNED_INT:qt.UNSIGNED_INT,UNSIGNED_BYTE:qt.UNSIGNED_BYTE,BYTE:qt.BYTE,SHORT:qt.SHORT,INT:qt.INT},Ab="Failed to convert GL type",Pe=class{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(let r in xb)if(xb[r]===t)return r;throw new Error(Ab)}static fromName(t){let r=QY[t];if(!r)throw new Error(Ab);return r}static getArrayType(t){switch(t){case qt.UNSIGNED_SHORT_5_6_5:case qt.UNSIGNED_SHORT_4_4_4_4:case qt.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=xb[t];if(!r)throw new Error(Ab);return r}}static getByteSize(t){return Pe.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(Pe.getArrayType(t))}static createTypedArray(t,r,i=0,s){s===void 0&&(s=(r.byteLength-i)/Pe.getByteSize(t));let n=Pe.getArrayType(t);return new n(r,i,s)}};function P3(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}function Tb(e,t=[0,0,0]){let r=e>>11&31,i=e>>5&63,s=e&31;return t[0]=r<<3,t[1]=i<<2,t[2]=s<<3,t}var i3t=1/256;var s3t=new Fr,n3t=new w,o3t=new Fr,a3t=new Fr,c3t=new Uint8Array(1);function M3(e,t=255){return ht(e,0,t)/t*2-1}function R3(e){return e<0?-1:1}function I3(e,t,r,i){if(P3(i),e<0||e>r||t<0||t>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(i.x=M3(e,r),i.y=M3(t,r),i.z=1-(Math.abs(i.x)+Math.abs(i.y)),i.z<0){let s=i.x;i.x=(1-Math.abs(i.y))*R3(s),i.y=(1-Math.abs(s))*R3(i.y)}return i.normalize()}function bb(e,t,r){return I3(e,t,255,r)}var us=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(t,r){this.json=t,this.buffer=r}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return Boolean(this.json[t])}getGlobalProperty(t,r=rt.UNSIGNED_INT,i=1){let s=this.json[t];return s&&Number.isFinite(s.byteOffset)?this._getTypedArrayFromBinary(t,r,i,1,s.byteOffset):s}getPropertyArray(t,r,i){let s=this.json[t];return s&&Number.isFinite(s.byteOffset)?("componentType"in s&&(r=Pe.fromName(s.componentType)),this._getTypedArrayFromBinary(t,r,i,this.featuresLength,s.byteOffset)):this._getTypedArrayFromArray(t,r,s)}getProperty(t,r,i,s,n){let o=this.json[t];if(!o)return o;let a=this.getPropertyArray(t,r,i);if(i===1)return a[s];for(let c=0;c<i;++c)n[c]=a[i*s+c];return n}_getTypedArrayFromBinary(t,r,i,s,n){let o=this._cachedTypedArrays,a=o[t];return a||(a=Pe.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+n,s*i),o[t]=a),a}_getTypedArrayFromArray(t,r,i){let s=this._cachedTypedArrays,n=s[t];return n||(n=Pe.createTypedArray(r,i),s[t]=n),n}};var tq={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eq={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},rq={SCALAR:(e,t,r)=>{t[r]=e},VEC2:(e,t,r)=>{t[2*r+0]=e[0],t[2*r+1]=e[1]},VEC3:(e,t,r)=>{t[3*r+0]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2]},VEC4:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT2:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT3:(e,t,r)=>{t[9*r+0]=e[0],t[9*r+1]=e[1],t[9*r+2]=e[2],t[9*r+3]=e[3],t[9*r+4]=e[4],t[9*r+5]=e[5],t[9*r+6]=e[6],t[9*r+7]=e[7],t[9*r+8]=e[8],t[9*r+9]=e[9]},MAT4:(e,t,r)=>{t[16*r+0]=e[0],t[16*r+1]=e[1],t[16*r+2]=e[2],t[16*r+3]=e[3],t[16*r+4]=e[4],t[16*r+5]=e[5],t[16*r+6]=e[6],t[16*r+7]=e[7],t[16*r+8]=e[8],t[16*r+9]=e[9],t[16*r+10]=e[10],t[16*r+11]=e[11],t[16*r+12]=e[12],t[16*r+13]=e[13],t[16*r+14]=e[14],t[16*r+15]=e[15]}};function B3(e,t,r,i){let{componentType:s}=e;nt(e.componentType);let n=typeof s=="string"?Pe.fromName(s):s,o=tq[e.type],a=eq[e.type],c=rq[e.type];return r+=e.byteOffset,{values:Pe.createTypedArray(n,t,r,o*i),type:n,size:o,unpacker:a,packer:c}}var Bi=e=>e!==void 0;function O3(e,t,r){if(!t)return null;let i=e.getExtension("3DTILES_batch_table_hierarchy"),s=t.HIERARCHY;return s&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=s,i=s),i?iq(i,r):null}function iq(e,t){let r,i,s,n=e.instancesLength,o=e.classes,a=e.classIds,c=e.parentCounts,l=e.parentIds,u=n;Bi(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,s=getBinaryAccessor(a),a=s.createArrayBufferView(t.buffer,t.byteOffset+a.byteOffset,n));let f;if(Bi(c))for(Bi(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,s=getBinaryAccessor(c),c=s.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,n)),f=new Uint16Array(n),u=0,r=0;r<n;++r)f[r]=u,u+=c[r];Bi(l)&&Bi(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,s=getBinaryAccessor(l),l=s.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,u));let h=o.length;for(r=0;r<h;++r){let m=o[r].length,_=o[r].instances,y=getBinaryProperties(m,_,t);o[r].instances=combine(y,_)}let d=new Array(h).fill(0),p=new Uint16Array(n);for(r=0;r<n;++r)i=a[r],p[r]=d[i],++d[i];let g={classes:o,classIds:a,classIndexes:p,parentCounts:c,parentIndexes:f,parentIds:l};return oq(g),g}function Wa(e,t,r){if(!e)return;let i=e.parentCounts;return e.parentIds?r(e,t):i>0?sq(e,t,r):nq(e,t,r)}function sq(e,t,r){let i=e.classIds,s=e.parentCounts,n=e.parentIds,o=e.parentIndexes,a=i.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,u=scratchStack;for(u.length=0,u.push(t);u.length>0;){if(t=u.pop(),c[t]===l)continue;c[t]=l;let f=r(e,t);if(Bi(f))return f;let h=s[t],d=o[t];for(let p=0;p<h;++p){let g=n[d+p];g!==t&&u.push(g)}}return null}function nq(e,t,r){let i=!0;for(;i;){let s=r(e,t);if(Bi(s))return s;let n=e.parentIds[t];i=n!==t,t=n}throw new Error("traverseHierarchySingleParent")}function oq(e){let t=[],i=e.classIds.length;for(let s=0;s<i;++s)F3(e,s,stack)}function F3(e,t,r){let i=e.parentCounts,s=e.parentIds,n=e.parentIndexes,a=e.classIds.length;if(!Bi(s))return;assert(t<a,`Parent index ${t} exceeds the total number of instances: ${a}`),assert(r.indexOf(t)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(t);let c=Bi(i)?i[t]:1,l=Bi(i)?n[t]:t;for(let u=0;u<c;++u){let f=s[l+u];f!==t&&F3(e,f,r)}r.pop(t)}function qe(e){return e!=null}var cm=(e,t)=>e,aq={HIERARCHY:!0,extensions:!0,extras:!0},So=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(t,r,i,s={}){nt(i>=0),this.json=t||{},this.binary=r,this.featureCount=i,this._extensions=this.json?.extensions||{},this._properties={};for(let n in this.json)aq[n]||(this._properties[n]=this.json[n]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=O3(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,r){if(this._checkBatchId(t),nt(typeof r=="string",r),this._hierarchy){let i=Wa(this._hierarchy,t,(s,n)=>{let o=s.classIds[n];return s.classes[o].name===r});return qe(i)}return!1}isExactClass(t,r){return nt(typeof r=="string",r),this.getExactClassName(t)===r}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){let r=this._hierarchy.classIds[t];return this._hierarchy.classes[r].name}}hasProperty(t,r){return this._checkBatchId(t),nt(typeof r=="string",r),qe(this._properties[r])||this._hasPropertyInHierarchy(t,r)}getPropertyNames(t,r){this._checkBatchId(t),r=qe(r)?r:[],r.length=0;let i=Object.keys(this._properties);return r.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(t,r),r}getProperty(t,r){if(this._checkBatchId(t),nt(typeof r=="string",r),this._binaryProperties){let s=this._binaryProperties[r];if(qe(s))return this._getBinaryProperty(s,t)}let i=this._properties[r];if(qe(i))return cm(i[t],!0);if(this._hierarchy){let s=this._getHierarchyProperty(t,r);if(qe(s))return s}}setProperty(t,r,i){let s=this.featureCount;if(this._checkBatchId(t),nt(typeof r=="string",r),this._binaryProperties){let o=this._binaryProperties[r];if(o){this._setBinaryProperty(o,t,i);return}}if(this._hierarchy&&this._setHierarchyProperty(this,t,r,i))return;let n=this._properties[r];qe(n)||(this._properties[r]=new Array(s),n=this._properties[r]),n[t]=cm(i,!0)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,r){return t.unpack(t.typedArray,r)}_setBinaryProperty(t,r,i){t.pack(i,t.typedArray,r)}_initializeBinaryProperties(){let t=null;for(let r in this._properties){let i=this._properties[r],s=this._initializeBinaryProperty(r,i);s&&(t=t||{},t[r]=s)}return t}_initializeBinaryProperty(t,r){if("byteOffset"in r){let i=r;nt(this.binary,`Property ${t} requires a batch table binary.`),nt(i.type,`Property ${t} requires a type.`);let s=B3(i,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:s.values,componentCount:s.size,unpack:s.unpacker,pack:s.packer}}return null}_hasPropertyInHierarchy(t,r){if(!this._hierarchy)return!1;let i=Wa(this._hierarchy,t,(s,n)=>{let o=s.classIds[n],a=s.classes[o].instances;return qe(a[r])});return qe(i)}_getPropertyNamesInHierarchy(t,r){Wa(this._hierarchy,t,(i,s)=>{let n=i.classIds[s],o=i.classes[n].instances;for(let a in o)o.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(t,r){return Wa(this._hierarchy,t,(i,s)=>{let n=i.classIds[s],o=i.classes[n],a=i.classIndexes[s],c=o.instances[r];return qe(c)?qe(c.typedArray)?this._getBinaryProperty(c,a):cm(c[a],!0):null})}_setHierarchyProperty(t,r,i,s){let n=Wa(this._hierarchy,r,(o,a)=>{let c=o.classIds[a],l=o.classes[c],u=o.classIndexes[a],f=l.instances[i];return qe(f)?(nt(a===r,`Inherited property "${i}" is read-only.`),qe(f.typedArray)?this._setBinaryProperty(f,u,s):f[u]=cm(s,!0),!0):!1});return qe(n)}};function rn(e,t,r=0){let i=new DataView(t);if(e.magic=i.getUint32(r,!0),r+=4,e.version=i.getUint32(r,!0),r+=4,e.byteLength=i.getUint32(r,!0),r+=4,e.version!==1)throw new Error(`3D Tile Version ${e.version} not supported`);return r}var ja=4,N3="b3dm tile in legacy format.";function Xa(e,t,r){let i=new DataView(t),s;e.header=e.header||{};let n=i.getUint32(r,!0);r+=ja;let o=i.getUint32(r,!0);r+=ja;let a=i.getUint32(r,!0);r+=ja;let c=i.getUint32(r,!0);return r+=ja,a>=570425344?(r-=ja*2,s=n,a=o,c=0,n=0,o=0,console.warn(N3)):c>=570425344&&(r-=ja,s=a,a=n,c=o,n=0,o=0,console.warn(N3)),e.header.featureTableJsonByteLength=n,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=c,e.header.batchLength=s,r}function Ya(e,t,r,i){return r=cq(e,t,r,i),r=lq(e,t,r,i),r}function cq(e,t,r,i){let{featureTableJsonByteLength:s,featureTableBinaryByteLength:n,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},s&&s>0){let a=yb(t,r,s);e.featureTableJson=JSON.parse(a)}return r+=s||0,e.featureTableBinary=new Uint8Array(t,r,n),r+=n||0,r}function lq(e,t,r,i){let{batchTableJsonByteLength:s,batchTableBinaryByteLength:n}=e.header||{};if(s&&s>0){let o=yb(t,r,s);e.batchTableJson=JSON.parse(o),r+=s,n&&n>0&&(e.batchTableBinary=new Uint8Array(t,r,n),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=n)}return r}function Eb(e,t,r){if(!t&&(!e||!e.batchIds||!r))return null;let{batchIds:i,isRGB565:s,pointCount:n=0}=e;if(i&&r){let o=new Uint8ClampedArray(n*3);for(let a=0;a<n;a++){let c=i[a],u=r.getProperty(c,"dimensions").map(f=>f*255);o[a*3]=u[0],o[a*3+1]=u[1],o[a*3+2]=u[2]}return{type:rt.UNSIGNED_BYTE,value:o,size:3,normalized:!0}}if(t&&s){let o=new Uint8ClampedArray(n*3);for(let a=0;a<n;a++){let c=Tb(t[a]);o[a*3]=c[0],o[a*3+1]=c[1],o[a*3+2]=c[2]}return{type:rt.UNSIGNED_BYTE,value:o,size:3,normalized:!0}}return t&&t.length===n*3?{type:rt.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:rt.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}var L3=new w;function D3(e,t){if(!t)return null;if(e.isOctEncoded16P){let r=new Float32Array((e.pointsLength||0)*3);for(let i=0;i<(e.pointsLength||0);i++)bb(t[i*2],t[i*2+1],L3),L3.toArray(r,i*3);return{type:rt.FLOAT,size:2,value:r}}return{type:rt.FLOAT,size:2,value:t}}function U3(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,uq(e,t)):{type:rt.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}function uq(e,t){let r=new w,i=new Float32Array(e.pointCount*3);for(let s=0;s<e.pointCount;s++)r.set(t[s*3],t[s*3+1],t[s*3+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(i,s*3);return i}async function k3(e,t,r,i,s){r=rn(e,t,r),r=Xa(e,t,r),r=Ya(e,t,r,i),fq(e);let{featureTable:n,batchTable:o}=hq(e);return await _q(e,n,o,i,s),dq(e,n,i),pq(e,n,o),gq(e,n),r}function fq(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}function hq(e){let t=new us(e.featureTableJson,e.featureTableBinary),r=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=r,e.featuresLength=r,e.pointsLength=r,e.pointCount=r,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",rt.FLOAT,3);let i=mq(e,t);return{featureTable:t,batchTable:i}}function dq(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions){if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",rt.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){let i=t.getPropertyArray("POSITION_QUANTIZED",rt.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=(1<<16)-1,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",rt.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",rt.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=U3(e,i,r)}}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function pq(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let i=null;t.hasProperty("RGBA")?(i=t.getPropertyArray("RGBA",rt.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?i=t.getPropertyArray("RGB",rt.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(i=t.getPropertyArray("RGB565",rt.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Eb(e,i,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",rt.UNSIGNED_BYTE,4))}function gq(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",rt.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",rt.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=D3(e,r)}}function mq(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",rt.UNSIGNED_SHORT,1),e.batchIds)){let i=t.getGlobalProperty("BATCH_LENGTH");if(!i)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:s,batchTableBinary:n}=e;r=new So(s,n,i)}return r}async function _q(e,t,r,i,s){let n,o,a,c=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=t.getExtension("3DTILES_draco_point_compression");if(l){o=l.properties;let f=l.byteOffset,h=l.byteLength;if(!o||!Number.isFinite(f)||!h)throw new Error("Draco properties, byteOffset, and byteLength must be defined");n=(e.featureTableBinary||[]).slice(f,f+h),e.hasPositions=Number.isFinite(o.POSITION),e.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),e.hasNormals=Number.isFinite(o.NORMAL),e.hasBatchIds=Number.isFinite(o.BATCH_ID),e.isTranslucent=Number.isFinite(o.RGBA)}if(!n)return!0;let u={buffer:n,properties:{...o,...a},featureTableProperties:o,batchTableProperties:a,dequantizeInShader:!1};return await yq(e,u,i,s)}async function yq(e,t,r,i){if(!i)return;let s={...r,draco:{...r?.draco,extraAttributes:t.batchTableProperties||{}}};delete s["3d-tiles"];let n=await $e(t.buffer,Hg,s,i),o=n.attributes.POSITION&&n.attributes.POSITION.value,a=n.attributes.COLOR_0&&n.attributes.COLOR_0.value,c=n.attributes.NORMAL&&n.attributes.NORMAL.value,l=n.attributes.BATCH_ID&&n.attributes.BATCH_ID.value,u=o&&n.attributes.POSITION.value.quantization,f=c&&n.attributes.NORMAL.value.quantization;if(u){let d=n.POSITION.data.quantization,p=d.range;e.quantizedVolumeScale=new w(p,p,p),e.quantizedVolumeOffset=new w(d.minValues),e.quantizedRange=(1<<d.quantizationBits)-1,e.isQuantizedDraco=!0}f&&(e.octEncodedRange=(1<<n.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);let h={};if(t.batchTableProperties)for(let d of Object.keys(t.batchTableProperties))n.attributes[d]&&n.attributes[d].value&&(h[d.toLowerCase()]=n.attributes[d].value);e.attributes={positions:o,colors:Eb(e,a,void 0),normals:c,batchIds:l,...h}}var lm={URI:0,EMBEDDED:1};function um(e,t,r,i){e.rotateYtoZ=!0;let s=(e.byteOffset||0)+(e.byteLength||0)-r;if(s===0)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=i?.["3d-tiles"]&&i["3d-tiles"].assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=pn(t,r,s),e.gltfByteOffset=0,e.gltfByteLength=s,r%4===0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function fm(e,t,r,i){let s=r?.["3d-tiles"]||{};if(xq(e,t,r),s.loadGLTF){if(!i)return;if(e.gltfUrl){let{fetch:n}=i,o=await n(e.gltfUrl,r);e.gltfArrayBuffer=await o.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){let n=await $e(e.gltfArrayBuffer,as,r,i);e.gltf=xo(n),e.gpuMemoryUsageInBytes=af(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}function xq(e,t,r){switch(t){case lm.URI:if(e.gltfArrayBuffer){let i=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),n=new TextDecoder().decode(i);e.gltfUrl=n.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case lm.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function V3(e,t,r,i,s){r=Aq(e,t,r,i,s),await fm(e,lm.EMBEDDED,i,s);let n=e?.gltf?.extensions;return n&&n.CESIUM_RTC&&(e.rtcCenter=n.CESIUM_RTC.center),r}function Aq(e,t,r,i,s){r=rn(e,t,r),r=Xa(e,t,r),r=Ya(e,t,r,i),r=um(e,t,r,i);let n=new us(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=n.getGlobalProperty("RTC_CENTER",rt.FLOAT,3),r}async function z3(e,t,r,i,s){return r=Tq(e,t,r,i,s),await fm(e,e.gltfFormat||0,i,s),r}function Tq(e,t,r,i,s){if(r=rn(e,t,r),e.version!==1)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=Xa(e,t,r);let n=new DataView(t);if(e.gltfFormat=n.getUint32(r,!0),r+=4,r=Ya(e,t,r,i),r=um(e,t,r,i),!e?.header?.featureTableJsonByteLength||e.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let o=new us(e.featureTableJson,e.featureTableBinary),a=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",rt.FLOAT,3);let c=new So(e.batchTableJson,e.batchTableBinary,a);return bq(e,o,c,a),r}function bq(e,t,r,i){let s=new Array(i),n=new w,o=new w,a=new w,c=new w,l=new mt,u=new gr,f=new w,h={},d=new q,p=[],g=[],m=[],_=[];for(let y=0;y<i;y++){let x;if(t.hasProperty("POSITION"))x=t.getProperty("POSITION",rt.FLOAT,3,y,n);else if(t.hasProperty("POSITION_QUANTIZED")){x=t.getProperty("POSITION_QUANTIZED",rt.UNSIGNED_SHORT,3,y,n);let T=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",rt.FLOAT,3);if(!T)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let L=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",rt.FLOAT,3);if(!L)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let V=65535;for(let z=0;z<3;z++)x[z]=x[z]/V*L[z]+T[z]}if(!x)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");n.copy(x),h.translation=n,e.normalUp=t.getProperty("NORMAL_UP",rt.FLOAT,3,y,p),e.normalRight=t.getProperty("NORMAL_RIGHT",rt.FLOAT,3,y,g);let E=!1;if(e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",rt.UNSIGNED_SHORT,2,y,p),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",rt.UNSIGNED_SHORT,2,y,g),e.octNormalUp)throw e.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");e.eastNorthUp?(ot.WGS84.eastNorthUpToFixedFrame(n,d),d.getRotationMatrix3(l)):l.identity()}E&&(c.copy(o).cross(a).normalize(),l.setColumn(0,o),l.setColumn(1,a),l.setColumn(2,c)),u.fromMatrix3(l),h.rotation=u,f.set(1,1,1);let P=t.getProperty("SCALE",rt.FLOAT,1,y,m);Number.isFinite(P)&&f.multiplyByScalar(P);let B=t.getProperty("SCALE_NON_UNIFORM",rt.FLOAT,3,y,p);B&&f.scale(B),h.scale=f;let F=t.getProperty("BATCH_ID",rt.UNSIGNED_SHORT,1,y,_);F===void 0&&(F=y);let M=new q().fromQuaternion(h.rotation);d.identity(),d.translate(h.translation),d.multiplyRight(M),d.scale(h.scale);let v=d.clone();s[y]={modelMatrix:v,batchId:F}}e.instances=s}async function H3(e,t,r,i,s,n){r=rn(e,t,r);let o=new DataView(t);for(e.tilesLength=o.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-r>12;){let a={shape:"tile3d"};e.tiles.push(a),r=await n(t,r,i,s,a)}return r}async function G3(e,t,r,i){if(e.rotateYtoZ=!0,e.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!i)return t.byteLength;let s=await $e(t,as,r,i);e.gltf=xo(s),e.gpuMemoryUsageInBytes=af(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}async function Sb(e,t=0,r,i,s={shape:"tile3d"}){switch(s.byteOffset=t,s.type=w3(e,t),s.type){case Eo.COMPOSITE:return await H3(s,e,t,r,i,Sb);case Eo.BATCHED_3D_MODEL:return await V3(s,e,t,r,i);case Eo.GLTF:return await G3(s,e,r,i);case Eo.INSTANCED_3D_MODEL:return await z3(s,e,t,r,i);case Eo.POINT_CLOUD:return await k3(s,e,t,r,i);default:throw new Error(`3DTileLoader: unknown type ${s.type}`)}}async function vb(e,t,r){if(new Uint32Array(e.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(e.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let n=W3(e.slice(8,16)),o=new Uint8Array(e,24,n),c=new TextDecoder("utf8").decode(o),l=JSON.parse(c),u=W3(e.slice(16,24)),f=new ArrayBuffer(0);if(u&&(f=e.slice(24+n)),await hm(l,l.tileAvailability,f,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await hm(l,h,f,r);else await hm(l,l.contentAvailability,f,r);return await hm(l,l.childSubtreeAvailability,f,r),l}async function hm(e,t,r,i){let s=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if(typeof s!="number")return;let n=e.bufferViews[s],o=e.buffers[n.buffer];if(!i?.baseUrl)throw new Error("Url is not provided");if(!i.fetch)throw new Error("fetch is not provided");if(o.uri){let c=`${i?.baseUrl||""}/${o.uri}`,u=await(await i.fetch(c)).arrayBuffer();t.explicitBitstream=new Uint8Array(u,n.byteOffset,n.byteLength);return}let a=e.buffers.slice(0,n.buffer).reduce((c,l)=>c+l.byteLength,0);t.explicitBitstream=new Uint8Array(r.slice(a,a+o.byteLength),n.byteOffset,n.byteLength)}function W3(e){let t=new DataView(e),r=t.getUint32(0,!0),i=t.getUint32(4,!0);return r+2**32*i}var dm={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:am,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:vb,options:{}};var Mr=null;try{Mr=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 Ot(e,t,r){this.low=e|0,this.high=t|0,this.unsigned=!!r}Ot.prototype.__isLong__;Object.defineProperty(Ot.prototype,"__isLong__",{value:!0});function Me(e){return(e&&e.__isLong__)===!0}function j3(e){var t=Math.clz32(e&-e);return e?31-t:t}Ot.isLong=Me;var X3={},Y3={};function vo(e,t){var r,i,s;return t?(e>>>=0,(s=0<=e&&e<256)&&(i=Y3[e],i)?i:(r=pt(e,0,!0),s&&(Y3[e]=r),r)):(e|=0,(s=-128<=e&&e<128)&&(i=X3[e],i)?i:(r=pt(e,e<0?-1:0,!1),s&&(X3[e]=r),r))}Ot.fromInt=vo;function Rr(e,t){if(isNaN(e))return t?fs:si;if(t){if(e<0)return fs;if(e>=J3)return tB}else{if(e<=-K3)return Ke;if(e+1>=K3)return Q3}return e<0?Rr(-e,t).neg():pt(e%Ka|0,e/Ka|0,t)}Ot.fromNumber=Rr;function pt(e,t,r){return new Ot(e,t,r)}Ot.fromBits=pt;var pm=Math.pow;function wb(e,t,r){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(r=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?fs:si;if(r=r||10,r<2||36<r)throw RangeError("radix");var i;if((i=e.indexOf("-"))>0)throw Error("interior hyphen");if(i===0)return wb(e.substring(1),t,r).neg();for(var s=Rr(pm(r,8)),n=si,o=0;o<e.length;o+=8){var a=Math.min(8,e.length-o),c=parseInt(e.substring(o,o+a),r);if(a<8){var l=Rr(pm(r,a));n=n.mul(l).add(Rr(c))}else n=n.mul(s),n=n.add(Rr(c))}return n.unsigned=t,n}Ot.fromString=wb;function ni(e,t){return typeof e=="number"?Rr(e,t):typeof e=="string"?wb(e,t):pt(e.low,e.high,typeof t=="boolean"?t:e.unsigned)}Ot.fromValue=ni;var q3=1<<16,Eq=1<<24,Ka=q3*q3,J3=Ka*Ka,K3=J3/2,$3=vo(Eq),si=vo(0);Ot.ZERO=si;var fs=vo(0,!0);Ot.UZERO=fs;var qa=vo(1);Ot.ONE=qa;var Z3=vo(1,!0);Ot.UONE=Z3;var Cb=vo(-1);Ot.NEG_ONE=Cb;var Q3=pt(-1,2147483647,!1);Ot.MAX_VALUE=Q3;var tB=pt(-1,-1,!0);Ot.MAX_UNSIGNED_VALUE=tB;var Ke=pt(0,-2147483648,!1);Ot.MIN_VALUE=Ke;var G=Ot.prototype;G.toInt=function(){return this.unsigned?this.low>>>0:this.low};G.toNumber=function(){return this.unsigned?(this.high>>>0)*Ka+(this.low>>>0):this.high*Ka+(this.low>>>0)};G.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Ke)){var r=Rr(t),i=this.div(r),s=i.mul(r).sub(this);return i.toString(t)+s.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var n=Rr(pm(t,6),this.unsigned),o=this,a="";;){var c=o.div(n),l=o.sub(c.mul(n)).toInt()>>>0,u=l.toString(t);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(Ke)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,r=31;r>0&&!(t&1<<r);r--);return this.high!=0?r+33:r+1};G.isZero=function(){return this.high===0&&this.low===0};G.eqz=G.isZero;G.isNegative=function(){return!this.unsigned&&this.high<0};G.isPositive=function(){return this.unsigned||this.high>=0};G.isOdd=function(){return(this.low&1)===1};G.isEven=function(){return(this.low&1)===0};G.equals=function(t){return Me(t)||(t=ni(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};G.eq=G.equals;G.notEquals=function(t){return!this.eq(t)};G.neq=G.notEquals;G.ne=G.notEquals;G.lessThan=function(t){return this.comp(t)<0};G.lt=G.lessThan;G.lessThanOrEqual=function(t){return this.comp(t)<=0};G.lte=G.lessThanOrEqual;G.le=G.lessThanOrEqual;G.greaterThan=function(t){return this.comp(t)>0};G.gt=G.greaterThan;G.greaterThanOrEqual=function(t){return this.comp(t)>=0};G.gte=G.greaterThanOrEqual;G.ge=G.greaterThanOrEqual;G.compare=function(t){if(Me(t)||(t=ni(t)),this.eq(t))return 0;var r=this.isNegative(),i=t.isNegative();return r&&!i?-1:!r&&i?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};G.comp=G.compare;G.negate=function(){return!this.unsigned&&this.eq(Ke)?Ke:this.not().add(qa)};G.neg=G.negate;G.add=function(t){Me(t)||(t=ni(t));var r=this.high>>>16,i=this.high&65535,s=this.low>>>16,n=this.low&65535,o=t.high>>>16,a=t.high&65535,c=t.low>>>16,l=t.low&65535,u=0,f=0,h=0,d=0;return d+=n+l,h+=d>>>16,d&=65535,h+=s+c,f+=h>>>16,h&=65535,f+=i+a,u+=f>>>16,f&=65535,u+=r+o,u&=65535,pt(h<<16|d,u<<16|f,this.unsigned)};G.subtract=function(t){return Me(t)||(t=ni(t)),this.add(t.neg())};G.sub=G.subtract;G.multiply=function(t){if(this.isZero())return this;if(Me(t)||(t=ni(t)),Mr){var r=Mr.mul(this.low,this.high,t.low,t.high);return pt(r,Mr.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?fs:si;if(this.eq(Ke))return t.isOdd()?Ke:si;if(t.eq(Ke))return this.isOdd()?Ke:si;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($3)&&t.lt($3))return Rr(this.toNumber()*t.toNumber(),this.unsigned);var i=this.high>>>16,s=this.high&65535,n=this.low>>>16,o=this.low&65535,a=t.high>>>16,c=t.high&65535,l=t.low>>>16,u=t.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+=s*u,f+=h>>>16,h&=65535,h+=n*l,f+=h>>>16,h&=65535,h+=o*c,f+=h>>>16,h&=65535,f+=i*u+s*l+n*c+o*a,f&=65535,pt(d<<16|p,f<<16|h,this.unsigned)};G.mul=G.multiply;G.divide=function(t){if(Me(t)||(t=ni(t)),t.isZero())throw Error("division by zero");if(Mr){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?Mr.div_u:Mr.div_s)(this.low,this.high,t.low,t.high);return pt(r,Mr.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?fs:si;var i,s,n;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return fs;if(t.gt(this.shru(1)))return Z3;n=fs}else{if(this.eq(Ke)){if(t.eq(qa)||t.eq(Cb))return Ke;if(t.eq(Ke))return qa;var o=this.shr(1);return i=o.div(t).shl(1),i.eq(si)?t.isNegative()?qa:Cb:(s=this.sub(t.mul(i)),n=i.add(s.div(t)),n)}else if(t.eq(Ke))return this.unsigned?fs:si;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();n=si}for(s=this;s.gte(t);){i=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(i)/Math.LN2),c=a<=48?1:pm(2,a-48),l=Rr(i),u=l.mul(t);u.isNegative()||u.gt(s);)i-=c,l=Rr(i,this.unsigned),u=l.mul(t);l.isZero()&&(l=qa),n=n.add(l),s=s.sub(u)}return n};G.div=G.divide;G.modulo=function(t){if(Me(t)||(t=ni(t)),Mr){var r=(this.unsigned?Mr.rem_u:Mr.rem_s)(this.low,this.high,t.low,t.high);return pt(r,Mr.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};G.mod=G.modulo;G.rem=G.modulo;G.not=function(){return pt(~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?j3(this.low):j3(this.high)+32};G.ctz=G.countTrailingZeros;G.and=function(t){return Me(t)||(t=ni(t)),pt(this.low&t.low,this.high&t.high,this.unsigned)};G.or=function(t){return Me(t)||(t=ni(t)),pt(this.low|t.low,this.high|t.high,this.unsigned)};G.xor=function(t){return Me(t)||(t=ni(t)),pt(this.low^t.low,this.high^t.high,this.unsigned)};G.shiftLeft=function(t){return Me(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?pt(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):pt(0,this.low<<t-32,this.unsigned)};G.shl=G.shiftLeft;G.shiftRight=function(t){return Me(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?pt(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):pt(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};G.shr=G.shiftRight;G.shiftRightUnsigned=function(t){return Me(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?pt(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?pt(this.high,0,this.unsigned):pt(this.high>>>t-32,0,this.unsigned)};G.shru=G.shiftRightUnsigned;G.shr_u=G.shiftRightUnsigned;G.rotateLeft=function(t){var r;return Me(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?pt(this.high,this.low,this.unsigned):t<32?(r=32-t,pt(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,pt(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))};G.rotl=G.rotateLeft;G.rotateRight=function(t){var r;return Me(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?pt(this.high,this.low,this.unsigned):t<32?(r=32-t,pt(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,pt(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))};G.rotr=G.rotateRight;G.toSigned=function(){return this.unsigned?pt(this.low,this.high,!1):this};G.toUnsigned=function(){return this.unsigned?this:pt(this.low,this.high,!0)};G.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};G.toBytesLE=function(){var t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};G.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};Ot.fromBytes=function(t,r,i){return i?Ot.fromBytesLE(t,r):Ot.fromBytesBE(t,r)};Ot.fromBytesLE=function(t,r){return new Ot(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)};Ot.fromBytesBE=function(t,r){return new Ot(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)};var $a=Ot;var Sq=16;function mf(e){e==="X"&&(e="");let t=e.padEnd(Sq,"0");return $a.fromString(t,!0,16)}function Pb(e){if(e.isZero())return"X";let t=e.countTrailingZeros(),r=t%4;t=(t-r)/4;let i=t;t*=4;let n=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}function Mb(e,t){let r=vq(e).shiftRightUnsigned(2);return e.add($a.fromNumber(2*t+1-4).multiply(r))}function vq(e){return e.and(e.not().add(1))}var Cq=3,wq=30,Pq=2*wq+1,eB=180/Math.PI;function iB(e){if(e.length===0)throw new Error(`Invalid Hilbert quad key ${e}`);let t=e.split("/"),r=parseInt(t[0],10),i=t[1],s=i.length,n=0,o=[0,0];for(let a=s-1;a>=0;a--){n=s-a;let c=i[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);Mq(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 sB(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<Cq+Pq;)t="0"+t;let r=t.lastIndexOf("1"),i=t.substring(0,3),s=t.substring(3,r),n=s.length/2,o=$a.fromString(i,!0,2).toString(10),a="";if(n!==0)for(a=$a.fromString(s,!0,2).toString(4);a.length<n;)a="0"+a;return`${o}/${a}`}function Rb(e,t,r){let i=1<<t;return[(e[0]+r[0])/i,(e[1]+r[1])/i]}function rB(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Ib(e){return[rB(e[0]),rB(e[1])]}function Bb(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function Ob([e,t,r]){let i=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*eB,i*eB]}function Mq(e,t,r,i){if(i===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function nB(e){let t=Rb(e.ij,e.level,[.5,.5]),r=Ib(t),i=Bb(e.face,r);return Ob(i)}var Rq=100;function Fb(e){let{face:t,ij:r,level:i}=e,s=[[0,0],[0,1],[1,1],[1,0],[0,0]],n=Math.max(1,Math.ceil(Rq*Math.pow(2,-i))),o=new Float64Array(4*n*2+2),a=0,c=0;for(let l=0;l<4;l++){let u=s[l].slice(0),f=s[l+1],h=(f[0]-u[0])/n,d=(f[1]-u[1])/n;for(let p=0;p<n;p++){u[0]+=h,u[1]+=d;let g=Rb(r,i,u),m=Ib(g),_=Bb(t,m),y=Ob(_);Math.abs(y[1])>89.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 Ja(e){let t=Iq(e);return iB(t)}function Iq(e){if(e.indexOf("/")>0)return e;let t=mf(e);return sB(t)}function Nb(e){let t=Ja(e);return nB(t)}function aB(e){let t;if(e.face===2||e.face===5){let r=null,i=0;for(let s=0;s<4;s++){let n=`${e.face}/${s}`,o=Ja(n),a=Fb(o);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,i),i+=a.length}t=oB(r)}else{let r=Fb(e);t=oB(r)}return t}function oB(e){if(e.length%2!==0)throw new Error("Invalid corners");let t=[],r=[];for(let i=0;i<e.length;i+=2)t.push(e[i]),r.push(e[i+1]);return t.sort((i,s)=>i-s),r.sort((i,s)=>i-s),{west:t[0],east:t[t.length-1],north:r[r.length-1],south:r[0]}}function Lb(e,t){let r=t?.minimumHeight||0,i=t?.maximumHeight||0,s=Ja(e),n=aB(s),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,i)),u.push(new w(c,l,i)),u.push(new w(c,a,i)),u.push(new w(o,a,i)),u}function gm(e){let t=e.token,r={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},i=Lb(t,r),s=Nb(t),n=s[0],o=s[1],a=ot.WGS84.cartographicToCartesian([n,o,r.maximumHeight]),c=new w(a[0],a[1],a[2]);i.push(c);let l=Zu(i);return[...l.center,...l.halfAxes]}var Bq=4,Oq=8,Fq={QUADTREE:Bq,OCTREE:Oq};function Nq(e,t,r){if(e?.box){let i=mf(e.s2VolumeInfo.token),s=Mb(i,t),n=Pb(s),o={...e.s2VolumeInfo};switch(o.token=n,r){case"OCTREE":let l=e.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:gm(o),s2VolumeInfo:o}}}async function Ub(e){let{implicitOptions:t,parentData:r={mortonIndex:0,x:0,y:0,z:0},childIndex:i=0,s2VolumeBox:s,loaderOptions:n}=e,{subtree:o,level:a=0,globalData:c={level:0,mortonIndex:0,x:0,y:0,z:0}}=e,{subdivisionScheme:l,subtreeLevels:u,maximumLevel:f,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=t,g={children:[],lodMetricValue:0,contentUrl:""};if(!f)return U_.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 _=Fq[l],y=Math.log2(_),x=i&1,E=i>>1&1,P=i>>2&1,B=(_**a-1)/(_-1),F=Co(r.mortonIndex,i,y),M=B+F,v=Co(r.x,x,1),T=Co(r.y,E,1),L=Co(r.z,P,1),V=!1;a>=u&&(V=Db(o.childSubtreeAvailability,F));let z=Co(c.x,v,a),W=Co(c.y,T,a),Z=Co(c.z,L,a);if(V){let bt=`${p}/${d}`,Et=mm(bt,m,z,W,Z);o=await Jt(Et,dm,n),c={mortonIndex:F,x:v,y:T,z:L,level:a},F=0,M=0,v=0,T=0,L=0,a=0}if(!Db(o.tileAvailability,M))return g;Db(o.contentAvailability,M)&&(g.contentUrl=mm(h,m,z,W,Z));let Rt=a+1,gt={mortonIndex:F,x:v,y:T,z:L};for(let bt=0;bt<_;bt++){let Et=Nq(s,bt,l),Te=await Ub({subtree:o,implicitOptions:t,loaderOptions:n,parentData:gt,childIndex:bt,level:Rt,globalData:{...c},s2VolumeBox:Et});if(Te.contentUrl||Te.children.length){let bc=m+1,v_=Lq(Te,bc,{childTileX:v,childTileY:T,childTileZ:L},t,s);g.children.push(v_)}}return g}function Db(e,t){let r;return Array.isArray(e)?(r=e[0],e.length>1&&U_.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=e,"constant"in r?Boolean(r.constant):r.explicitBitstream?kq(t,r.explicitBitstream):!1}function Lq(e,t,r,i,s){let{basePath:n,refine:o,getRefine:a,lodMetricType:c,getTileType:l,rootLodMetricValue:u,rootBoundingVolume:f}=i,h=e.contentUrl&&e.contentUrl.replace(`${n}/`,""),d=u/2**t,p=s?.box?{box:s.box}:f,g=Dq(t,p,r);return{children:e.children,contentUrl:e.contentUrl,content:{uri:h},id:e.contentUrl,refine:a(o),type:l(e),lodMetricType:c,lodMetricValue:d,geometricError:d,transform:e.transform,boundingVolume:g}}function Dq(e,t,r){if(t.region){let{childTileX:i,childTileY:s,childTileZ:n}=r,[o,a,c,l,u,f]=t.region,h=2**e,d=(c-o)/h,p=(l-a)/h,g=(f-u)/h,[m,_]=[o+d*i,o+d*(i+1)],[y,x]=[a+p*s,a+p*(s+1)],[E,P]=[u+g*n,u+g*(n+1)];return{region:[m,y,_,x,E,P]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function Co(e,t,r){return(e<<r)+t}function mm(e,t,r,i,s){let n=Uq({level:t,x:r,y:i,z:s});return e.replace(/{level}|{x}|{y}|{z}/gi,o=>n[o])}function Uq(e){let t={};for(let r in e)t[`{${r}}`]=e[r];return t}function kq(e,t){let r=Math.floor(e/8),i=e%8;return(t[r]>>i&1)===1}function Vb(e,t=""){if(!t)return Pr.EMPTY;let i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return Pr.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Pr.SCENEGRAPH;default:return i||Pr.EMPTY}}function zb(e){switch(e){case"REPLACE":case"replace":return Ce.REPLACE;case"ADD":case"add":return Ce.ADD;default:return e}}function kb(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){let i=new URL(e,`${t}/`);return decodeURI(i.toString())}else if(e.startsWith("/"))return e;return Je.resolve(t,e)}function cB(e,t){if(!e)return null;let r;if(e.content){let s=e.content.uri||e.content?.url;typeof s<"u"&&(r=kb(s,t))}return{...e,id:r,contentUrl:r,lodMetricType:ls.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Vb(e,r),refine:zb(e.refine)}}async function fB(e,t,r){let i=null,s=uB(e.root);s&&e.root?i=await lB(e.root,e,t,s,r):i=cB(e.root,t);let n=[];for(n.push(i);n.length>0;){let o=n.pop()||{},a=o.children||[],c=[];for(let l of a){let u=uB(l),f;u?f=await lB(l,e,t,u,r):f=cB(l,t),f&&(c.push(f),n.push(f))}o.children=c}return i}async function lB(e,t,r,i,s){let{subdivisionScheme:n,maximumLevel:o,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=i,u=mm(l,0,0,0,0),f=kb(u,r),h=await Jt(f,dm,s),d=e.content?.uri,p=d?kb(d,r):"",g=t?.root?.refine,m=e.geometricError,_=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(_){let P={box:gm(_),s2VolumeInfo:_};e.boundingVolume=P}let y=e.boundingVolume,x={contentUrlTemplate:p,subtreesUriTemplate:l,subdivisionScheme:n,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:o,refine:g,basePath:r,lodMetricType:ls.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:y,getTileType:Vb,getRefine:zb};return await Vq(e,r,h,x,s)}async function Vq(e,t,r,i,s){if(!e)return null;let{children:n,contentUrl:o}=await Ub({subtree:r,implicitOptions:i,loaderOptions:s}),a,c=null;return o&&(a=o,c={uri:o.replace(`${t}/`,"")}),{...e,id:a,contentUrl:a,lodMetricType:ls.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Vb(e,a),refine:zb(e.refine),content:c||e.content,children:n}}function uB(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}var _m={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:am,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:zq,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function zq(e,t={},r){let i=t["3d-tiles"]||{},s;return i.isTileset==="auto"?s=r?.url&&r.url.indexOf(".json")!==-1:s=i.isTileset,s?Hq(e,t,r):Gq(e,t,r)}async function Hq(e,t,r){let i=JSON.parse(new TextDecoder().decode(e)),s=r?.url||"",n=Wq(s),o=await fB(i,n,t||{});return{...i,shape:"tileset3d",loader:_m,url:s,queryString:r?.queryString||"",basePath:n,root:o||i.root,type:pe.TILES3D,lodMetricType:ls.GEOMETRIC_ERROR,lodMetricValue:i.root?.geometricError||0}}async function Gq(e,t,r){let i={content:{shape:"tile3d",featureIds:null}};return await Sb(e,0,t,r,i.content),i.content}function Wq(e){return Je.dirname(e)}var hB=[0],jq={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:_m,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,r)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}},ym=class extends It{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:t}){return t.somethingChanged}updateState({props:t,oldProps:r,changeFlags:i}){if(t.data&&t.data!==r.data&&this._loadTileset(t.data),i.viewportChanged){let{activeViewports:s}=this.state;Object.keys(s).length&&(this._updateTileset(s),this.state.lastUpdatedViewports=s,this.state.activeViewports={})}if(i.propsChanged){let{layerMap:s}=this.state;for(let n in s)s[n].needsUpdate=!0}}activateViewport(t){let{activeViewports:r,lastUpdatedViewports:i}=this.state;this.internalState.viewport=t,r[t.id]=t;let s=i?.[t.id];(!s||!t.equals(s))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:t,sourceLayer:r}){let i=r&&r.props.tile;return t.picked&&(t.object=i),t.sourceTile=i,t}filterSubLayer({layer:t,viewport:r}){let{tile:i}=t.props,{id:s}=r;return i.selected&&i.viewportIds.includes(s)}_updateAutoHighlight(t){let r=t.sourceTile,i=this.state.layerMap[r?.id];i&&i.layer&&i.layer.updateAutoHighlight(t)}async _loadTileset(t){let{loadOptions:r={}}=this.props,i=this.props.loader||this.props.loaders,s=Array.isArray(i)?i[0]:i,n={loadOptions:{...r}},o=t;if(s.preload){let l=await s.preload(t,r);l.url&&(o=l.url),l.headers&&(n.loadOptions.fetch={...n.loadOptions.fetch,headers:l.headers}),Object.assign(n,l)}let a=await Jt(o,s,n.loadOptions),c=new gf(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(t){let{lastUpdatedViewports:r}=this.state;this.props.onTileLoad(t),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(t){delete this.state.layerMap[t.id],this.props.onTileUnload(t)}_updateTileset(t){if(!t)return;let{tileset3d:r}=this.state,{timeline:i}=this.context,s=Object.keys(t).length;!i||!s||!r||r.selectTiles(Object.values(t)).then(n=>{this.state.frameNumber!==n&&this.setState({frameNumber:n})})}_getSubLayer(t,r){if(!t.content)return null;switch(t.type){case Pr.POINTCLOUD:return this._makePointCloudLayer(t,r);case Pr.SCENEGRAPH:return this._make3DModelLayer(t);case Pr.MESH:return this._makeSimpleMeshLayer(t,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${t.content.type}`)}}_makePointCloudLayer(t,r){let{attributes:i,pointCount:s,constantRGBA:n,cartographicOrigin:o,modelMatrix:a}=t.content,{positions:c,normals:l,colors:u}=i;if(!c)return null;let f=r&&r.props.data||{header:{vertexCount:s},attributes:{POSITION:c,NORMAL:l,COLOR_0:u}},{pointSize:h,getPointColor:d}=this.props,p=this.getSubLayerClass("pointcloud",eo);return new p({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${t.id}`,tile:t,data:f,coordinateSystem:X.METER_OFFSETS,coordinateOrigin:o,modelMatrix:a,getColor:n||d,_offset:0})}_make3DModelLayer(t){let{gltf:r,instances:i,cartographicOrigin:s,modelMatrix:n}=t.content,o=this.getSubLayerClass("scenegraph",Ao);return new o({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${t.id}`,tile:t,data:i||hB,scenegraph:r,coordinateSystem:X.METER_OFFSETS,coordinateOrigin:s,modelMatrix:n,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(t,r){let i=t.content,{attributes:s,indices:n,modelMatrix:o,cartographicOrigin:a,coordinateSystem:c=X.METER_OFFSETS,material:l,featureIds:u}=i,{_getMeshColor:f}=this.props,h=r&&r.props.mesh||new it({topology:"triangle-list",attributes:Xq(s),indices:n}),d=this.getSubLayerClass("mesh",hf);return new d(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${t.id}`,tile:t,mesh:h,data:hB,getColor:f(t),pbrMaterial:l,modelMatrix:o,coordinateOrigin:a,coordinateSystem:c,featureIds:u,_offset:0})}renderLayers(){let{tileset3d:t,layerMap:r}=this.state;return t?t.tiles.map(i=>{let s=r[i.id]=r[i.id]||{tile:i},{layer:n}=s;return i.selected&&(n?s.needsUpdate&&(n=this._getSubLayer(i,n),s.needsUpdate=!1):n=this._getSubLayer(i)),s.layer=n,n}).filter(Boolean):null}},_f=ym;(()=>{ym.defaultProps=jq})(),(()=>{ym.layerName="Tile3DLayer"})();function Xq(e){let t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}var Yq=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 Hb(e){return e>>1^-(e&1)}function qq(e){let t=0,r={};for(let[i,s]of Yq){let n=s===8?e.getFloat64:e.getFloat32;r[i]=n.call(e,t,!0),t+=s}return{header:r,headerEndPosition:t}}function Kq(e,t){let r=t,i=3,s=e.getUint32(r,!0),n=new Uint16Array(s*i);r+=Uint32Array.BYTES_PER_ELEMENT;let o=Uint16Array.BYTES_PER_ELEMENT,a=s*o,c=r,l=c+a,u=l+a,f=0,h=0,d=0;for(let p=0;p<s;p++)f+=Hb(e.getUint16(c+o*p,!0)),h+=Hb(e.getUint16(l+o*p,!0)),d+=Hb(e.getUint16(u+o*p,!0)),n[p]=f,n[p+s]=h,n[p+s*2]=d;return r+=a*3,{vertexData:n,vertexDataEndPosition:r}}function yf(e,t,r,i,s=!0){let n;if(i===2?n=new Uint16Array(e,t,r):n=new Uint32Array(e,t,r),!s)return n;let o=0;for(let a=0;a<n.length;++a){let c=n[a];n[a]=o-c,c===0&&++o}return n}function $q(e,t,r){let i=r,s=3,o=t.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;i%o!==0&&(i+=o-i%o);let a=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=yf(e.buffer,i,c,o);return i+=c*o,{triangleIndicesEndPosition:i,triangleIndices:l}}function Jq(e,t,r){let i=r,s=3,o=t.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let c=yf(e.buffer,i,a,o,!1);i+=a*o;let l=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let u=yf(e.buffer,i,l,o,!1);i+=l*o;let f=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let h=yf(e.buffer,i,f,o,!1);i+=f*o;let d=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let p=yf(e.buffer,i,d,o,!1);return i+=d*o,{edgeIndicesEndPosition:i,westIndices:c,southIndices:u,eastIndices:h,northIndices:p}}function Zq(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Qq(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function tK(e,t){let r={};if(e.byteLength<=t)return{extensions:r,extensionsEndPosition:t};let i=t;for(;i<e.byteLength;){let s=e.getUint8(i,!0);i+=Uint8Array.BYTES_PER_ELEMENT;let n=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;let o=new DataView(e.buffer,i,n);switch(s){case 1:{r.vertexNormals=Zq(o);break}case 2:{r.waterMask=Qq(o);break}default:}i+=n}return{extensions:r,extensionsEndPosition:i}}var wo={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},eK={maxDecodingStep:wo.extensions};function Gb(e,t){let r=Object.assign({},eK,t),i=new DataView(e),{header:s,headerEndPosition:n}=qq(i);if(r.maxDecodingStep<wo.vertices)return{header:s};let{vertexData:o,vertexDataEndPosition:a}=Kq(i,n);if(r.maxDecodingStep<wo.triangleIndices)return{header:s,vertexData:o};let{triangleIndices:c,triangleIndicesEndPosition:l}=$q(i,o,a);if(r.maxDecodingStep<wo.edgeIndices)return{header:s,vertexData:o,triangleIndices:c};let{westIndices:u,southIndices:f,eastIndices:h,northIndices:d,edgeIndicesEndPosition:p}=Jq(i,o,l);if(r.maxDecodingStep<wo.extensions)return{header:s,vertexData:o,triangleIndices:c,westIndices:u,northIndices:d,eastIndices:h,southIndices:f};let{extensions:g}=tK(i,p);return{header:s,vertexData:o,triangleIndices:c,westIndices:u,northIndices:d,eastIndices:h,southIndices:f,extensions:g}}function xm(e,t,r,i){let s=i?iK(i,e.POSITION.value):rK(t),n=new e.POSITION.value.constructor(s.length*6),o=new e.TEXCOORD_0.value.constructor(s.length*4),a=new t.constructor(s.length*6);for(let l=0;l<s.length;l++){let u=s[l];sK({edge:u,edgeIndex:l,attributes:e,skirtHeight:r,newPosition:n,newTexcoord0:o,newTriangles:a})}e.POSITION.value=Dc(e.POSITION.value,n),e.TEXCOORD_0.value=Dc(e.TEXCOORD_0.value,o);let c=t instanceof Array?t.concat(a):Dc(t,a);return{attributes:e,triangles:c}}function rK(e){let t=[];for(let s=0;s<e.length;s+=3)t.push([e[s],e[s+1]]),t.push([e[s+1],e[s+2]]),t.push([e[s+2],e[s]]);t.sort((s,n)=>Math.min(...s)-Math.min(...n)||Math.max(...s)-Math.max(...n));let r=[],i=0;for(;i<t.length;)t[i][0]===t[i+1]?.[1]&&t[i][1]===t[i+1]?.[0]?i+=2:(r.push(t[i]),i++);return r}function iK(e,t){e.westIndices.sort((i,s)=>t[3*i+1]-t[3*s+1]),e.eastIndices.sort((i,s)=>t[3*s+1]-t[3*i+1]),e.southIndices.sort((i,s)=>t[3*s]-t[3*i]),e.northIndices.sort((i,s)=>t[3*i]-t[3*s]);let r=[];for(let i in e){let s=e[i];for(let n=0;n<s.length-1;n++)r.push([s[n],s[n+1]])}return r}function sK({edge:e,edgeIndex:t,attributes:r,skirtHeight:i,newPosition:s,newTexcoord0:n,newTriangles:o}){let a=r.POSITION.value.length,c=t*2,l=t*2+1;s.set(r.POSITION.value.subarray(e[0]*3,e[0]*3+3),c*3),s[c*3+2]=s[c*3+2]-i,s.set(r.POSITION.value.subarray(e[1]*3,e[1]*3+3),l*3),s[l*3+2]=s[l*3+2]-i,n.set(r.TEXCOORD_0.value.subarray(e[0]*2,e[0]*2+2),c*2),n.set(r.TEXCOORD_0.value.subarray(e[1]*2,e[1]*2+2),l*2);let u=t*2*3;o[u]=e[0],o[u+1]=a/3+l,o[u+2]=e[1],o[u+3]=a/3+l,o[u+4]=e[0],o[u+5]=a/3+c}function Wb(e,t={}){let{bounds:r}=t,{header:i,vertexData:s,triangleIndices:n,westIndices:o,northIndices:a,eastIndices:c,southIndices:l}=Gb(e,wo.triangleIndices),u=n,f=nK(s,i,r),h=Ui(f);if(t?.skirtHeight){let{attributes:d,triangles:p}=xm(f,u,t.skirtHeight,{westIndices:o,northIndices:a,eastIndices:c,southIndices:l});f=d,u=p}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:h},schema:void 0,topology:"triangle-list",mode:4,indices:{value:u,size:1},attributes:f}}function nK(e,t,r){let{minHeight:i,maxHeight:s}=t,[n,o,a,c]=r||[0,0,1,1],l=a-n,u=c-o,f=s-i,h=e.length/3,d=new Float32Array(h*3),p=new Float32Array(h*2);for(let g=0;g<h;g++){let m=e[g]/32767,_=e[g+h]/32767,y=e[g+h*2]/32767;d[3*g+0]=m*l+n,d[3*g+1]=_*u+o,d[3*g+2]=y*f+i,p[2*g+0]=m,p[2*g+1]=_}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:p,size:2}}}var xf=class{constructor(t=257){this.gridSize=t;let r=t-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let i=0;i<this.numTriangles;i++){let s=i+2,n=0,o=0,a=0,c=0,l=0,u=0;for(s&1?a=c=l=r:n=o=u=r;(s>>=1)>1;){let h=n+a>>1,d=o+c>>1;s&1?(a=n,c=o,n=l,o=u):(n=a,o=c,a=l,c=u),l=h,u=d}let f=i*4;this.coords[f+0]=n,this.coords[f+1]=o,this.coords[f+2]=a,this.coords[f+3]=c}}createTile(t){return new jb(t,this)}},jb=class{constructor(t,r){let i=r.gridSize;if(t.length!==i*i)throw new Error(`Expected terrain data of length ${i*i} (${i} x ${i}), got ${t.length}.`);this.terrain=t,this.martini=r,this.errors=new Float32Array(t.length),this.update()}update(){let{numTriangles:t,numParentTriangles:r,coords:i,gridSize:s}=this.martini,{terrain:n,errors:o}=this;for(let a=t-1;a>=0;a--){let c=a*4,l=i[c+0],u=i[c+1],f=i[c+2],h=i[c+3],d=l+f>>1,p=u+h>>1,g=d+p-u,m=p+l-d,_=(n[u*s+l]+n[h*s+f])/2,y=p*s+d,x=Math.abs(_-n[y]);if(o[y]=Math.max(o[y],x),a<r){let E=(u+m>>1)*s+(l+g>>1),P=(h+m>>1)*s+(f+g>>1);o[y]=Math.max(o[y],o[E],o[P])}}}getMesh(t=0){let{gridSize:r,indices:i}=this.martini,{errors:s}=this,n=0,o=0,a=r-1;i.fill(0);function c(d,p,g,m,_,y){let x=d+g>>1,E=p+m>>1;Math.abs(d-_)+Math.abs(p-y)>1&&s[E*r+x]>t?(c(_,y,d,p,x,E),c(g,m,_,y,x,E)):(i[p*r+d]=i[p*r+d]||++n,i[m*r+g]=i[m*r+g]||++n,i[y*r+_]=i[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,E=p+m>>1;if(Math.abs(d-_)+Math.abs(p-y)>1&&s[E*r+x]>t)h(_,y,d,p,x,E),h(g,m,_,y,x,E);else{let P=i[p*r+d]-1,B=i[m*r+g]-1,F=i[y*r+_]-1;l[2*P]=d,l[2*P+1]=p,l[2*B]=g,l[2*B+1]=m,l[2*F]=_,l[2*F+1]=y,u[f++]=P,u[f++]=B,u[f++]=F}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:u}}};var Af=class{constructor(t,r,i=r){this.data=t,this.width=r,this.height=i,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 s=r-1,n=i-1,o=this._addPoint(0,0),a=this._addPoint(s,0),c=this._addPoint(0,n),l=this._addPoint(s,n),u=this._addTriangle(l,o,c,-1,-1,-1);this._addTriangle(o,l,a,u,-1,-1),this._flush()}run(t=1){for(;this.getMaxError()>t;)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(t,r){return this.data[this.width*r+t]}_flush(){let t=this.coords;for(let r=0;r<this._pendingLen;r++){let i=this._pending[r],s=2*this.triangles[i*3+0],n=2*this.triangles[i*3+1],o=2*this.triangles[i*3+2];this._findCandidate(t[s],t[s+1],t[n],t[n+1],t[o],t[o+1],i)}this._pendingLen=0}_findCandidate(t,r,i,s,n,o,a){let c=Math.min(t,i,n),l=Math.min(r,s,o),u=Math.max(t,i,n),f=Math.max(r,s,o),h=Po(i,s,n,o,c,l),d=Po(n,o,t,r,c,l),p=Po(t,r,i,s,c,l),g=s-r,m=t-i,_=o-s,y=i-n,x=r-o,E=n-t,P=Po(t,r,i,s,n,o),B=this.heightAt(t,r)/P,F=this.heightAt(i,s)/P,M=this.heightAt(n,o)/P,v=0,T=0,L=0,V=0;for(let z=l;z<=f;z++){let W=0;h<0&&_!==0&&(W=Math.max(W,Math.floor(-h/_))),d<0&&x!==0&&(W=Math.max(W,Math.floor(-d/x))),p<0&&g!==0&&(W=Math.max(W,Math.floor(-p/g)));let Z=h+_*W,ut=d+x*W,st=p+g*W,Rt=!1;for(let gt=c+W;gt<=u;gt++){if(Z>=0&&ut>=0&&st>=0){Rt=!0;let bt=B*Z+F*ut+M*st,Et=Math.abs(bt-this.heightAt(gt,z));V+=Et*Et,Et>v&&(v=Et,T=gt,L=z)}else if(Rt)break;Z+=_,ut+=x,st+=g}h+=y,d+=E,p+=m}(T===t&&L===r||T===i&&L===s||T===n&&L===o)&&(v=0),this._candidates[2*a]=T,this._candidates[2*a+1]=L,this._rms[a]=V,this._queuePush(a,v,V)}_step(){let t=this._queuePop(),r=t*3+0,i=t*3+1,s=t*3+2,n=this.triangles[r],o=this.triangles[i],a=this.triangles[s],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*t],g=this._candidates[2*t+1],m=this._addPoint(p,g);if(Po(c,l,u,f,p,g)===0)this._handleCollinear(m,r);else if(Po(u,f,h,d,p,g)===0)this._handleCollinear(m,i);else if(Po(h,d,c,l,p,g)===0)this._handleCollinear(m,s);else{let _=this._halfedges[r],y=this._halfedges[i],x=this._halfedges[s],E=this._addTriangle(n,o,m,_,-1,-1,r),P=this._addTriangle(o,a,m,y,-1,E+1),B=this._addTriangle(a,n,m,x,E+2,P+1);this._legalize(E),this._legalize(P),this._legalize(B)}}_addPoint(t,r){let i=this.coords.length>>1;return this.coords.push(t,r),i}_addTriangle(t,r,i,s,n,o,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=t,this.triangles[a+1]=r,this.triangles[a+2]=i,this._halfedges[a+0]=s,this._halfedges[a+1]=n,this._halfedges[a+2]=o,s>=0&&(this._halfedges[s]=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(t){let r=this._halfedges[t];if(r<0)return;let i=t-t%3,s=r-r%3,n=i+(t+1)%3,o=i+(t+2)%3,a=s+(r+2)%3,c=s+(r+1)%3,l=this.triangles[o],u=this.triangles[t],f=this.triangles[n],h=this.triangles[a],d=this.coords;if(!oK(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(i/3),this._queueRemove(s/3);let y=this._addTriangle(l,h,f,-1,m,p,i),x=this._addTriangle(h,l,u,y,g,_,s);this._legalize(y+1),this._legalize(x+2)}_handleCollinear(t,r){let i=r-r%3,s=i+(r+1)%3,n=i+(r+2)%3,o=this.triangles[n],a=this.triangles[r],c=this.triangles[s],l=this._halfedges[s],u=this._halfedges[n],f=this._halfedges[r];if(f<0){let B=this._addTriangle(t,o,a,-1,u,-1,i),F=this._addTriangle(o,t,c,B,-1,l);this._legalize(B+1),this._legalize(F+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,t,u,-1,-1,i),x=this._addTriangle(a,g,t,_,-1,y+1,h),E=this._addTriangle(g,c,t,m,-1,x+1),P=this._addTriangle(c,o,t,l,y+2,E+1);this._legalize(y),this._legalize(x),this._legalize(E),this._legalize(P)}_queuePush(t,r,i){let s=this._queue.length;this._queueIndices[t]=s,this._queue.push(t),this._errors.push(r),this._rmsSum+=i,this._queueUp(s)}_queuePop(){let t=this._queue.length-1;return this._queueSwap(0,t),this._queueDown(0,t),this._queuePopBack()}_queuePopBack(){let t=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[t],this._queueIndices[t]=-1,t}_queueRemove(t){let r=this._queueIndices[t];if(r<0){let s=this._pending.indexOf(t);if(s!==-1)this._pending[s]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let i=this._queue.length-1;i!==r&&(this._queueSwap(r,i),this._queueDown(r,i)||this._queueUp(r)),this._queuePopBack()}_queueLess(t,r){return this._errors[t]>this._errors[r]}_queueSwap(t,r){let i=this._queue[t],s=this._queue[r];this._queue[t]=s,this._queue[r]=i,this._queueIndices[i]=r,this._queueIndices[s]=t;let n=this._errors[t];this._errors[t]=this._errors[r],this._errors[r]=n}_queueUp(t){let r=t;for(;;){let i=r-1>>1;if(i===r||!this._queueLess(r,i))break;this._queueSwap(i,r),r=i}}_queueDown(t,r){let i=t;for(;;){let s=2*i+1;if(s>=r||s<0)break;let n=s+1,o=s;if(n<r&&this._queueLess(n,s)&&(o=n),!this._queueLess(o,i))break;this._queueSwap(i,o),i=o}return i>t}};function Po(e,t,r,i,s,n){return(r-s)*(t-n)-(i-n)*(e-s)}function oK(e,t,r,i,s,n,o,a){let c=e-o,l=t-a,u=r-o,f=i-a,h=s-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 gB(e,t){let{meshMaxError:r,bounds:i,elevationDecoder:s}=t,{data:n,width:o,height:a}=e,c,l;switch(t.tesselator){case"martini":c=Am(n,o,a,s,t.tesselator),l=dB(r,o,c);break;case"delatin":c=Am(n,o,a,s,t.tesselator),l=pB(r,o,a,c);break;default:o===a&&!(a&o-1)?(c=Am(n,o,a,s,"martini"),l=dB(r,o,c)):(c=Am(n,o,a,s,"delatin"),l=pB(r,o,a,c));break}let{vertices:u}=l,{triangles:f}=l,h=aK(u,c,o,a,i),d=Ui(h);if(t.skirtHeight){let{attributes:p,triangles:g}=xm(h,f,t.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 dB(e,t,r){let i=t+1,n=new xf(i).createTile(r),{vertices:o,triangles:a}=n.getMesh(e);return{vertices:o,triangles:a}}function pB(e,t,r,i){let s=new Af(i,t+1,r+1);s.run(e);let{coords:n,triangles:o}=s;return{vertices:n,triangles:o}}function Am(e,t,r,i,s){let{rScaler:n,bScaler:o,gScaler:a,offset:c}=i,l=new Float32Array((t+1)*(r+1));for(let u=0,f=0;f<r;f++)for(let h=0;h<t;h++,u++){let d=u*4,p=e[d+0],g=e[d+1],m=e[d+2];l[u+f]=p*n+g*a+m*o+c}if(s==="martini"){for(let u=(t+1)*t,f=0;f<t;f++,u++)l[u]=l[u-t-1];for(let u=r,f=0;f<r+1;f++,u+=r+1)l[u]=l[u-1]}return l}function aK(e,t,r,i,s){let n=r+1,o=e.length/2,a=new Float32Array(o*3),c=new Float32Array(o*2),[l,u,f,h]=s||[0,0,r,i],d=(f-l)/r,p=(h-u)/i;for(let g=0;g<o;g++){let m=e[g*2],_=e[g*2+1],y=_*n+m;a[3*g+0]=m*d+l,a[3*g+1]=-_*p+h,a[3*g+2]=t[y],c[2*g+0]=m/r,c[2*g+1]=_/i}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var Tm="4.2.0-beta.2";var bm={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:Tm,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var mB={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:Tm,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var cK={...bm,parse:lK};async function lK(e,t,r){let i={...t,mimeType:"application/x.image",image:{...t?.image,type:"data"}},s=await $e(e,[],i,r),n={...cK.options.terrain,...t?.terrain};return gB(s,n)}var xFt={...mB,parseSync:(e,t)=>Wb(e,t?.["quantized-mesh"]),parse:async(e,t)=>Wb(e,t?.["quantized-mesh"])};var _B=[1],uK={...Mi.defaultProps,elevationData:Qs,texture:{...Qs,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:[bm]};function yB(e){return Array.isArray(e)?e.join(";"):e||""}var Em=class extends It{updateState({props:t,oldProps:r}){let i=t.elevationData!==r.elevationData;if(i){let{elevationData:n}=t,o=n&&(Array.isArray(n)||n.includes("{x}")&&n.includes("{y}"));this.setState({isTiled:o})}let s=i||t.meshMaxError!==r.meshMaxError||t.elevationDecoder!==r.elevationDecoder||t.bounds!==r.bounds;if(!this.state.isTiled&&s){let n=this.loadTerrain(t);this.setState({terrain:n})}t.workerUrl&&k.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:t,bounds:r,elevationDecoder:i,meshMaxError:s,signal:n}){if(!t)return null;let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?s*2:0,...o?.terrain,bounds:r,meshMaxError:s,elevationDecoder:i}};let{fetch:a}=this.props;return a(t,{propName:"elevationData",layer:this,loadOptions:o,signal:n})}getTiledTerrainData(t){let{elevationData:r,fetch:i,texture:s,elevationDecoder:n,meshMaxError:o}=this.props,{viewport:a}=this.context,c=Pi(r,t),l=s&&Pi(s,t),{signal:u}=t,f=[0,0],h=[0,0];if(a.isGeospatial){let m=t.bbox;f=a.projectFlat([m.west,m.south]),h=a.projectFlat([m.east,m.north])}else{let m=t.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?i(l,{propName:"texture",layer:this,loaders:[],signal:u}).catch(m=>null):Promise.resolve(null);return Promise.all([p,g])}renderSubLayers(t){let r=this.getSubLayerClass("mesh",Ri),{color:i,wireframe:s,material:n}=this.props,{data:o}=t;if(!o)return null;let[a,c]=o;return new r(t,{data:_B,mesh:a,texture:c,_instanced:!1,coordinateSystem:X.CARTESIAN,getPosition:l=>[0,0,0],getColor:i,wireframe:s,material:n})}onViewportLoad(t){if(!t)return;let{zRange:r}=this.state,i=t.map(o=>o.content).filter(Boolean).map(o=>o[0].header.boundingBox.map(c=>c[2]));if(i.length===0)return;let s=Math.min(...i.map(o=>o[0])),n=Math.max(...i.map(o=>o[1]));(!r||s<r[0]||n>r[1])&&this.setState({zRange:[s,n]})}renderLayers(){let{color:t,material:r,elevationData:i,texture:s,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 Mi(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:yB(i),texture:yB(s),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(!i)return null;let x=this.getSubLayerClass("mesh",Ri);return new x(this.getSubLayerProps({id:"mesh"}),{data:_B,mesh:this.state.terrain,texture:s,_instanced:!1,getPosition:E=>[0,0,0],getColor:t,material:r,wireframe:n})}},Tf=Em;(()=>{Em.defaultProps=uK})(),(()=>{Em.layerName="TerrainLayer"})();var fK=`
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);
}
`,hK=`
uniform bool brushing_enabled;
in float brushing_isVisible;
`,dK={source:0,target:1,custom:2,source_target:3},pK={"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;
}
`},xB={name:"brushing",dependencies:[te],vs:fK,fs:hK,inject:pK,getUniforms:e=>{if(!e||!("viewport"in e))return{};let{brushingEnabled:t=!0,brushingRadius:r=1e4,brushingTarget:i="source",mousePosition:s,viewport:n}=e;return{brushing_enabled:Boolean(t&&s&&n.containsPixel(s)),brushing_radius:r,brushing_target:dK[i]||0,brushing_mousePos:s?n.unproject([s.x-n.x,s.y-n.y]):[0,0]}}};var gK={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},Sm=class extends Lt{getShaders(){return{modules:[xB]}}initializeState(t,r){let i=this.getAttributeManager();i&&i.add({brushingTargets:{size:2,stepMode:"dynamic",accessor:"getBrushingTarget"}});let s=()=>{this.getCurrentLayer()?.setNeedsRedraw()};this.state.onMouseMove=s,t.deck&&t.deck.eventManager.on({pointermove:s,pointerleave:s})}finalizeState(t,r){if(t.deck){let i=this.state.onMouseMove;t.deck.eventManager.off({pointermove:i,pointerleave:i})}}},bf=Sm;(()=>{Sm.defaultProps=gK})(),(()=>{Sm.extensionName="BrushingExtension"})();var AB=`
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
`,TB=`
uniform bool filter_transformColor;
in float dataFilter_value;
`;function bB(e){if(!e||!("extensions"in e))return{};let{filterRange:t=[-1,1],filterEnabled:r=!0,filterTransformSize:i=!0,filterTransformColor:s=!0}=e,n=e.filterSoftRange||t;return{...Number.isFinite(t[0])?{filter_min:t[0],filter_softMin:n[0],filter_softMax:n[1],filter_max:t[1]}:{filter_min:t.map(o=>o[0]),filter_softMin:n.map(o=>o[0]),filter_softMax:n.map(o=>o[1]),filter_max:t.map(o=>o[1])},filter_enabled:r,filter_useSoftMargin:Boolean(e.filterSoftRange),filter_transformSize:r&&i,filter_transformColor:r&&s}}function mK(e){if(!e||!("extensions"in e))return{};let t=bB(e);if(Number.isFinite(t.filter_min)){let r=Math.fround(t.filter_min);t.filter_min-=r,t.filter_softMin-=r,t.filter_min64High=r;let i=Math.fround(t.filter_max);t.filter_max-=i,t.filter_softMax-=i,t.filter_max64High=i}else{let r=t.filter_min.map(Math.fround);t.filter_min=t.filter_min.map((s,n)=>s-r[n]),t.filter_softMin=t.filter_softMin.map((s,n)=>s-r[n]),t.filter_min64High=r;let i=t.filter_max.map(Math.fround);t.filter_max=t.filter_max.map((s,n)=>s-i[n]),t.filter_softMax=t.filter_softMax.map((s,n)=>s-i[n]),t.filter_max64High=i}return t}var EB={"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;
}
`},SB={name:"data-filter",vs:AB,fs:TB,inject:EB,getUniforms:bB},vB={name:"data-filter-fp64",vs:AB,fs:TB,inject:EB,getUniforms:mK};var _K=`#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;
}
`,yK=`#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;
}
`,xK=["float32-renderable-webgl","texture-blend-float-webgl"];function CB(e){return xK.every(t=>e.features.has(t))}function wB(e,t){return t?e.createFramebuffer({width:1,height:1,colorAttachments:[e.createTexture({format:"rgba32float",type:5126,mipmaps:!1})]}):e.createFramebuffer({width:256,height:64,colorAttachments:[e.createTexture({format:"rgba8unorm",type:5126,mipmaps:!1})]})}function PB(e,t,r){return t.defines.NON_INSTANCED_MODEL=1,r&&(t.defines.FLOAT_TARGET=1),new J(e,{id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,drawMode:0,vs:_K,fs:yK,...t})}var MB={blend:!0,blendFunc:[1,1,1,1],blendEquation:[32774,32774],depthTest:!1};var TK={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},bK={categorySize:0,filterSize:1,fp64:!1,countItems:!1},RB={1:"float",2:"vec2",3:"vec3",4:"vec4"},vm=class extends Lt{constructor(t={}){super({...bK,...t})}getShaders(t){let{categorySize:r,filterSize:i,fp64:s}=t.opts,n={};return r&&(n.DATACATEGORY_TYPE=RB[r],n.DATACATEGORY_CHANNELS=r),i&&(n.DATAFILTER_TYPE=RB[i],n.DATAFILTER_DOUBLE=Boolean(s)),{modules:[s?vB:SB],defines:n}}initializeState(t,r){let i=this.getAttributeManager(),{categorySize:s,filterSize:n,fp64:o}=r.opts;i&&(n&&i.add({filterValues:{size:n,type:o?"float64":"float32",stepMode:"dynamic",accessor:"getFilterValue"}}),s&&i.add({filterCategoryValues:{size:s,stepMode:"dynamic",accessor:"getFilterCategory",transform:s===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(i&&r.opts.countItems){let c=CB(a);i.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=wB(a,c),u=PB(a,r.getShaders.call(this,r),c);this.setState({filterFBO:l,filterModel:u})}}updateState({props:t,oldProps:r,changeFlags:i},s){let n=this.getAttributeManager(),{categorySize:o}=s.opts;if(this.state.filterModel){let a=n.attributes.filterValues?.needsUpdate()||n.attributes.filterCategoryValues?.needsUpdate()||t.filterEnabled!==r.filterEnabled||t.filterRange!==r.filterRange||t.filterSoftRange!==r.filterSoftRange||t.filterCategories!==r.filterCategories;a&&this.setState({filterNeedsUpdate:a})}n?.attributes.filterCategoryValues&&((n.attributes.filterCategoryValues.needsUpdate()||!vt(t.filterCategories,r.filterCategories,2))&&this.setState({categoryBitMask:null}),i.dataChanged&&(this.setState({categoryMap:Array(o).fill(0).map(()=>({}))}),n.attributes.filterCategoryValues.setNeedsUpdate("categoryMap")))}draw(t,r){let i=this.state.filterFBO,s=this.state.filterModel,n=this.state.filterNeedsUpdate,{onFilteredItemsChange:o}=this.props;if(this.state.categoryBitMask||r._updateCategoryBitMask.call(this,t,r),t.uniforms.filter_categoryBitMask=this.state.categoryBitMask,n&&o&&s){let{attributes:{filterValues:a,filterCategoryValues:c,filterIndices:l}}=this.getAttributeManager();s.setVertexCount(this.getNumInstances()),this.context.device.clearWebGL({framebuffer:i,color:[0,0,0,0]}),s.updateModuleSettings(t.moduleParameters),s.setAttributes({...a?.getValue(),...c?.getValue(),...l?.getValue()}),s.setUniforms(t.uniforms),s.device.withParametersWebGL({framebuffer:i,...MB,viewport:[0,0,i.width,i.height]},()=>{s.draw(this.context.renderPass)});let u=s.device.readPixelsToArrayWebGL(i),f=0;for(let h=0;h<u.length;h++)f+=u[h];o({id:this.id,count:f}),this.state.filterNeedsUpdate=!1}}finalizeState(){let t=this.state.filterFBO,r=this.state.filterModel;t?.destroy(),r?.destroy()}_updateCategoryBitMask(t,r){let{categorySize:i}=r.opts;if(!i)return;let{filterCategories:s}=this.props,n=new Uint32Array([0,0,0,0]),o=i===1?[s]:s,a=i===1?128:i===2?64:32;for(let c=0;c<o.length;c++){let l=o[c];for(let u of l){let f=r._getCategoryKey.call(this,u,c);if(f<a){let h=c*(a/32)+Math.floor(f/32);n[h]+=Math.pow(2,f%32)}else k.warn(`Exceeded maximum number of categories (${a})`)()}}this.state.categoryBitMask=n}_getCategoryKey(t,r){let i=this.state.categoryMap[r];return t in i||(i[t]=Object.keys(i).length),i[t]}},Ef=vm;(()=>{vm.defaultProps=TK})(),(()=>{vm.extensionName="DataFilterExtension"})();var IB=`const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
uniform vec2 project_uViewProjectionMatrixFP64[16];
void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) {
#if defined(NVIDIA_FP64_WORKAROUND)
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64 * ONE);
#else
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64);
#endif
out_val[1] = sum_fp64(PI_FP64,
log_fp64(tan_fp64(sum_fp64(PI_4_FP64, radians_fp64(lnglat_fp64.zw) / 2.0))));
return;
}
void project_position_fp64(vec4 position_fp64, out vec2 out_val[2]) {
vec2 pos_fp64[2];
mercatorProject_fp64(position_fp64, pos_fp64);
out_val[0] = mul_fp64(pos_fp64[0], WORLD_SCALE_FP64);
out_val[1] = mul_fp64(pos_fp64[1], WORLD_SCALE_FP64);
return;
}
void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val[2]) {
vec4 position64xy = vec4(
position.x, position64xyLow.x,
position.y, position64xyLow.y);
project_position_fp64(position64xy, out_val);
}
vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) {
vec2 vertex_pos_clipspace[4];
mat4_vec4_mul_fp64(project_uViewProjectionMatrixFP64, vertex_pos_modelspace,
vertex_pos_clipspace);
return vec4(
vertex_pos_clipspace[0].x,
vertex_pos_clipspace[1].x,
vertex_pos_clipspace[2].x,
vertex_pos_clipspace[3].x
);
}
vec4 project_position_to_clipspace(
vec3 position, vec3 position64xyLow, vec3 offset, out vec4 commonPosition
) {
vec2 offset64[4];
vec4_fp64(vec4(offset, 0.0), offset64);
float z = project_size(position.z);
vec2 projectedPosition64xy[2];
project_position_fp64(position.xy, position64xyLow.xy, projectedPosition64xy);
vec2 commonPosition64[4];
commonPosition64[0] = sum_fp64(offset64[0], projectedPosition64xy[0]);
commonPosition64[1] = sum_fp64(offset64[1], projectedPosition64xy[1]);
commonPosition64[2] = sum_fp64(offset64[2], vec2(z, 0.0));
commonPosition64[3] = vec2(1.0, 0.0);
commonPosition = vec4(projectedPosition64xy[0].x, projectedPosition64xy[1].x, z, 1.0);
return project_common_position_to_clipspace_fp64(commonPosition64);
}
vec4 project_position_to_clipspace(
vec3 position, vec3 position64xyLow, vec3 offset
) {
vec4 commonPosition;
return project_position_to_clipspace(
position, position64xyLow, offset, commonPosition
);
}
`;var{fp64ify:EK,fp64ifyMatrix4:SK}=sd,Cm={name:"project64",dependencies:[te,sd],vs:IB,getUniforms:CK},vK=He(wK);function CK(e){if(e&&"viewport"in e){let{viewProjectionMatrix:t,scale:r}=e.viewport;return vK({viewProjectionMatrix:t,scale:r})}return{}}function wK({viewProjectionMatrix:e,scale:t}){let r=SK(e),i=EK(t);return{project_uViewProjectionMatrixFP64:r,project64_uViewProjectionMatrix:r,project64_uScale:i}}var Xb=class extends Lt{getShaders(){let{coordinateSystem:t}=this.props;if(t!==X.LNGLAT&&t!==X.DEFAULT)throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[Cm]}}},Sf=Xb;(()=>{Xb.extensionName="Fp64Extension"})();var BB={inject:{"vs:#decl":`
in vec2 instanceDashArrays;
in float instanceDashOffsets;
out vec2 vDashArray;
out float vDashOffset;
`,"vs:#main-end":`
vDashArray = instanceDashArrays;
vDashOffset = instanceDashOffsets / width.x;
`,"fs:#decl":`
uniform float dashAlignMode;
uniform float capType;
uniform bool dashGapPickable;
in vec2 vDashArray;
in float vDashOffset;
`,"fs:#main-start":`
float solidLength = vDashArray.x;
float gapLength = vDashArray.y;
float unitLength = solidLength + gapLength;
float offset;
if (unitLength > 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;
}
}
}
}
}
`}},OB={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 PK={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},wm=class extends Lt{constructor({dash:t=!1,offset:r=!1,highPrecisionDash:i=!1}={}){super({dash:t||i,offset:r,highPrecisionDash:i})}isEnabled(t){return"pathTesselator"in t.state}getShaders(t){if(!t.isEnabled(this))return null;let r={};return t.opts.dash&&(r=Si(r,BB)),t.opts.offset&&(r=Si(r,OB)),r}initializeState(t,r){let i=this.getAttributeManager();!i||!r.isEnabled(this)||(r.opts.dash&&i.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},instanceDashOffsets:r.opts.highPrecisionDash?{size:1,accessor:"getPath",transform:r.getDashOffsets.bind(this)}:{size:1,update:s=>{s.constant=!0,s.value=[0]}}}),r.opts.offset&&i.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))}updateState(t,r){if(!r.isEnabled(this))return;let i={};r.opts.dash&&(i.dashAlignMode=this.props.dashJustified?1:0,i.dashGapPickable=Boolean(this.props.dashGapPickable)),this.state.model?.setUniforms(i)}getDashOffsets(t){let r=[0],i=this.props.positionFormat==="XY"?2:3,s=Array.isArray(t[0]),n=s?t.length:t.length/i,o,a;for(let c=0;c<n-1;c++)o=s?t[c]:t.slice(c*i,c*i+i),o=this.projectPosition(o),c>0&&(r[c]=r[c-1]+jt.dist(a,o)),a=o;return r[n-1]=0,r}},vf=wm;(()=>{wm.defaultProps=PK})(),(()=>{wm.extensionName="PathStyleExtension"})();var MK=`
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;
`,RK=`
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;
`,IK={"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 BK(e,t){if(!e)return{};if("fillPatternTexture"in e){let{fillPatternTexture:r}=e;return{fill_patternTexture:r,fill_patternTextureSize:[r.width,r.height]}}if("viewport"in e){let{fillPatternMask:r=!0,fillPatternEnabled:i=!0}=e,{project_uCommonOrigin:s}=t,n=[kr(s[0]),kr(s[1])];return{fill_uvCoordinateOrigin:s.slice(0,2),fill_uvCoordinateOrigin64Low:n,fill_patternMask:r,fill_patternEnabled:i}}return{}}var FB={name:"fill-pattern",vs:MK,fs:RK,inject:IK,dependencies:[te],getUniforms:BK};var OK={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{lodMaxClamp:0}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:e=>e.pattern},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},Pm=class extends Lt{constructor({pattern:t=!1}={}){super({pattern:t})}isEnabled(t){return t.getAttributeManager()!==null&&!("pathTesselator"in t.state)}getShaders(t){return t.isEnabled(this)?{modules:[t.opts.pattern&&FB].filter(Boolean)}:null}initializeState(t,r){if(!r.isEnabled(this))return;let i=this.getAttributeManager();r.opts.pattern&&i.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:t,oldProps:r},i){i.isEnabled(this)&&t.fillPatternMapping&&t.fillPatternMapping!==r.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")}draw(t,r){if(!r.isEnabled(this))return;let{fillPatternAtlas:i}=this.props;this.setModuleParameters({fillPatternTexture:i||this.state.emptyTexture})}finalizeState(){this.state.emptyTexture?.delete()}getPatternFrame(t){let{fillPatternMapping:r}=this.getCurrentLayer().props,i=r&&r[t];return i?[i.x,i.y,i.width,i.height]:[0,0,0,0]}},Cf=Pm;(()=>{Pm.defaultProps=OK})(),(()=>{Pm.extensionName="FillStyleExtension"})();var FK={clipBounds:[0,0,1,1],clipByInstance:void 0},NB=`
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];
}
`,NK={name:"clip-vs",vs:NB},LK={"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;
`},DK={name:"clip-fs",fs:NB},UK={"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;
`},Mm=class extends Lt{getShaders(){let t="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(t=Boolean(this.props.clipByInstance)),this.state.clipByInstance=t,t?{modules:[NK],inject:LK}:{modules:[DK],inject:UK}}draw({uniforms:t}){let{clipBounds:r}=this.props;if(this.state.clipByInstance)t.clip_bounds=r;else{let i=this.projectPosition([r[0],r[1],0]),s=this.projectPosition([r[2],r[3],0]);t.clip_bounds=[Math.min(i[0],s[0]),Math.min(i[1],s[1]),Math.max(i[0],s[0]),Math.max(i[1],s[1])]}}},Mo=Mm;(()=>{Mm.defaultProps=FK})(),(()=>{Mm.extensionName="ClipExtension"})();var kK=`
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);
}
`,VK={"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;
`},zK=(e,t)=>{if(!e||!("dummyCollisionMap"in e))return{};let{collisionFBO:r,drawToCollisionMap:i,dummyCollisionMap:s}=e;return{collision_sort:Boolean(i),collision_texture:!i&&r?r.colorAttachments[0]:s}},LB={name:"collision",dependencies:[te],vs:kK,inject:VK,getUniforms:zK};var wf=class extends ye{renderCollisionMap(t,r){let s=[0,0,0,0],n=[1,1,t.width-2*1,t.height-2*1];this.render({...r,clearColor:s,scissorRect:n,target:t,pass:"collision"})}getLayerParameters(t,r,i){return{...t.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}getModuleParameters(){return{drawToCollisionMap:!0,picking:{isActive:1,isAttribute:!1},lightSources:{}}}};var Yb=2,Pf=class{constructor(){this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFBOs={}}setup(t){this.context=t;let{device:r}=t;this.dummyCollisionMap=r.createTexture({width:1,height:1}),this.collisionFilterPass=new wf(r,{id:"default-collision-filter"})}preRender({effects:t,layers:r,layerFilter:i,viewports:s,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=t?.filter(m=>m.useInPicking&&c[m.id]),h=c["mask-effect"]?.didRender,d=this._groupByCollisionGroup(l,u),p=s[0],g=!this.lastViewport||!this.lastViewport.equals(p)||h;for(let m in d){let _=this.collisionFBOs[m],y=d[m],[x,E]=l.canvasContext.getPixelSize();_.resize({width:x/Yb,height:E/Yb}),this._render(y,{effects:f,layerFilter:i,onViewportActive:n,views:o,viewport:p,viewportChanged:g})}}_render(t,{effects:r,layerFilter:i,onViewportActive:s,views:n,viewport:o,viewportChanged:a}){let{collisionGroup:c}=t,l=this.channels[c];if(!l)return;let u=a||t===l||!vt(l.layers,t.layers,1)||t.layerBounds.some((f,h)=>!Ct(f,l.layerBounds[h]))||t.allLayersLoaded!==l.allLayersLoaded||t.layers.some(f=>f.props.transitions);if(this.channels[c]=t,u){this.lastViewport=o;let f=this.collisionFBOs[c];this.collisionFilterPass.renderCollisionMap(f,{pass:"collision-filter",isPicking:!0,layers:t.layers,effects:r,layerFilter:i,viewports:o?[o]:[],onViewportActive:s,views:n,moduleParameters:{dummyCollisionMap:this.dummyCollisionMap,devicePixelRatio:f.device.canvasContext.getDevicePixelRatio()/Yb}})}}_groupByCollisionGroup(t,r){let i={};for(let s of r){let{collisionGroup:n}=s.props,o=i[n];o||(o={collisionGroup:n,layers:[],layerBounds:[],allLayersLoaded:!0},i[n]=o),o.layers.push(s),o.layerBounds.push(s.getBounds()),s.isLoaded||(o.allLayersLoaded=!1)}for(let s of Object.keys(i))this.collisionFBOs[s]||this.createFBO(t,s),this.channels[s]||(this.channels[s]=i[s]);for(let s of Object.keys(this.collisionFBOs))i[s]||this.destroyFBO(s);return i}getModuleParameters(t){let{collisionGroup:r}=t.props,{collisionFBOs:i,dummyCollisionMap:s}=this;return{collisionFBO:i[r],dummyCollisionMap:s}}cleanup(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(let t of Object.keys(this.collisionFBOs))this.destroyFBO(t);this.collisionFBOs={},this.lastViewport=void 0}createFBO(t,r){let{width:i,height:s}=t.gl.canvas,n=t.createTexture({format:"rgba8unorm",width:i,height:s,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),o=t.createTexture({format:"depth16unorm",width:i,height:s,mipmaps:!1,dataFormat:6402,type:5125});this.collisionFBOs[r]=t.createFramebuffer({id:`collision-${r}`,width:i,height:s,colorAttachments:[n],depthStencilAttachment:o})}destroyFBO(t){let r=this.collisionFBOs[t];r.colorAttachments[0]?.destroy(),r.depthStencilAttachment?.destroy(),r.destroy(),delete this.collisionFBOs[t]}};var HK={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},Rm=class extends Lt{getShaders(){return{modules:[LB]}}draw({uniforms:t,context:r,moduleParameters:i}){let{collisionEnabled:s}=this.props,{collisionFBO:n,drawToCollisionMap:o}=i,a=s&&Boolean(n);t.collision_enabled=a,o&&(this.props=this.clone(this.props.collisionTestProps).props)}initializeState(t,r){if(this.getAttributeManager()===null)return;this.context.deck?._addDefaultEffect(new Pf),this.getAttributeManager().add({collisionPriorities:{size:1,stepMode:"dynamic",accessor:"getCollisionPriority"}})}getNeedsPickingBuffer(){return this.props.collisionEnabled}},Mf=Rm;(()=>{Rm.defaultProps=HK})(),(()=>{Rm.extensionName="CollisionFilterExtension"})();var GK=`
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);
}
`,WK=`
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;
}
}
`,jK={"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;
}
`},XK=e=>e&&"maskMap"in e?{mask_texture:e.maskMap}:{},DB={name:"mask",dependencies:[te],vs:GK,fs:WK,inject:jK,getUniforms:XK};var YK={blendColorOperation:"subtract",blendColorSrcFactor:"zero",blendColorDstFactor:"one",blendAlphaOperation:"subtract",blendAlphaSrcFactor:"zero",blendAlphaDstFactor:"one"},Rf=class extends ye{constructor(t,r){super(t,r);let{mapSize:i=2048}=r;this.maskMap=t.createTexture({format:"rgba8unorm",width:i,height:i,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.fbo=t.createFramebuffer({id:"maskmap",width:i,height:i,colorAttachments:[this.maskMap]})}render(t){let r=2**t.channel,i=[255,255,255,255];super.render({...t,clearColor:i,colorMask:r,target:this.fbo,pass:"mask"})}getLayerParameters(t,r,i){return{...t.props.parameters,blend:!0,depthTest:!1,...YK}}shouldDrawLayer(t){return t.props.operation.includes("mask")}delete(){this.fbo.delete(),this.maskMap.delete()}};function Za(e,t){let r=[1/0,1/0,-1/0,-1/0];for(let i of e){let s=i.getBounds();if(s){let n=i.projectPosition(s[0],{viewport:t,autoOffset:!1}),o=i.projectPosition(s[1],{viewport:t,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 Qa(e){let{bounds:t,viewport:r,border:i=0}=e,{isGeospatial:s}=r;if(t[2]<=t[0]||t[3]<=t[1])return null;let n=r.unprojectPosition([(t[0]+t[2])/2,(t[1]+t[3])/2,0]),{width:o,height:a,zoom:c}=e;if(c===void 0){o=o-i*2,a=a-i*2;let l=Math.min(o/(t[2]-t[0]),a/(t[3]-t[1]));c=Math.min(Math.log2(l),20)}else if(!o||!a){let l=2**c;o=Math.round(Math.abs(t[2]-t[0])*l),a=Math.round(Math.abs(t[3]-t[1])*l);let u=qK-i*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 s?new ne({id:r.id,x:i,y:i,width:o,height:a,longitude:n[0],latitude:n[1],zoom:c,orthographic:!0}):new Zi({id:r.id,x:i,y:i,width:o,height:a,target:n,zoom:c,flipY:!1})}function KK(e,t){let r;if(t&&t.length===2){let[n,o]=t,a=e.getBounds({z:n}),c=e.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=e.getBounds();let i=e.projectPosition(r.slice(0,2)),s=e.projectPosition(r.slice(2,4));return[i[0],i[1],s[0],s[1]]}function tc(e,t,r){if(!e)return[0,0,1,1];let i=KK(t,r),s=$K(i);return e[2]-e[0]<=s[2]-s[0]&&e[3]-e[1]<=s[3]-s[1]?e:[Math.max(e[0],s[0]),Math.max(e[1],s[1]),Math.min(e[2],s[2]),Math.min(e[3],s[3])]}function $K(e){let t=e[2]-e[0],r=e[3]-e[1],i=(e[0]+e[2])/2,s=(e[1]+e[3])/2;return[i-t,s-r,i+t,s+r]}var If=class{constructor(){this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.channels=[],this.masks=null}setup({device:t}){this.dummyMaskMap=t.createTexture({width:1,height:1}),this.maskPass=new Rf(t,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap}preRender({layers:t,layerFilter:r,viewports:i,onViewportActive:s,views:n,isPicking:o}){let a=!1;if(o)return{didRender:a};let c=t.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=i[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:s,views:n,viewport:u,viewportChanged:f});a||=d}return{didRender:a}}_renderChannel(t,{layerFilter:r,onViewportActive:i,views:s,viewport:n,viewportChanged:o}){let a=!1,c=this.channels[t.index];if(!c)return a;let l=t===c||t.layers.length!==c.layers.length||t.layers.some((u,f)=>u!==c.layers[f]||u.props.transitions)||t.layerBounds.some((u,f)=>u!==c.layerBounds[f]);if(t.bounds=c.bounds,t.maskBounds=c.maskBounds,this.channels[t.index]=t,l||o){this.lastViewport=n;let u=Za(t.layers,n);if(t.bounds=u&&tc(u,n),l||!Ct(t.bounds,c.bounds)){let{maskPass:f,maskMap:h}=this,d=u&&Qa({bounds:t.bounds,viewport:n,width:h.width,height:h.height,border:1});t.maskBounds=d?d.getBounds():[0,0,1,1],f.render({pass:"mask",channel:t.index,layers:t.layers,layerFilter:r,viewports:d?[d]:[],onViewportActive:i,views:s,moduleParameters:{devicePixelRatio:1}}),a=!0}}return this.masks[t.id]={index:t.index,bounds:t.maskBounds,coordinateOrigin:t.coordinateOrigin,coordinateSystem:t.coordinateSystem},a}_sortMaskChannels(t){let r={},i=0;for(let s of t){let{id:n}=s.root,o=r[n];if(!o){if(++i>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:s.root.props.coordinateOrigin,coordinateSystem:s.root.props.coordinateSystem},r[n]=o}o.layers.push(s),o.layerBounds.push(s.getBounds())}for(let s=0;s<4;s++){let n=this.channels[s];(!n||!(n.id in r))&&(this.channels[s]=null)}for(let s in r){let n=r[s];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 JK={maskId:"",maskByInstance:void 0,maskInverted:!1},Im=class extends Lt{initializeState(){this.context.deck?._addDefaultEffect(new If)}getShaders(){let t="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(t=Boolean(this.props.maskByInstance)),this.state.maskByInstance=t,{modules:[DB]}}draw({uniforms:t,context:r,moduleParameters:i}){t.mask_maskByInstance=this.state.maskByInstance;let{maskId:s,maskInverted:n}=this.props,{maskChannels:o}=i,{viewport:a}=r;if(o&&o[s]){let{index:c,bounds:l,coordinateOrigin:u}=o[s],{coordinateSystem:f}=o[s];t.mask_enabled=!0,t.mask_channel=c,t.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);t.mask_bounds=[d[0],d[1],p[0],p[1]]}else s&&k.warn(`Could not find a mask layer with id: ${s}`)(),t.mask_enabled=!1}},Bf=Im;(()=>{Im.defaultProps=JK})(),(()=>{Im.extensionName="MaskExtension"})();var Oi={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},UB=Object.keys(Oi).map(e=>`const float TERRAIN_MODE_${e} = ${Oi[e]}.0;`).join(`
`),Of={name:"terrain",dependencies:[te],inject:{"vs:#decl":`
uniform float terrain_mode;
uniform sampler2D terrain_map;
uniform vec4 terrain_bounds;
out vec3 commonPos;
`+UB,"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;
`+UB,"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:(e={},t)=>{if("dummyHeightMap"in e){let{drawToTerrainHeightMap:r,heightMap:i,heightMapBounds:s,dummyHeightMap:n,terrainCover:o,useTerrainHeightMap:a,terrainSkipRender:c}=e,{project_uCommonOrigin:l}=t,u=c?Oi.SKIP:Oi.NONE,f=n,h=null;if(r)u=Oi.WRITE_HEIGHT_MAP,h=s;else if(a&&i)u=Oi.USE_HEIGHT_MAP,f=i,h=s;else if(o){let d=e.picking?.isActive;f=(d?o.getPickingFramebuffer():o.getRenderFramebuffer())?.colorAttachments[0].texture,d&&(u=Oi.SKIP),f?(u=u===Oi.SKIP?Oi.USE_COVER_ONLY:Oi.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 Ff(e,t){return e.createFramebuffer({id:t.id,colorAttachments:[e.createTexture({id:t.id,...t.float&&{format:"rgba32float",type:5126},mipmaps:!1,sampler:t.interpolate===!1?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}var Bm=class{constructor(t){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=t,this.tile=kB(t)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:t,viewport:r,layers:i,layerNeedsRedraw:s}){t&&(this.targetLayer=t);let n=r?this._updateViewport(r):!1,o=i?this._updateLayers(i):!1;if(s){for(let a of this.layers)if(s[a]){o=!0;break}}return o||n}_updateLayers(t){let r=!1;if(t=this.tile?ZK(this.tile,t):t,t.length!==this.layers.length)r=!0;else for(let i=0;i<t.length;i++)if(t[i].id!==this.layers[i]){r=!0;break}return r&&(this.layers=t.map(i=>i.id)),r}_updateViewport(t){let r=this.targetLayer,i=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){i=!0,this.targetBounds=this.tile.boundingBox;let n=t.projectPosition(this.targetBounds[0]),o=t.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[n[0],n[1],o[0],o[1]]}}else this.targetBounds!==r.getBounds()&&(i=!0,this.targetBounds=r.getBounds(),this.targetBoundsCommon=Za([r],t));if(!this.targetBoundsCommon)return!1;let s=Math.ceil(t.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{let n=this.renderViewport?.zoom;i=i||s!==n;let o=tc(this.targetBoundsCommon,t),a=this.bounds;i=i||!a||o.some((c,l)=>c!==a[l]),this.bounds=o}return i&&(this.renderViewport=Qa({bounds:this.bounds,zoom:s,viewport:t})),i}getRenderFramebuffer(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=Ff(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=Ff(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(t){return t.filter(({id:r})=>this.layers.includes(r))}delete(){let{fbo:t,pickingFbo:r}=this;t&&(t.colorAttachments[0].destroy(),t.destroy()),r&&(r.colorAttachments[0].destroy(),r.destroy())}};function ZK(e,t){return t.filter(r=>{let i=kB(r);return i?QK(e.boundingBox,i.boundingBox):!0})}function kB(e){for(;e;){let{tile:t}=e.props;if(t)return t;e=e.parent}return null}function QK(e,t){return e&&t?e[0][0]<t[1][0]&&t[0][0]<e[1][0]&&e[0][1]<t[1][1]&&t[0][1]<e[1][1]:!1}var t$={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},Om=class extends ye{getRenderableLayers(t,r){let{layers:i}=r,s=[],n=this._getDrawLayerParams(t,r,!0);for(let o=0;o<i.length;o++){let a=i[o];!a.isComposite&&n[o].shouldDrawLayer&&s.push(a)}return s}renderHeightMap(t,r){let i=t.getRenderFramebuffer(),s=t.renderViewport;!i||!s||(i.resize(s),this.render({...r,target:i,pass:"terrain-height-map",layers:r.layers,viewports:[s],effects:[],clearColor:[0,0,0,0]}))}renderTerrainCover(t,r){let i=t.getRenderFramebuffer(),s=t.renderViewport;if(!i||!s)return;let n=t.filterLayers(r.layers);i.resize(s),this.render({...r,target:i,pass:`terrain-cover-${t.id}`,layers:n,effects:[],viewports:[s],clearColor:[0,0,0,0]})}getLayerParameters(t,r,i){return{...t.props.parameters,blend:!0,depthTest:!1,...t.props.operation.includes("terrain")&&t$}}};var Fm=class extends Vr{constructor(){super(...arguments),this.drawParameters={}}getRenderableLayers(t,r){let{layers:i}=r,s=[];this.drawParameters={},this._resetColorEncoder(r.pickZ);let n=this._getDrawLayerParams(t,r);for(let o=0;o<i.length;o++){let a=i[o];!a.isComposite&&n[o].shouldDrawLayer&&(s.push(a),this.drawParameters[a.id]=n[o].layerParameters)}return s}renderTerrainCover(t,r){let i=t.getPickingFramebuffer(),s=t.renderViewport;if(!i||!s)return;let n=t.filterLayers(r.layers),o=t.targetLayer;o.props.pickable&&n.unshift(o),i.resize(s),this.render({...r,pickingFBO:i,pass:`terrain-cover-picking-${t.id}`,layers:n,effects:[],viewports:[s],cullRect:void 0,deviceRect:s,pickZ:!1})}getLayerParameters(t,r,i){let s;return this.drawParameters[t.id]?s=this.drawParameters[t.id]:(s=super.getLayerParameters(t,r,i),s.blend=!0),{...s,depthTest:!1}}};var VB=2048,Nf=class{static isSupported(t){return t.isTextureFormatRenderable("rgba32float")}constructor(t){this.renderViewport=null,this.bounds=null,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=t}getRenderFramebuffer(){return this.renderViewport?(this.fbo||(this.fbo=Ff(this.device,{id:"height-map",float:!0})),this.fbo):null}shouldUpdate({layers:t,viewport:r}){let i=t.length!==this.layers.length||t.some((n,o)=>n!==this.layers[o]||n.props.transitions||n.getBounds()!==this.layersBounds[o]);i&&(this.layers=t,this.layersBounds=t.map(n=>n.getBounds()),this.layersBoundsCommon=Za(t,r));let s=!this.lastViewport||!r.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(i||s){let n=tc(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?Qa({bounds:[r.center[0]-1,r.center[1]-1,r.center[0]+1,r.center[1]+1],zoom:r.zoom,width:Math.min(a,VB),height:Math.min(c,VB),viewport:r}):null,!0}return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}};var Nm=class{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:t,deck:r}){this.dummyHeightMap=t.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new Om(t,{id:"terrain"}),this.terrainPickingPass=new Fm(t,{id:"terrain-picking"}),Nf.isSupported(t)?this.heightMap=new Nf(t):k.warn("Terrain offset mode is not supported by this browser")(),r._addDefaultShaderModule(Of)}preRender(t){if(t.pickZ){this.isDrapingEnabled=!1;return}let{viewports:r}=t,i=t.pass.startsWith("picking");this.isPicking=i,this.isDrapingEnabled=!0;let s=r[0],n=(i?this.terrainPickingPass:this.terrainPass).getRenderableLayers(s,t),o=n.filter(c=>c.props.operation.includes("terrain"));if(o.length===0)return;i||n.filter(l=>l.state.terrainDrawMode==="offset").length>0&&this._updateHeightMap(o,s,t);let a=n.filter(c=>c.state.terrainDrawMode==="drape");this._updateTerrainCovers(o,a,s,t)}getModuleParameters(t){let{terrainDrawMode:r}=t.state;return{heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(t.id):null,useTerrainHeightMap:r==="offset",terrainSkipRender:r==="drape"||!t.props.operation.includes("draw")}}cleanup({deck:t}){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(),t._removeDefaultShaderModule(Of)}_updateHeightMap(t,r,i){!this.heightMap||!this.heightMap.shouldUpdate({layers:t,viewport:r})||this.terrainPass.renderHeightMap(this.heightMap,{...i,layers:t,moduleParameters:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,devicePixelRatio:1,drawToTerrainHeightMap:!0}})}_updateTerrainCovers(t,r,i,s){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 t)this._updateTerrainCover(o,r,i,s);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(t,r,i,s){let n=this.isPicking?this.terrainPickingPass:this.terrainPass,o=this.terrainCovers.get(t.id);o||(o=new Bm(t),this.terrainCovers.set(t.id,o));try{let a=o.shouldUpdate({targetLayer:t,viewport:i,layers:r});(this.isPicking||o.isDirty||a)&&(n.renderTerrainCover(o,{...s,layers:r,moduleParameters:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1,devicePixelRatio:1}}),this.isPicking||(o.isDirty=!1))}catch(a){t.raiseError(a,`Error rendering terrain cover ${o.id}`)}}_pruneTerrainCovers(){let t=[];for(let[r,i]of this.terrainCovers)i.isActive||t.push(r);for(let r of t)this.terrainCovers.delete(r)}};var e$={terrainDrawMode:void 0},Lm=class extends Lt{getShaders(){return{modules:[Of]}}initializeState(){this.context.deck?._addDefaultEffect(new Nm)}updateState(t){let{props:r,oldProps:i}=t;if(this.state.terrainDrawMode&&r.terrainDrawMode===i.terrainDrawMode&&r.extruded===i.extruded)return;let{terrainDrawMode:s}=r;if(!s){let n=this.props.extruded,o=this.getAttributeManager()?.attributes,a=o&&"instancePositions"in o;s=n||a?"offset":"drape"}this.setState({terrainDrawMode:s})}onNeedsRedraw(){let t=this.state;t.terrainDrawMode==="drape"&&(t.terrainCoverNeedsRedraw=!0)}},Lf=Lm;(()=>{Lm.defaultProps=e$})(),(()=>{Lm.extensionName="TerrainExtension"})();function $b(e,t,r){let i=r$(e),s=Object.keys(i).filter(n=>i[n]!==Array);return i$(e,{propArrayTypes:i,...t},{numericPropKeys:r&&r.numericPropKeys||s,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function r$(e){let t={};for(let r of e)if(r.properties)for(let i in r.properties){let s=r.properties[i];t[i]=l$(s,t[i])}return t}function i$(e,t,r){let{pointPositionsCount:i,pointFeaturesCount:s,linePositionsCount:n,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:f,propArrayTypes:h,coordLength:d}=t,{numericPropKeys:p=[],PositionDataType:g=Float32Array,triangulate:m=!0}=r,_=e[0]&&"id"in e[0],y=e.length>65535?Uint32Array:Uint16Array,x={type:"Point",positions:new g(i*d),globalFeatureIds:new y(i),featureIds:s>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},E={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 F of[x,E,P])for(let M of p){let v=h[M];F.numericProps[M]=new v(F.positions.length/d)}E.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 F of e){let M=F.geometry,v=F.properties||{};switch(M.type){case"Point":s$(M,x,B,d,v),x.properties.push(Kb(v,p)),_&&x.fields.push({id:F.id}),B.pointFeature++;break;case"LineString":n$(M,E,B,d,v),E.properties.push(Kb(v,p)),_&&E.fields.push({id:F.id}),B.lineFeature++;break;case"Polygon":o$(M,P,B,d,v),P.properties.push(Kb(v,p)),_&&P.fields.push({id:F.id}),B.polygonFeature++;break;default:throw new Error("Invalid geometry type")}B.feature++}return c$(x,E,P,d)}function s$(e,t,r,i,s){t.positions.set(e.data,r.pointPosition*i);let n=e.data.length/i;Jb(t,s,r.pointPosition,n),t.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+n),t.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+n),r.pointPosition+=n}function n$(e,t,r,i,s){t.positions.set(e.data,r.linePosition*i);let n=e.data.length/i;Jb(t,s,r.linePosition,n),t.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+n),t.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+n);for(let o=0,a=e.indices.length;o<a;++o){let c=e.indices[o],l=o===a-1?e.data.length:e.indices[o+1];t.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/i}}function o$(e,t,r,i,s){t.positions.set(e.data,r.polygonPosition*i);let n=e.data.length/i;Jb(t,s,r.polygonPosition,n),t.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+n),t.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+n);for(let o=0,a=e.indices.length;o<a;++o){let c=r.polygonPosition;t.polygonIndices[r.polygonObject++]=c;let l=e.areas[o],u=e.indices[o],f=e.indices[o+1];for(let d=0,p=u.length;d<p;++d){let g=u[d],m=d===p-1?f===void 0?e.data.length:f[0]:u[d+1];t.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(m-g)/i}let h=r.polygonPosition;a$(t,l,u,{startPosition:c,endPosition:h,coordLength:i})}}function a$(e,t,r,{startPosition:i,endPosition:s,coordLength:n}){if(!e.triangles)return;let o=i*n,a=s*n,c=e.positions.subarray(o,a),l=r[0],u=r.slice(1).map(h=>(h-l)/n),f=FA(c,u,n,t);for(let h=0,d=f.length;h<d;++h)e.triangles.push(i+f[h])}function qb(e,t){let r={};for(let i in e)r[i]={value:e[i],size:t};return r}function c$(e,t,r,i){let s={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:i},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:qb(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:i},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:qb(t.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:i},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:qb(r.numericProps,1)}};return s.polygons&&r.triangles&&(s.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),s}function Jb(e,t,r,i){for(let s in e.numericProps)if(s in t){let n=t[s];e.numericProps[s].fill(n,r,r+i)}}function Kb(e,t){let r={};for(let i in e)t.includes(i)||(r[i]=e[i]);return r}function l$(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}function km(e,t){let r=t?.globalFeatureId;return r!==void 0?u$(e,r):f$(e,t?.type)}function u$(e,t){let r=HB(e);for(let i of r){let s=0,n=i.featureIds.value[0];for(let o=0;o<i.featureIds.value.length;o++){let a=i.featureIds.value[o];if(a!==n){if(t===i.globalFeatureIds.value[s])return Dm(i,s,o);s=o,n=a}}if(t===i.globalFeatureIds.value[s])return Dm(i,s,i.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}function f$(e,t){let r=HB(e,t);return h$(r)}function zB(e,t,r){switch(e.type){case"Point":return m$(e,t,r);case"LineString":return g$(e,t,r);case"Polygon":return GB(e,t,r);default:let i=e;throw new Error(`Unsupported geometry type: ${i?.type}`)}}function HB(e,t){let r=[];return e.points&&(e.points.type="Point",r.push(e.points)),e.lines&&(e.lines.type="LineString",r.push(e.lines)),e.polygons&&(e.polygons.type="Polygon",r.push(e.polygons)),r}function h$(e){let t=[];for(let r of e){if(r.featureIds.value.length===0)continue;let i=0,s=r.featureIds.value[0];for(let n=0;n<r.featureIds.value.length;n++){let o=r.featureIds.value[n];o!==s&&(t.push(Dm(r,i,n)),i=n,s=o)}t.push(Dm(r,i,r.featureIds.value.length))}return t}function Dm(e,t,r){let i=zB(e,t,r),s=p$(e,t,r),n=d$(e,t,r);return{type:"Feature",geometry:i,properties:s,...n}}function d$(e,t=0,r){return e.fields&&e.fields[e.featureIds.value[t]]}function p$(e,t=0,r){let i=Object.assign({},e.properties[e.featureIds.value[t]]);for(let s in e.numericProps)i[s]=e.numericProps[s].value[t];return i}function GB(e,t=-1/0,r=1/0){let{positions:i}=e,s=e.polygonIndices.value.filter(c=>c>=t&&c<=r),n=e.primitivePolygonIndices.value.filter(c=>c>=t&&c<=r);if(!(s.length>2)){let c=[];for(let l=0;l<n.length-1;l++){let u=n[l],f=n[l+1],h=Um(i,u,f);c.push(h)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<s.length-1;c++){let l=s[c],u=s[c+1],f=GB(e,l,u).coordinates;a.push(f)}return{type:"MultiPolygon",coordinates:a}}function g$(e,t=-1/0,r=1/0){let{positions:i}=e,s=e.pathIndices.value.filter(a=>a>=t&&a<=r);if(!(s.length>2))return{type:"LineString",coordinates:Um(i,s[0],s[1])};let o=[];for(let a=0;a<s.length-1;a++){let c=Um(i,s[a],s[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function m$(e,t,r){let{positions:i}=e,s=Um(i,t,r);return s.length>1?{type:"MultiPoint",coordinates:s}:{type:"Point",coordinates:s[0]}}function Um(e,t,r){t=t||0,r=r||e.value.length/e.size;let i=[];for(let s=t;s<r;s++){let n=Array();for(let o=s*e.size;o<(s+1)*e.size;o++)n.push(Number(e.value[o]));i.push(n)}return i}var sE=li($B(),1);function JB(e){let t=e.length;if(t<=1)return[e];let r=[],i,s;for(let n=0;n<t;n++){let o=F$(e[n]);o!==0&&(s===void 0&&(s=o<0),s===o<0?(i&&r.push(i),i=[e[n]]):i&&i.push(e[n]))}return i&&r.push(i),r}function F$(e){let t=0;for(let r=0,i=e.length-1,s,n;r<e.length;i=r++)s=e[r],n=e[i],t+=(n[0]-s[0])*(s[1]+n[1]);return t}function ZB(e,t,r){t&&r&&(e===1?t.id=r.readVarint():e===2?N$(r,t):e===3?t.type=r.readVarint():e===4&&(t._geometry=r.pos))}function N$(e,t){let r=e.readVarint()+e.pos;for(;e.pos<r;){let i=t._keys[e.readVarint()],s=t._values[e.readVarint()];t.properties[i]=s}}var ic=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,r,i,s,n){this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=s,this._values=n,t.readFields(ZB,this,r)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,i=1,s=0,n=0,o=0,a=[],c;for(;t.pos<r;){if(s<=0){let l=t.readVarint();i=l&7,s=l>>3}if(s--,i===1||i===2)n+=t.readSVarint(),o+=t.readSVarint(),i===1&&(c&&a.push(c),c=[]),c&&c.push([n,o]);else if(i===7)c&&c.push(c[0].slice());else throw new Error(`unknown command ${i}`)}return c&&a.push(c),a}bbox(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,i=1,s=0,n=0,o=0,a=1/0,c=-1/0,l=1/0,u=-1/0;for(;t.pos<r;){if(s<=0){let f=t.readVarint();i=f&7,s=f>>3}if(s--,i===1||i===2)n+=t.readSVarint(),o+=t.readSVarint(),n<a&&(a=n),n>c&&(c=n),o<l&&(l=o),o>u&&(u=o);else if(i!==7)throw new Error(`unknown command ${i}`)}return[a,l,c,u]}_toGeoJSON(t){let r=this.loadGeometry(),i=ic.types[this.type],s,n;switch(this.type){case 1:let a=[];for(s=0;s<r.length;s++)a[s]=r[s][0];r=a,t(r,this);break;case 2:for(s=0;s<r.length;s++)t(r[s],this);break;case 3:for(r=JB(r),s=0;s<r.length;s++)for(n=0;n<r[s].length;n++)t(r[s][n],this);break}r.length===1?r=r[0]:i=`Multi${i}`;let o={type:"Feature",geometry:{type:i,coordinates:r},properties:this.properties};return this.id!==null&&(o.id=this.id),o}toGeoJSON(t){if(typeof t=="function")return this._toGeoJSON(t);let{x:r,y:i,z:s}=t,n=this.extent*Math.pow(2,s),o=this.extent*r,a=this.extent*i;function c(l){for(let u=0;u<l.length;u++){let f=l[u];f[0]=(f[0]+o)*360/n-180;let h=180-(f[1]+a)*360/n;f[1]=360/Math.PI*Math.atan(Math.exp(h*Math.PI/180))-90}}return this._toGeoJSON(c)}};var Hm=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(L$,this,r),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let r=this._pbf.readVarint()+this._pbf.pos;return new ic(this._pbf,r,this.extent,this._keys,this._values)}};function L$(e,t,r){t&&r&&(e===15?t.version=r.readVarint():e===1?t.name=r.readString():e===5?t.extent=r.readVarint():e===2?t._features.push(r.pos):e===3?t._keys.push(r.readString()):e===4&&t._values.push(D$(r)))}function D$(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let i=e.readVarint()>>3;t=i===1?e.readString():i===2?e.readFloat():i===3?e.readDouble():i===4?e.readVarint64():i===5?e.readVarint():i===6?e.readSVarint():i===7?e.readBoolean():null}return t}var Gm=class{layers;constructor(t,r){this.layers=t.readFields(U$,{},r)}};function U$(e,t,r){if(e===3&&r){let i=new Hm(r,r.readVarint()+r.pos);i.length&&t&&(t[i.name]=i)}}function QB(e){let t=e.indices.length,r="Polygon";if(t<=1)return{type:r,data:e.data,areas:[[Xs(e.data)]],indices:[e.indices]};let i=[],s=[],n=[],o=[],a,c=0;for(let l,u=0,f;u<t;u++){f=e.indices[u]-c,l=e.indices[u+1]-c||e.data.length;let h=e.data.slice(f,l),d=Xs(h);if(d===0){let p=e.data.slice(0,f),g=e.data.slice(l);e.data=p.concat(g),c+=l-f;continue}a===void 0&&(a=d<0),a===d<0?(o.length&&(i.push(n),s.push(o)),o=[f],n=[d]):(n.push(d),o.push(f))}return n&&i.push(n),o.length&&s.push(o),{type:r,areas:i,indices:s,data:e.data}}function tO(e,t,r,i){for(let s=0,n=e.length;s<n;s+=2){e[s]=(e[s]+t)*360/i-180;let o=180-(e[s+1]+r)*360/i;e[s+1]=360/Math.PI*Math.atan(Math.exp(o*Math.PI/180))-90}}function eO(e,t,r){t&&r&&(e===1?t.id=r.readVarint():e===2?k$(r,t):e===3?t.type=r.readVarint():e===4&&(t._geometry=r.pos))}function k$(e,t){let r=e.readVarint()+e.pos;for(;e.pos<r;){let i=t._keys[e.readVarint()],s=t._values[e.readVarint()];t.properties[i]=s}}var rO,Ro,tE,Wm,eE,rE,Df;var jm=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,r,i,s,n,o){this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=s,this._values=n,this._geometryInfo=o,t.readFields(eO,this,r)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,rO=t.readVarint()+t.pos,Ro=1,Wm=0,eE=0,rE=0,Df=0;let r=[],i=[];for(;t.pos<rO;)if(Wm<=0&&(tE=t.readVarint(),Ro=tE&7,Wm=tE>>3),Wm--,Ro===1||Ro===2)eE+=t.readSVarint(),rE+=t.readSVarint(),Ro===1&&r.push(Df),i.push(eE,rE),Df+=2;else if(Ro===7){if(Df>0){let s=r[r.length-1];i.push(i[s],i[s+1]),Df+=2}}else throw new Error(`unknown command ${Ro}`);return{data:i,indices:r}}_toBinaryCoordinates(t){let r=this.loadGeometry(),i;t(r.data,this);let s=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=r.indices.length,i={type:"Point",...r};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=r.indices.length,this._geometryInfo.linePositionsCount+=r.data.length/s,i={type:"LineString",...r};break;case 3:i=QB(r),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=i.indices.length;for(let o of i.indices)this._geometryInfo.polygonRingsCount+=o.length;this._geometryInfo.polygonPositionsCount+=i.data.length/s;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let n={type:"Feature",geometry:i,properties:this.properties};return this.id!==null&&(n.id=this.id),n}toBinaryCoordinates(t){if(typeof t=="function")return this._toBinaryCoordinates(t);let{x:r,y:i,z:s}=t,n=this.extent*Math.pow(2,s),o=this.extent*r,a=this.extent*i;return this._toBinaryCoordinates(c=>tO(c,o,a,n))}};var Xm=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(V$,this,r),this.length=this._features.length}feature(t,r){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let i=this._pbf.readVarint()+this._pbf.pos;return new jm(this._pbf,i,this.extent,this._keys,this._values,r)}};function V$(e,t,r){t&&r&&(e===15?t.version=r.readVarint():e===1?t.name=r.readString():e===5?t.extent=r.readVarint():e===2?t._features.push(r.pos):e===3?t._keys.push(r.readString()):e===4&&t._values.push(z$(r)))}function z$(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let i=e.readVarint()>>3;t=i===1?e.readString():i===2?e.readFloat():i===3?e.readDouble():i===4?e.readVarint64():i===5?e.readVarint():i===6?e.readSVarint():i===7?e.readBoolean():null}return t}var Ym=class{layers;constructor(t,r){this.layers=t.readFields(H$,{},r)}};function H$(e,t,r){if(e===3&&r){let i=new Xm(r,r.readVarint()+r.pos);i.length&&t&&(t[i.name]=i)}}function nE(e,t){let r=W$(t),i=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(i){case"columnar-table":return{shape:"columnar-table",data:iE(e,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:iO(e,r)};case"geojson":return iO(e,r);case"binary-geometry":return iE(e,r);case"binary":return iE(e,r);default:throw new Error(i||"undefined shape")}}function iE(e,t){let[r,i]=G$(e,t),s=$b(r,i);return s.byteLength=e.byteLength,s}function G$(e,t){let r=[],i={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[r,i];let s=new Ym(new sE.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(s.layers)).forEach(o=>{let a=s.layers[o];if(a)for(let c=0;c<a.length;c++){let l=a.feature(c,i),u=X$(l,t,o);r.push(u)}}),[r,i]}function iO(e,t){if(e.byteLength<=0)return[];let r=[],i=new Gm(new sE.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(n=>{let o=i.layers[n];if(o)for(let a=0;a<o.length;a++){let c=o.feature(a),l=j$(c,t,n);r.push(l)}}),r}function W$(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:r}=e.mvt,i=r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.z);if(t&&!i)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function j$(e,t,r){let i=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:Y$);return t.layerProperty&&(i.properties[t.layerProperty]=r),i}function X$(e,t,r){let i=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:q$);return t.layerProperty&&i.properties&&(i.properties[t.layerProperty]=r),i}function Y$(e,t){let{extent:r}=t;for(let i=0;i<e.length;i++){let s=e[i];s[0]/=r,s[1]/=r}}function q$(e,t){let{extent:r}=t;for(let i=0,s=e.length;i<s;++i)e[i]/=r}var K$="4.2.0-beta.2",qm={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:K$,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:null}}},$$={...qm,parse:async(e,t)=>nE(e,t),parseSync:nE,binary:!0};var J$={Point:sO,MultiPoint:Z$,LineString:nO,MultiLineString:Q$,Polygon:oO,MultiPolygon:tJ};function sO([e,t],[r,i],s){let n=se(r[0],i[0],e),o=se(r[1],i[1],t);return s.unprojectFlat([n,o])}function oE(e,t,r){return e.map(i=>sO(i,t,r))}function Z$(e,t,r){return oE(e,t,r)}function nO(e,t,r){return oE(e,t,r)}function Q$(e,t,r){return e.map(i=>nO(i,t,r))}function oO(e,t,r){return e.map(i=>oE(i,t,r))}function tJ(e,t,r){return e.map(i=>oO(i,t,r))}function aO(e,t,r){let i=r.projectFlat([t.west,t.north]),s=r.projectFlat([t.east,t.south]),n=[i,s];return{...e,coordinates:J$[e.type](e.coordinates,n,r)}}var eJ=["points","lines","polygons"];function aE(e,t,r,i){for(let s of eJ){let n=e[s]&&rJ(e[s],t,r,i);if(n>=0)return n}return-1}function rJ(e,t,r,i){let s=e.featureIds.value;if(!s.length)return-1;let n=0,o=s[s.length-1]+1;if(i){let c=iJ(e,i);if(c)n=c[0],o=c[1]+1;else return-1}let a=-1;if(t in e.numericProps){let c=e.numericProps[t].value.findIndex((l,u)=>l===r&&s[u]>=n&&s[u]<o);return c>=0?e.globalFeatureIds.value[c]:-1}else t?a=cO(e.properties,c=>c[t]===r,n,o):e.fields&&(a=cO(e.fields,c=>c.id===r,n,o));return a>=0?sJ(e,a):-1}function iJ(e,t){if(!e.__layers){let r={},{properties:i}=e;for(let s=0;s<i.length;s++){let{layerName:n}=i[s];n&&(r[n]?r[n][1]=s:r[n]=[s,s])}e.__layers=r}return e.__layers[t]}function sJ(e,t){if(!e.__ids){let r=[],i=e.featureIds.value,s=e.globalFeatureIds.value;for(let n=0;n<i.length;n++)r[i[n]]=s[n];e.__ids=r}return e.__ids[t]}function cO(e,t,r,i){for(let s=r;s<i;s++)if(t(e[s],s))return s;return-1}var cE=512,nJ={...Ci.defaultProps,data:Qs,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[qm],binary:!0},Km=class extends Mi{initializeState(){super.initializeState();let t=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:t,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:t,oldProps:r,context:i,changeFlags:s}){s.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:t,oldProps:r,context:i,changeFlags:s}),this._setWGS84PropertyForTiles());let{highlightColor:n}=t;n!==r.highlightColor&&Array.isArray(n)&&this.setState({highlightColor:n})}async _updateTileData(){let t=this.props.data,r=null;if(typeof t=="string"&&!xT(t)){let{onDataLoad:i,fetch:s}=this.props;this.setState({data:null,tileJSON:null});try{r=await s(t,{propName:"data",layer:this,loaders:[]})}catch(n){this.raiseError(n,"loading TileJSON"),t=null}i&&i(r,{propName:"data",layer:this})}else t&&typeof t=="object"&&"tilejson"in t&&(r=t);r&&(t=r.tiles),this.setState({data:t,tileJSON:r})}_getTilesetOptions(){let t=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:i,maxZoom:s}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>i&&(t.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(s)||r.maxzoom<s)&&(t.maxZoom=r.maxzoom)),t}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(t){let{data:r,binary:i}=this.state,{index:s,signal:n}=t,o=Pi(r,t);if(!o)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,mimeType:"application/x-protobuf",mvt:{...a?.mvt,coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:s},gis:i?{format:"binary"}:{}},c(o,{propName:"data",layer:this,loadOptions:a,signal:n})}renderSubLayers(t){let{x:r,y:i,z:s}=t.tile.index,n=Math.pow(2,s),o=cE/n,a=-o,c=cE*r/n,l=cE*(1-i/n),u=new q().scale([o,a,1]);t.autoHighlight=!1,this.context.viewport.resolution||(t.modelMatrix=u,t.coordinateOrigin=[c,l,0],t.coordinateSystem=X.CARTESIAN,t.extensions=[...t.extensions||[],new Mo]);let f=super.renderSubLayers(t);return this.state.binary&&!(f instanceof Ci)&&k.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),f}_updateAutoHighlight(t){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:i,hoveredFeatureLayerName:s}=this.state,n=t.object,o=null,a=null;n&&(o=lE(n,r),a=lO(n));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(t)),(i!==o||s!==a)&&this.setState({highlightColor:c,hoveredFeatureId:o,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(t){let r=super.getPickingInfo(t);if(this.state.binary&&r.index!==-1){let{data:i}=t.sourceLayer.props;r.object=km(i,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=fO(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(t){return{highlightedObjectIndex:this.getHighlightedObjectIndex(t),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(t){let{hoveredFeatureId:r,hoveredFeatureLayerName:i,binary:s}=this.state,{uniqueIdProperty:n,highlightedFeatureId:o}=this.props,a=t.content,c=uO(o);if(!(uO(r)||c))return-1;let u=c?o:r;return Array.isArray(a)?a.findIndex(f=>{let h=lE(f,n)===u,d=c||lO(f)===i;return h&&d}):a&&s?aE(a,n,u,c?"":i):-1}_pickObjects(t){let{deck:r,viewport:i}=this.context,s=i.width,n=i.height,o=i.x,a=i.y,c=[this.id];return r.pickObjects({x:o,y:a,width:s,height:n,layerIds:c,maxObjects:t})}getRenderedFeatures(t=null){let r=this._pickObjects(t),i=new Set,s=[];for(let n of r){let o=lE(n.object,this.props.uniqueIdProperty);o===void 0?s.push(n.object):i.has(o)||(i.add(o),s.push(n.object))}return s}_setWGS84PropertyForTiles(){let t="dataInWGS84";this.state.tileset.selectedTiles.forEach(i=>{i.hasOwnProperty(t)||Object.defineProperty(i,t,{get:()=>{if(!i.content)return null;if(this.state.binary&&Array.isArray(i.content)&&!i.content.length)return[];let{bbox:s}=i;if(i._contentWGS84===void 0&&AT(s)){let n=this.state.binary?km(i.content):i.content;i._contentWGS84=n.map(o=>fO(o,s,this.context.viewport))}return i._contentWGS84}})})}},Uf=Km;(()=>{Km.layerName="MVTLayer"})(),(()=>{Km.defaultProps=nJ})();function lE(e,t){if(e.properties&&t)return e.properties[t];if("id"in e)return e.id}function lO(e){return e.properties?.layerName||null}function uO(e){return e!=null&&e!==""}function fO(e,t,r){let i={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(i.geometry,"coordinates",{get:()=>aO(e.geometry,t,r).coordinates}),i}var hO="0123456789bcdefghjkmnpqrstuvwxyz",dO={};for(let e=0;e<hO.length;e++)dO[hO.charAt(e)]=e;var oJ=-90,aJ=90,cJ=-180,lJ=180;function uJ(e){let t=!0,r=aJ,i=oJ,s=lJ,n=cJ,o,a=0;for(let c=0,l=e.length;c<l;c++){let u=e[c].toLowerCase();a=dO[u];for(let f=4;f>=0;f--){let h=a>>f&1;t?(o=(s+n)/2,h===1?n=o:s=o):(o=(r+i)/2,h===1?i=o:r=o),t=!t}}return[i,n,r,s]}function pO(e){let[t,r,i,s]=uJ(e);return[s,i,s,t,r,t,r,i,s,i]}var fJ={getGeohash:{type:"accessor",value:e=>e.geohash}},$m=class extends ir{indexToBounds(){let{data:t,getGeohash:r}=this.props;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(i,s)=>pO(r(i,s))}}},kf=$m;(()=>{$m.layerName="GeohashLayer"})(),(()=>{$m.defaultProps=fJ})();var uE={};$t(uE,{Buffer:()=>Q,BufferTransform:()=>Ar,CubeGeometry:()=>Wi,Device:()=>Qe,Framebuffer:()=>mi,Geometry:()=>it,GroupNode:()=>er,Model:()=>J,ModelNode:()=>xi,ScenegraphNode:()=>Tr,SphereGeometry:()=>Il,Texture:()=>xt,TextureTransform:()=>yi,attachDevice:()=>_J,createDevice:()=>yJ,enforceWebGL2:()=>xJ,getAvailableDevices:()=>pJ,getSupportedDevices:()=>gJ,registerDevices:()=>dJ,setDefaultDeviceProps:()=>mJ,stats:()=>hJ});var{stats:hJ,registerDevices:dJ,getAvailableDevices:pJ,getSupportedDevices:gJ,setDefaultDeviceProps:mJ,attachDevice:_J,createDevice:yJ,enforceWebGL2:xJ}=ze;var fE={};$t(fE,{fetchFile:()=>ko,load:()=>Jt,parse:()=>Ts,registerLoaders:()=>Wc});var Jm=class{constructor(t){this.map=null,this.width=0,this.height=0,this.props={...t},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(t){let r=this.props,i={...this.props,...t};if(this.props=i,!this.map)return;this._update(r,i)&&this.redraw()}redraw(){let t=this.map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}getMap(){return this.map}_initialize(t){let{mapLib:r,container:i}=t;r.accessToken=t.mapboxApiAccessToken||"",this.map=new t.mapLib.Map({container:i,maxZoom:24,...t.mapOptions,...gO(t.viewState),style:t.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(i,"offsetWidth",{get:()=>this.width}),Object.defineProperty(i,"clientWidth",{get:()=>this.width}),Object.defineProperty(i,"offsetHeight",{get:()=>this.height}),Object.defineProperty(i,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(t,r){t.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let s=t.width!==r.width||t.height!==r.height;s&&(this.width=r.width,this.height=r.height,this.map.resize());let n=t.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(gO(o)),s||a}};function gO(e){return{center:[e.longitude,e.latitude],zoom:e.zoom,bearing:e.bearing??0,pitch:e.pitch??0}}var mO={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function AJ(e){let{container:t=document.body}=e;if(typeof t=="string"&&(t=document.getElementById(t)),!t)throw Error("Deck: container not found");window.getComputedStyle(t).position==="static"&&(t.style.position="relative");let i=document.createElement("div");t.appendChild(i),Object.assign(i.style,mO);let s=document.createElement("canvas");return t.appendChild(s),Object.assign(s.style,mO),{container:t,mapCanvas:i,deckCanvas:s}}var Vf=class extends We{constructor(t){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:i}=AJ(t),s=t.viewState||t.initialViewState,n=Number.isFinite(s&&s.latitude),{map:o=globalThis.mapboxgl||globalThis.maplibregl}=t;super({canvas:i,...t}),o&&o.Map?this._map=n&&new Jm({...t,width:0,height:0,viewState:s,container:r,mapLib:o}):this._map=o}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(t){"mapStyle"in t&&this._map&&this._map.setProps({mapStyle:t.mapStyle}),super.setProps(t)}_drawLayers(t,r){if(this._map){let i=this.getViewports()[0];i&&this._map.setProps({width:i.width,height:i.height,viewState:i})}super._drawLayers(t,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,uE);Object.assign(globalThis.loaders,fE);var Mt={SUM:1,MEAN:2,MIN:3,MAX:4};function _O(e,t){return e+t}function TJ(e,t){return t>e?t:e}function bJ(e,t){return t<e?t:e}function EJ(e,t){if(Number.isFinite(t))return e.length?t:null;let r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(_O,0)/r.length:null}function SJ(e,t){if(Number.isFinite(t))return e.length?e.length*t:null;let r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(_O,0):null}function vJ(e,t){if(Number.isFinite(t))return e.length?t:null;let r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(TJ,-1/0):null}function CJ(e,t){if(Number.isFinite(t))return e.length?t:null;let r=e.map(t).filter(Number.isFinite);return r.length?r.reduce(bJ,1/0):null}function sc(e,t,r){let i=Mt[e]||Mt.SUM;switch(t=wJ(t,r),i){case Mt.MIN:return s=>CJ(s,t);case Mt.SUM:return s=>SJ(s,t);case Mt.MEAN:return s=>EJ(s,t);case Mt.MAX:return s=>vJ(s,t);default:return null}}function wJ(e,t={}){return Number.isFinite(e)?e:r=>(t.index=r.index,e(r.source,t))}function yO(e,t={}){return r=>(t.indices=r.map(i=>i.index),e(r.map(i=>i.source),t))}var xO={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},sn=3402823466e29,hE=[32775,32774],dE=[32776,32774],AO=[32776,32775],pE={[Mt.SUM]:32774,[Mt.MEAN]:32774,[Mt.MIN]:hE,[Mt.MAX]:dE};var TO={size:1,operation:Mt.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},bO=4;var EO=`#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 SO=`#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 vO=`#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 CO=`#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 wO=`#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 PJ={minFilter:"nearest",magFilter:"nearest"};function nc(e,t){let{width:r=1,height:i=1,data:s=null,parameters:n=PJ}=t;return e.createTexture({data:s,format:"rgba32float",mipmaps:!1,sampler:n,width:r,height:i})}function zf(e,t){let{id:r,width:i=1,height:s=1,texture:n}=t;return e.createFramebuffer({id:r,width:i,height:s,colorAttachments:[n]})}var MJ=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],PO={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},RJ=["float32-renderable-webgl","texture-blend-float-webgl"],ae=class{static getAggregationData({aggregationData:t,maxData:r,minData:i,maxMinData:s,pixelIndex:n}){let o=n*bO,a={};return t&&(a.cellCount=t[o+3],a.cellWeight=t[o]),s?(a.maxCellWieght=s[0],a.minCellWeight=s[3]):(r&&(a.maxCellWieght=r[0],a.totalCount=r[3]),i&&(a.minCellWeight=i[0],a.totalCount=i[3])),a}static getCellData({countsData:t,size:r=1}){let i=t.length/4,s=new Float32Array(i*r),n=new Uint32Array(i);for(let o=0;o<i;o++){for(let a=0;a<r;a++)s[o*r+a]=t[o*4+a];n[o]=t[o*4+3]}return{cellCounts:n,cellWeights:s}}static isSupported(t){return RJ.every(r=>t.features.has(r))}constructor(t,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=t;let i=["float32-renderable-webgl"];this._hasGPUSupport=i.every(s=>t.features.has(s)),this._hasGPUSupport&&this._setupModels()}delete(){let{gridAggregationModel:t,allAggregationModel:r,meanTransform:i}=this,{textures:s,framebuffers:n,maxMinFramebuffers:o,minFramebuffers:a,maxFramebuffers:c,meanTextures:l,resources:u}=this.state;t?.destroy(),r?.destroy(),i?.destroy(),BJ([n,s,o,a,c,l,u])}run(t={}){this.setState({results:{}});let r=this._normalizeAggregationParams(t);return this._runAggregation(r)}getData(t){let r={},i=this.state.results;i[t].aggregationData||(i[t].aggregationData=i[t].aggregationBuffer.getData()),r.aggregationData=i[t].aggregationData;for(let s in PO){let n=PO[s];(i[t][s]||i[t][n])&&(i[t][s]=i[t][s]||i[t][n].getData(),r[s]=i[t][s])}return r}updateShaders(t={}){this.setState({shaderOptions:t,modelDirty:!0})}_normalizeAggregationParams(t){let r={...xO,...t},{weights:i}=r;return i&&(r.weights=IJ(i)),r}setState(t){Object.assign(this.state,t)}_getAggregateData(t){let r={},{textures:i,framebuffers:s,maxMinFramebuffers:n,minFramebuffers:o,maxFramebuffers:a,resources:c}=this.state,{weights:l}=t;for(let u in l){r[u]={};let{needMin:f,needMax:h,combineMaxMin:d}=l[u];r[u].aggregationTexture=i[u],r[u].aggregationBuffer=this.device.readPixelsToBufferWebGL(s[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(t){let{cellSize:r,projectPoints:i,attributes:s,moduleSettings:n,numCol:o,numRow:a,weights:c,translation:l,scaling:u}=t,{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:i,translation:l,scaling:u};for(let _ in c){let{needMin:y,needMax:x}=c[_],E=y&&x&&c[_].combineMaxMin;this._renderToWeightsTexture({id:_,parameters:g,moduleSettings:n,uniforms:m,gridSize:p,attributes:s,weights:c}),E?this._renderToMaxMinTexture({id:_,parameters:{...g,blendEquation:AO},gridSize:p,minOrMaxFb:f[_],clearParams:{clearColor:[0,0,0,sn]},combineMaxMin:E}):(y&&this._renderToMaxMinTexture({id:_,parameters:{...g,blendEquation:hE},gridSize:p,minOrMaxFb:h[_],clearParams:{clearColor:[sn,sn,sn,0]},combineMaxMin:E}),x&&this._renderToMaxMinTexture({id:_,parameters:{...g,blendEquation:dE},gridSize:p,minOrMaxFb:d[_],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:E}))}}_renderToMaxMinTexture(t){let{id:r,gridSize:i,minOrMaxFb:s,combineMaxMin:n,clearParams:o={}}=t,{framebuffers:a}=this.state,{allAggregationModel:c}=this;this.device.withParametersWebGL({...o,framebuffer:s,viewport:[0,0,i[0],i[1]]},()=>{this.device.clearWebGL({color:!0}),c.setUniforms({gridSize:i,combineMaxMin:n}),c.setBindings({uSampler:a[r].texture}),c.draw()})}_renderToWeightsTexture(t){let{id:r,parameters:i,moduleSettings:s,uniforms:n,gridSize:o,weights:a}=t,{framebuffers:c,equations:l,weightAttributes:u}=this.state,{gridAggregationModel:f}=this,{operation:h}=a[r],d=h===Mt.MIN?[sn,sn,sn,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:{...i,blendEquation:l[r]},moduleSettings:s,uniforms:n,attributes:p})}),h===Mt.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=NJ(this.device,m),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),c[r].attach({[36064]:g[r]})}}_runAggregation(t){this._updateModels(t),this._setupFramebuffers(t),this._renderAggregateData(t);let r=this._getAggregateData(t);return this.setState({results:r}),r}_setupFramebuffers(t){let{textures:r,framebuffers:i,maxMinFramebuffers:s,minFramebuffers:n,maxFramebuffers:o,meanTextures:a,equations:c}=this.state,{weights:l}=t,{numCol:u,numRow:f}=t,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]||nc(this.device,{id:`${d}-texture`,width:u,height:f}),r[d].resize(h);let y=r[d];_===Mt.MEAN&&(a[d]=a[d]||nc(this.device,{id:`${d}-mean-texture`,width:u,height:f}),a[d].resize(h),y=a[d]),i[d]?i[d].attach({[36064]:y}):i[d]=zf(this.device,{id:`${d}-fb`,width:u,height:f,texture:y}),i[d].resize(h),c[d]=pE[_]||pE[Mt.SUM],(p||g)&&(p&&g&&m?s[d]||(y=l[d].maxMinTexture||this._getMinMaxTexture(`${d}-maxMinTexture`),s[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(t){let{resources:r}=this.state;return r[t]||(r[t]=nc(this.device,{id:"resourceName"})),r[t]}_setupModels({numCol:t=0,numRow:r=0}={}){let{shaderOptions:i}=this.state;if(this.gridAggregationModel?.destroy(),this.gridAggregationModel=OJ(this.device,i),!this.allAggregationModel){let s=t*r;this.allAggregationModel=FJ(this.device,s)}}_setupWeightAttributes(t){let{weightAttributes:r}=this.state,{weights:i}=t;for(let s in i)r[s]=t.attributes[s]}_trackGPUResultBuffers(t,r){let{resources:i}=this.state;for(let s in t)if(t[s]){for(let n of MJ)if(t[s][n]&&r[s][n]!==t[s][n]){let o=`gpu-result-${s}-${n}`;i[o]&&i[o].delete(),i[o]=t[s][n]}}}_updateModels(t){let{vertexCount:r,attributes:i,numCol:s,numRow:n}=t,{modelDirty:o}=this.state;o&&(this._setupModels(t),this.setState({modelDirty:!1})),this._setupWeightAttributes(t),this.gridAggregationModel.setVertexCount(r),this.gridAggregationModel.setAttributes(i),this.allAggregationModel.setInstanceCount(s*n)}};function IJ(e){let t={};for(let r in e)t[r]={...TO,...e[r]};return t}function BJ(e){e=Array.isArray(e)?e:[e],e.forEach(t=>{for(let r in t)t[r].delete()})}function OJ(e,t){let r=Si({vs:EO,fs:SO,modules:[Hi,dt]},t);return new J(e,{id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:aa(),...r})}function FJ(e,t){return new J(e,{id:"All-Aggregation-Model",vs:vO,fs:CO,modules:[Hi],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:t,attributes:{position:[0,0]}})}function NJ(e,t){return new yi(e,{vs:wO,_targetTextureVarying:"meanValues",...t})}var Ir=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function nn(e,t=!1,r=Float32Array){let i;if(Number.isFinite(e[0]))i=new r(e);else{i=new r(e.length*4);let s=0;for(let n=0;n<e.length;n++){let o=e[n];i[s++]=o[0],i[s++]=o[1],i[s++]=o[2],i[s++]=Number.isFinite(o[3])?o[3]:255}}if(t)for(let s=0;s<i.length;s++)i[s]/=255;return i}var MO=`#version 300 es
#define SHADER_NAME screen-grid-layer-vertex-shader
#define RANGE_COUNT 6
in vec3 positions;
in vec3 instancePositions;
in vec4 instanceCounts;
in vec3 instancePickingColors;
uniform float opacity;
uniform vec3 cellScale;
uniform vec4 minColor;
uniform vec4 maxColor;
uniform vec4 colorRange[RANGE_COUNT];
uniform vec2 colorDomain;
uniform bool shouldUseMinMax;
uniform sampler2D maxTexture;
out vec4 vColor;
out float vSampleCount;
vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
vec4 outColor = vec4(0., 0., 0., 0.);
if (value >= 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 RO=`#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 LJ=[0,0,0,0],DJ=[0,255,0,255],UJ=["minColor","maxColor","colorRange","colorDomain"],kJ={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:Ir},Zm=class extends lt{getShaders(){return{vs:MO,fs:RO,modules:[_t]}}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t);let{oldProps:r,props:i,changeFlags:s}=t,n=this.getAttributeManager();i.numInstances!==r.numInstances?n.invalidateAll():r.cellSizePixels!==i.cellSizePixels&&n.invalidate("instancePositions"),this._updateUniforms(r,i,s)}draw({uniforms:t}){let{parameters:r,maxTexture:i}=this.props,s=this.props.minColor||LJ,n=this.props.maxColor||DJ,o=this.props.colorDomain||[1,0],a=this.state.model;a.setUniforms(t),a.setBindings({maxTexture:i}),a.setUniforms({minColor:s,maxColor:n,colorDomain:o}),a.setParameters({depthWriteEnabled:!1,...r}),a.draw(this.context.renderPass)}calculateInstancePositions(t,{numInstances:r}){let{width:i,height:s}=this.context.viewport,{cellSizePixels:n}=this.props,o=Math.ceil(i/n),{value:a,size:c}=t;for(let l=0;l<r;l++){let u=l%o,f=Math.floor(l/o);a[l*c+0]=u*n/i*2-1,a[l*c+1]=1-f*n/s*2,a[l*c+2]=0}}_getModel(){return new J(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new it({topology:"triangle-list",attributes:{positions:new Float32Array([0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0])}}),isInstanced:!0})}_shouldUseMinMax(){let{minColor:t,maxColor:r,colorDomain:i,colorRange:s}=this.props;return t||r?(k.deprecated("ScreenGridLayer props: minColor and maxColor","colorRange, colorDomain")(),!0):!(i||s)}_updateUniforms(t,r,i){let s=this.state.model;if(UJ.some(n=>t[n]!==r[n])&&s.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),t.colorRange!==r.colorRange&&s.setUniforms({colorRange:nn(r.colorRange)}),t.cellMarginPixels!==r.cellMarginPixels||t.cellSizePixels!==r.cellSizePixels||i.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]);s.setUniforms({cellScale:u})}}},oc=Zm;(()=>{Zm.layerName="ScreenGridCellLayer"})(),(()=>{Zm.defaultProps=kJ})();function IO(e,t){let r={};for(let i in e)t.includes(i)||(r[i]=e[i]);return r}var gE=class extends It{initializeAggregationLayer(t){super.initializeState(this.context),this.setState({ignoreProps:IO(this.constructor._propTypes,t.data.props),dimensions:t})}updateState(t){super.updateState(t);let{changeFlags:r}=t;if(r.extensionsChanged){let i=this.getShaders({});i&&i.defines&&(i.defines.NON_INSTANCED_MODEL=1),this.updateShaders(i)}this._updateAttributes()}updateAttributes(t){this.setState({changedAttributes:t})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:t,mousePosition:r,device:i}=this.context;return Object.assign(Object.create(this.props),{viewport:t,mousePosition:r,picking:{isActive:0},devicePixelRatio:i.canvasContext.cssToDeviceRatio()})}updateShaders(t){}isAggregationDirty(t,r={}){let{props:i,oldProps:s,changeFlags:n}=t,{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:Ea({oldProps:s,newProps:i,ignoreProps:c,propTypes:this.constructor._propTypes});for(let h of l)if(i[h]!==s[h])return!0;return!1}isAttributeChanged(t){let{changedAttributes:r}=this.state;return t?r&&r[t]!==void 0:!VJ(r)}_getAttributeManager(){return new qr(this.context.device,{id:this.props.id,stats:this.context.stats})}},nr=gE;(()=>{gE.layerName="AggregationLayer"})();function VJ(e){let t=!0;for(let r in e){t=!1;break}return t}function Qm(e,t,r){let i=r;return i.domain=()=>e,i.range=()=>t,i}function BO(e,t){return Qm(e,t,i=>qJ(e,t,i))}function zJ(e,t){return Qm(e,t,i=>KJ(e,t,i))}function HJ(e,t){let r=e.sort(OO),i=0,s=Math.max(1,t.length),n=new Array(s-1);for(;++i<s;)n[i-1]=GJ(r,i/s);let o=a=>jJ(n,t,a);return o.thresholds=()=>n,Qm(e,t,o)}function OO(e,t){return e-t}function GJ(e,t){let r=e.length;if(t<=0||r<2)return e[0];if(t>=1)return e[r-1];let i=(r-1)*t,s=Math.floor(i),n=e[s],o=e[s+1];return n+(o-n)*(i-s)}function WJ(e,t){let r=0,i=e.length;for(;r<i;){let s=r+i>>>1;OO(e[s],t)>0?i=s:r=s+1}return r}function jJ(e,t,r){return t[WJ(e,r)]}function XJ(e,t,r,i){let s=`${i}`,n=t.get(s);return n===void 0&&(n=e.push(i),t.set(s,n)),r[(n-1)%r.length]}function YJ(e,t){let r=new Map,i=[];for(let n of e){let o=`${n}`;r.has(o)||r.set(o,i.push(n))}return Qm(e,t,n=>XJ(i,r,t,n))}function qJ(e,t,r){let i=e[1]-e[0];if(i<=0)return k.warn("quantizeScale: invalid domain, returning range[0]")(),t[0];let s=i/t.length,n=Math.floor((r-e[0])/s),o=Math.max(Math.min(n,t.length-1),0);return t[o]}function KJ(e,t,r){return(r-e[0])/(e[1]-e[0])*(t[1]-t[0])+t[0]}function FO(e){return e!=null}function $J(e){let t=[];return e.forEach(r=>{!t.includes(r)&&FO(r)&&t.push(r)}),t}function NO(e,t){return(typeof t=="function"?e.map(t):e).filter(FO)}function LO(e,t){return NO(e,t)}function DO(e,t){return $J(NO(e,t))}function UO(e,t,r){return Math.max(t,Math.min(r,e))}function kO(e){switch(e){case"quantize":return BO;case"linear":return zJ;case"quantile":return HJ;case"ordinal":return YJ;default:return BO}}var zO=e=>e.length,JJ=3402823466e29,HO=e=>e.points,GO=e=>e.index,VO=(e,t)=>e<t?-1:e>t?1:e>=t?0:NaN,ZJ={getValue:zO,getPoints:HO,getIndex:GO,filterData:null},ds=class{constructor(t=[],r=ZJ){this.aggregatedBins=this.getAggregatedBins(t,r),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(t,r){let{getValue:i=zO,getPoints:s=HO,getIndex:n=GO,filterData:o}=r,a=typeof o=="function",c=t.length,l=[],u=0;for(let f=0;f<c;f++){let h=t[f],d=s(h),p=n(h),g=a?d.filter(o):d;h.filteredPoints=a?g:null;let m=g.length?i(g):null;m!=null&&(l[u]={i:Number.isFinite(p)?p:f,value:m,counts:g.length},u++)}return l}_percentileToIndex(t){let r=this.sortedBins.length;if(r<2)return[0,0];let[i,s]=t.map(a=>UO(a,0,100)),n=Math.ceil(i/100*(r-1)),o=Math.floor(s/100*(r-1));return[n,o]}getBinMap(){let t={};for(let r of this.aggregatedBins)t[r.i]=r;return t}_updateMinMaxValues(){let t=0,r=0,i=JJ,s=0;for(let n of this.aggregatedBins)t=t>n.counts?t:n.counts,r=r>n.value?r:n.value,i=i<n.value?i:n.value,s+=n.counts;this.maxCount=t,this.maxValue=r,this.minValue=i,this.totalCount=s}getValueRange(t){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((s,n)=>VO(s.value,n.value))),!this.sortedBins.length)return[];let r=0,i=this.sortedBins.length-1;if(Array.isArray(t)){let s=this._percentileToIndex(t);r=s[0],i=s[1]}return[this.sortedBins[r].value,this.sortedBins[i].value]}getValueDomainByScale(t,[r=0,i=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((n,o)=>VO(n.value,o.value))),!this.sortedBins.length)return[];let s=this._percentileToIndex([r,i]);return this._getScaleDomain(t,s)}_getScaleDomain(t,[r,i]){let s=this.sortedBins;switch(t){case"quantize":case"linear":return[s[r].value,s[i].value];case"quantile":return LO(s.slice(r,i+1),n=>n.value);case"ordinal":return DO(s,n=>n.value);default:return[s[r].value,s[i].value]}}};var jO=6378e3;function t_(e){return Number.isFinite(e)?e:0}function e_(e,t){let r=e.positions.value,i=1/0,s=-1/0,n=1/0,o=-1/0,a,c;for(let u=0;u<t;u++)c=r[u*3],a=r[u*3+1],i=a<i?a:i,s=a>s?a:s,n=c<n?c:n,o=c>o?c:o;return{xMin:t_(n),xMax:t_(o),yMin:t_(i),yMax:t_(s)}}function QJ(e,t,r,i){let{width:s,height:n}=i,o=r===X.CARTESIAN?[-s/2,-n/2]:[-180,-90];k.assert(r===X.CARTESIAN||r===X.LNGLAT||r===X.DEFAULT);let{xMin:a,yMin:c}=e;return[-1*(WO(a-o[0],t.xOffset)+o[0]),-1*(WO(c-o[1],t.yOffset)+o[1])]}function WO(e,t){let r=e<0?-1:1,i=r<0?Math.abs(e)+t:Math.abs(e);return i=Math.floor(i/t)*t,i*r}function mE(e,t,r=!0){if(!r)return{xOffset:t,yOffset:t};let{yMin:i,yMax:s}=e,n=(i+s)/2;return tZ(t,n)}function r_(e,t,r,i){let s=mE(e,t,i!==X.CARTESIAN),n=QJ(e,s,i,r),{xMin:o,yMin:a,xMax:c,yMax:l}=e,u=c-o+s.xOffset,f=l-a+s.yOffset,h=Math.ceil(u/s.xOffset),d=Math.ceil(f/s.yOffset);return{gridOffset:s,translation:n,width:u,height:f,numCol:h,numRow:d}}function tZ(e,t){let r=eZ(e),i=rZ(t,e);return{yOffset:r,xOffset:i}}function eZ(e){return e/jO*(180/Math.PI)}function rZ(e,t){return t/jO*(180/Math.PI)/Math.cos(e*Math.PI/180)}function ac(e,t){let r=iZ(e,t),i=sZ(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:i}}function iZ(e,t){let{data:r=[],cellSize:i}=e,{attributes:s,viewport:n,projectPoints:o,numInstances:a}=t,c=s.positions.value,{size:l}=s.positions.getAccessor(),u=t.boundingBox||nZ(s.positions,a),f=t.posOffset||[180,90],h=t.gridOffset||mE(u,i);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}=Ht(r),E=new Array(3);for(let P of y){x.index++,E[0]=c[x.index*l],E[1]=c[x.index*l+1],E[2]=l>=3?c[x.index*l+2]:0;let[B,F]=o?n.project(E):E;if(Number.isFinite(B)&&Number.isFinite(F)){let M=Math.floor((F+f[1])/h.yOffset),v=Math.floor((B+f[0])/h.xOffset);if(!o||v>=0&&v<g&&M>=0&&M<m){let T=`${M}-${v}`;_[T]=_[T]||{count:0,points:[],lonIdx:v,latIdx:M},_[T].count+=1,_[T].points.push({source:P,index:x.index})}}}return{gridHash:_,gridOffset:h,offsets:[f[0]*-1,f[1]*-1]}}function sZ({gridHash:e,gridOffset:t,offsets:r}){let i=new Array(Object.keys(e).length),s=0;for(let n in e){let o=n.split("-"),a=parseInt(o[0],10),c=parseInt(o[1],10),l=s++;i[l]={index:l,position:[r[0]+t.xOffset*c,r[1]+t.yOffset*a],...e[n]}}return i}function nZ(e,t){let r=e.value,{size:i}=e.getAccessor(),s=1/0,n=-1/0,o=1/0,a=-1/0,c,l;for(let u=0;u<t;u++)l=r[u*i],c=r[u*i+1],Number.isFinite(l)&&Number.isFinite(c)&&(s=c<s?c:s,n=c>n?c:n,o=l<o?l:o,a=l>a?l:a);return{xMin:o,xMax:a,yMin:s,yMax:n}}var _E=class extends nr{initializeAggregationLayer({dimensions:t}){super.initializeAggregationLayer(t),this.setState({layerData:{},gpuGridAggregator:new ae(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:ac})}updateState(t){super.updateState(t),this.updateAggregationState(t);let{aggregationDataDirty:r,aggregationWeightsDirty:i,gpuAggregation:s}=this.state;if(this.getNumInstances()<=0)return;let n=!1;(r||s&&i)&&(this._updateAggregation(t),n=!0),!s&&(r||i)&&(this._updateWeightBins(),this._uploadAggregationResults(),n=!0),this.setState({aggregationDirty:n})}finalizeState(t){let{count:r}=this.state.weights;r&&r.aggregationBuffer&&r.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(t)}updateShaders(t){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(t)}updateAggregationState(t){k.assert(!1)}allocateResources(t,r){if(this.state.numRow!==t||this.state.numCol!==r){let i=r*t*4*4,{weights:s}=this.state;for(let n in s){let o=s[n];o.aggregationBuffer&&o.aggregationBuffer.delete(),o.aggregationBuffer=this.context.device.createBuffer({byteLength:i,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:t,maxMinData:r,maxData:i,minData:s}){let{count:n}=this.state.weights;n&&(n.aggregationData=t,n.maxMinData=r,n.maxData=i,n.minData=s)}_updateAggregation(t){let{cpuGridAggregator:r,gpuGridAggregator:i,gridOffset:s,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}=t,{viewport:p}=this.context,g=this.getAttributes(),m=this.getNumInstances();if(u){let{weights:_}=this.state;i.run({weights:_,cellSize:[s.xOffset,s.yOffset],numCol:f,numRow:h,translation:o,scaling:a,vertexCount:m,projectPoints:l,attributes:g,moduleSettings:this.getModuleSettings()})}else{let _=r(d,{gridOffset:s,projectPoints:l,attributes:g,viewport:p,posOffset:n,boundingBox:c});this.setState({layerData:_})}}_updateWeightBins(){let{getValue:t}=this.state,r=new ds(this.state.layerData.data||[],{getValue:t});this.setState({sortedBins:r})}_uploadAggregationResults(){let{numCol:t,numRow:r}=this.state,{data:i}=this.state.layerData,{aggregatedBins:s,minValue:n,maxValue:o,totalCount:a}=this.state.sortedBins,c=4,l=t*r*c,u=new Float32Array(l).fill(0);for(let p of s){let{lonIdx:g,latIdx:m}=i[p.i],{value:_,counts:y}=p,x=(g+m*t)*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})}},ps=_E;(()=>{_E.layerName="GridAggregationLayer"})();var oZ={...oc.defaultProps,getPosition:{type:"accessor",value:e=>e.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},XO="positions",aZ={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},i_=class extends ps{initializeState(){super.initializeAggregationLayer({dimensions:aZ,getCellSize:i=>i.cellSizePixels});let t={count:{size:1,operation:Mt.SUM,needMax:!0,maxTexture:nc(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:t,subLayerData:{attributes:{}},maxTexture:t.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[XO]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:t}){return this.state.supported&&t.somethingChanged}updateState(t){super.updateState(t)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:t,numRow:r,numCol:i,weights:s}=this.state,{updateTriggers:n}=this.props,{aggregationBuffer:o}=s.count,a=this.getSubLayerClass("cells",oc);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:n}),{data:{attributes:{instanceCounts:o}},maxTexture:t,numInstances:r*i})}finalizeState(t){super.finalizeState(t);let{aggregationBuffer:r,maxBuffer:i,maxTexture:s}=this.state;r?.delete(),i?.delete(),s?.delete()}getPickingInfo({info:t}){let{index:r}=t;if(r>=0){let{gpuGridAggregator:i,gpuAggregation:s,weights:n}=this.state,o=s?i.getData("count"):n.count;t.object=ae.getAggregationData({pixelIndex:r,...o})}return t}updateResults({aggregationData:t,maxData:r}){let{count:i}=this.state.weights;i.aggregationData=t,i.aggregationBuffer.write(t),i.maxData=r,i.maxTexture.setImageData({data:r})}updateAggregationState(t){let r=t.props.cellSizePixels,i=t.oldProps.cellSizePixels!==r,{viewportChanged:s}=t.changeFlags,n=t.props.gpuAggregation;this.state.gpuAggregation!==t.props.gpuAggregation&&n&&!ae.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(XO),{dimensions:c}=this.state,{data:l,weights:u}=c,f=a||o||s||this.isAggregationDirty(t,{compareAll:n,dimension:l}),h=this.isAggregationDirty(t,{dimension:u});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:h});let{viewport:d}=this.context;if(s||i){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(t),(f||h)&&this._resetResults()}_updateAccessors(t){let{getWeight:r,aggregation:i,data:s}=t.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=Mt[i]),this.setState({getValue:sc(i,r,{data:s})})}_resetResults(){let{count:t}=this.state.weights;t&&(t.aggregationData=null)}},Hf=i_;(()=>{i_.layerName="ScreenGridLayer"})(),(()=>{i_.defaultProps=oZ})();function YO(){}var qO=["getBins","getDomain","getScaleFunc"],KO=[{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}],cZ=e=>e.cellSize,gs=class{constructor(t){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=t.getCellSize||cZ,this._getAggregator=t.getAggregator,this._addDimension(t.dimensions||KO)}static defaultDimensions(){return KO}updateState(t,r){let{oldProps:i,props:s,changeFlags:n}=t;this.updateGetValueFuncs(i,s,n);let o=this.needsReProjectPoints(i,s,n),a=!1;return n.dataChanged||o?(this.getAggregatedData(s,r),a=!0):((this.getDimensionChanges(i,s,n)||[]).forEach(l=>typeof l=="function"&&l()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(t){this.state={...this.state,...t}}setDimensionState(t,r){this.setState({dimensions:{...this.state.dimensions,[t]:{...this.state.dimensions[t],...r}}})}normalizeResult(t={}){return t.hexagons?{data:t.hexagons,...t}:t.layerData?{data:t.layerData,...t}:t}getAggregatedData(t,r){let s=this._getAggregator(t)(t,r);this.setState({layerData:this.normalizeResult(s)}),this.changeFlags={layerData:!0},this.getSortedBins(t)}updateGetValueFuncs(t,r,i){for(let s in this.dimensionUpdaters){let{value:n,weight:o,aggregation:a}=this.dimensionUpdaters[s].getBins.triggers,c=r[n.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[s].getBins,t,r,i)&&(c?c=yO(c,{data:r.data}):c=sc(r[a.prop],r[o.prop],{data:r.data})),c&&this.setDimensionState(s,{getValue:c})}}needsReProjectPoints(t,r,i){return this._getCellSize(t)!==this._getCellSize(r)||this._getAggregator(t)!==this._getAggregator(r)||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPosition)}addDimension(t){this._addDimension(t)}_addDimension(t=[]){t.forEach(r=>{let{key:i}=r;this.dimensionUpdaters[i]=this.getDimensionUpdaters(r),this.state.dimensions[i]={getValue:null,domain:null,sortedBins:null,scaleFunc:YO}})}getDimensionUpdaters({key:t,accessor:r,pickingInfo:i,getBins:s,getDomain:n,getScaleFunc:o,nullValue:a}){return{key:t,accessor:r,pickingInfo:i,getBins:{updater:this.getDimensionSortedBins.bind(this),...s},getDomain:{updater:this.getDimensionValueDomain.bind(this),...n},getScaleFunc:{updater:this.getDimensionScale.bind(this),...o},attributeAccessor:this.getSubLayerDimensionAttribute(t,a)}}needUpdateDimensionStep(t,r,i,s){return Object.values(t.triggers).some(n=>n.updateTrigger?s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged[n.updateTrigger]):r[n.prop]!==i[n.prop])}getDimensionChanges(t,r,i){let s=[];for(let n in this.dimensionUpdaters){let o=qO.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[n][a],t,r,i));o&&s.push(this.dimensionUpdaters[n][o].updater.bind(this,r,this.dimensionUpdaters[n]))}return s.length?s:null}getUpdateTriggers(t){let r=t.updateTriggers||{},i={};for(let s in this.dimensionUpdaters){let{accessor:n}=this.dimensionUpdaters[s];i[n]={},qO.forEach(o=>{Object.values(this.dimensionUpdaters[s][o].triggers).forEach(({prop:a,updateTrigger:c})=>{if(c){let l=r[c];typeof l=="object"&&!Array.isArray(l)?Object.assign(i[n],l):l!==void 0&&(i[n][a]=l)}else i[n][a]=t[a]})})}return i}getSortedBins(t){for(let r in this.dimensionUpdaters)this.getDimensionSortedBins(t,this.dimensionUpdaters[r])}getDimensionSortedBins(t,r){let{key:i}=r,{getValue:s}=this.state.dimensions[i],n=new ds(this.state.layerData.data||[],{getValue:s,filterData:t._filterData});this.setDimensionState(i,{sortedBins:n}),this.getDimensionValueDomain(t,r)}getDimensionValueDomain(t,r){let{getDomain:i,key:s}=r,{triggers:{lowerPercentile:n,upperPercentile:o,scaleType:a}}=i,c=this.state.dimensions[s].sortedBins.getValueDomainByScale(t[a.prop],[t[n.prop],t[o.prop]]);this.setDimensionState(s,{valueDomain:c}),this.getDimensionScale(t,r)}getDimensionScale(t,r){let{key:i,getScaleFunc:s,getDomain:n}=r,{domain:o,range:a}=s.triggers,{scaleType:c}=n.triggers,{onSet:l}=s,u=t[a.prop],f=t[o.prop]||this.state.dimensions[i].valueDomain,d=kO(c&&t[c.prop])(f,u);typeof l=="object"&&typeof t[l.props]=="function"&&t[l.props](d.domain()),this.setDimensionState(i,{scaleFunc:d})}getSubLayerDimensionAttribute(t,r){return i=>{let{sortedBins:s,scaleFunc:n}=this.state.dimensions[t],o=s.binMap[i.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(t){let r={};for(let i in this.dimensionUpdaters){let{accessor:s}=this.dimensionUpdaters[i];r[s]=this.getSubLayerDimensionAttribute(t,i)}return r}getPickingInfo({info:t}){let r=t.picked&&t.index>-1,i=null;if(r){let s=this.state.layerData.data[t.index],n={};for(let o in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[o],{sortedBins:c}=this.state.dimensions[o],l=c.binMap[s.index]&&c.binMap[s.index].value;n[a]=l}i=Object.assign(n,s,{points:s.filteredPoints||s.points})}return t.picked=Boolean(i),t.object=i,t}getAccessor(t){return this.dimensionUpdaters.hasOwnProperty(t)?this.dimensionUpdaters[t].attributeAccessor:YO}};function $O(){}var lZ={colorDomain:null,colorRange:Ir,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:$O,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:$O,gridAggregator:ac,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:e=>e.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},s_=class extends nr{initializeState(){let t=new gs({getAggregator:i=>i.gridAggregator,getCellSize:i=>i.cellSize});this.state={cpuAggregator:t,aggregatorState:t.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(t){super.updateState(t),this.setState({aggregatorState:this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:t,extruded:r,cellSize:i,coverage:s,material:n,transitions:o}=this.props,{cpuAggregator:a}=this.state,c=this.getSubLayerClass("grid-cell",no),l=this._getSublayerUpdateTriggers();return new c({cellSize:i,coverage:s,material:n,elevationScale:t,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})}},on=s_;(()=>{s_.layerName="CPUGridLayer"})(),(()=>{s_.defaultProps=lZ})();var cc=Math.PI/3,uZ=[0,cc,2*cc,3*cc,4*cc,5*cc];function fZ(e){return e[0]}function hZ(e){return e[1]}function yE(){var e=0,t=0,r=1,i=1,s=fZ,n=hZ,o,a,c;function l(f){var h={},d=[],p,g=f.length;for(p=0;p<g;++p)if(!(isNaN(_=+s.call(null,m=f[p],p,f))||isNaN(y=+n.call(null,m,p,f)))){var m,_,y,x=Math.round(y=y/c),E=Math.round(_=_/a-(x&1)/2),P=y-x;if(Math.abs(P)*3>1){var B=_-E,F=E+(_<E?-1:1)/2,M=x+(y<x?-1:1),v=_-F,T=y-M;B*B+P*P>v*v+T*T&&(E=F+(x&1?1:-1)/2,x=M)}var L=E+"-"+x,V=h[L];V?V.push(m):(d.push(V=h[L]=[m]),V.x=(E+(x&1)/2)*a,V.y=x*c)}return d}function u(f){var h=0,d=0;return uZ.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(t/c),d=Math.round(e/a),p=h*c;p<i+o;p+=c,++h)for(var g=d*a+(h&1)*a/2;g<r+a/2;g+=a)f.push([g,p]);return f},l.mesh=function(){var f=u(o).slice(0,4).join("l");return l.centers().map(function(h){return"M"+h+"m"+f}).join("")},l.x=function(f){return arguments.length?(s=f,l):s},l.y=function(f){return arguments.length?(n=f,l):n},l.radius=function(f){return arguments.length?(o=+f,a=o*2*Math.sin(cc),c=o*1.5,l):o},l.size=function(f){return arguments.length?(e=t=0,r=+f[0],i=+f[1],l):[r-e,i-t]},l.extent=function(f){return arguments.length?(e=+f[0][0],t=+f[0][1],r=+f[1][0],i=+f[1][1],l):[[e,t],[r,i]]},l.radius(1)}function JO(e,t){let{data:r,radius:i}=e,{viewport:s,attributes:n}=t,o=r.length?dZ(r,t):null,a=pZ(i,s,o),c=[],{iterable:l,objectInfo:u}=Ht(r),f=n.positions.value,{size:h}=n.positions.getAccessor();for(let g of l){u.index++;let m=u.index*h,_=[f[m],f[m+1]];Number.isFinite(_[0])&&Number.isFinite(_[1])?c.push({screenCoord:s.projectFlat(_),source:g,index:u.index}):k.warn("HexagonLayer: invalid position")()}return{hexagons:yE().radius(a).x(g=>g.screenCoord[0]).y(g=>g.screenCoord[1])(c).map((g,m)=>({position:s.unprojectFlat([g.x,g.y]),points:g,index:m})),radiusCommon:a}}function dZ(e,t){let{attributes:r}=t,i=r.positions.value,{size:s}=r.positions.getAccessor(),n=1/0,o=1/0,a=-1/0,c=-1/0,l;for(l=0;l<s*e.length;l+=s){let u=i[l],f=i[l+1];Number.isFinite(u)&&Number.isFinite(f)&&(n=Math.min(u,n),a=Math.max(u,a),o=Math.min(f,o),c=Math.max(f,c))}return[n,o,a,c].every(Number.isFinite)?[(n+a)/2,(o+c)/2]:null}function pZ(e,t,r){let{unitsPerMeter:i}=t.getDistanceScales(r);return e*i[0]}function ZO(){}var gZ={colorDomain:null,colorRange:Ir,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:ZO,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:ZO,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:JO,getPosition:{type:"accessor",value:e=>e.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},n_=class extends nr{initializeState(){let t=new gs({getAggregator:i=>i.hexagonAggregator,getCellSize:i=>i.radius});this.state={cpuAggregator:t,aggregatorState:t.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(t){if(super.updateState(t),t.changeFlags.propsOrDataChanged){let r=this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==r.layerData){let{hexagonVertices:i}=r.layerData||{};this.setState({vertices:i&&this.convertLatLngToMeterOffset(i)})}this.setState({aggregatorState:r})}}convertLatLngToMeterOffset(t){let{viewport:r}=this.context;if(Array.isArray(t)&&t.length===6){let i=t[0],s=t[3],n=[(i[0]+s[0])/2,(i[1]+s[1])/2],o=r.projectFlat(n),{metersPerUnit:a}=r.getDistanceScales(n);return t.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:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:t,extruded:r,coverage:i,material:s,transitions:n}=this.props,{aggregatorState:o,vertices:a}=this.state,c=this.getSubLayerClass("hexagon-cell",$r),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:t,extruded:r,coverage:i,material:s,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})}},Gf=n_;(()=>{n_.layerName="HexagonLayer"})(),(()=>{n_.defaultProps=gZ})();var K=.16666666666666666,O={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},lc=[O.W,O.SW,O.S],uc=[O.S,O.SE,O.E],fc=[O.E,O.NE,O.N],hc=[O.NW,O.W,O.N],dc=[[-.5,K],[-.5,-K],[-K,-.5],[K,-.5]],pc=[[-K,-.5],[K,-.5],[.5,-K],[.5,K]],gc=[[.5,-K],[.5,K],[K,.5],[-K,.5]],mc=[[-.5,K],[-.5,-K],[K,.5],[-K,.5]],QO=[O.W,O.SW,O.SE,O.E],tF=[O.S,O.SE,O.NE,O.N],eF=[O.NW,O.W,O.E,O.NE],rF=[O.NW,O.SW,O.S,O.N],iF=[[-.5,K],[-.5,-K],[.5,-K],[.5,K]],sF=[[-K,-.5],[K,-.5],[K,.5],[-K,.5]],mZ=[O.NW,O.SW,O.SE,O.NE],nF=[O.NW,O.SW,O.SE,O.E,O.N],oF=[O.W,O.SW,O.SE,O.NE,O.N],aF=[O.NW,O.W,O.S,O.SE,O.NE],cF=[O.NW,O.SW,O.S,O.E,O.NE],lF=[O.NW,O.W,[.5,-K],[.5,K],O.N],uF=[[-K,-.5],[K,-.5],O.E,O.NE,O.N],fF=[[-.5,K],[-.5,-K],O.S,O.SE,O.E],hF=[O.W,O.SW,O.S,[K,.5],[-K,.5]],dF=[O.NW,O.W,[-K,-.5],[K,-.5],O.N],pF=[[-.5,K],[-.5,-K],O.E,O.NE,O.N],gF=[O.S,O.SE,O.E,[K,.5],[-K,.5]],mF=[O.W,O.SW,O.S,[.5,-K],[.5,K]],_F=[O.W,O.SW,O.SE,O.E,[K,.5],[-K,.5]],yF=[[-.5,K],[-.5,-K],O.S,O.SE,O.NE,O.N],xF=[O.NW,O.W,[-K,-.5],[K,-.5],O.E,O.NE],AF=[O.NW,O.SW,O.S,[.5,-K],[.5,K],O.N],_c=[O.W,O.SW,O.S,O.E,O.NE,O.N],yc=[O.NW,O.W,O.S,O.SE,O.E,O.N],o_=[[-.5,K],[-.5,-K],[-K,-.5],[K,-.5],O.E,O.NE,O.N],a_=[O.W,O.SW,O.S,[.5,-K],[.5,K],[K,.5],[-K,.5]],c_=[O.NW,O.W,[-K,-.5],[K,-.5],[.5,-K],[.5,K],O.N],l_=[[-.5,K],[-.5,-K],O.S,O.SE,O.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:[[O.W,O.S]],2:[[O.S,O.E]],3:[[O.W,O.E]],4:[[O.N,O.E]],5:{0:[[O.W,O.S],[O.N,O.E]],1:[[O.W,O.N],[O.S,O.E]]},6:[[O.N,O.S]],7:[[O.W,O.N]],8:[[O.W,O.N]],9:[[O.N,O.S]],10:{0:[[O.W,O.N],[O.S,O.E]],1:[[O.W,O.S],[O.N,O.E]]},11:[[O.N,O.E]],12:[[O.W,O.E]],13:[[O.S,O.E]],14:[[O.W,O.S]],15:[]};function j(e){return parseInt(e,4)}var EF={[j("0000")]:[],[j("2222")]:[],[j("2221")]:[lc],[j("2212")]:[uc],[j("2122")]:[fc],[j("1222")]:[hc],[j("0001")]:[lc],[j("0010")]:[uc],[j("0100")]:[fc],[j("1000")]:[hc],[j("2220")]:[dc],[j("2202")]:[pc],[j("2022")]:[gc],[j("0222")]:[mc],[j("0002")]:[dc],[j("0020")]:[pc],[j("0200")]:[gc],[j("2000")]:[mc],[j("0011")]:[QO],[j("0110")]:[tF],[j("1100")]:[eF],[j("1001")]:[rF],[j("2211")]:[QO],[j("2112")]:[tF],[j("1122")]:[eF],[j("1221")]:[rF],[j("2200")]:[iF],[j("2002")]:[sF],[j("0022")]:[iF],[j("0220")]:[sF],[j("1111")]:[mZ],[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")]:[_c],[j("0121")]:[_c],[j("1012")]:[yc],[j("1210")]:[yc],[j("0101")]:{0:[lc,fc],1:[_c],2:[_c]},[j("1010")]:{0:[hc,uc],1:[yc],2:[yc]},[j("2121")]:{0:[_c],1:[_c],2:[lc,fc]},[j("1212")]:{0:[yc],1:[yc],2:[hc,uc]},[j("2120")]:{0:[o_],1:[o_],2:[dc,fc]},[j("2021")]:{0:[a_],1:[a_],2:[lc,gc]},[j("1202")]:{0:[c_],1:[c_],2:[hc,pc]},[j("0212")]:{0:[l_],1:[l_],2:[uc,mc]},[j("0102")]:{0:[dc,fc],1:[o_],2:[o_]},[j("0201")]:{0:[lc,gc],1:[a_],2:[a_]},[j("1020")]:{0:[hc,pc],1:[c_],2:[c_]},[j("2010")]:{0:[uc,mc],1:[l_],2:[l_]},[j("2020")]:{0:[mc,pc],1:[TF],2:[dc,gc]},[j("0202")]:{0:[gc,dc],1:[TF],2:[mc,pc]}};var Io={ISO_LINES:1,ISO_BANDS:2},_Z={zIndex:0,zOffset:.005};function Wf(e,t){return Array.isArray(t)?e<t[0]?0:e<t[1]?1:2:e>=t?1:0}function SF(e){let{cellWeights:t,x:r,y:i,width:s,height:n}=e,o=e.threshold;e.thresholdValue&&(k.deprecated("thresholdValue","threshold")(),o=e.thresholdValue);let a=r<0,c=r>=s-1,l=i<0,u=i>=n-1,f=a||c||l||u,h={},d={};a||u?d.top=0:(h.top=t[(i+1)*s+r],d.top=Wf(h.top,o)),c||u?d.topRight=0:(h.topRight=t[(i+1)*s+r+1],d.topRight=Wf(h.topRight,o)),c||l?d.right=0:(h.right=t[i*s+r+1],d.right=Wf(h.right,o)),a||l?d.current=0:(h.current=t[i*s+r],d.current=Wf(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=Wf((h.top+h.topRight+h.right+h.current)/4,o)),{code:y,meanCode:x}}function xE(e){let{gridOrigin:t,cellSize:r,x:i,y:s,code:n,meanCode:o,type:a=Io.ISO_LINES}=e,c={..._Z,...e.thresholdData},l=a===Io.ISO_BANDS?EF[n]:bF[n];Array.isArray(l)||(l=l[o]);let u=c.zIndex*c.zOffset,f=(i+1)*r[0],h=(s+1)*r[1],d=t[0]+f,p=t[1]+h;if(a===Io.ISO_BANDS){let m=[];return l.forEach(_=>{let y=[];_.forEach(x=>{let E=d+x[0]*r[0],P=p+x[1]*r[1];y.push([E,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:e,cellWeights:t,gridSize:r,gridOrigin:i,cellSize:s}){let n=[],o=[],a=r[0],c=r[1],l=0,u=0;for(let f of e){let{contour:h}=f,{threshold:d}=h;for(let p=-1;p<a;p++)for(let g=-1;g<c;g++){let{code:m,meanCode:_}=SF({cellWeights:t,threshold:d,x:p,y:g,width:a,height:c}),y={type:Io.ISO_BANDS,gridOrigin:i,cellSize:s,x:p,y:g,width:a,height:c,code:m,meanCode:_,thresholdData:f};if(Array.isArray(d)){y.type=Io.ISO_BANDS;let x=xE(y);for(let E of x)o[u++]={vertices:E,contour:h}}else{y.type=Io.ISO_LINES;let x=xE(y);for(let E=0;E<x.length;E+=2)n[l++]={start:x[E],end:x[E+1],contour:h}}}}return{contourSegments:n,contourPolygons:o}}var CF=[255,255,255,255],yZ=1,xZ=1,AZ={cellSize:{type:"number",min:1,max:1e3,value:1e3},getPosition:{type:"accessor",value:e=>e.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:xZ}],optional:!0,compare:3},zOffset:.005},wF="positions",TZ={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},u_=class extends ps{initializeState(){super.initializeAggregationLayer({dimensions:TZ}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:Mt.SUM}}}),this.getAttributeManager().add({[wF]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(t){super.updateState(t);let r=!1,{oldProps:i,props:s}=t,{aggregationDirty:n}=this.state;(i.contours!==s.contours||i.zOffset!==s.zOffset)&&(r=!0,this._updateThresholdData(t.props)),this.getNumInstances()>0&&(n||r)&&this._generateContours()}renderLayers(){let{contourSegments:t,contourPolygons:r}=this.state.contourData,i=this.getSubLayerClass("lines",to),s=this.getSubLayerClass("bands",Zr),n=t&&t.length>0&&new i(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||yZ}),o=r&&r.length>0&&new s(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||CF});return[n,o]}updateAggregationState(t){let{props:r,oldProps:i}=t,{cellSize:s,coordinateSystem:n}=r,{viewport:o}=this.context,a=i.cellSize!==s,c=r.gpuAggregation;this.state.gpuAggregation!==r.gpuAggregation&&c&&!ae.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=e_(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:p})),f||a){let{gridOffset:_,translation:y,width:x,height:E,numCol:P,numRow:B}=r_(p,s,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:E,numCol:P,numRow:B})}let g=f||l||this.isAggregationDirty(t,{dimension:h,compareAll:c}),m=this.isAggregationDirty(t,{dimension:d});m&&this._updateAccessors(t),(g||m)&&this._resetResults(),this.setState({aggregationDataDirty:g,aggregationWeightsDirty:m})}_updateAccessors(t){let{getWeight:r,aggregation:i,data:s}=t.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=Mt[i]),this.setState({getValue:sc(i,r,{data:s})})}_resetResults(){let{count:t}=this.state.weights;t&&(t.aggregationData=null)}_generateContours(){let{numCol:t,numRow:r,gridOrigin:i,gridOffset:s,thresholdData:n}=this.state,{count:o}=this.state.weights,{aggregationData:a}=o;a||(a=o.aggregationBuffer.readSyncWebGL(),o.aggregationData=a);let{cellWeights:c}=ae.getCellData({countsData:a}),l=vF({thresholdData:n,cellWeights:c,gridSize:[t,r],gridOrigin:i,cellSize:[s.xOffset,s.yOffset]});this.setState({contourData:l})}_updateThresholdData(t){let{contours:r,zOffset:i}=t,s=r.length,n=new Array(s);for(let o=0;o<s;o++){let a=r[o];n[o]={contour:a,zIndex:a.zIndex||o,zOffset:i}}this.setState({thresholdData:n})}},jf=u_;(()=>{u_.layerName="ContourLayer"})(),(()=>{u_.defaultProps=AZ})();var PF=`#version 300 es
#define SHADER_NAME gpu-grid-cell-layer-vertex-shader
#define RANGE_COUNT 6
in vec3 positions;
in vec3 normals;
in vec4 colors;
in vec4 elevations;
in vec3 instancePickingColors;
uniform vec2 offset;
uniform bool extruded;
uniform float cellSize;
uniform float coverage;
uniform float opacity;
uniform float elevationScale;
uniform ivec2 gridSize;
uniform vec2 gridOrigin;
uniform vec2 gridOriginLow;
uniform vec2 gridOffset;
uniform vec2 gridOffsetLow;
uniform vec4 colorRange[RANGE_COUNT];
uniform vec2 elevationRange;
uniform vec2 colorDomain;
uniform bool colorDomainValid;
uniform vec2 elevationDomain;
uniform bool elevationDomainValid;
layout(std140) uniform;
uniform ColorData
{
vec4 maxMinCount;
} colorData;
uniform ElevationData
{
vec4 maxMinCount;
} elevationData;
#define EPSILON 0.00001
out vec4 vColor;
vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
vec4 outColor = vec4(0., 0., 0., 0.);
if (value >= (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 MF=`#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 AE=0,TE=1,bZ={colorDomain:null,colorRange:Ir,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},f_=class extends lt{getShaders(){return super.getShaders({vs:PF,fs:MF,modules:[dt,_r,_t,Hi]})}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 Wi,isInstanced:!0})}draw({uniforms:t}){let{cellSize:r,offset:i,extruded:s,elevationScale:n,coverage:o,gridSize:a,gridOrigin:c,gridOffset:l,elevationRange:u,colorMaxMinBuffer:f,elevationMaxMinBuffer:h}=this.props,d=this.state.model,p=[kr(c[0]),kr(c[1])],g=[kr(l[0]),kr(l[1])],m=this.getDomainUniforms(),_=nn(this.props.colorRange);this.bindUniformBuffers(f,h),d.setUniforms(t),d.setUniforms(m),d.setUniforms({cellSize:r,offset:i,extruded:s,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(t,r){t.bind({target:35345,index:AE}),r.bind({target:35345,index:TE})}unbindUniformBuffers(t,r){t.unbind({target:35345,index:AE}),r.unbind({target:35345,index:TE})}getDomainUniforms(){let{colorDomain:t,elevationDomain:r}=this.props,i={};return t!==null?(i.colorDomainValid=!0,i.colorDomain=t):i.colorDomainValid=!1,r!==null?(i.elevationDomainValid=!0,i.elevationDomain=r):i.elevationDomainValid=!1,i}_setupUniformBuffer(t){let r=t.pipeline.handle,i=this.context.gl,s=i.getUniformBlockIndex(r,"ColorData"),n=i.getUniformBlockIndex(r,"ElevationData");i.uniformBlockBinding(r,s,AE),i.uniformBlockBinding(r,n,TE)}},Xf=f_;(()=>{f_.layerName="GPUGridCellLayer"})(),(()=>{f_.defaultProps=bZ})();var EZ={colorDomain:null,colorRange:Ir,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:e=>e.position},extruded:!1,material:!0},SZ={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},RF="positions",h_=class extends ps{initializeState({device:t}){let r=ae.isSupported(t);r||k.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),super.initializeAggregationLayer({dimensions:SZ}),this.setState({gpuAggregation:!1,projectPoints:!1,isSupported:r,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:t.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:t.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"}),this.getAttributeManager().add({[RF]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},color:{size:3,accessor:"getColorWeight"},elevation:{size:3,accessor:"getElevationWeight"}})}updateState(t){if(this.state.isSupported===!1)return;super.updateState(t);let{aggregationDirty:r}=this.state;r&&this.setState({gridHash:null})}getHashKeyForIndex(t){let{numRow:r,numCol:i,boundingBox:s,gridOffset:n}=this.state,o=[i,r],a=[s.xMin,s.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(t/o[0]),u=t-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(t){let{numRow:r,numCol:i,boundingBox:s,gridOffset:n}=this.state,o=[i,r],a=[s.xMin,s.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(t/o[0]),u=t-l*o[0],f=l*c[1]+a[1];return[u*c[0]+a[0],f]}getPickingInfo({info:t,mode:r}){let{index:i}=t,s=null;if(i>=0){let n=this.state.gpuGridAggregator,o=this.getPositionForIndex(i),a=ae.getAggregationData({pixelIndex:i,...n.getData("color")}),c=ae.getAggregationData({pixelIndex:i,...n.getData("elevation")});if(s={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=ac(l,{gridOffset:d,attributes:_,viewport:m,translation:p,boundingBox:g}).gridHash,this.setState({gridHash:u})}let f=this.getHashKeyForIndex(i),h=u[f];Object.assign(s,h)}}return t.picked=Boolean(s),t.object=s,t}renderLayers(){if(!this.state.isSupported)return null;let{elevationScale:t,extruded:r,cellSize:i,coverage:s,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=nn(this.props.colorRange),_=this.getSubLayerClass("gpu-grid-cell",Xf);return new _({gridSize:[f,u],gridOrigin:h,gridOffset:[d.xOffset,d.yOffset],colorRange:m,elevationRange:o,colorDomain:a,elevationDomain:c,cellSize:i,coverage:s,material:n,elevationScale:t,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(t){let{color:r,elevation:i}=this.state.weights;[r,i].forEach(s=>{let{aggregationBuffer:n,maxMinBuffer:o}=s;o?.destroy(),n?.destroy()}),super.finalizeState(t)}updateAggregationState(t){let{props:r,oldProps:i}=t,{cellSize:s,coordinateSystem:n}=r,{viewport:o}=this.context,a=i.cellSize!==s,{dimensions:c}=this.state,l=this.isAttributeChanged(RF),u=l||this.isAttributeChanged(),{boundingBox:f}=this.state;if(l&&(f=e_(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:f})),l||a){let{gridOffset:d,translation:p,width:g,height:m,numCol:_,numRow:y}=r_(f,s,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(t,{dimension:c.data,compareAll:!0});h&&this._updateAccessors(t),this.setState({aggregationDataDirty:h})}_updateAccessors(t){let{colorAggregation:r,elevationAggregation:i}=t.props,{color:s,elevation:n}=this.state.weights;s.operation=Mt[r],n.operation=Mt[i]}},an=h_;(()=>{h_.layerName="GPUGridLayer"})(),(()=>{h_.defaultProps=EZ})();var vZ={...an.defaultProps,...on.defaultProps,gpuAggregation:!1},d_=class extends It{initializeState(){this.state={useGPUAggregation:!1}}updateState({props:t}){this.setState({useGPUAggregation:!1})}renderLayers(){let{data:t,updateTriggers:r}=this.props,i=this.state.useGPUAggregation?"GPU":"CPU",s=this.state.useGPUAggregation?this.getSubLayerClass("GPU",an):this.getSubLayerClass("CPU",on);return new s(this.props,this.getSubLayerProps({id:i,updateTriggers:r}),{data:t})}canUseGPUAggregation(t){let{gpuAggregation:r,lowerPercentile:i,upperPercentile:s,getColorValue:n,getElevationValue:o,colorScaleType:a}=t;return!(!r||!ae.isSupported(this.context.device)||i!==0||s!==100||n!==null||o!==null||a==="quantile"||a==="ordinal")}},Yf=d_;(()=>{d_.layerName="GridLayer"})(),(()=>{d_.defaultProps=vZ})();function BF(e){let t=e.map(a=>a[0]),r=e.map(a=>a[1]),i=Math.min.apply(null,t),s=Math.max.apply(null,t),n=Math.min.apply(null,r),o=Math.max.apply(null,r);return[i,n,s,o]}function OF(e,t){return t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3]}var IF=new Float32Array(12);function bE(e,t=2){let r=0;for(let i of e)for(let s=0;s<t;s++)IF[r++]=i[s]||0;return IF}function FF(e,t,r){let[i,s,n,o]=e,a=n-i,c=o-s,l=a,u=c;a/c<t/r?l=t/r*c:u=r/t*a,l<t&&(l=t,u=r);let f=(n+i)/2,h=(o+s)/2;return[f-l/2,h-u/2,f+l/2,h+u/2]}function NF(e,t){let[r,i,s,n]=t;return[(e[0]-r)/(s-r),(e[1]-i)/(n-i)]}var LF=`#version 300 es
#define SHADER_NAME heatp-map-layer-vertex-shader
uniform sampler2D maxTexture;
uniform float intensity;
uniform vec2 colorDomain;
uniform float threshold;
uniform float aggregationMode;
in vec3 positions;
in vec2 texCoords;
out vec2 vTexCoords;
out float vIntensityMin;
out float vIntensityMax;
void main(void) {
gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
vTexCoords = texCoords;
vec4 maxTexture = texture(maxTexture, vec2(0.5));
float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
float minValue = maxValue * threshold;
if (colorDomain[1] > 0.) {
maxValue = colorDomain[1];
minValue = colorDomain[0];
}
vIntensityMax = intensity / maxValue;
vIntensityMin = intensity / minValue;
}
`;var DF=`#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 EE=class extends lt{getShaders(){return{vs:LF,fs:DF,modules:[dt]}}initializeState({device:t}){this.setState({model:this._getModel(t)})}_getModel(t){let{vertexCount:r,data:i,weightsTexture:s,maxTexture:n,colorTexture:o}=this.props;return new J(t,{...this.getShaders(),id:this.props.id,bindings:{weightsTexture:s,maxTexture:n,colorTexture:o},attributes:i.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-fan-webgl",vertexCount:r})}draw({uniforms:t}){let{model:r}=this.state,{intensity:i,threshold:s,aggregationMode:n,colorDomain:o}=this.props;r.setUniforms({...t,intensity:i,threshold:s,aggregationMode:n,colorDomain:o}),r.draw(this.context.renderPass)}},qf=EE;(()=>{EE.layerName="TriangleLayer"})();var SE=`#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 vE=`#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 UF=`#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 kF=`#version 300 es
in vec4 outTexture;
out vec4 fragColor;
void main() {
fragColor = outTexture;
fragColor.g = outTexture.r / max(1.0, outTexture.a);
}
`;var CZ=2,CE={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},VF=[0,0],wZ={SUM:0,MEAN:1},PZ={getPosition:{type:"accessor",value:e=>e.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:Ir,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}},MZ=["float32-renderable-webgl","texture-blend-float-webgl"],RZ={data:{props:["radiusPixels"]}},p_=class extends nr{initializeState(){super.initializeAggregationLayer(RZ),this.setState({colorDomain:VF}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t),this._updateHeatmapState(t)}_updateHeatmapState(t){let{props:r,oldProps:i}=t,s=this._getChangeFlags(t);(s.dataChanged||s.viewportChanged)&&(s.boundsChanged=this._updateBounds(s.dataChanged),this._updateTextureRenderingBounds()),s.dataChanged||s.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):s.viewportZoomChanged&&this._debouncedUpdateWeightmap(),r.colorRange!==i.colorRange&&this._updateColorTexture(t),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:t.context.viewport.zoom})}renderLayers(){let{weightsTexture:t,triPositionBuffer:r,triTexCoordBuffer:i,maxWeightsTexture:s,colorTexture:n,colorDomain:o}=this.state,{updateTriggers:a,intensity:c,threshold:l,aggregation:u}=this.props,f=this.getSubLayerClass("triangle",qf);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:X.DEFAULT,data:{attributes:{positions:r,texCoords:i}},vertexCount:4,maxTexture:s,colorTexture:n,aggregationMode:wZ[u]||0,weightsTexture:t,intensity:c,threshold:l,colorDomain:o})}finalizeState(t){super.finalizeState(t);let{weightsTransform:r,weightsTexture:i,maxWeightTransform:s,maxWeightsTexture:n,triPositionBuffer:o,triTexCoordBuffer:a,colorTexture:c,updateTimer:l}=this.state;r?.destroy(),i?.destroy(),s?.destroy(),n?.destroy(),o?.destroy(),a?.destroy(),c?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new qr(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(t){let r={},{dimensions:i}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(t,{compareAll:!0,dimension:i.data})&&"aggregation is dirty",r.viewportChanged=t.changeFlags.viewportChanged;let{zoom:s}=this.state;return(!t.context.viewport||t.context.viewport.zoom!==s)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:t,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...CE,width:t,height:t,format:r}),maxWeightsTexture:this.context.device.createTexture({...CE,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:t}=this.context,{weightsTextureSize:r}=this.props,i=Math.min(r,t.limits.maxTextureDimension2D),s=MZ.every(a=>t.features.has(a)),n=s?"rgba32float":"rgba8unorm",o=s?1:1/255;this.setState({textureSize:i,format:n,weightsScale:o}),s||k.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(t){let{weightsTransform:r}=this.state,{weightsTexture:i}=this.state,s=this.getAttributeManager();r?.destroy(),r=new yi(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:s.getBufferLayouts(),vertexCount:1,targetTexture:i,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...t}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:t}=this.context,{textureSize:r,weightsTexture:i,maxWeightsTexture:s}=this.state,n=this.getShaders({vs:SE,fs:vE});this._createWeightsTransform(n);let o=this.getShaders({vs:UF,fs:kF}),a=new yi(t,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:i},uniforms:{textureSize:r},targetTexture:s,...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:i,maxWeightsTexture:s,maxWeightTransform:a,zoom:null,triPositionBuffer:t.createBuffer({byteLength:48}),triTexCoordBuffer:t.createBuffer({byteLength:48})})}updateShaders(t){this._createWeightsTransform({vs:SE,fs:vE,...t})}_updateMaxWeightValue(){let{maxWeightTransform:t}=this.state;t.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(t=!1){let{viewport:r}=this.context,i=[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)),s=BF(i),n={visibleWorldBounds:s,viewportCorners:i},o=!1;if(t||!this.state.worldBounds||!OF(this.state.worldBounds,s)){let a=this._worldToCommonBounds(s),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:t,triTexCoordBuffer:r,normalizedCommonBounds:i,viewportCorners:s}=this.state,{viewport:n}=this.context;t.write(bE(s,3));let o=s.map(a=>NF(n.projectPosition(a),i));r.write(bE(o,2))}_updateColorTexture(t){let{colorRange:r}=t.props,{colorTexture:i}=this.state,s=nn(r,!1,Uint8Array);i&&i?.width===r.length?i.setSubImageData({data:s}):(i?.destroy(),i=this.context.device.createTexture({...CE,data:s,width:r.length,height:1})),this.setState({colorTexture:i})}_updateWeightmap(){let{radiusPixels:t,colorDomain:r,aggregation:i}=this.props,{worldBounds:s,textureSize:n,weightsScale:o}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let c=this._worldToCommonBounds(s,{useLayerCoordinateSystem:!0});if(r&&i==="SUM"){let{viewport:g}=this.context,m=g.distanceScales.metersPerUnit[2]*(c[2]-c[0])/n;this.state.colorDomain=r.map(_=>_*m*o)}else this.state.colorDomain=r||VF;let u=this.getAttributeManager().getAttributes(),f=this.getModuleSettings(),h=u.positions.buffer,d={radiusPixels:t,commonBounds:c,textureWidth:n,weightsScale:o},p=u.weights.buffer;a.model.setAttributes({positions:h,weights:p}),a.model.setVertexCount(this.getNumInstances()),a.model.setUniforms(d),a.model.updateModuleSettings(f),a.run({parameters:{viewport:[0,0,n,n]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(t=!1){let{updateTimer:r}=this.state,{debounceTimeout:i}=this.props;t?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),i)),this.setState({updateTimer:r})}_worldToCommonBounds(t,r={}){let{useLayerCoordinateSystem:i=!1}=r,[s,n,o,a]=t,{viewport:c}=this.context,{textureSize:l}=this.state,{coordinateSystem:u}=this.props,f=i&&(u===X.LNGLAT_OFFSETS||u===X.METER_OFFSETS),h=f?c.projectPosition(this.props.coordinateOrigin):[0,0],d=l*CZ/c.scale,p,g;return i&&!f?(p=this.projectPosition([s,n,0]),g=this.projectPosition([o,a,0])):(p=c.projectPosition([s,n,0]),g=c.projectPosition([o,a,0])),FF([p[0]-h[0],p[1]-h[1],g[0]-h[0],g[1]-h[1]],d,d)}_commonToWorldBounds(t){let[r,i,s,n]=t,{viewport:o}=this.context,a=o.unprojectPosition([r,i]),c=o.unprojectPosition([s,n]);return a.slice(0,2).concat(c.slice(0,2))}},Kf=p_;(()=>{p_.layerName="HeatmapLayer"})(),(()=>{p_.defaultProps=PZ})();var wE=85.05113;function ME(e,t,r,i){if(r){if(r.userData._googleMap===e)return r;g_(r)}let s={click:null,rightclick:null,dblclick:null,mousemove:null,mouseout:null},n=new We({...i,useDevicePixels:i.interleaved?!0:i.useDevicePixels,style:i.interleaved?null:{pointerEvents:"none"},parent:IZ(t,i.style),views:new Gr({repeat:!0}),initialViewState:{longitude:0,latitude:0,zoom:1},controller:!1});for(let o in s)s[o]=e.addListener(o,a=>OZ(n,o,a));return n.userData._googleMap=e,n.userData._eventListeners=s,n}function IZ(e,t){let r=document.createElement("div");return r.style.position="absolute",Object.assign(r.style,t),"getPanes"in e?e.getPanes()?.overlayLayer.appendChild(r):e.getMap()?.getDiv().appendChild(r),r}function g_(e){let{_eventListeners:t}=e.userData;for(let r in t)t[r]&&t[r].remove();e.finalize()}function zF(e,t){let{width:r,height:i}=HF(e),s=t.getProjection(),n=e.getBounds();if(!n)return{width:r,height:i,left:0,top:0};let o=n.getNorthEast(),a=n.getSouthWest(),c=s.fromLatLngToDivPixel(o),l=s.fromLatLngToDivPixel(a),u=PE(s,r/2,i/2),f=new google.maps.LatLng(0,u[0]),h=s.fromLatLngToContainerPixel(f),d=s.fromLatLngToDivPixel(f);if(!c||!l||!d||!h)return{width:r,height:i,left:0,top:0};let p=Math.round(d.x-h.x),g=d.y-h.y,m=PE(s,r/2,0),_=PE(s,r/2,i),y=u[1],x=u[0];if(Math.abs(y)>wE){y=y>0?wE:-wE;let v=new google.maps.LatLng(y,x),T=s.fromLatLngToContainerPixel(v);g+=T.y-i/2}g=Math.round(g);let P=180*new Fr(m).sub(_).verticalAngle()/Math.PI;P<0&&(P+=360);let B=e.getHeading()||0,F=e.getZoom()-1,M;if(P===0)M=i?(l.y-c.y)/i:1;else if(P===B){let v=new Fr([c.x,c.y]).sub([l.x,l.y]).len(),T=new Fr([r,-i]).len();M=T?v/T:1}return F+=Math.log2(M||1),{width:r,height:i,left:p,top:g,zoom:F,bearing:P,pitch:e.getTilt(),latitude:y,longitude:x}}function RE(e,t){let{width:r,height:i}=HF(e),{center:s,heading:n,tilt:o,zoom:a}=t.getCameraParams(),c=25,l=i?r/i: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:i,viewState:{altitude:d,bearing:n,latitude:s.lat(),longitude:s.lng(),pitch:o,projectionMatrix:h,repeat:!0,zoom:a-1}}}function HF(e){let t=e.getDiv().firstChild;return{width:t.offsetWidth,height:t.offsetHeight}}function PE(e,t,r){let i=new google.maps.Point(t,r),s=e.fromContainerPixelToLatLng(i);return[s.lng(),s.lat()]}function BZ(e,t){if(e.pixel)return e.pixel;let r=t.getViewports()[0].project([e.latLng.lng(),e.latLng.lat()]);return{x:r[0],y:r[1]}}function OZ(e,t,r){if(!e.isInitialized)return;let i={type:t,offsetCenter:BZ(r,e),srcEvent:r};switch(t){case"click":case"rightclick":i.type="click",i.tapCount=1,e._onPointerDown(i),e._onEvent(i);break;case"dblclick":i.type="click",i.tapCount=2,e._onEvent(i);break;case"mousemove":i.type="pointermove",e._onPointerMove(i);break;case"mouseout":i.type="pointerleave",e._onPointerMove(i);break;default:return}}var FZ=()=>!1,NZ={depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],blendEquation:32774};function GF(){}var LZ={interleaved:!0},$f=class{constructor(t){this.props={},this._map=null,this._deck=null,this._overlay=null,this.setProps({...LZ,...t})}setMap(t){if(t===this._map)return;let{VECTOR:r,UNINITIALIZED:i}=google.maps.RenderingType;this._map&&(!t&&this._map.getRenderingType()===r&&this.props.interleaved&&this._overlay.requestRedraw(),this._overlay?.setMap(null),this._map=null),t&&(this._map=t,t.getRenderingType()!==i?this._createOverlay(t):t.addListener("renderingtype_changed",()=>{this._createOverlay(t)}))}setProps(t){if(Object.assign(this.props,t),this._deck){let r=this._deck.getCanvas();if(t.style&&r?.parentElement){let i=r.parentElement.style;Object.assign(i,t.style),t.style=null}this._deck.setProps(t)}}pickObject(t){return this._deck&&this._deck.pickObject(t)}pickMultipleObjects(t){return this._deck&&this._deck.pickMultipleObjects(t)}pickObjects(t){return this._deck&&this._deck.pickObjects(t)}finalize(){this.setMap(null),this._deck&&(g_(this._deck),this._deck=null)}_createOverlay(t){let{interleaved:r}=this.props,{VECTOR:i,UNINITIALIZED:s}=google.maps.RenderingType,n=t.getRenderingType();if(n===s)return;let a=n===i&&google.maps.WebGLOverlayView?google.maps.WebGLOverlayView:google.maps.OverlayView,c=new a;c instanceof google.maps.WebGLOverlayView?(r?(c.onAdd=GF,c.onContextRestored=this._onContextRestored.bind(this),c.onDraw=this._onDrawVectorInterleaved.bind(this)):(c.onAdd=this._onAdd.bind(this),c.onContextRestored=GF,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(t)}_onAdd(){this._deck=ME(this._map,this._overlay,this._deck,this.props)}_onContextRestored({gl:t}){if(!this._map||!this._overlay)return;let r=()=>{this._overlay&&this._overlay.requestRedraw()},i=ME(this._map,this._overlay,this._deck,{gl:t,_customRender:r,...this.props});this._deck=i;let s=i.animationLoop;s._renderFrame=()=>{let n=t.getParameter(34964);i.device.withParametersWebGL({},()=>{s.props.onRender(s.animationProps)}),t.bindBuffer(34962,n)}}_onContextLost(){this._deck&&(g_(this._deck),this._deck=null)}_onRemove(){this._deck?.setProps({layerFilter:FZ})}_onDrawRaster(){if(!this._deck||!this._map)return;let t=this._deck,{width:r,height:i,left:s,top:n,...o}=zF(this._map,this._overlay),c=t.getCanvas()?.parentElement||t.props.parent;if(c){let u=c.style;u.left=`${s}px`,u.top=`${n}px`}let l=1e4;t.setProps({width:r,height:i,viewState:{altitude:l,...o}}),t.redraw()}_onDrawVectorInterleaved({gl:t,transformer:r}){if(!this._deck||!this._map)return;let i=this._deck;if(i.setProps({...RE(this._map,r),width:null,height:null}),i.isInitialized){let s=i.device,n=s.getParametersWebGL(36006);i.setProps({_framebuffer:n}),s.getCanvasContext().resize(),i.needsRedraw({clearRedrawFlags:!0}),s.setParametersWebGL({viewport:[0,0,t.canvas.width,t.canvas.height],scissor:[0,0,t.canvas.width,t.canvas.height],stencilFunc:[519,0,255,519,0,255]}),s.withParametersWebGL(NZ,()=>{i._drawLayers("google-vector",{clearCanvas:!1})})}}_onDrawVectorOverlay({transformer:t}){if(!this._deck||!this._map)return;let r=this._deck;r.setProps({...RE(this._map,t)}),r.redraw()}};var IE=512,DZ=Math.PI/180;function m_({map:e,gl:t,deck:r}){if(e.__deck)return e.__deck;let i=r?.props._customRender,s=r?.props.onLoad,n=OE({...r?.props,_customRender:()=>{e.triggerRepaint(),i?.("")}}),o;return(!r||r.props.gl===t)&&(Object.assign(n,{gl:t,width:null,height:null,touchAction:"unset",viewState:xc(e)}),r?.isInitialized?WF(r,e):n.onLoad=()=>{s?.(),WF(o,e)}),r?(o=r,r.setProps(n),r.userData.isExternal=!0):(o=new We(n),e.on("remove",()=>{BE(e)})),o.userData.mapboxLayers=new Set,e.__deck=o,e.on("render",()=>{o.isInitialized&&kZ(o,e)}),o}function WF(e,t){let r=()=>{e.isInitialized?VZ(e,t):t.off("move",r)};t.on("move",r)}function BE(e){e.__deck?.finalize(),e.__deck=null}function OE(e){return{...e,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...e.parameters},views:e.views||[new Gr({id:"mapbox"})]}}function jF(e,t){e.userData.mapboxLayers.add(t),FE(e)}function XF(e,t){e.userData.mapboxLayers.delete(t),FE(e)}function YF(e,t){FE(e)}function qF(e,t,r){let{currentViewport:i}=e.userData,s=!1;i||(i=KF(e,t,!0),e.userData.currentViewport=i,s=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:({layer:n})=>r.id===n.id||n.props.operation.includes("terrain"),clearStack:s,clearCanvas:!1})}function xc(e){let{lng:t,lat:r}=e.getCenter(),i={longitude:(t+540)%360-180,latitude:r,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&UZ(e,i),i}function UZ(e,t){if(e.getFreeCameraOptions){let{position:r}=e.getFreeCameraOptions();if(!r||r.z===void 0)return;let i=e.transform.height,{longitude:s,latitude:n,pitch:o}=t,a=r.x*IE,c=(1-r.y)*IE,l=r.z*IE,u=Xt([s,n]),f=a-u[0],h=c-u[1],d=Math.sqrt(f*f+h*h),p=o*DZ,g=1.5*i,m=p<.001?g*Math.cos(p)/l:g*Math.sin(p)/d;t.zoom=Math.log2(m);let _=g*Math.cos(p)/m,y=l-_;t.position=[0,0,y/Pn(n)]}else typeof e.transform.elevation=="number"&&(t.position=[0,0,e.transform.elevation])}function KF(e,t,r=!0){return new ne({id:"mapbox",x:0,y:0,width:e.width,height:e.height,...xc(t),nearZMultiplier:r?.02:.1,nearZ:t.transform._nearZ/t.transform.height,farZ:t.transform._farZ/t.transform.height})}function kZ(e,t){let{mapboxLayers:r,isExternal:i}=e.userData;if(i){let s=Array.from(r,u=>u.id),o=Oe(e.props.layers,Boolean).some(u=>u&&!s.includes(u.id)),a=e.getViewports(),c=a.findIndex(u=>u.id==="mapbox"),l=a.length>1||c<0;(o||l)&&(c>=0&&(a=a.slice(),a[c]=KF(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:a,layerFilter:u=>(!e.props.layerFilter||e.props.layerFilter(u))&&(u.viewport.id!=="mapbox"||!s.includes(u.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}function VZ(e,t){e.setProps({viewState:xc(t)}),e.needsRedraw({clearRedrawFlags:!0})}function FE(e){if(e.userData.isExternal)return;let t=[];e.userData.mapboxLayers.forEach(r=>{let i=r.props.type,s=new i(r.props);t.push(s)}),e.setProps({layers:t})}var Jf=class{constructor(t){if(!t.id)throw new Error("Layer must have an unique id");this.id=t.id,this.type="custom",this.renderingMode=t.renderingMode||"3d",this.map=null,this.deck=null,this.props=t}onAdd(t,r){this.map=t,this.deck=m_({map:t,gl:r,deck:this.props.deck}),jF(this.deck,this)}onRemove(){this.deck&&XF(this.deck,this)}setProps(t){Object.assign(this.props,t,{id:this.id}),this.deck&&YF(this.deck,this)}render(){qF(this.deck,this.map,this)}};var NE="__UNDEFINED__";function Zf(e,t,r,i){if(!e||!t||!e.style||!e.style._loaded)return;let s=Oe(i,Boolean);if(r!==i){let a=Oe(r,Boolean),c=new Set(a.map(l=>l.id));for(let l of s)c.delete(l.id);for(let l of c)e.getLayer(l)&&e.removeLayer(l)}for(let a of s){let c=e.getLayer(a.id);c?c.implementation.setProps(a.props):e.addLayer(new Jf({id:a.id,deck:t}),a.props.beforeId)}let n=e.style._order,o={};for(let a of s){let{beforeId:c}=a.props;(!c||!n.includes(c))&&(c=NE),o[c]=o[c]||[],o[c].push(a.id)}for(let a in o){let c=o[a],l=a===NE?n.length:n.indexOf(a),u=a===NE?void 0:a;for(let f=c.length-1;f>=0;f--){let h=c[f],d=n.indexOf(h);d!==l-1&&(e.moveLayer(h,u),d>l&&l++),l--,u=h}}}var Qf=class{constructor(t){this._handleStyleChange=()=>{Zf(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:s,clientHeight:n}=this._map.getContainer();Object.assign(this._container.style,{width:`${s}px`,height:`${n}px`})}},this._updateViewState=()=>{let s=this._deck;s&&(s.setProps({viewState:xc(this._map)}),s.isInitialized&&s.redraw())},this._handleMouseEvent=s=>{let n=this._deck;if(!n||!n.isInitialized)return;let o={type:s.type,offsetCenter:s.point,srcEvent:s},a=this._lastMouseDownPoint;switch(!s.point&&a&&(o.deltaX=s.originalEvent.clientX-a.clientX,o.deltaY=s.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={...s.point,clientX:s.originalEvent.clientX,clientY:s.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,...i}=t;this._interleaved=r,this._props=i}setProps(t){this._interleaved&&t.layers&&Zf(this._map,this._deck,this._props.layers,t.layers),Object.assign(this._props,t),this._deck&&this._deck.setProps(this._interleaved?OE(this._props):this._props)}onAdd(t){return this._map=t,this._interleaved?this._onAddInterleaved(t):this._onAddOverlaid(t)}_onAddOverlaid(t){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 We({...this._props,parent:r,viewState:xc(t)}),t.on("resize",this._updateContainerSize),t.on("render",this._updateViewState),t.on("mousedown",this._handleMouseEvent),t.on("dragstart",this._handleMouseEvent),t.on("drag",this._handleMouseEvent),t.on("dragend",this._handleMouseEvent),t.on("mousemove",this._handleMouseEvent),t.on("mouseout",this._handleMouseEvent),t.on("click",this._handleMouseEvent),t.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(t){let r=t.painter.context.gl;return r instanceof WebGLRenderingContext&&k.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=m_({map:t,gl:r,deck:new We({...this._props,gl:r})}),t.on("styledata",this._handleStyleChange),Zf(t,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){let t=this._map;t&&(this._interleaved?this._onRemoveInterleaved(t):this._onRemoveOverlaid(t)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(t){t.off("resize",this._updateContainerSize),t.off("render",this._updateViewState),t.off("mousedown",this._handleMouseEvent),t.off("dragstart",this._handleMouseEvent),t.off("drag",this._handleMouseEvent),t.off("dragend",this._handleMouseEvent),t.off("mousemove",this._handleMouseEvent),t.off("mouseout",this._handleMouseEvent),t.off("click",this._handleMouseEvent),t.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(t){t.off("styledata",this._handleStyleChange),Zf(t,this._deck,this._props.layers,[]),BE(t)}getDefaultPosition(){return"top-left"}pickObject(t){return At(this._deck),this._deck.pickObject(t)}pickMultipleObjects(t){return At(this._deck),this._deck.pickMultipleObjects(t)}pickObjects(t){return At(this._deck),this._deck.pickObjects(t)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}};var T_,Bt,eN,zZ,Bo,$F,rN,LE,HZ,th={},iN=[],GZ=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,UE=Array.isArray;function cn(e,t){for(var r in t)e[r]=t[r];return e}function sN(e){var t=e.parentNode;t&&t.removeChild(e)}function WZ(e,t,r){var i,s,n,o={};for(n in t)n=="key"?i=t[n]:n=="ref"?s=t[n]:o[n]=t[n];if(arguments.length>2&&(o.children=arguments.length>3?T_.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(n in e.defaultProps)o[n]===void 0&&(o[n]=e.defaultProps[n]);return y_(e,o,i,s,null)}function y_(e,t,r,i,s){var n={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:s??++eN,__i:-1,__u:0};return s==null&&Bt.vnode!=null&&Bt.vnode(n),n}function Ac(e){return e.children}function x_(e,t){this.props=e,this.context=t}function Oo(e,t){if(t==null)return e.__?Oo(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?Oo(e):null}function nN(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return nN(e)}}function JF(e){(!e.__d&&(e.__d=!0)&&Bo.push(e)&&!A_.__r++||$F!==Bt.debounceRendering)&&(($F=Bt.debounceRendering)||rN)(A_)}function A_(){var e,t,r,i,s,n,o,a,c;for(Bo.sort(LE);e=Bo.shift();)e.__d&&(t=Bo.length,i=void 0,n=(s=(r=e).__v).__e,a=[],c=[],(o=r.__P)&&((i=cn({},s)).__v=s.__v+1,Bt.vnode&&Bt.vnode(i),kE(o,i,s,r.__n,o.ownerSVGElement!==void 0,32&s.__u?[n]:null,a,n??Oo(s),!!(32&s.__u),c),i.__v=s.__v,i.__.__k[i.__i]=i,cN(a,i,c),i.__e!=n&&nN(i)),Bo.length>t&&Bo.sort(LE));A_.__r=0}function oN(e,t,r,i,s,n,o,a,c,l,u){var f,h,d,p,g,m=i&&i.__k||iN,_=t.length;for(r.__d=c,jZ(r,t,m),c=r.__d,f=0;f<_;f++)(d=r.__k[f])!=null&&typeof d!="boolean"&&typeof d!="function"&&(h=d.__i===-1?th:m[d.__i]||th,d.__i=f,kE(e,d,h,s,n,o,a,c,l,u),p=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&VE(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=Oo(h)),c=aN(d,c,e)):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 jZ(e,t,r){var i,s,n,o,a,c=t.length,l=r.length,u=l,f=0;for(e.__k=[],i=0;i<c;i++)o=i+f,(s=e.__k[i]=(s=t[i])==null||typeof s=="boolean"||typeof s=="function"?null:typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?y_(null,s,null,null,null):UE(s)?y_(Ac,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?y_(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s)!=null?(s.__=e,s.__b=e.__b+1,a=XZ(s,r,o,u),s.__i=a,n=null,a!==-1&&(u--,(n=r[a])&&(n.__u|=131072)),n==null||n.__v===null?(a==-1&&f--,typeof s.type!="function"&&(s.__u|=65536)):a!==o&&(a===o+1?f++:a>o?u>c-o?f+=a-o:f--:a<o?a==o-1&&(f=a-o):f=0,a!==i+f&&(s.__u|=65536))):(n=r[o])&&n.key==null&&n.__e&&!(131072&n.__u)&&(n.__e==e.__d&&(e.__d=Oo(n)),DE(n,n,!1),r[o]=null,u--);if(u)for(i=0;i<l;i++)(n=r[i])!=null&&!(131072&n.__u)&&(n.__e==e.__d&&(e.__d=Oo(n)),DE(n,n))}function aN(e,t,r){var i,s;if(typeof e.type=="function"){for(i=e.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=e,t=aN(i[s],t,r));return t}e.__e!=t&&(r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function XZ(e,t,r,i){var s=e.key,n=e.type,o=r-1,a=r+1,c=t[r];if(c===null||c&&s==c.key&&n===c.type&&!(131072&c.__u))return r;if(i>(c!=null&&!(131072&c.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((c=t[o])&&!(131072&c.__u)&&s==c.key&&n===c.type)return o;o--}if(a<t.length){if((c=t[a])&&!(131072&c.__u)&&s==c.key&&n===c.type)return a;a++}}return-1}function ZF(e,t,r){t[0]==="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||GZ.test(t)?r:r+"px"}function __(e,t,r,i,s){var n;t:if(t==="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)r&&t in r||ZF(e.style,t,"");if(r)for(t in r)i&&r[t]===i[t]||ZF(e.style,t,r[t])}else if(t[0]==="o"&&t[1]==="n")n=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+n]=r,r?i?r.u=i.u:(r.u=Date.now(),e.addEventListener(t,n?tN:QF,n)):e.removeEventListener(t,n?tN:QF,n);else{if(s)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=r??"";break t}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,r))}}function QF(e){if(this.l){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Bt.event?Bt.event(e):e)}}function tN(e){if(this.l)return this.l[e.type+!0](Bt.event?Bt.event(e):e)}function kE(e,t,r,i,s,n,o,a,c,l){var u,f,h,d,p,g,m,_,y,x,E,P,B,F,M,v=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(c=!!(32&r.__u),n=[a=t.__e=r.__e]),(u=Bt.__b)&&u(t);t:if(typeof v=="function")try{if(_=t.props,y=(u=v.contextType)&&i[u.__c],x=u?y?y.props.value:u.__:i,r.__c?m=(f=t.__c=r.__c).__=f.__E:("prototype"in v&&v.prototype.render?t.__c=f=new v(_,x):(t.__c=f=new x_(_,x),f.constructor=v,f.render=qZ),y&&y.sub(f),f.props=_,f.state||(f.state={}),f.context=x,f.__n=i,h=f.__d=!0,f.__h=[],f._sb=[]),f.__s==null&&(f.__s=f.state),v.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=cn({},f.__s)),cn(f.__s,v.getDerivedStateFromProps(_,f.__s))),d=f.props,p=f.state,f.__v=t,h)v.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(v.getDerivedStateFromProps==null&&_!==d&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(_,x),!f.__e&&(f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(_,f.__s,x)===!1||t.__v===r.__v)){for(t.__v!==r.__v&&(f.props=_,f.state=f.__s,f.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(T){T&&(T.__=t)}),E=0;E<f._sb.length;E++)f.__h.push(f._sb[E]);f._sb=[],f.__h.length&&o.push(f);break t}f.componentWillUpdate!=null&&f.componentWillUpdate(_,f.__s,x),f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(d,p,g)})}if(f.context=x,f.props=_,f.__P=e,f.__e=!1,P=Bt.__r,B=0,"prototype"in v&&v.prototype.render){for(f.state=f.__s,f.__d=!1,P&&P(t),u=f.render(f.props,f.state,f.context),F=0;F<f._sb.length;F++)f.__h.push(f._sb[F]);f._sb=[]}else do f.__d=!1,P&&P(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++B<25);f.state=f.__s,f.getChildContext!=null&&(i=cn(cn({},i),f.getChildContext())),h||f.getSnapshotBeforeUpdate==null||(g=f.getSnapshotBeforeUpdate(d,p)),oN(e,UE(M=u!=null&&u.type===Ac&&u.key==null?u.props.children:u)?M:[M],t,r,i,s,n,o,a,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),m&&(f.__E=f.__=null)}catch(T){t.__v=null,c||n!=null?(t.__e=a,t.__u|=c?160:32,n[n.indexOf(a)]=null):(t.__e=r.__e,t.__k=r.__k),Bt.__e(T,t,r)}else n==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=YZ(r.__e,t,r,i,s,n,o,c,l);(u=Bt.diffed)&&u(t)}function cN(e,t,r){t.__d=void 0;for(var i=0;i<r.length;i++)VE(r[i],r[++i],r[++i]);Bt.__c&&Bt.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(n){n.call(s)})}catch(n){Bt.__e(n,s.__v)}})}function YZ(e,t,r,i,s,n,o,a,c){var l,u,f,h,d,p,g,m=r.props,_=t.props,y=t.type;if(y==="svg"&&(s=!0),n!=null){for(l=0;l<n.length;l++)if((d=n[l])&&"setAttribute"in d==!!y&&(y?d.localName===y:d.nodeType===3)){e=d,n[l]=null;break}}if(e==null){if(y===null)return document.createTextNode(_);e=s?document.createElementNS("http://www.w3.org/2000/svg",y):document.createElement(y,_.is&&_),n=null,a=!1}if(y===null)m===_||a&&e.data===_||(e.data=_);else{if(n=n&&T_.call(e.childNodes),m=r.props||th,!a&&n!=null)for(m={},l=0;l<e.attributes.length;l++)m[(d=e.attributes[l]).name]=d.value;for(l in m)d=m[l],l=="children"||(l=="dangerouslySetInnerHTML"?f=d:l==="key"||l in _||__(e,l,null,d,s));for(l in _)d=_[l],l=="children"?h=d:l=="dangerouslySetInnerHTML"?u=d:l=="value"?p=d:l=="checked"?g=d:l==="key"||a&&typeof d!="function"||m[l]===d||__(e,l,d,m[l],s);if(u)a||f&&(u.__html===f.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(f&&(e.innerHTML=""),oN(e,UE(h)?h:[h],t,r,i,s&&y!=="foreignObject",n,o,n?n[0]:r.__k&&Oo(r,0),a,c),n!=null)for(l=n.length;l--;)n[l]!=null&&sN(n[l]);a||(l="value",p!==void 0&&(p!==e[l]||y==="progress"&&!p||y==="option"&&p!==m[l])&&__(e,l,p,m[l],!1),l="checked",g!==void 0&&g!==e[l]&&__(e,l,g,m[l],!1))}return e}function VE(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(i){Bt.__e(i,r)}}function DE(e,t,r){var i,s;if(Bt.unmount&&Bt.unmount(e),(i=e.ref)&&(i.current&&i.current!==e.__e||VE(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){Bt.__e(n,t)}i.base=i.__P=null,e.__c=void 0}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&DE(i[s],t,r||typeof e.type!="function");r||e.__e==null||sN(e.__e),e.__=e.__e=e.__d=void 0}function qZ(e,t,r){return this.constructor(e,r)}function Tc(e,t,r){var i,s,n,o;Bt.__&&Bt.__(e,t),s=(i=typeof r=="function")?null:r&&r.__k||t.__k,n=[],o=[],kE(t,e=(!i&&r||t).__k=WZ(Ac,null,[e]),s||th,th,t.ownerSVGElement!==void 0,!i&&r?[r]:s?null:t.firstChild?T_.call(t.childNodes):null,n,!i&&r?r:s?s.__e:t.firstChild,i,o),cN(n,e,o)}T_=iN.slice,Bt={__e:function(e,t,r,i){for(var s,n,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((n=s.constructor)&&n.getDerivedStateFromError!=null&&(s.setState(n.getDerivedStateFromError(e)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,i||{}),o=s.__d),o)return s.__E=s}catch(a){e=a}throw e}},eN=0,zZ=function(e){return e!=null&&e.constructor==null},x_.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=cn({},this.state),typeof e=="function"&&(e=e(cn({},r),this.props)),e&&cn(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),JF(this))},x_.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),JF(this))},x_.prototype.render=Ac,Bo=[],rN=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,LE=function(e,t){return e.__v.__b-t.__v.__b},A_.__r=0,HZ=0;var KZ=0,J6t=Array.isArray;function Gt(e,t,r,i,s,n){var o,a,c={};for(a in t)a=="ref"?o=t[a]:c[a]=t[a];var l={type:e,props:c,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--KZ,__i:-1,__u:0,__source:s,__self:n};if(typeof e=="function"&&(o=e.defaultProps))for(a in o)c[a]===void 0&&(c[a]=o[a]);return Bt.vnode&&Bt.vnode(l),l}var lN=e=>{let{className:t,label:r,onClick:i}=e;return Gt("div",{className:"deck-widget-button",children:Gt("button",{className:`deck-widget-icon-button ${t}`,type:"button",onClick:i,title:r,children:Gt("div",{className:"deck-widget-icon"})})})},uN=e=>{let{children:t,orientation:r}=e;return Gt("div",{className:`deck-widget-button-group ${r}`,children:t})},zE=e=>{let{className:t,label:r,onClick:i}=e;return Gt("button",{className:`deck-widget-icon-button ${t}`,type:"button",onClick:i,title:r,children:Gt("div",{className:"deck-widget-icon"})})};var b_=class{constructor(t){this.id="fullscreen",this.placement="top-left",this.fullscreen=!1,this.id=t.id||"fullscreen",this.placement=t.placement||"top-left",t.enterLabel=t.enterLabel||"Enter Fullscreen",t.exitLabel=t.exitLabel||"Exit Fullscreen",t.style=t.style||{},this.props=t}onAdd({deck:t}){let{style:r,className:i}=this.props,s=document.createElement("div");return s.classList.add("deck-widget","deck-widget-fullscreen"),i&&s.classList.add(i),r&&Object.entries(r).map(([n,o])=>s.style.setProperty(n,o)),this.deck=t,this.element=s,this.update(),document.addEventListener("fullscreenchange",this.onFullscreenChange.bind(this)),s}onRemove(){this.deck=void 0,this.element=void 0,document.removeEventListener("fullscreenchange",this.onFullscreenChange.bind(this))}update(){let{enterLabel:t,exitLabel:r}=this.props,i=this.element;if(!i)return;let s=Gt(lN,{onClick:this.handleClick.bind(this),label:this.fullscreen?r:t,className:this.fullscreen?"deck-widget-fullscreen-exit":"deck-widget-fullscreen-enter"});Tc(s,i)}setProps(t){let r=this.props,i=this.element;i&&(r.className!==t.className&&(r.className&&i.classList.remove(r.className),t.className&&i.classList.add(t.className)),vt(r.style,t.style,1)||(r.style&&Object.entries(r.style).map(([s])=>i.style.removeProperty(s)),t.style&&Object.entries(t.style).map(([s,n])=>i.style.setProperty(s,n)))),Object.assign(this.props,t)}getContainer(){return this.props.container||this.deck?.getCanvas()?.parentElement}onFullscreenChange(){let t=this.fullscreen,r=document.fullscreenElement===this.getContainer();t!==r&&(this.fullscreen=!this.fullscreen),this.update()}async handleClick(){this.fullscreen?await this.exitFullscreen():await this.requestFullscreen(),this.update()}async requestFullscreen(){let t=this.getContainer();t?.requestFullscreen?await t.requestFullscreen({navigationUI:"hide"}):this.togglePseudoFullscreen()}async exitFullscreen(){document.exitFullscreen?await document.exitFullscreen():this.togglePseudoFullscreen()}togglePseudoFullscreen(){this.getContainer()?.classList.toggle("deck-pseudo-fullscreen")}};var E_=class{constructor(t){this.id="compass",this.placement="top-left",this.viewId=null,this.id=t.id||"compass",this.viewId=t.viewId||null,this.placement=t.placement||"top-left",t.transitionDuration=t.transitionDuration||200,t.label=t.label||"Compass",t.style=t.style||{},this.props=t}setProps(t){Object.assign(this.props,t)}onViewportChange(t){this.viewport=t,this.update()}onAdd({deck:t}){let{style:r,className:i}=this.props,s=document.createElement("div");return s.classList.add("deck-widget","deck-widget-compass"),i&&s.classList.add(i),r&&Object.entries(r).map(([n,o])=>s.style.setProperty(n,o)),this.deck=t,this.element=s,this.update(),s}getRotation(){return this.viewport instanceof ne?[-this.viewport.bearing,this.viewport.pitch]:this.viewport instanceof Kr?[0,Math.max(-80,Math.min(80,this.viewport.latitude))]:[0,0]}update(){let[t,r]=this.getRotation(),i=this.element;if(!i)return;let s=Gt("div",{className:"deck-widget-button",style:{perspective:100},children:Gt("button",{type:"button",onClick:()=>this.handleCompassReset(),label:this.props.label,style:{transform:`rotateX(${r}deg)`},children:Gt("svg",{fill:"none",width:"100%",height:"100%",viewBox:"0 0 26 26",children:Gt("g",{transform:`rotate(${t},13,13)`,children:[Gt("path",{d:"M10 13.0001L12.9999 5L15.9997 13.0001H10Z",fill:"var(--icon-compass-north-color, #F05C44)"}),Gt("path",{d:"M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z",fill:"var(--icon-compass-south-color, #C2C2CC)"})]})})})});Tc(s,i)}onRemove(){this.deck=void 0,this.element=void 0}handleCompassReset(){let t=this.viewId||this.viewport?.id||"default-view";if(this.viewport instanceof ne){let r={...this.viewport,bearing:0,...this.getRotation()[0]===0?{pitch:0}:{},transitionDuration:this.props.transitionDuration,transitionInterpolator:new Qi};this.deck._onViewStateChange({viewId:t,viewState:r,interactionState:{}})}}};var S_=class{constructor(t){this.id="zoom",this.placement="top-left",this.orientation="vertical",this.viewId=null,this.id=t.id||"zoom",this.viewId=t.viewId||null,this.placement=t.placement||"top-left",this.orientation=t.orientation||"vertical",t.transitionDuration=t.transitionDuration||200,t.zoomInLabel=t.zoomInLabel||"Zoom In",t.zoomOutLabel=t.zoomOutLabel||"Zoom Out",t.style=t.style||{},this.props=t}onAdd({deck:t}){let{style:r,className:i}=this.props,s=document.createElement("div");s.classList.add("deck-widget","deck-widget-zoom"),i&&s.classList.add(i),r&&Object.entries(r).map(([o,a])=>s.style.setProperty(o,a));let n=Gt(uN,{orientation:this.orientation,children:[Gt(zE,{onClick:()=>this.handleZoomIn(),label:this.props.zoomInLabel,className:"deck-widget-zoom-in"}),Gt(zE,{onClick:()=>this.handleZoomOut(),label:this.props.zoomOutLabel,className:"deck-widget-zoom-out"})]});return Tc(n,s),this.deck=t,this.element=s,s}onRemove(){this.deck=void 0,this.element=void 0}setProps(t){Object.assign(this.props,t)}onViewportChange(t){this.viewport=t}handleZoom(t){let r=this.viewId||this.viewport?.id||"default-view",i={...this.viewport,zoom:t,transitionDuration:this.props.transitionDuration,transitionInterpolator:new Qi};this.deck._onViewStateChange({viewId:r,viewState:i,interactionState:{}})}handleZoomIn(){this.viewport&&this.handleZoom(this.viewport.zoom+1)}handleZoomOut(){this.viewport&&this.handleZoom(this.viewport.zoom-1)}};var $Z={"--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"},JZ={"--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"},ZZ={"--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"},QZ={"--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 eh=li(ef(),1);ns._checkH3Lib=()=>{let e='include the <script src="https://unpkg.com/h3-js@^4.0.0"></script> tag before the deck.gl script tag. https://deck.gl/docs/api-reference/geo-layers/h3-hexagon-layer';if(eh){if(eh.polyfill&&!eh.polygonToCells)throw new Error(`Incompatible h3-js version. ${e}`)}else throw new Error(`To use H3 functionality, ${e}`)};return WN(tQ);})();
return __exports__;
});