(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 k0=Object.create;var xi=Object.defineProperty;var D0=Object.getOwnPropertyDescriptor;var B0=Object.getOwnPropertyNames;var U0=Object.getPrototypeOf,L0=Object.prototype.hasOwnProperty;var V0=(e,t,r)=>t in e?xi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var z0=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rr=(e,t)=>{for(var r in t)xi(e,r,{get:t[r],enumerable:!0})},Xu=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of B0(t))!L0.call(e,i)&&i!==r&&xi(e,i,{get:()=>t[i],enumerable:!(s=D0(t,i))||s.enumerable});return e};var W0=(e,t,r)=>(r=e!=null?k0(U0(e)):{},Xu(t||!e||!e.__esModule?xi(r,"default",{value:e,enumerable:!0}):r,e)),j0=e=>Xu(xi({},"__esModule",{value:!0}),e);var B=(e,t,r)=>(V0(e,typeof t!="symbol"?t+"":t,r),r);var rm=z0((h5,fc)=>{(function(e,t,r,s){"use strict";var i=["","webkit","Moz","MS","ms","o"],n=t.createElement("div"),o="function",a=Math.round,c=Math.abs,l=Date.now;function h(d,p,T){return setTimeout(w(d,T),p)}function f(d,p,T){return Array.isArray(d)?(u(d,T[p],T),!0):!1}function u(d,p,T){var R;if(d)if(d.forEach)d.forEach(p,T);else if(d.length!==s)for(R=0;R\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",Y=e.console&&(e.console.warn||e.console.log);return Y&&Y.call(e.console,R,U),d.apply(this,arguments)}}var m;typeof Object.assign!="function"?m=function(p){if(p===s||p===null)throw new TypeError("Cannot convert undefined or null to object");for(var T=Object(p),R=1;R-1}function D(d){return d.trim().split(/\s+/g)}function N(d,p,T){if(d.indexOf&&!T)return d.indexOf(p);for(var R=0;RAt[p]}):R=R.sort()),R}function $(d,p){for(var T,R,C=p[0].toUpperCase()+p.slice(1),U=0;U1&&!T.firstMultiple?T.firstMultiple=Mu(p):C===1&&(T.firstMultiple=!1);var U=T.firstInput,Y=T.firstMultiple,pt=Y?Y.center:U.center,_t=p.center=Pu(R);p.timeStamp=l(),p.deltaTime=p.timeStamp-U.timeStamp,p.angle=kc(pt,_t),p.distance=_o(pt,_t),f0(T,p),p.offsetDirection=Cu(p.deltaX,p.deltaY);var At=Iu(p.deltaTime,p.deltaX,p.deltaY);p.overallVelocityX=At.x,p.overallVelocityY=At.y,p.overallVelocity=c(At.x)>c(At.y)?At.x:At.y,p.scale=Y?p0(Y.pointers,R):1,p.rotation=Y?d0(Y.pointers,R):0,p.maxPointers=T.prevInput?p.pointers.length>T.prevInput.maxPointers?p.pointers.length:T.prevInput.maxPointers:p.pointers.length,u0(T,p);var we=d.element;F(p.srcEvent.target,we)&&(we=p.srcEvent.target),p.target=we}function f0(d,p){var T=p.center,R=d.offsetDelta||{},C=d.prevDelta||{},U=d.prevInput||{};(p.eventType===xt||U.eventType===lt)&&(C=d.prevDelta={x:U.deltaX||0,y:U.deltaY||0},R=d.offsetDelta={x:T.x,y:T.y}),p.deltaX=C.x+(T.x-R.x),p.deltaY=C.y+(T.y-R.y)}function u0(d,p){var T=d.lastInterval||p,R=p.timeStamp-T.timeStamp,C,U,Y,pt;if(p.eventType!=It&&(R>a0||T.velocity===s)){var _t=p.deltaX-T.deltaX,At=p.deltaY-T.deltaY,we=Iu(R,_t,At);U=we.x,Y=we.y,C=c(we.x)>c(we.y)?we.x:we.y,pt=Cu(_t,At),d.lastInterval=p}else C=T.velocity,U=T.velocityX,Y=T.velocityY,pt=T.direction;p.velocity=C,p.velocityX=U,p.velocityY=Y,p.direction=pt}function Mu(d){for(var p=[],T=0;T=c(p)?d<0?gi:_i:p<0?mi:Ti}function _o(d,p,T){T||(T=vu);var R=p[T[0]]-d[T[0]],C=p[T[1]]-d[T[1]];return Math.sqrt(R*R+C*C)}function kc(d,p,T){T||(T=vu);var R=p[T[0]]-d[T[0]],C=p[T[1]]-d[T[1]];return Math.atan2(C,R)*180/Math.PI}function d0(d,p){return kc(p[1],p[0],go)+kc(d[1],d[0],go)}function p0(d,p){return _o(p[0],p[1],go)/_o(d[0],d[1],go)}var g0={mousedown:xt,mousemove:Cr,mouseup:lt},_0="mousedown",m0="mousemove mouseup";function mo(){this.evEl=_0,this.evWin=m0,this.pressed=!1,Ht.apply(this,arguments)}A(mo,Ht,{handler:function(p){var T=g0[p.type];T&xt&&p.button===0&&(this.pressed=!0),T&Cr&&p.which!==1&&(T=lt),this.pressed&&(T<&&(this.pressed=!1),this.callback(this.manager,T,{pointers:[p],changedPointers:[p],pointerType:Fc,srcEvent:p}))}});var T0={pointerdown:xt,pointermove:Cr,pointerup:lt,pointercancel:It,pointerout:It},y0={2:pi,3:n0,4:Fc,5:o0},Ou="pointerdown",Nu="pointermove pointerup pointercancel";e.MSPointerEvent&&!e.PointerEvent&&(Ou="MSPointerDown",Nu="MSPointerMove MSPointerUp MSPointerCancel");function Dc(){this.evEl=Ou,this.evWin=Nu,Ht.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}A(Dc,Ht,{handler:function(p){var T=this.store,R=!1,C=p.type.toLowerCase().replace("ms",""),U=T0[C],Y=y0[p.pointerType]||p.pointerType,pt=Y==pi,_t=N(T,p.pointerId,"pointerId");U&xt&&(p.button===0||pt)?_t<0&&(T.push(p),_t=T.length-1):U&(lt|It)&&(R=!0),!(_t<0)&&(T[_t]=p,this.callback(this.manager,U,{pointers:T,changedPointers:[p],pointerType:Y,srcEvent:p}),R&&T.splice(_t,1))}});var b0={touchstart:xt,touchmove:Cr,touchend:lt,touchcancel:It},E0="touchstart",x0="touchstart touchmove touchend touchcancel";function Fu(){this.evTarget=E0,this.evWin=x0,this.started=!1,Ht.apply(this,arguments)}A(Fu,Ht,{handler:function(p){var T=b0[p.type];if(T===xt&&(this.started=!0),!!this.started){var R=A0.call(this,p,T);T&(lt|It)&&R[0].length-R[1].length===0&&(this.started=!1),this.callback(this.manager,T,{pointers:R[0],changedPointers:R[1],pointerType:pi,srcEvent:p})}}});function A0(d,p){var T=L(d.touches),R=L(d.changedTouches);return p&(lt|It)&&(T=q(T.concat(R),"identifier",!0)),[T,R]}var S0={touchstart:xt,touchmove:Cr,touchend:lt,touchcancel:It},w0="touchstart touchmove touchend touchcancel";function To(){this.evTarget=w0,this.targetIds={},Ht.apply(this,arguments)}A(To,Ht,{handler:function(p){var T=S0[p.type],R=R0.call(this,p,T);R&&this.callback(this.manager,T,{pointers:R[0],changedPointers:R[1],pointerType:pi,srcEvent:p})}});function R0(d,p){var T=L(d.touches),R=this.targetIds;if(p&(xt|Cr)&&T.length===1)return R[T[0].identifier]=!0,[T,T];var C,U,Y=L(d.changedTouches),pt=[],_t=this.target;if(U=T.filter(function(At){return F(At.target,_t)}),p===xt)for(C=0;C-1&&R.splice(U,1)};setTimeout(C,v0)}}function P0(d){for(var p=d.srcEvent.clientX,T=d.srcEvent.clientY,R=0;R-1&&this.requireFail.splice(p,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(d){return!!this.simultaneous[d.id]},emit:function(d){var p=this,T=this.state;function R(C){p.manager.emit(C,d)}T=er&&R(p.options.event+zu(T))},tryEmit:function(d){if(this.canEmit())return this.emit(d);this.state=Se},canEmit:function(){for(var d=0;dp.threshold&&C&p.direction},attrTest:function(d){return ae.prototype.attrTest.call(this,d)&&(this.state&Xt||!(this.state&Xt)&&this.directionTest(d))},emit:function(d){this.pX=d.deltaX,this.pY=d.deltaY;var p=Wu(d.direction);p&&(d.additionalEvent=this.options.event+p),this._super.emit.call(this,d)}});function Vc(){ae.apply(this,arguments)}A(Vc,ae,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Nr]},attrTest:function(d){return this._super.attrTest.call(this,d)&&(Math.abs(d.scale-1)>this.options.threshold||this.state&Xt)},emit:function(d){if(d.scale!==1){var p=d.scale<1?"in":"out";d.additionalEvent=this.options.event+p}this._super.emit.call(this,d)}});function zc(){Le.apply(this,arguments),this._timer=null,this._input=null}A(zc,Le,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Vu]},process:function(d){var p=this.options,T=d.pointers.length===p.pointers,R=d.distancep.time;if(this._input=d,!R||!T||d.eventType&(lt|It)&&!C)this.reset();else if(d.eventType&xt)this.reset(),this._timer=h(function(){this.state=Ue,this.tryEmit()},p.time,this);else if(d.eventType<)return Ue;return Se},reset:function(){clearTimeout(this._timer)},emit:function(d){this.state===Ue&&(d&&d.eventType<?this.manager.emit(this.options.event+"up",d):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function Wc(){ae.apply(this,arguments)}A(Wc,ae,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Nr]},attrTest:function(d){return this._super.attrTest.call(this,d)&&(Math.abs(d.rotation)>this.options.threshold||this.state&Xt)}});function jc(){ae.apply(this,arguments)}A(jc,ae,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Ae|Or,pointers:1},getTouchAction:function(){return xo.prototype.getTouchAction.call(this)},attrTest:function(d){var p=this.options.direction,T;return p&(Ae|Or)?T=d.overallVelocity:p&Ae?T=d.overallVelocityX:p&Or&&(T=d.overallVelocityY),this._super.attrTest.call(this,d)&&p&d.offsetDirection&&d.distance>this.options.threshold&&d.maxPointers==this.options.pointers&&c(T)>this.options.velocity&&d.eventType<},emit:function(d){var p=Wu(d.offsetDirection);p&&this.manager.emit(this.options.event+p,d),this.manager.emit(this.options.event,d)}});function Ao(){Le.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}A(Ao,Le,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Uc]},process:function(d){var p=this.options,T=d.pointers.length===p.pointers,R=d.distanceqs,Attribute:()=>tr,AttributeManager:()=>cs,COORDINATE_SYSTEM:()=>X,CompositeLayer:()=>qm,Controller:()=>vt,Deck:()=>dc,DeckGL:()=>fo,DeckRenderer:()=>rs,DirectionalLight:()=>$e,FirstPersonController:()=>gs,FirstPersonView:()=>Qm,FirstPersonViewport:()=>ds,FlyToInterpolator:()=>lo,Layer:()=>wc,LayerExtension:()=>e0,LayerManager:()=>Gr,LightingEffect:()=>Er,LinearInterpolator:()=>mt,MapController:()=>es,MapView:()=>Wa,OPERATION:()=>Og,OrbitController:()=>_s,OrbitView:()=>Jm,OrbitViewport:()=>fs,OrthographicController:()=>ms,OrthographicView:()=>Gm,OrthographicViewport:()=>us,PointLight:()=>Gs,PostProcessEffect:()=>En,TRANSITION_EVENTS:()=>wn,Tesselator:()=>ho,TransitionInterpolator:()=>Qe,UNIT:()=>ln,VERSION:()=>Ra,View:()=>Rt,Viewport:()=>kt,WebMercatorViewport:()=>Js,_CameraLight:()=>Tn,_Component:()=>fi,_ComponentState:()=>ls,_GlobeController:()=>Ts,_GlobeView:()=>t0,_GlobeViewport:()=>hs,_LayersPass:()=>ge,_PickLayersPass:()=>Ye,_SunLight:()=>yn,_compareProps:()=>xc,_count:()=>Ac,_deepEqual:()=>at,_fillArray:()=>La,_flatten:()=>Ar,_memoize:()=>te,_mergeShaders:()=>eo,_registerLoggers:()=>wa,assert:()=>rt,createIterable:()=>li,fp64LowPart:()=>jf,getShaderAssembler:()=>Na,gouraudLighting:()=>fa,log:()=>j,phongLighting:()=>ua,picking:()=>zf,project:()=>yr,project32:()=>Nf,shadow:()=>Ys});var Gh={};rr(Gh,{Buffer:()=>V,BufferTransform:()=>Zt,CubeGeometry:()=>Zi,Device:()=>Bt,Framebuffer:()=>Re,Geometry:()=>fe,GroupNode:()=>zr,Model:()=>zt,ModelNode:()=>Ki,ScenegraphNode:()=>Pe,SphereGeometry:()=>Qi,Texture:()=>G,TextureTransform:()=>Yi,attachDevice:()=>fE,createDevice:()=>uE,enforceWebGL2:()=>dE,getAvailableDevices:()=>cE,getSupportedDevices:()=>lE,registerDevices:()=>aE,setDefaultDeviceProps:()=>hE,stats:()=>oE});var So=globalThis,H0=globalThis.document||{},wo=globalThis.process||{},X0=globalThis.console,$u=globalThis.navigator||{};function Ro(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 Tt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Ro()}function Xc(e){return!e&&!Tt()?"Node":Ro(e)?"Electron":(e||$u.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var $c="4.0.7";function Y0(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var vo=class{constructor(t,r,s="sessionStorage"){this.storage=Y0(s),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 Yu(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 qu(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}var Mo;(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"})(Mo||(Mo={}));var q0=10;function Ku(e){return typeof e!="string"?e:(e=e.toUpperCase(),Mo[e]||Mo.WHITE)}function Zu(e,t,r){return!Tt&&typeof e=="string"&&(t&&(e=`\x1B[${Ku(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${Ku(r)+q0}m${e}\x1B[49m`)),e}function Qu(e,t=["constructor"]){let r=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(r),i=e;for(let n of s){let o=i[n];typeof o=="function"&&(t.find(a=>n===a)||(i[n]=o.bind(e)))}}function Ai(e,t){if(!e)throw new Error(t||"Assertion failed")}function Fr(){let e;if(Tt()&&So.performance)e=So?.performance?.now?.();else if("hrtime"in wo){let t=wo?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var bs={debug:Tt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},K0={enabled:!0,level:0};function Es(){}var Ju={},Gu={once:!0},Ct=class{constructor({id:t}={id:""}){this.VERSION=$c,this._startTs=Fr(),this._deltaTs=Fr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new vo(`__probe-${this.id}__`,K0),this.timeStamp(`${this.id} started`),Qu(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((Fr()-this._startTs).toPrecision(10))}getDelta(){return Number((Fr()-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,bs.warn,arguments,Gu)}error(t){return this._getLogFunction(0,t,bs.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,bs.log,arguments,{time:!0,once:!0})}log(t,r){return this._getLogFunction(t,r,bs.debug,arguments)}info(t,r){return this._getLogFunction(t,r,console.info,arguments)}once(t,r){return this._getLogFunction(t,r,bs.debug||bs.info,arguments,Gu)}table(t,r,s){return r?this._getLogFunction(t,r,console.table||Es,s&&[s],{tag:Q0(r)}):Es}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||Es)}group(t,r,s={collapsed:!1}){let i=td({logLevel:t,message:r,opts:s}),{collapsed:n}=s;return i.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(t,r,s={}){return this.group(t,r,Object.assign({},s,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||Es)}withGroup(t,r,s){this.group(t,r)();try{s()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=ed(t)}_getLogFunction(t,r,s,i,n){if(this._shouldLog(t)){n=td({logLevel:t,message:r,args:i,opts:n}),s=s||n.method,Ai(s),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=Fr();let o=n.tag||n.message;if(n.once&&o)if(!Ju[o])Ju[o]=Fr();else return Es;return r=Z0(this.id,n.message,n),s.bind(console,r,...n.args)}return Es}};Ct.VERSION=$c;function ed(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 Ai(Number.isFinite(t)&&t>=0),t}function td(e){let{logLevel:t,message:r}=e;e.logLevel=ed(t);let s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&s.unshift(r),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let i=typeof e.message;return Ai(i==="string"||i==="object"),Object.assign(e,{args:s},e.opts)}function Z0(e,t,r){if(typeof t=="string"){let s=r.time?qu(Yu(r.total)):"";t=r.time?`${e}: ${s} ${t}`:`${e}: ${t}`,t=Zu(t,r.color,r.background)}return t}function Q0(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var M3=new Ct({id:"@probe.gl/log"});var P=new Ct({id:"luma.gl"});function Si(){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 kr=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=Si(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Si()-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 $t=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:s}=t,i=this.stats[r];return i||(t instanceof kr?i=t:i=new kr(r,s),this.stats[r]=i),i}};var Yc=class{stats=new Map;getStats(t){return this.get(t)}get(t){return this.stats.has(t)||this.stats.set(t,new $t({id:t})),this.stats.get(t)}},xs=new Yc;function J0(){let e="9.0.27",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||(Tt()&&P.log(1,`${e} - ${t}`)(),globalThis.luma=globalThis.luma||{VERSION:e,version:e,log:P,stats:xs}),e}var rd=J0();function G0(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)?e:null}function sr(e){return Array.isArray(e)?e.length===0||typeof e[0]=="number"?e:null:G0(e)}var qc={};function ot(e="id"){qc[e]=qc[e]||1;let t=qc[e]++;return`${e}-${t}`}function ir(e){let t=!0;for(let r in e){t=!1;break}return t}var W=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(t,r,s){if(!t)throw new Error("no device");this._device=t,this.props=tT(r,s);let i=this.props.id!=="undefined"?this.props.id:ot(this[Symbol.toStringTag]);this.props.id=i,this.id=i,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 s=this._device.statsManager.getStats("Resource Counts");s.get("GPU Memory").addCount(t),s.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()}};B(W,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function tT(e,t){let r={...t};for(let s in e)e[s]!==void 0&&(r[s]=e[s]);return r}var wi=class extends W{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(t,r){let s={...r};(r.usage||0)&wi.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?s.indexType="uint32":r.data instanceof Uint16Array&&(s.indexType="uint16")),super(t,s,wi.defaultProps),this.usage=r.usage||0,this.indexType=s.indexType,this.updateTimestamp=t.incrementTimestamp()}readSyncWebGL(t,r){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(t,r,s){let i=ArrayBuffer.isView(t)?t.buffer:t,n=Math.min(t?t.byteLength:s,wi.DEBUG_DATA_MAX_LENGTH);t===null?this.debugData=new ArrayBuffer(n):r===0&&s===t.byteLength?this.debugData=i.slice(0,n):this.debugData=i.slice(r,r+n)}},V=wi;B(V,"defaultProps",{...W.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),B(V,"MAP_READ",1),B(V,"MAP_WRITE",2),B(V,"COPY_SRC",4),B(V,"COPY_DST",8),B(V,"INDEX",16),B(V,"VERTEX",32),B(V,"UNIFORM",64),B(V,"STORAGE",128),B(V,"INDIRECT",256),B(V,"QUERY_RESOLVE",512),B(V,"DEBUG_DATA_MAX_LENGTH",32);function Po(e){let t=sd[e],r=eT(t),s=e.includes("norm"),i=!s&&!e.startsWith("float"),n=e.startsWith("s");return{dataType:sd[e],byteLength:r,integer:i,signed:n,normalized:s}}function eT(e){return rT[e]}var sd={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},rT={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var sT=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],iT=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function id(e){return sT.some(t=>e.startsWith(t))}function Io(e){let t=iT.exec(e);if(t){let[,r,s,i,n,o]=t;if(r){let a=`${i}${s}`,c=Po(a);return{format:r,components:r.length,srgb:n==="-srgb",unsized:o==="-unsized",webgl:o==="-webgl",...c}}}return oT(e)}var nT={"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 oT(e){let t=nT[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 Ri=class{},vi=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)}},Kc=class{get[Symbol.toStringTag](){return"Device"}constructor(t){this.props={...Kc.defaultProps,...t},this.id=this.props.id||ot(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=xs;_lumaData={};isTextureFormatCompressed(t){return id(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)&V.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?r.indexType="uint32":t.data instanceof Uint16Array?r.indexType="uint16":P.warn("indices buffer content must be of integer type")()),r}},Bt=Kc;B(Bt,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(P.get("debug")),spector:Boolean(P.get("spector")||P.get("spectorjs")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:t=>P.error(t.message)}),B(Bt,"VERSION",rd);function z(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}var Mi=new Map,Zc=class{static registerDevices(t){for(let r of t)z(r.type&&r.isSupported&&r.create),Mi.set(r.type,r)}static getAvailableDevices(){return Array.from(Mi).map(t=>t.type)}static getSupportedDevices(){return Array.from(Mi).filter(t=>t.isSupported()).map(t=>t.type)}static setDefaultDeviceProps(t){Object.assign(Bt.defaultProps,t)}static async attachDevice(t){let r=nd(t.devices)||Mi;if(t.handle instanceof WebGL2RenderingContext){let s=r.get("webgl");if(s)return await s.attach(t.handle)}if(t.handle===null){let s=r.get("unknown");if(s)return await s.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(t={}){t={...Zc.defaultProps,...t},t.gl&&(t.type="webgl");let r=nd(t.devices)||Mi,s,i;switch(t.type){case"webgpu":if(s=r.get("webgpu"),s)return await s.create(t);break;case"webgl":if(i=r.get("webgl"),i)return await i.create(t);break;case"unknown":let n=r.get("unknown");if(n)return await n.create(t);break;case"best-available":if(s=r.get("webgpu"),s?.isSupported?.())return await s.create(t);if(i=r.get("webgl"),i?.isSupported?.())return await i.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(s,i){return s==="webgl"||s==="experimental-webgl"?this.originalGetContext("webgl2",i):this.originalGetContext(s,i)}}},Ot=Zc;B(Ot,"defaultProps",{...Bt.defaultProps,type:"best-available",devices:void 0}),B(Ot,"stats",xs),B(Ot,"log",P);function nd(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 aT=Tt()&&typeof document<"u",Co=()=>aT&&document.readyState==="complete",cT={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},nr=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return Co()}constructor(t){if(this.props={...cT,...t},t=this.props,!Tt()){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=fT(t.canvas):this.canvas=t.canvas;else{let r=uT(t),s=hT(t?.container||null);s.insertBefore(r,s.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 s of r)s.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 s=this.cssToDeviceRatio(),[i,n]=this.getDrawingBufferSize();return dT(t,s,i,n,r)}setDevicePixelRatio(t,r={}){if(!this.htmlCanvas)return;let s="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!s||!i)&&(P.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,s=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let n=this._canvasSizeInfo;if(n.clientWidth!==s||n.clientHeight!==i||n.devicePixelRatio!==t){let o=t,a=Math.floor(s*o),c=Math.floor(i*o);this.htmlCanvas.width=a,this.htmlCanvas.height=c;let[l,h]=this.getDrawingBufferSize();(l!==a||h!==c)&&(o=Math.min(l/s,h/i),this.htmlCanvas.width=Math.floor(s*o),this.htmlCanvas.height=Math.floor(i*o),P.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=s,this._canvasSizeInfo.clientHeight=i,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)}};B(nr,"pageLoaded",lT());function lT(){return Co()||typeof window>"u"?Promise.resolve():new Promise(e=>{window.addEventListener("load",()=>e())})}function hT(e){if(typeof e=="string"){let t=document.getElementById(e);if(!t&&!Co())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 fT(e){let t=document.getElementById(e);if(!t&&!Co())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 uT(e){let{width:t,height:r}=e,s=document.createElement("canvas");return s.id="lumagl-auto-created-canvas",s.width=t||1,s.height=r||1,s.style.width=Number.isFinite(t)?`${t}px`:"100%",s.style.height=Number.isFinite(r)?`${r}px`:"100%",s}function dT(e,t,r,s,i){let n=e,o=od(n[0],t,r),a=ad(n[1],t,s,i),c=od(n[0]+1,t,r),l=c===r-1?c:c-1;c=ad(n[1]+1,t,s,i);let h;return i?(c=c===0?c:c+1,h=a,a=c):h=c===s-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(h-a+1,1)}}function od(e,t,r){return Math.min(Math.round(e*t),r-1)}function ad(e,t,r,s){return s?Math.max(0,r-1-Math.round(e*t)):Math.min(Math.round(e*t),r-1)}var Qc=class extends W{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(t,r,s=Qc.defaultProps){super(t,r,s),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=t.incrementTimestamp()}},G=Qc;B(G,"defaultProps",{...W.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}),B(G,"COPY_SRC",1),B(G,"COPY_DST",2),B(G,"TEXTURE_BINDING",4),B(G,"STORAGE_BINDING",8),B(G,"RENDER_ATTACHMENT",16);var Jc=class extends W{get[Symbol.toStringTag](){return"TextureView"}constructor(t,r){super(t,r,Jc.defaultProps)}},or=Jc;B(or,"defaultProps",{...W.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function ld(e,t,r){let s="",i=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<=i.length;a++)for(s+=hd(i[a-1],a,r);n.length>o&&n[o].lineNum===a;){let c=n[o++];s+=cd(c,i,c.lineNum,{...r,inlineSource:!1})}return s;case"issues":case"no":for(let a of e)s+=cd(a,i,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return s}}function cd(e,t,r,s){if(s?.inlineSource){let i=pT(t,r),n=e.linePos>0?`${" ".repeat(e.linePos+5)}^^^ `:"";return` ${i}${n}${e.type.toUpperCase()}: ${e.message} `}return s?.html?`
${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function pT(e,t,r){let s="";for(let i=t-2;i<=t;i++){let n=e[i-1];n!==void 0&&(s+=hd(n,t,r))}return s}function hd(e,t,r){let s=r?.html?_T(e):e;return`${gT(String(t),4)}: ${s}${r?.html?"
":` `}`}function gT(e,t){let r="";for(let s=e.length;s",">").replaceAll('"',""").replaceAll("'","'")}function Gc(e,t){return{name:mT(e,t),language:"glsl",version:TT(e)}}function mT(e,t="unnamed"){let s=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return s?s[1]:t}function TT(e){let t=100,r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let s=parseInt(r[1],10);Number.isFinite(s)&&(t=s)}return t}var tl=class extends W{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(t,r){super(t,{id:yT(r),...r},tl.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=Gc(this.source).name,s=`${this.stage} ${r}`,i=ld(t,this.source,{showSourceCode:"all",html:!0}),n=this.getTranslatedSource();n&&(i+=`

Translated Source



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

Shader Compilation Error in ${s}



${i}
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);let a=document.getElementsByClassName("luma-compiler-log-error");a[0]?.scrollIntoView&&a[0].scrollIntoView(),o.onclick=()=>{let c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}},ar=tl;B(ar,"defaultProps",{...W.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function yT(e){return Gc(e.source).name||e.id||ot(`unnamed ${e.stage}-shader`)}var el=class extends W{get[Symbol.toStringTag](){return"Sampler"}constructor(t,r){super(t,r,el.defaultProps)}},cr=el;B(cr,"defaultProps",{...W.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 rl=class extends W{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(t,r={}){super(t,r,rl.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(t){let r=!t;if(t){let[s,i]=Array.isArray(t)?t:[t.width,t.height];r=r||i!==this.height||s!==this.width,this.width=s,this.height=i}r&&(P.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(r=>{if(typeof r=="string"){let s=this.createColorTexture(r);return this.attachResource(s),s.view}return r instanceof G?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 G?this.depthStencilAttachment=t.view:this.depthStencilAttachment=t}createColorTexture(t){return this.device.createTexture({id:"color-attachment",usage:G.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}createDepthStencilTexture(t){return this.device.createTexture({id:"depth-stencil-attachment",usage:G.RENDER_ATTACHMENT,format:t,width:this.width,height:this.height})}resizeAttachments(t,r){for(let s=0;s":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},xT={f32:4,f16:2,i32:4,u32:4};function cl(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);let[r,s]=e.split("x"),i=r,n=s?parseInt(s):1,o=Po(i),a={type:i,components:n,byteLength:o.byteLength*n,integer:o.integer,signed:o.signed,normalized:o.normalized};return t&&(a.webglOnly=!0),a}function Oo(e,t){let r={};for(let s of e.attributes)r[s.name]=AT(e,t,s.name);return r}function ud(e,t,r=16){let s=Oo(e,t),i=new Array(r).fill(null);for(let n of Object.values(s))i[n.location]=n;return i}function AT(e,t,r){let s=ST(e,r),i=wT(t,r);if(!s)return null;let n=fd(s.type),o=i?.vertexFormat||n.defaultVertexFormat,a=cl(o);return{attributeName:i?.attributeName||s.name,bufferName:i?.bufferName||s.name,location:s.location,shaderType:s.type,shaderDataType:n.dataType,shaderComponents:n.components,vertexFormat:o,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:n.integer,stepMode:i?.stepMode||s.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function ST(e,t){let r=e.attributes.find(s=>s.name===t);return r||P.warn(`shader layout attribute "${t}" not present in shader`),r||null}function wT(e,t){RT(e);let r=vT(e,t);return r||(r=MT(e,t),r)?r:(P.warn(`layout for attribute "${t}" not present in buffer layout`),null)}function RT(e){for(let t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&P.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function vT(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 MT(e,t){for(let r of e){let s=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let o=cl(n.format);s+=o.byteLength}let i=r.attributes?.find(n=>n.attribute===t);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:s}}return null}function ll(e,t){let r={...e,attributes:e.attributes.map(s=>({...s}))};for(let s of t?.attributes||[]){let i=r.attributes.find(n=>n.name===s.name);i?(i.type=s.type||i.type,i.stepMode=s.stepMode||i.stepMode):P.warn(`shader layout attribute ${s.name} not present in shader`)}return r}var hl=class extends W{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(t,r){super(t,r,hl.defaultProps),this.maxVertexAttributes=t.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=ud(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(t,r){throw new Error("constant attributes not supported")}},Rs=hl;B(Rs,"defaultProps",{...W.defaultProps,renderPipeline:null});var fl=class extends W{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(t,r){super(t,r,fl.defaultProps)}},vs=fl;B(vs,"defaultProps",{...W.defaultProps,layout:void 0,buffers:{}});var ul=class extends W{get[Symbol.toStringTag](){return"QuerySet"}constructor(t,r){super(t,r,ul.defaultProps)}},Ms=ul;B(Ms,"defaultProps",{...W.defaultProps,type:void 0,count:void 0});var PT={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function dd(e){let t=PT[e];return z(e),t}function pd(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}var No;function Fo(e){return(!No||No.byteLengthi.type==="uniform"&&i.name===t?.name);if(!r)throw new Error(t?.name);let s=r;for(let i of s.uniforms||[])this.bindingLayout[i.name]=i}}setUniforms(t){for(let[r,s]of Object.entries(t))this._setUniform(r,s),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${s}`)}setNeedsRedraw(t){this.needsRedraw=this.needsRedraw||t}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(t,r){_d(this.uniforms[t],r)||(this.uniforms[t]=md(r),this.modifiedUniforms[t]=!0,this.modified=!0)}};var Pi=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(t){for(let[r,s]of Object.entries(t)){let i=r,n=new ko(s.uniformTypes||{});this.uniformBufferLayouts.set(i,n);let o=new Do({name:r});o.setUniforms(s.defaultUniforms||{}),this.uniformBlocks.set(i,o)}}destroy(){for(let t of this.uniformBuffers.values())t.destroy()}setUniforms(t){for(let[r,s]of Object.entries(t))this.uniformBlocks.get(r).setUniforms(s);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,s){s&&this.setUniforms(s);let i=this.getUniformBufferByteLength(r),n=t.createBuffer({usage:V.UNIFORM|V.COPY_DST,byteLength:i}),o=this.getUniformBufferData(r);return n.write(o),n}getManagedUniformBuffer(t,r){if(!this.uniformBuffers.get(r)){let s=this.getUniformBufferByteLength(r),i=t.createBuffer({usage:V.UNIFORM|V.COPY_DST,byteLength:s});this.uniformBuffers.set(r,i)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let t=!1;for(let r of this.uniformBlocks.keys()){let s=this.updateUniformBuffer(r);t||=s}return t&&P.log(3,`UniformStore.updateUniformBuffers(): ${t}`)(),t}updateUniformBuffer(t){let r=this.uniformBlocks.get(t),s=this.uniformBuffers.get(t),i=!1;if(s&&r.needsRedraw){i||=r.needsRedraw;let n=this.getUniformBufferData(t);this.uniformBuffers.get(t).write(n);let a=this.uniformBlocks.get(t).getAllUniforms();P.log(4,`Writing to uniform buffer ${String(t)}`,n,a)()}return i}};function Bo(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 Ii(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 gl(e,t,r){if(!t||t>4)throw new Error(`size ${t}`);let s=t,i=Bo(e);if(i==="uint8"&&r&&s===1)return"unorm8-webgl";if(i==="uint8"&&r&&s===3)return"unorm8x3-webgl";if(i==="uint8"||i==="sint8"){if(s===1||s===3)throw new Error(`size: ${t}`);return r&&(i=i.replace("int","norm")),`${i}x${s}`}if(i==="uint16"||i==="sint16"){if(s===1||s===3)throw new Error(`size: ${t}`);return r&&(i=i.replace("int","norm")),`${i}x${s}`}return s===1?i:`${i}x${s}`}function Td(e){return sr(e)!==null||typeof e=="number"||typeof e=="boolean"}function Br(e){let t={bindings:{},uniforms:{}};return Object.keys(e).forEach(r=>{let s=e[r];Td(s)?t.uniforms[r]=s:t.bindings[r]=s}),t}function _l(e,t,r){let{removedProps:s={},deprecatedProps:i={},replacedProps:n={}}=r;for(let a in s)if(a in t){let l=s[a]?`${e}.${s[a]}`:"N/A";P.removed(`${e}.${a}`,l)()}for(let a in i)if(a in t){let c=i[a];P.deprecated(`${e}.${a}`,`${e}.${c}`)()}let o=null;for(let[a,c]of Object.entries(n))a in t&&(P.deprecated(`${e}.${a}`,`${e}.${c}`)(),o=o||Object.assign({},t),o[c]=t[a],delete o[a]);return o||t}var IT="";async function ml(e,t){return await new Promise((r,s)=>{try{let i=new Image;i.onload=()=>r(i),i.onerror=()=>s(new Error(`Could not load image ${e}.`)),i.crossOrigin=t?.crossOrigin||"anonymous",i.src=e.startsWith("http")?e:IT+e}catch(i){s(i)}})}async function Ci(e,t){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let s=document.createElement("script");return s.setAttribute("type","text/javascript"),s.setAttribute("src",e),t&&(s.id=t),new Promise((i,n)=>{s.onload=i,s.onerror=o=>n(new Error(`Unable to load script '${e}': ${o}`)),r.appendChild(s)})}function Oi(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 s=0;s=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 i of r)this._setChannelTime(i,this.time);let s=this.animations.values();for(let i of s){let{animation:n,channel:o}=i;n.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,r){let s=OT++;return this.animations.set(s,{animation:t,channel:r}),t.setTime(this.getTime(r)),s}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 s=r-t.delay,i=t.duration*t.repeat;s>=i?t.time=t.duration*t.rate:(t.time=Math.max(0,s)%t.duration,t.time*=t.rate)}};var NT=0,FT={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:Ot.stats.get(`animation-loop-${NT++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},Ni=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={...FT,...t},t=this.props,!t.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=t.stats||new $t({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=Tl(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(yl(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:s}=this._getSizeAndAspect();(t!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),s!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=r,this.animationProps.aspect=s,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let 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 s=this.props.onAddHTML(r);s&&(r.innerHTML=s)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[t,r]=this.device?.canvasContext?.getPixelSize()||[1,1],s=1,i=this.device?.canvasContext?.canvas;return i&&i.clientHeight?s=i.clientWidth/i.clientHeight:t>0&&r>0&&(s=t/r),{width:t,height:r,aspect:s}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(t){t instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[t.offsetX,t.offsetY])}_onMouseleave(t){this._getAnimationProps()._mousePosition=null}};function ve(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var bl={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 bd(e){let t={};for(let[r,s]of Object.entries(e))t[r]=kT(s);return t}function Ed(e,t,r){let s={};for(let[i,n]of Object.entries(t))e&&i in e&&!n.private?(n.validate&&ve(n.validate(e[i],n),`${r}: invalid ${i}`),s[i]=e[i]):s[i]=n.value;return s}function kT(e){let t=yd(e);if(t!=="object")return{value:e,...bl[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...bl[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=yd(e.value),{...e,...bl[t],type:t}):{type:"object",value:null};throw new Error("props")}function yd(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var xd=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif `,Ad=`#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 DT={vertex:xd,fragment:Ad},Sd=/void\s+main\s*\([^)]*\)\s*\{\n?/,wd=/}\n?[^{}]*$/,El=[],Fi="__LUMA_INJECT_DECLARATIONS__";function Rd(e){let t={vertex:{},fragment:{}};for(let r in e){let s=e[r],i=BT(r);typeof s=="string"&&(s={order:0,injection:s}),t[i][r]=s}return t}function BT(e){let t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function ki(e,t,r,s=!1){let i=t==="vertex";for(let n in r){let o=r[n];o.sort((c,l)=>c.order-l.order),El.length=o.length;for(let c=0,l=o.length;cc+a));break;case"vs:#main-end":i&&(e=e.replace(wd,c=>a+c));break;case"fs:#decl":i||(e=e.replace(Fi,a));break;case"fs:#main-start":i||(e=e.replace(Sd,c=>c+a));break;case"fs:#main-end":i||(e=e.replace(wd,c=>a+c));break;default:e=e.replace(n,c=>c+a)}}return e=e.replace(Fi,""),s&&(e=e.replace(/\}\s*$/,n=>n+DT[t])),e}var UT=1,Ut=class{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(t){return t.map(r=>{if(r instanceof Ut)return r;ve(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-${UT++}`);let s=new Ut(r);return s.dependencies=Ut.instantiateModules(r.dependencies||[]),s})}constructor(t){let{name:r,vs:s,fs:i,dependencies:n=[],uniformTypes:o={},uniformPropTypes:a={},getUniforms:c,deprecations:l=[],defines:h={},inject:f={}}=t;ve(typeof r=="string"),this.name=r,this.vs=s,this.fs=i,this.getModuleUniforms=c,this.dependencies=Ut.instantiateModules(n),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=h,this.injections=Rd(f),this.uniformTypes=o,a&&(this.uniforms=bd(a))}getModuleSource(t){let r;switch(t){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:ve(!1)}let s=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} --------------- #define MODULE_${s} ${r} `}getUniforms(t,r){return this.getModuleUniforms?this.getModuleUniforms(t,r):Ed(t,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(t,r){this.deprecations.forEach(s=>{s.regex?.test(t)&&(s.deprecated?r.deprecated(s.old,s.new)():r.removed(s.old,s.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={},s=this.uniforms;for(let i in s){let n=s[i];i in t&&!n.private?(n.validate&&ve(n.validate(t[i],n),`${this.name}: invalid ${i}`),r[i]=t[i]):r[i]=n.value}return r}};function xl(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=vd(e.platformInfo,e.vs),r;return e.fs&&(r=vd(e.platformInfo,e.fs)),{...e,vs:t,fs:r}}function vd(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 Lr(e){let t=Ut.instantiateModules(e);return LT(t)}function LT(e){let t={},r={};return Md({modules:e,level:0,moduleMap:t,moduleDepth:r}),Object.keys(r).sort((s,i)=>r[i]-r[s]).map(s=>t[s])}function Md(e){let{modules:t,level:r,moduleMap:s,moduleDepth:i}=e;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let n of t)s[n.name]=n,(i[n.name]===void 0||i[n.name]o.order-a.order);for(let o of n)r+=` ${o.injection} `}i.footer&&(r+=` ${i.footer}`),r+=`} `}return r}function wl(e){let t={vertex:{},fragment:{}};for(let r of e){let s,i;typeof r!="string"?(s=r,i=s.hook):(s={},i=r),i=i.trim();let[n,o]=i.split(":"),a=i.replace(/\(.+/,""),c=Object.assign(s,{signature:o});switch(n){case"vs":t.vertex[a]=c;break;case"fs":t.fragment[a]=c;break;default:throw new Error(n)}}return t}function Nd(e,t){return{name:WT(e,t),language:"glsl",version:jT(e)}}function WT(e,t="unnamed"){let s=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return s?s[1]:t}function jT(e){let t=100,r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let s=parseInt(r[1],10);Number.isFinite(s)&&(t=s)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}var kd=` ${Fi} `,HT=`precision highp float; `;function Dd(e){let t=Lr(e.modules||[]);return{source:Rl(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:vl(t)}}function Bd(e){let t=Lr(e.modules||[]);return{vs:Rl(e.platformInfo,{...e,source:e.vs,stage:"vertex",modules:t}),fs:Rl(e.platformInfo,{...e,source:e.fs,stage:"fragment",modules:t}),getUniforms:vl(t)}}function Ud(e){let{vs:t,fs:r}=e,s=Lr(e.modules||[]);return{vs:Fd(e.platformInfo,{...e,source:t,stage:"vertex",modules:s}),fs:Fd(e.platformInfo,{...e,source:r,stage:"fragment",modules:s}),getUniforms:vl(s)}}function Rl(e,t){let{source:r,stage:s,modules:i,hookFunctions:n=[],inject:o={},log:a}=t;ve(typeof r=="string","shader source must be a string");let c=r,l="",h=wl(n),f={},u={},_={};for(let b in o){let y=typeof o[b]=="string"?{injection:o[b],order:0}:o[b],A=/^(v|f)s:(#)?([\w-]+)$/.exec(b);if(A){let w=A[2],v=A[3];w?v==="decl"?u[b]=[y]:_[b]=[y]:f[b]=[y]}else _[b]=[y]}let m=e.type!=="webgpu"?i:[];for(let b of m){a&&b.checkDeprecations(c,a);let y=b.getModuleSource(s,"wgsl");l+=y;let A=b.injections[s];for(let w in A){let v=/^(v|f)s:#([\w-]+)$/.exec(w);if(v){let I=v[2]==="decl"?u:_;I[w]=I[w]||[],I[w].push(A[w])}else f[w]=f[w]||[],f[w].push(A[w])}}return l+=kd,l=ki(l,s,u),l+=Sl(h[s],f),l+=c,l=ki(l,s,_),l}function Fd(e,t){let{id:r,source:s,stage:i,language:n="glsl",modules:o,defines:a={},hookFunctions:c=[],inject:l={},prologue:h=!0,log:f}=t;ve(typeof s=="string","shader source must be a string");let u=n==="glsl"?Nd(s).version:-1,_=e.shaderLanguageVersion,m=u===100?"#version 100":"#version 300 es",y=s.split(` `).slice(1).join(` `),A={};o.forEach(F=>{Object.assign(A,F.getDefines())}),Object.assign(A,a);let w="";switch(n){case"wgsl":break;case"glsl":w=h?`${m} // ----- PROLOGUE ------------------------- ${XT({id:r,source:s,stage:i})} ${`#define SHADER_TYPE_${i.toUpperCase()}`} ${Pd(e)} ${i==="fragment"?HT:""} // ----- APPLICATION DEFINES ------------------------- ${$T(A)} `:`${m} `;break}let v=wl(c),M={},I={},O={};for(let F in l){let k=typeof l[F]=="string"?{injection:l[F],order:0}:l[F],D=/^(v|f)s:(#)?([\w-]+)$/.exec(F);if(D){let N=D[2],L=D[3];N?L==="decl"?I[F]=[k]:O[F]=[k]:M[F]=[k]}else O[F]=[k]}for(let F of o){f&&F.checkDeprecations(y,f);let k=F.getModuleSource(i);w+=k;let D=F.injections[i];for(let N in D){let L=/^(v|f)s:#([\w-]+)$/.exec(N);if(L){let $=L[2]==="decl"?I:O;$[N]=$[N]||[],$[N].push(D[N])}else M[N]=M[N]||[],M[N].push(D[N])}}return w+="// ----- MAIN SHADER SOURCE -------------------------",w+=kd,w=ki(w,i,I),w+=Sl(v[i],M),w+=y,w=ki(w,i,O),n==="glsl"&&u!==_&&(w=Cd(w,i)),w.trim()}function vl(e){return function(r){let s={};for(let i of e){let n=i.getUniforms(r,s);Object.assign(s,n)}return s}}function XT(e){let{id:t,source:r,stage:s}=e;return t&&r.indexOf("SHADER_NAME")===-1?` #define SHADER_NAME ${t}_${s} `:""}function $T(e={}){let t="";for(let r in e){let s=e[r];(s||Number.isFinite(s))&&(t+=`#define ${r.toUpperCase()} ${e[r]} `)}return t}var Ps=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Ps.defaultShaderAssembler=Ps.defaultShaderAssembler||new Ps,Ps.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(s=>s.name!==r)}addShaderHook(t,r){r&&(t=Object.assign(r,{hook:t})),this._hookFunctions.push(t)}assembleShader(t){let r=this._getModuleList(t.modules),s=this._hookFunctions,i=xl(t);return{...Dd({platformInfo:t.platformInfo,...i,modules:r,hookFunctions:s}),modules:r}}assembleShaderPair(t){let r=xl(t),s=this._getModuleList(t.modules),i=this._hookFunctions,{platformInfo:n}=t;return{...t.platformInfo.shaderLanguage==="wgsl"?Bd({platformInfo:n,...r,modules:s,hookFunctions:i}):Ud({platformInfo:n,...r,modules:s,hookFunctions:i}),modules:s}}_getModuleList(t=[]){let r=new Array(this._defaultModules.length+t.length),s={},i=0;for(let n=0,o=this._defaultModules.length;n":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}`)}}search(t){this.left.search(t),this.right.search(t)}},Zo=class extends le{constructor(){super()}},Ql=class extends Zo{constructor(t,r){super(),this.selector=t,this.body=r}get astNodeType(){return"case"}search(t){this.searchBlock(this.body,t)}},Jl=class extends Zo{constructor(t){super(),this.body=t}get astNodeType(){return"default"}search(t){this.searchBlock(this.body,t)}},Gl=class extends le{constructor(t,r,s){super(),this.name=t,this.type=r,this.attributes=s}get astNodeType(){return"argument"}},th=class extends le{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"elseif"}search(t){this.condition.search(t),this.searchBlock(this.body,t)}},eh=class extends le{constructor(t,r,s){super(),this.name=t,this.type=r,this.attributes=s}get astNodeType(){return"member"}},rh=class extends le{constructor(t,r){super(),this.name=t,this.value=r}get astNodeType(){return"attribute"}},S,x;(function(e){e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(x||(x={}));var E=class{constructor(t,r,s){this.name=t,this.type=r,this.rule=s}toString(){return this.name}},g=class{};S=g;g.none=new E("",x.reserved,"");g.eof=new E("EOF",x.token,"");g.reserved={asm:new E("asm",x.reserved,"asm"),bf16:new E("bf16",x.reserved,"bf16"),do:new E("do",x.reserved,"do"),enum:new E("enum",x.reserved,"enum"),f16:new E("f16",x.reserved,"f16"),f64:new E("f64",x.reserved,"f64"),handle:new E("handle",x.reserved,"handle"),i8:new E("i8",x.reserved,"i8"),i16:new E("i16",x.reserved,"i16"),i64:new E("i64",x.reserved,"i64"),mat:new E("mat",x.reserved,"mat"),premerge:new E("premerge",x.reserved,"premerge"),regardless:new E("regardless",x.reserved,"regardless"),typedef:new E("typedef",x.reserved,"typedef"),u8:new E("u8",x.reserved,"u8"),u16:new E("u16",x.reserved,"u16"),u64:new E("u64",x.reserved,"u64"),unless:new E("unless",x.reserved,"unless"),using:new E("using",x.reserved,"using"),vec:new E("vec",x.reserved,"vec"),void:new E("void",x.reserved,"void")};g.keywords={array:new E("array",x.keyword,"array"),atomic:new E("atomic",x.keyword,"atomic"),bool:new E("bool",x.keyword,"bool"),f32:new E("f32",x.keyword,"f32"),i32:new E("i32",x.keyword,"i32"),mat2x2:new E("mat2x2",x.keyword,"mat2x2"),mat2x3:new E("mat2x3",x.keyword,"mat2x3"),mat2x4:new E("mat2x4",x.keyword,"mat2x4"),mat3x2:new E("mat3x2",x.keyword,"mat3x2"),mat3x3:new E("mat3x3",x.keyword,"mat3x3"),mat3x4:new E("mat3x4",x.keyword,"mat3x4"),mat4x2:new E("mat4x2",x.keyword,"mat4x2"),mat4x3:new E("mat4x3",x.keyword,"mat4x3"),mat4x4:new E("mat4x4",x.keyword,"mat4x4"),ptr:new E("ptr",x.keyword,"ptr"),sampler:new E("sampler",x.keyword,"sampler"),sampler_comparison:new E("sampler_comparison",x.keyword,"sampler_comparison"),struct:new E("struct",x.keyword,"struct"),texture_1d:new E("texture_1d",x.keyword,"texture_1d"),texture_2d:new E("texture_2d",x.keyword,"texture_2d"),texture_2d_array:new E("texture_2d_array",x.keyword,"texture_2d_array"),texture_3d:new E("texture_3d",x.keyword,"texture_3d"),texture_cube:new E("texture_cube",x.keyword,"texture_cube"),texture_cube_array:new E("texture_cube_array",x.keyword,"texture_cube_array"),texture_multisampled_2d:new E("texture_multisampled_2d",x.keyword,"texture_multisampled_2d"),texture_storage_1d:new E("texture_storage_1d",x.keyword,"texture_storage_1d"),texture_storage_2d:new E("texture_storage_2d",x.keyword,"texture_storage_2d"),texture_storage_2d_array:new E("texture_storage_2d_array",x.keyword,"texture_storage_2d_array"),texture_storage_3d:new E("texture_storage_3d",x.keyword,"texture_storage_3d"),texture_depth_2d:new E("texture_depth_2d",x.keyword,"texture_depth_2d"),texture_depth_2d_array:new E("texture_depth_2d_array",x.keyword,"texture_depth_2d_array"),texture_depth_cube:new E("texture_depth_cube",x.keyword,"texture_depth_cube"),texture_depth_cube_array:new E("texture_depth_cube_array",x.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new E("texture_depth_multisampled_2d",x.keyword,"texture_depth_multisampled_2d"),texture_external:new E("texture_external",x.keyword,"texture_external"),u32:new E("u32",x.keyword,"u32"),vec2:new E("vec2",x.keyword,"vec2"),vec3:new E("vec3",x.keyword,"vec3"),vec4:new E("vec4",x.keyword,"vec4"),bitcast:new E("bitcast",x.keyword,"bitcast"),block:new E("block",x.keyword,"block"),break:new E("break",x.keyword,"break"),case:new E("case",x.keyword,"case"),continue:new E("continue",x.keyword,"continue"),continuing:new E("continuing",x.keyword,"continuing"),default:new E("default",x.keyword,"default"),diagnostic:new E("diagnostic",x.keyword,"diagnostic"),discard:new E("discard",x.keyword,"discard"),else:new E("else",x.keyword,"else"),enable:new E("enable",x.keyword,"enable"),fallthrough:new E("fallthrough",x.keyword,"fallthrough"),false:new E("false",x.keyword,"false"),fn:new E("fn",x.keyword,"fn"),for:new E("for",x.keyword,"for"),function:new E("function",x.keyword,"function"),if:new E("if",x.keyword,"if"),let:new E("let",x.keyword,"let"),const:new E("const",x.keyword,"const"),loop:new E("loop",x.keyword,"loop"),while:new E("while",x.keyword,"while"),private:new E("private",x.keyword,"private"),read:new E("read",x.keyword,"read"),read_write:new E("read_write",x.keyword,"read_write"),return:new E("return",x.keyword,"return"),requires:new E("requires",x.keyword,"requires"),storage:new E("storage",x.keyword,"storage"),switch:new E("switch",x.keyword,"switch"),true:new E("true",x.keyword,"true"),alias:new E("alias",x.keyword,"alias"),type:new E("type",x.keyword,"type"),uniform:new E("uniform",x.keyword,"uniform"),var:new E("var",x.keyword,"var"),override:new E("override",x.keyword,"override"),workgroup:new E("workgroup",x.keyword,"workgroup"),write:new E("write",x.keyword,"write"),r8unorm:new E("r8unorm",x.keyword,"r8unorm"),r8snorm:new E("r8snorm",x.keyword,"r8snorm"),r8uint:new E("r8uint",x.keyword,"r8uint"),r8sint:new E("r8sint",x.keyword,"r8sint"),r16uint:new E("r16uint",x.keyword,"r16uint"),r16sint:new E("r16sint",x.keyword,"r16sint"),r16float:new E("r16float",x.keyword,"r16float"),rg8unorm:new E("rg8unorm",x.keyword,"rg8unorm"),rg8snorm:new E("rg8snorm",x.keyword,"rg8snorm"),rg8uint:new E("rg8uint",x.keyword,"rg8uint"),rg8sint:new E("rg8sint",x.keyword,"rg8sint"),r32uint:new E("r32uint",x.keyword,"r32uint"),r32sint:new E("r32sint",x.keyword,"r32sint"),r32float:new E("r32float",x.keyword,"r32float"),rg16uint:new E("rg16uint",x.keyword,"rg16uint"),rg16sint:new E("rg16sint",x.keyword,"rg16sint"),rg16float:new E("rg16float",x.keyword,"rg16float"),rgba8unorm:new E("rgba8unorm",x.keyword,"rgba8unorm"),rgba8unorm_srgb:new E("rgba8unorm_srgb",x.keyword,"rgba8unorm_srgb"),rgba8snorm:new E("rgba8snorm",x.keyword,"rgba8snorm"),rgba8uint:new E("rgba8uint",x.keyword,"rgba8uint"),rgba8sint:new E("rgba8sint",x.keyword,"rgba8sint"),bgra8unorm:new E("bgra8unorm",x.keyword,"bgra8unorm"),bgra8unorm_srgb:new E("bgra8unorm_srgb",x.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new E("rgb10a2unorm",x.keyword,"rgb10a2unorm"),rg11b10float:new E("rg11b10float",x.keyword,"rg11b10float"),rg32uint:new E("rg32uint",x.keyword,"rg32uint"),rg32sint:new E("rg32sint",x.keyword,"rg32sint"),rg32float:new E("rg32float",x.keyword,"rg32float"),rgba16uint:new E("rgba16uint",x.keyword,"rgba16uint"),rgba16sint:new E("rgba16sint",x.keyword,"rgba16sint"),rgba16float:new E("rgba16float",x.keyword,"rgba16float"),rgba32uint:new E("rgba32uint",x.keyword,"rgba32uint"),rgba32sint:new E("rgba32sint",x.keyword,"rgba32sint"),rgba32float:new E("rgba32float",x.keyword,"rgba32float"),static_assert:new E("static_assert",x.keyword,"static_assert")};g.tokens={decimal_float_literal:new E("decimal_float_literal",x.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 E("hex_float_literal",x.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 E("int_literal",x.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new E("uint_literal",x.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new E("ident",x.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new E("and",x.token,"&"),and_and:new E("and_and",x.token,"&&"),arrow:new E("arrow ",x.token,"->"),attr:new E("attr",x.token,"@"),forward_slash:new E("forward_slash",x.token,"/"),bang:new E("bang",x.token,"!"),bracket_left:new E("bracket_left",x.token,"["),bracket_right:new E("bracket_right",x.token,"]"),brace_left:new E("brace_left",x.token,"{"),brace_right:new E("brace_right",x.token,"}"),colon:new E("colon",x.token,":"),comma:new E("comma",x.token,","),equal:new E("equal",x.token,"="),equal_equal:new E("equal_equal",x.token,"=="),not_equal:new E("not_equal",x.token,"!="),greater_than:new E("greater_than",x.token,">"),greater_than_equal:new E("greater_than_equal",x.token,">="),shift_right:new E("shift_right",x.token,">>"),less_than:new E("less_than",x.token,"<"),less_than_equal:new E("less_than_equal",x.token,"<="),shift_left:new E("shift_left",x.token,"<<"),modulo:new E("modulo",x.token,"%"),minus:new E("minus",x.token,"-"),minus_minus:new E("minus_minus",x.token,"--"),period:new E("period",x.token,"."),plus:new E("plus",x.token,"+"),plus_plus:new E("plus_plus",x.token,"++"),or:new E("or",x.token,"|"),or_or:new E("or_or",x.token,"||"),paren_left:new E("paren_left",x.token,"("),paren_right:new E("paren_right",x.token,")"),semicolon:new E("semicolon",x.token,";"),star:new E("star",x.token,"*"),tilde:new E("tilde",x.token,"~"),underscore:new E("underscore",x.token,"_"),xor:new E("xor",x.token,"^"),plus_equal:new E("plus_equal",x.token,"+="),minus_equal:new E("minus_equal",x.token,"-="),times_equal:new E("times_equal",x.token,"*="),division_equal:new E("division_equal",x.token,"/="),modulo_equal:new E("modulo_equal",x.token,"%="),and_equal:new E("and_equal",x.token,"&="),or_equal:new E("or_equal",x.token,"|="),xor_equal:new E("xor_equal",x.token,"^="),shift_right_equal:new E("shift_right_equal",x.token,">>="),shift_left_equal:new E("shift_left_equal",x.token,"<<=")};g.simpleTokens={"@":S.tokens.attr,"{":S.tokens.brace_left,"}":S.tokens.brace_right,":":S.tokens.colon,",":S.tokens.comma,"(":S.tokens.paren_left,")":S.tokens.paren_right,";":S.tokens.semicolon};g.literalTokens={"&":S.tokens.and,"&&":S.tokens.and_and,"->":S.tokens.arrow,"/":S.tokens.forward_slash,"!":S.tokens.bang,"[":S.tokens.bracket_left,"]":S.tokens.bracket_right,"=":S.tokens.equal,"==":S.tokens.equal_equal,"!=":S.tokens.not_equal,">":S.tokens.greater_than,">=":S.tokens.greater_than_equal,">>":S.tokens.shift_right,"<":S.tokens.less_than,"<=":S.tokens.less_than_equal,"<<":S.tokens.shift_left,"%":S.tokens.modulo,"-":S.tokens.minus,"--":S.tokens.minus_minus,".":S.tokens.period,"+":S.tokens.plus,"++":S.tokens.plus_plus,"|":S.tokens.or,"||":S.tokens.or_or,"*":S.tokens.star,"~":S.tokens.tilde,_:S.tokens.underscore,"^":S.tokens.xor,"+=":S.tokens.plus_equal,"-=":S.tokens.minus_equal,"*=":S.tokens.times_equal,"/=":S.tokens.division_equal,"%=":S.tokens.modulo_equal,"&=":S.tokens.and_equal,"|=":S.tokens.or_equal,"^=":S.tokens.xor_equal,">>=":S.tokens.shift_right_equal,"<<=":S.tokens.shift_left_equal};g.regexTokens={decimal_float_literal:S.tokens.decimal_float_literal,hex_float_literal:S.tokens.hex_float_literal,int_literal:S.tokens.int_literal,uint_literal:S.tokens.uint_literal,ident:S.tokens.ident};g.storage_class=[S.keywords.function,S.keywords.private,S.keywords.workgroup,S.keywords.uniform,S.keywords.storage];g.access_mode=[S.keywords.read,S.keywords.write,S.keywords.read_write];g.sampler_type=[S.keywords.sampler,S.keywords.sampler_comparison];g.sampled_texture_type=[S.keywords.texture_1d,S.keywords.texture_2d,S.keywords.texture_2d_array,S.keywords.texture_3d,S.keywords.texture_cube,S.keywords.texture_cube_array];g.multisampled_texture_type=[S.keywords.texture_multisampled_2d];g.storage_texture_type=[S.keywords.texture_storage_1d,S.keywords.texture_storage_2d,S.keywords.texture_storage_2d_array,S.keywords.texture_storage_3d];g.depth_texture_type=[S.keywords.texture_depth_2d,S.keywords.texture_depth_2d_array,S.keywords.texture_depth_cube,S.keywords.texture_depth_cube_array,S.keywords.texture_depth_multisampled_2d];g.texture_external_type=[S.keywords.texture_external];g.any_texture_type=[...S.sampled_texture_type,...S.multisampled_texture_type,...S.storage_texture_type,...S.depth_texture_type,...S.texture_external_type];g.texel_format=[S.keywords.r8unorm,S.keywords.r8snorm,S.keywords.r8uint,S.keywords.r8sint,S.keywords.r16uint,S.keywords.r16sint,S.keywords.r16float,S.keywords.rg8unorm,S.keywords.rg8snorm,S.keywords.rg8uint,S.keywords.rg8sint,S.keywords.r32uint,S.keywords.r32sint,S.keywords.r32float,S.keywords.rg16uint,S.keywords.rg16sint,S.keywords.rg16float,S.keywords.rgba8unorm,S.keywords.rgba8unorm_srgb,S.keywords.rgba8snorm,S.keywords.rgba8uint,S.keywords.rgba8sint,S.keywords.bgra8unorm,S.keywords.bgra8unorm_srgb,S.keywords.rgb10a2unorm,S.keywords.rg11b10float,S.keywords.rg32uint,S.keywords.rg32sint,S.keywords.rg32float,S.keywords.rgba16uint,S.keywords.rgba16sint,S.keywords.rgba16float,S.keywords.rgba32uint,S.keywords.rgba32sint,S.keywords.rgba32float];g.const_literal=[S.tokens.int_literal,S.tokens.uint_literal,S.tokens.decimal_float_literal,S.tokens.hex_float_literal,S.keywords.true,S.keywords.false];g.literal_or_ident=[S.tokens.ident,S.tokens.int_literal,S.tokens.uint_literal,S.tokens.decimal_float_literal,S.tokens.hex_float_literal];g.element_count_expression=[S.tokens.int_literal,S.tokens.uint_literal,S.tokens.ident];g.template_types=[S.keywords.vec2,S.keywords.vec3,S.keywords.vec4,S.keywords.mat2x2,S.keywords.mat2x3,S.keywords.mat2x4,S.keywords.mat3x2,S.keywords.mat3x3,S.keywords.mat3x4,S.keywords.mat4x2,S.keywords.mat4x3,S.keywords.mat4x4,S.keywords.atomic,S.keywords.bitcast,...S.any_texture_type];g.attribute_name=[S.tokens.ident,S.keywords.block,S.keywords.diagnostic];g.assignment_operators=[S.tokens.equal,S.tokens.plus_equal,S.tokens.minus_equal,S.tokens.times_equal,S.tokens.division_equal,S.tokens.modulo_equal,S.tokens.and_equal,S.tokens.or_equal,S.tokens.xor_equal,S.tokens.shift_right_equal,S.tokens.shift_left_equal];g.increment_operators=[S.tokens.plus_plus,S.tokens.minus_minus];var Qo=class{constructor(t,r,s){this.type=t,this.lexeme=r,this.line=s}toString(){return this.lexeme}isTemplateType(){return g.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==g.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},sh=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 Qo(g.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 o=1;for(;o>0;){if(this._isAtEnd())return!0;if(t=this._advance(),t==` `)this._line++;else if(t=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else t=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}let r=g.simpleTokens[t];if(r)return this._addToken(r),!0;let s=g.none,i=this._isAlpha(t),n=t==="_";if(this._isAlphaNumeric(t)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)t+=this._advance(),o=this._peekAhead()}if(i){let o=g.keywords[t];if(o)return this._addToken(o),!0}if(i||n)return this._addToken(g.tokens.ident),!0;for(;;){let o=this._findType(t),a=this._peekAhead();if(t=="-"&&this._tokens.length>0){if(a=="=")return this._current++,t+=a,this._addToken(g.tokens.minus_equal),!0;if(a=="-")return this._current++,t+=a,this._addToken(g.tokens.minus_minus),!0;let c=this._tokens.length-1;if((g.literal_or_ident.indexOf(this._tokens[c].type)!=-1||this._tokens[c].type==g.tokens.paren_right)&&a!=">")return this._addToken(o),!0}if(t==">"&&(a==">"||a=="=")){let c=!1,l=this._tokens.length-1;for(let h=0;h<5&&l>=0&&g.assignment_operators.indexOf(this._tokens[l].type)===-1;++h,--l)if(this._tokens[l].type===g.tokens.less_than){l>0&&this._tokens[l-1].isArrayOrTemplateType()&&(c=!0);break}if(c)return this._addToken(o),!0}if(o===g.none){let c=t,l=0,h=2;for(let f=0;f=this._source.length}_isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}_isAlphaNumeric(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"||t=="_"||t>="0"&&t<="9"}_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 Qo(t,r,this._line))}},ih=class{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new Pl,this._deferArrayCountEval=[]}parse(t){this._initialize(t),this._deferArrayCountEval.length=0;let r=[];for(;!this._isAtEnd();){let s=this._global_decl_or_directive();if(!s)break;r.push(s)}if(this._deferArrayCountEval.length>0){for(let s of this._deferArrayCountEval){let i=s.arrayType,n=s.countNode;if(n instanceof zi){let a=n.name,c=this._context.constants.get(a);if(c)try{let l=c.evaluate(this._context);i.count=l}catch{}}}this._deferArrayCountEval.length=0}return r}_initialize(t){if(t)if(typeof t=="string"){let r=new sh(t);this._tokens=r.scanTokens()}else this._tokens=t;else this._tokens=[];this._current=0}_error(t,r){return{token:t,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==g.eof}_match(t){if(t instanceof E)return this._check(t)?(this._advance(),!0):!1;for(let r=0,s=t.length;r'.");let i=this._paren_expression();return new Yl(s,i)}let t=this._type_decl(),r=this._argument_expression_list();return new ql(t,r)}_argument_expression_list(){if(!this._match(g.tokens.paren_left))return null;let t=[];do{if(this._check(g.tokens.paren_right))break;let r=this._short_circuit_or_expression();t.push(r)}while(this._match(g.tokens.comma));return this._consume(g.tokens.paren_right,"Expected ')' for agument list"),t}_optional_paren_expression(){this._match(g.tokens.paren_left);let t=this._short_circuit_or_expression();return this._match(g.tokens.paren_right),new qo([t])}_paren_expression(){this._consume(g.tokens.paren_left,"Expected '('.");let t=this._short_circuit_or_expression();return this._consume(g.tokens.paren_right,"Expected ')'."),new qo([t])}_struct_decl(){if(!this._match(g.keywords.struct))return null;let t=this._currentLine,r=this._consume(g.tokens.ident,"Expected name for struct.").toString();this._consume(g.tokens.brace_left,"Expected '{' for struct body.");let s=[];for(;!this._check(g.tokens.brace_right);){let o=this._attribute(),a=this._consume(g.tokens.ident,"Expected variable name.").toString();this._consume(g.tokens.colon,"Expected ':' for struct member type.");let c=this._attribute(),l=this._type_decl();l!=null&&(l.attributes=c),this._check(g.tokens.brace_right)?this._match(g.tokens.comma):this._consume(g.tokens.comma,"Expected ',' for struct member."),s.push(new eh(a,l,o))}this._consume(g.tokens.brace_right,"Expected '}' after struct body.");let i=this._currentLine,n=new ze(r,s,t,i);return this._context.structs.set(r,n),n}_global_variable_decl(){let t=this._variable_decl();return t&&this._match(g.tokens.equal)&&(t.value=this._const_expression()),t}_override_variable_decl(){let t=this._override_decl();return t&&this._match(g.tokens.equal)&&(t.value=this._const_expression()),t}_global_const_decl(){if(!this._match(g.keywords.const))return null;let t=this._consume(g.tokens.ident,"Expected variable name"),r=null;if(this._match(g.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}let s=null;if(this._match(g.tokens.equal)){let n=this._short_circuit_or_expression();if(n instanceof fr)s=n;else if(n instanceof $o&&n.initializer instanceof fr)s=n.initializer;else try{let o=n.evaluate(this._context);s=new Yo(o)}catch{s=n}}let i=new Lo(t.toString(),r,"","",s);return this._context.constants.set(i.name,i),i}_global_let_decl(){if(!this._match(g.keywords.let))return null;let t=this._consume(g.tokens.ident,"Expected variable name"),r=null;if(this._match(g.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}let s=null;return this._match(g.tokens.equal)&&(s=this._const_expression()),new Li(t.toString(),r,"","",s)}_const_expression(){if(this._match(g.const_literal))return new Ho(this._previous().toString());let t=this._type_decl();this._consume(g.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(g.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(g.tokens.comma));)this._advance();return this._consume(g.tokens.paren_right,"Expected ')'."),new fr(t,r)}_variable_decl(){if(!this._match(g.keywords.var))return null;let t="",r="";this._match(g.tokens.less_than)&&(t=this._consume(g.storage_class,"Expected storage_class.").toString(),this._match(g.tokens.comma)&&(r=this._consume(g.access_mode,"Expected access_mode.").toString()),this._consume(g.tokens.greater_than,"Expected '>'."));let s=this._consume(g.tokens.ident,"Expected variable name"),i=null;if(this._match(g.tokens.colon)){let n=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=n)}return new We(s.toString(),i,t,r,null)}_override_decl(){if(!this._match(g.keywords.override))return null;let t=this._consume(g.tokens.ident,"Expected variable name"),r=null;if(this._match(g.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}return new Uo(t.toString(),r,null)}_diagnostic(){this._consume(g.tokens.paren_left,"Expected '('");let t=this._consume(g.tokens.ident,"Expected severity control name.");this._consume(g.tokens.comma,"Expected ','");let r=this._consume(g.tokens.ident,"Expected diagnostic rule name.");return this._consume(g.tokens.paren_right,"Expected ')'"),new Wl(t.toString(),r.toString())}_enable_directive(){let t=this._consume(g.tokens.ident,"identity expected.");return new Vl(t.toString())}_requires_directive(){let t=[this._consume(g.tokens.ident,"identity expected.").toString()];for(;this._match(g.tokens.comma);){let r=this._consume(g.tokens.ident,"identity expected.");t.push(r.toString())}return new zl(t)}_type_alias(){let t=this._consume(g.tokens.ident,"identity expected.");this._consume(g.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let s=new zo(t.toString(),r);return this._context.aliases.set(s.name,s),s}_type_decl(){if(this._check([g.tokens.ident,...g.texel_format,g.keywords.bool,g.keywords.f32,g.keywords.i32,g.keywords.u32])){let s=this._advance(),i=s.toString();return this._context.structs.has(i)?this._context.structs.get(i):this._context.aliases.has(i)?this._context.aliases.get(i).type:new je(s.toString())}let t=this._texture_sampler_types();if(t)return t;if(this._check(g.template_types)){let s=this._advance().toString(),i=null,n=null;return this._match(g.tokens.less_than)&&(i=this._type_decl(),n=null,this._match(g.tokens.comma)&&(n=this._consume(g.access_mode,"Expected access_mode for pointer").toString()),this._consume(g.tokens.greater_than,"Expected '>' for type.")),new Wo(s,i,n)}if(this._match(g.keywords.ptr)){let s=this._previous().toString();this._consume(g.tokens.less_than,"Expected '<' for pointer.");let i=this._consume(g.storage_class,"Expected storage_class for pointer");this._consume(g.tokens.comma,"Expected ',' for pointer.");let n=this._type_decl(),o=null;return this._match(g.tokens.comma)&&(o=this._consume(g.access_mode,"Expected access_mode for pointer").toString()),this._consume(g.tokens.greater_than,"Expected '>' for pointer."),new $l(s,i.toString(),n,o)}let r=this._attribute();if(this._match(g.keywords.array)){let s=null,i=-1,n=this._previous(),o=null;if(this._match(g.tokens.less_than)){s=this._type_decl(),this._context.aliases.has(s.name)&&(s=this._context.aliases.get(s.name).type);let c="";if(this._match(g.tokens.comma)){o=this._shift_expression();try{c=o.evaluate(this._context).toString(),o=null}catch{c="1"}}this._consume(g.tokens.greater_than,"Expected '>' for array."),i=c?parseInt(c):0}let a=new jo(n.toString(),r,s,i);return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(g.sampler_type))return new Vr(this._previous().toString(),null,null);if(this._match(g.depth_texture_type))return new Vr(this._previous().toString(),null,null);if(this._match(g.sampled_texture_type)||this._match(g.multisampled_texture_type)){let t=this._previous();this._consume(g.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(g.tokens.greater_than,"Expected '>' for sampler type."),new Vr(t.toString(),r,null)}if(this._match(g.storage_texture_type)){let t=this._previous();this._consume(g.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(g.texel_format,"Invalid texel format.").toString();this._consume(g.tokens.comma,"Expected ',' after texel format.");let s=this._consume(g.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(g.tokens.greater_than,"Expected '>' for sampler type."),new Vr(t.toString(),r,s)}return null}_attribute(){let t=[];for(;this._match(g.tokens.attr);){let r=this._consume(g.attribute_name,"Expected attribute name"),s=new rh(r.toString(),null);if(this._match(g.tokens.paren_left)){if(s.value=this._consume(g.literal_or_ident,"Expected attribute value").toString(),this._check(g.tokens.comma)){this._advance();do{let i=this._consume(g.literal_or_ident,"Expected attribute value").toString();s.value instanceof Array||(s.value=[s.value]),s.value.push(i)}while(this._match(g.tokens.comma))}this._consume(g.tokens.paren_right,"Expected ')'")}t.push(s)}return t.length==0?null:t}},ur=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}},Jo=class{constructor(t,r,s){this.name=t,this.type=r,this.attributes=s,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Is=class extends ur{constructor(t,r){super(t,r),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},Bi=class extends ur{constructor(t,r){super(t,r),this.count=0,this.stride=0}get isArray(){return!0}},Go=class extends ur{constructor(t,r,s,i){super(t,s),this.format=r,this.access=i}get isTemplate(){return!0}},hr;(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"})(hr||(hr={}));var Cs=class{constructor(t,r,s,i,n,o,a){this.name=t,this.type=r,this.group=s,this.binding=i,this.attributes=n,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},nh=class{constructor(t,r){this.name=t,this.type=r}},Os=class{constructor(t,r){this.align=t,this.size=r}},oh=class{constructor(t,r,s,i){this.name=t,this.type=r,this.locationType=s,this.location=i,this.interpolation=null}},ta=class{constructor(t,r,s,i){this.name=t,this.type=r,this.locationType=s,this.location=i}},ah=class{constructor(t,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=t,this.stage=r}},ch=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},lh=class{constructor(t,r,s,i){this.name=t,this.type=r,this.attributes=s,this.id=i}},hh=class{constructor(t){this.resources=null,this.inUse=!1,this.info=null,this.node=t}},qt=class{constructor(t){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new ch,this.functions=[],this._types=new Map,this._functions=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 s=new ih().parse(t);for(let i of s)i instanceof Ui&&this._functions.set(i.name,new hh(i));for(let i of s)if(i instanceof ze){let n=this._getTypeInfo(i,null);n instanceof Is&&this.structs.push(n)}for(let i of s){if(i instanceof zo){this.aliases.push(this._getAliasInfo(i));continue}if(i instanceof Uo){let n=i,o=this._getAttributeNum(n.attributes,"id",0),a=n.type!=null?this._getTypeInfo(n.type,n.attributes):null;this.overrides.push(new lh(n.name,a,n.attributes,o));continue}if(this._isUniformVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new Cs(n.name,c,o,a,n.attributes,hr.Uniform,n.access);this.uniforms.push(l);continue}if(this._isStorageVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),h=new Cs(n.name,c,o,a,n.attributes,l?hr.StorageTexture:hr.Storage,n.access);this.storage.push(h);continue}if(this._isTextureVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),h=new Cs(n.name,c,o,a,n.attributes,l?hr.StorageTexture:hr.Texture,n.access);l?this.storage.push(h):this.textures.push(h);continue}if(this._isSamplerVar(i)){let n=i,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new Cs(n.name,c,o,a,n.attributes,hr.Sampler,n.access);this.samplers.push(l);continue}if(i instanceof Ui){let n=this._getAttribute(i,"vertex"),o=this._getAttribute(i,"fragment"),a=this._getAttribute(i,"compute"),c=n||o||a,l=new ah(i.name,c?.name);l.startLine=i.startLine,l.endLine=i.endLine,this.functions.push(l),this._functions.get(i.name).info=l,c&&(this._functions.get(i.name).inUse=!0,l.inUse=!0,l.resources=this._findResources(i,!!c),l.inputs=this._getInputs(i.args),l.outputs=this._getOutputs(i.returnType),this.entry[c.name].push(l));continue}}for(let i of this._functions.values())i.info&&(i.info.inUse=i.inUse,this._addCalls(i.node,i.info.calls));for(let i of this.uniforms)this._markStructsInUse(i.type);for(let i of this.storage)this._markStructsInUse(i.type)}_markStructsInUse(t){if(t.isStruct){t.inUse=!0;for(let r of t.members)this._markStructsInUse(r.type)}else if(t.isArray)this._markStructsInUse(t.format);else if(t.isTemplate)this._markStructsInUse(t.format);else{let r=this._getAlias(t.name);r&&this._markStructsInUse(r)}}_addCalls(t,r){var s;for(let i of t.calls){let n=(s=this._functions.get(i.name))===null||s===void 0?void 0:s.info;n&&r.add(n)}}findResource(t,r){for(let s of this.uniforms)if(s.group==t&&s.binding==r)return s;for(let s of this.storage)if(s.group==t&&s.binding==r)return s;for(let s of this.textures)if(s.group==t&&s.binding==r)return s;for(let s of this.samplers)if(s.group==t&&s.binding==r)return s;return null}_findResource(t){for(let r of this.uniforms)if(r.name==t)return r;for(let r of this.storage)if(r.name==t)return r;for(let r of this.textures)if(r.name==t)return r;for(let r of this.samplers)if(r.name==t)return r;return null}_markStructsFromAST(t){let r=this._getTypeInfo(t,null);this._markStructsInUse(r)}_findResources(t,r){let s=[],i=this,n=[];return t.search(o=>{if(o instanceof Ns)n.push({});else if(o instanceof Fs)n.pop();else if(o instanceof We){let a=o;r&&a.type!==null&&this._markStructsFromAST(a.type),n.length>0&&(n[n.length-1][a.name]=a)}else if(o instanceof fr){let a=o;r&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Li){let a=o;r&&a.type!==null&&this._markStructsFromAST(a.type),n.length>0&&(n[n.length-1][a.name]=a)}else if(o instanceof zi){let a=o;if(n.length>0&&n[n.length-1][a.name])return;let c=i._findResource(a.name);c&&s.push(c)}else if(o instanceof Xo){let a=o,c=i._functions.get(a.name);c&&(r&&(c.inUse=!0),t.calls.add(c.node),c.resources===null&&(c.resources=i._findResources(c.node,r)),s.push(...c.resources))}else if(o instanceof Vo){let a=o,c=i._functions.get(a.name);c&&(r&&(c.inUse=!0),t.calls.add(c.node),c.resources===null&&(c.resources=i._findResources(c.node,r)),s.push(...c.resources))}}),[...new Map(s.map(o=>[o.name,o])).values()]}getBindGroups(){let t=[];function r(s,i){s>=t.length&&(t.length=s+1),t[s]===void 0&&(t[s]=[]),i>=t[s].length&&(t[s].length=i+1)}for(let s of this.uniforms){r(s.group,s.binding);let i=t[s.group];i[s.binding]=s}for(let s of this.storage){r(s.group,s.binding);let i=t[s.group];i[s.binding]=s}for(let s of this.textures){r(s.group,s.binding);let i=t[s.group];i[s.binding]=s}for(let s of this.samplers){r(s.group,s.binding);let i=t[s.group];i[s.binding]=s}return t}_getOutputs(t,r=void 0){if(r===void 0&&(r=[]),t instanceof ze)this._getStructOutputs(t,r);else{let s=this._getOutputInfo(t);s!==null&&r.push(s)}return r}_getStructOutputs(t,r){for(let s of t.members)if(s.type instanceof ze)this._getStructOutputs(s.type,r);else{let i=this._getAttribute(s,"location")||this._getAttribute(s,"builtin");if(i!==null){let n=this._getTypeInfo(s.type,s.type.attributes),o=this._parseInt(i.value),a=new ta(s.name,n,i.name,o);r.push(a)}}}_getOutputInfo(t){let r=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(r!==null){let s=this._getTypeInfo(t,t.attributes),i=this._parseInt(r.value);return new ta("",s,r.name,i)}return null}_getInputs(t,r=void 0){r===void 0&&(r=[]);for(let s of t)if(s.type instanceof ze)this._getStructInputs(s.type,r);else{let i=this._getInputInfo(s);i!==null&&r.push(i)}return r}_getStructInputs(t,r){for(let s of t.members)if(s.type instanceof ze)this._getStructInputs(s.type,r);else{let i=this._getInputInfo(s);i!==null&&r.push(i)}}_getInputInfo(t){let r=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(r!==null){let s=this._getAttribute(t,"interpolation"),i=this._getTypeInfo(t.type,t.attributes),n=this._parseInt(r.value),o=new oh(t.name,i,r.name,n);return s!==null&&(o.interpolation=this._parseString(s.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 nh(t.name,this._getTypeInfo(t.type,null))}_getTypeInfo(t,r){if(this._types.has(t))return this._types.get(t);if(t instanceof jo){let i=t,n=this._getTypeInfo(i.format,i.attributes),o=new Bi(i.name,r);return o.format=n,o.count=i.count,this._types.set(t,o),this._updateTypeInfo(o),o}if(t instanceof ze){let i=t,n=new Is(i.name,r);n.startLine=i.startLine,n.endLine=i.endLine;for(let o of i.members){let a=this._getTypeInfo(o.type,o.attributes);n.members.push(new Jo(o.name,a,o.attributes))}return this._types.set(t,n),this._updateTypeInfo(n),n}if(t instanceof Vr){let i=t,n=i.format instanceof je,o=i.format?n?this._getTypeInfo(i.format,null):new ur(i.format,null):null,a=new Go(i.name,o,r,i.access);return this._types.set(t,a),this._updateTypeInfo(a),a}if(t instanceof Wo){let i=t,n=i.format?this._getTypeInfo(i.format,null):null,o=new Go(i.name,n,r,i.access);return this._types.set(t,o),this._updateTypeInfo(o),o}let s=new ur(t.name,r);return this._types.set(t,s),this._updateTypeInfo(s),s}_updateTypeInfo(t){var r,s;let i=this._getTypeSize(t);if(t.size=(r=i?.size)!==null&&r!==void 0?r:0,t instanceof Bi){let n=this._getTypeSize(t.format);t.stride=(s=n?.size)!==null&&s!==void 0?s:0,this._updateTypeInfo(t.format)}t instanceof Is&&this._updateStructInfo(t)}_updateStructInfo(t){var r;let s=0,i=0,n=0,o=0;for(let a=0,c=t.members.length;ae.name);qt._samplerTypes=g.sampler_type.map(e=>e.name);function fh(e){let t={attributes:[],bindings:[]},r;try{r=ZT(e)}catch(n){return P.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:Vd(a.type)});t.bindings.push({type:"uniform",name:n.name,location:n.binding,group:n.group,members:o})}let s=r.entry.vertex[0],i=s?.inputs.length||0;for(let n=0;n`:e.name}function ZT(e){try{return new qt(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 QT=`#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 } `,uh={name:"fp32",vs:QT};var JT=[0,1,1,1],GT=`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; } } `,ty=`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); } `,ea={name:"picking",vs:GT,fs:ty,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:JT},getUniforms:ey};function ey(e={},t){let r={};if(e.highlightedObjectColor!==void 0)if(e.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let s=e.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=s}if(e.highlightColor){let s=Array.from(e.highlightColor,i=>i/255);Number.isFinite(s[3])||(s[3]=1),r.highlightColor=s}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 dh(e,t=[],r=0){let s=Math.fround(e),i=e-s;return t[r]=s,t[r+1]=i,t}function zd(e){return e-Math.fround(e)}function Wd(e){let t=new Float32Array(32);for(let r=0;r<4;++r)for(let s=0;s<4;++s){let i=r*4+s;dh(e[s*4+r],t,i*2)}return t}var jd=`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 ry={ONE:1};function sy(){return ry}var ph={name:"fp64-arithmetic",vs:jd,getUniforms:sy,fp64ify:dh,fp64LowPart:zd,fp64ifyMatrix4:Wd};var iy=1/Math.PI*180,ny=1/180*Math.PI,oy={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...oy}};var ht=globalThis.mathgl.config;function Wi(e,{precision:t=ht.precision}={}){return e=ay(e),`${parseFloat(e.toPrecision(t))}`}function He(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ds(e,t){return gh(e,r=>r*ny,t)}function dr(e,t){return gh(e,r=>r*iy,t)}function J(e,t,r){return gh(e,s=>Math.max(t,Math.min(r,s)))}function Xe(e,t,r){return He(e)?e.map((s,i)=>Xe(s,t[i],r)):r*t+(1-r)*e}function Vt(e,t,r){let s=ht.EPSILON;r&&(ht.EPSILON=r);try{if(e===t)return!0;if(He(e)&&He(t)){if(e.length!==t.length)return!1;for(let i=0;i0?", ":"")+Wi(this[s],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r=0&&t=0&&tpy,angle:()=>Ny,ceil:()=>gy,clone:()=>hy,copy:()=>uy,create:()=>Hd,cross:()=>Ry,dist:()=>Wy,distance:()=>qd,div:()=>zy,divide:()=>Yd,dot:()=>wy,equals:()=>By,exactEquals:()=>Dy,floor:()=>_y,forEach:()=>Xy,fromValues:()=>fy,inverse:()=>Ay,len:()=>Uy,length:()=>Zd,lerp:()=>vy,max:()=>Ty,min:()=>my,mul:()=>Vy,multiply:()=>$d,negate:()=>xy,normalize:()=>Sy,random:()=>My,rotate:()=>Oy,round:()=>yy,scale:()=>by,scaleAndAdd:()=>Ey,set:()=>dy,sqrDist:()=>jy,sqrLen:()=>Hy,squaredDistance:()=>Kd,squaredLength:()=>Qd,str:()=>ky,sub:()=>Ly,subtract:()=>Xd,transformMat2:()=>Py,transformMat2d:()=>Iy,transformMat3:()=>Cy,transformMat4:()=>mh,zero:()=>Fy});var st=typeof Float32Array<"u"?Float32Array:Array,Me=Math.random;function Kt(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var k2=Math.PI/180;function Hd(){let e=new st(2);return st!=Float32Array&&(e[0]=0,e[1]=0),e}function hy(e){let t=new st(2);return t[0]=e[0],t[1]=e[1],t}function fy(e,t){let r=new st(2);return r[0]=e,r[1]=t,r}function uy(e,t){return e[0]=t[0],e[1]=t[1],e}function dy(e,t,r){return e[0]=t,e[1]=r,e}function py(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function Xd(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function $d(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function Yd(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function gy(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function _y(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function my(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function Ty(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function yy(e,t){return e[0]=Kt(t[0]),e[1]=Kt(t[1]),e}function by(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function Ey(e,t,r,s){return e[0]=t[0]+r[0]*s,e[1]=t[1]+r[1]*s,e}function qd(e,t){let r=t[0]-e[0],s=t[1]-e[1];return Math.sqrt(r*r+s*s)}function Kd(e,t){let r=t[0]-e[0],s=t[1]-e[1];return r*r+s*s}function Zd(e){let t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function Qd(e){let t=e[0],r=e[1];return t*t+r*r}function xy(e,t){return e[0]=-t[0],e[1]=-t[1],e}function Ay(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Sy(e,t){let r=t[0],s=t[1],i=r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function wy(e,t){return e[0]*t[0]+e[1]*t[1]}function Ry(e,t,r){let s=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=s,e}function vy(e,t,r,s){let i=t[0],n=t[1];return e[0]=i+s*(r[0]-i),e[1]=n+s*(r[1]-n),e}function My(e,t){t=t===void 0?1:t;let r=Me()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function Py(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[2]*i,e[1]=r[1]*s+r[3]*i,e}function Iy(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[2]*i+r[4],e[1]=r[1]*s+r[3]*i+r[5],e}function Cy(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[3]*i+r[6],e[1]=r[1]*s+r[4]*i+r[7],e}function mh(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[4]*i+r[12],e[1]=r[1]*s+r[5]*i+r[13],e}function Oy(e,t,r,s){let i=t[0]-r[0],n=t[1]-r[1],o=Math.sin(s),a=Math.cos(s);return e[0]=i*a-n*o+r[0],e[1]=i*o+n*a+r[1],e}function Ny(e,t){let r=e[0],s=e[1],i=t[0],n=t[1],o=Math.sqrt((r*r+s*s)*(i*i+n*n)),a=o&&(r*i+s*n)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function Fy(e){return e[0]=0,e[1]=0,e}function ky(e){return`vec2(${e[0]}, ${e[1]})`}function Dy(e,t){return e[0]===t[0]&&e[1]===t[1]}function By(e,t){let r=e[0],s=e[1],i=t[0],n=t[1];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(s-n)<=1e-6*Math.max(1,Math.abs(s),Math.abs(n))}var Uy=Zd,Ly=Xd,Vy=$d,zy=Yd,Wy=qd,jy=Kd,Hy=Qd,Xy=function(){let e=Hd();return function(t,r,s,i,n,o){let a,c;for(r||(r=2),s||(s=0),i?c=Math.min(i*r+s,t.length):c=t.length,a=s;aZy,angle:()=>wh,bezier:()=>h1,ceil:()=>Qy,clone:()=>$y,copy:()=>qy,create:()=>tp,cross:()=>yh,dist:()=>y1,distance:()=>ip,div:()=>T1,divide:()=>sp,dot:()=>Th,equals:()=>g1,exactEquals:()=>p1,floor:()=>Jy,forEach:()=>A1,fromValues:()=>Yy,hermite:()=>l1,inverse:()=>n1,len:()=>E1,length:()=>oa,lerp:()=>a1,max:()=>t1,min:()=>Gy,mul:()=>m1,multiply:()=>rp,negate:()=>i1,normalize:()=>o1,random:()=>f1,rotateX:()=>xh,rotateY:()=>Ah,rotateZ:()=>Sh,round:()=>e1,scale:()=>r1,scaleAndAdd:()=>s1,set:()=>Ky,slerp:()=>c1,sqrDist:()=>b1,sqrLen:()=>x1,squaredDistance:()=>np,squaredLength:()=>op,str:()=>d1,sub:()=>_1,subtract:()=>ep,transformMat3:()=>bh,transformMat4:()=>ji,transformQuat:()=>Eh,zero:()=>u1});function tp(){let e=new st(3);return st!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function $y(e){let t=new st(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function oa(e){let t=e[0],r=e[1],s=e[2];return Math.sqrt(t*t+r*r+s*s)}function Yy(e,t,r){let s=new st(3);return s[0]=e,s[1]=t,s[2]=r,s}function qy(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ky(e,t,r,s){return e[0]=t,e[1]=r,e[2]=s,e}function Zy(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function ep(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function rp(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function sp(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function Qy(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Jy(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Gy(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 t1(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 e1(e,t){return e[0]=Kt(t[0]),e[1]=Kt(t[1]),e[2]=Kt(t[2]),e}function r1(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function s1(e,t,r,s){return e[0]=t[0]+r[0]*s,e[1]=t[1]+r[1]*s,e[2]=t[2]+r[2]*s,e}function ip(e,t){let r=t[0]-e[0],s=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+s*s+i*i)}function np(e,t){let r=t[0]-e[0],s=t[1]-e[1],i=t[2]-e[2];return r*r+s*s+i*i}function op(e){let t=e[0],r=e[1],s=e[2];return t*t+r*r+s*s}function i1(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function n1(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function o1(e,t){let r=t[0],s=t[1],i=t[2],n=r*r+s*s+i*i;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 Th(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function yh(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[0],a=r[1],c=r[2];return e[0]=i*c-n*a,e[1]=n*o-s*c,e[2]=s*a-i*o,e}function a1(e,t,r,s){let i=t[0],n=t[1],o=t[2];return e[0]=i+s*(r[0]-i),e[1]=n+s*(r[1]-n),e[2]=o+s*(r[2]-o),e}function c1(e,t,r,s){let i=Math.acos(Math.min(Math.max(Th(t,r),-1),1)),n=Math.sin(i),o=Math.sin((1-s)*i)/n,a=Math.sin(s*i)/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 l1(e,t,r,s,i,n){let o=n*n,a=o*(2*n-3)+1,c=o*(n-2)+n,l=o*(n-1),h=o*(3-2*n);return e[0]=t[0]*a+r[0]*c+s[0]*l+i[0]*h,e[1]=t[1]*a+r[1]*c+s[1]*l+i[1]*h,e[2]=t[2]*a+r[2]*c+s[2]*l+i[2]*h,e}function h1(e,t,r,s,i,n){let o=1-n,a=o*o,c=n*n,l=a*o,h=3*n*a,f=3*c*o,u=c*n;return e[0]=t[0]*l+r[0]*h+s[0]*f+i[0]*u,e[1]=t[1]*l+r[1]*h+s[1]*f+i[1]*u,e[2]=t[2]*l+r[2]*h+s[2]*f+i[2]*u,e}function f1(e,t){t=t===void 0?1:t;let r=Me()*2*Math.PI,s=Me()*2-1,i=Math.sqrt(1-s*s)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=s*t,e}function ji(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[3]*s+r[7]*i+r[11]*n+r[15];return o=o||1,e[0]=(r[0]*s+r[4]*i+r[8]*n+r[12])/o,e[1]=(r[1]*s+r[5]*i+r[9]*n+r[13])/o,e[2]=(r[2]*s+r[6]*i+r[10]*n+r[14])/o,e}function bh(e,t,r){let s=t[0],i=t[1],n=t[2];return e[0]=s*r[0]+i*r[3]+n*r[6],e[1]=s*r[1]+i*r[4]+n*r[7],e[2]=s*r[2]+i*r[5]+n*r[8],e}function Eh(e,t,r){let s=r[0],i=r[1],n=r[2],o=r[3],a=t[0],c=t[1],l=t[2],h=i*l-n*c,f=n*a-s*l,u=s*c-i*a,_=i*u-n*f,m=n*h-s*u,b=s*f-i*h,y=o*2;return h*=y,f*=y,u*=y,_*=2,m*=2,b*=2,e[0]=a+h+_,e[1]=c+f+m,e[2]=l+u+b,e}function xh(e,t,r,s){let i=[],n=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],n[0]=i[0],n[1]=i[1]*Math.cos(s)-i[2]*Math.sin(s),n[2]=i[1]*Math.sin(s)+i[2]*Math.cos(s),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Ah(e,t,r,s){let i=[],n=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],n[0]=i[2]*Math.sin(s)+i[0]*Math.cos(s),n[1]=i[1],n[2]=i[2]*Math.cos(s)-i[0]*Math.sin(s),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Sh(e,t,r,s){let i=[],n=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],n[0]=i[0]*Math.cos(s)-i[1]*Math.sin(s),n[1]=i[0]*Math.sin(s)+i[1]*Math.cos(s),n[2]=i[2],e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function wh(e,t){let r=e[0],s=e[1],i=e[2],n=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+s*s+i*i)*(n*n+o*o+a*a)),l=c&&Th(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function u1(e){return e[0]=0,e[1]=0,e[2]=0,e}function d1(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function p1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function g1(e,t){let r=e[0],s=e[1],i=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(s-o)<=1e-6*Math.max(1,Math.abs(s),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}var _1=ep,m1=rp,T1=sp,y1=ip,b1=np,E1=oa,x1=op,A1=function(){let e=tp();return function(t,r,s,i,n,o){let a,c;for(r||(r=3),s||(s=0),i?c=Math.min(i*r+s,t.length):c=t.length,a=s;aq1,adjoint:()=>P1,clone:()=>w1,copy:()=>R1,create:()=>S1,decompose:()=>L1,determinant:()=>Ph,equals:()=>J1,exactEquals:()=>Q1,frob:()=>Y1,fromQuat:()=>Dh,fromQuat2:()=>D1,fromRotation:()=>O1,fromRotationTranslation:()=>cp,fromRotationTranslationScale:()=>V1,fromRotationTranslationScaleOrigin:()=>z1,fromScaling:()=>C1,fromTranslation:()=>I1,fromValues:()=>v1,fromXRotation:()=>N1,fromYRotation:()=>F1,fromZRotation:()=>k1,frustum:()=>Bh,getRotation:()=>U1,getScaling:()=>lp,getTranslation:()=>B1,identity:()=>ap,invert:()=>Mh,lookAt:()=>Vh,mul:()=>G1,multiply:()=>Hi,multiplyScalar:()=>K1,multiplyScalarAndAdd:()=>Z1,ortho:()=>Lh,orthoNO:()=>fp,orthoZO:()=>H1,perspective:()=>Uh,perspectiveFromFieldOfView:()=>j1,perspectiveNO:()=>hp,perspectiveZO:()=>W1,rotate:()=>Oh,rotateX:()=>Nh,rotateY:()=>Fh,rotateZ:()=>kh,scale:()=>Ch,set:()=>M1,str:()=>$1,sub:()=>tb,subtract:()=>up,targetTo:()=>X1,translate:()=>Ih,transpose:()=>vh});function S1(){let e=new st(16);return st!=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 w1(e){let t=new st(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 R1(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 v1(e,t,r,s,i,n,o,a,c,l,h,f,u,_,m,b){let y=new st(16);return y[0]=e,y[1]=t,y[2]=r,y[3]=s,y[4]=i,y[5]=n,y[6]=o,y[7]=a,y[8]=c,y[9]=l,y[10]=h,y[11]=f,y[12]=u,y[13]=_,y[14]=m,y[15]=b,y}function M1(e,t,r,s,i,n,o,a,c,l,h,f,u,_,m,b,y){return e[0]=t,e[1]=r,e[2]=s,e[3]=i,e[4]=n,e[5]=o,e[6]=a,e[7]=c,e[8]=l,e[9]=h,e[10]=f,e[11]=u,e[12]=_,e[13]=m,e[14]=b,e[15]=y,e}function ap(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 vh(e,t){if(e===t){let r=t[1],s=t[2],i=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]=s,e[9]=n,e[11]=t[14],e[12]=i,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 Mh(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],f=t[9],u=t[10],_=t[11],m=t[12],b=t[13],y=t[14],A=t[15],w=r*a-s*o,v=r*c-i*o,M=r*l-n*o,I=s*c-i*a,O=s*l-n*a,F=i*l-n*c,k=h*b-f*m,D=h*y-u*m,N=h*A-_*m,L=f*y-u*b,q=f*A-_*b,$=u*A-_*y,H=w*$-v*q+M*L+I*N-O*D+F*k;return H?(H=1/H,e[0]=(a*$-c*q+l*L)*H,e[1]=(i*q-s*$-n*L)*H,e[2]=(b*F-y*O+A*I)*H,e[3]=(u*O-f*F-_*I)*H,e[4]=(c*N-o*$-l*D)*H,e[5]=(r*$-i*N+n*D)*H,e[6]=(y*M-m*F-A*v)*H,e[7]=(h*F-u*M+_*v)*H,e[8]=(o*q-a*N+l*k)*H,e[9]=(s*N-r*q-n*k)*H,e[10]=(m*O-b*M+A*w)*H,e[11]=(f*M-h*O-_*w)*H,e[12]=(a*D-o*L-c*k)*H,e[13]=(r*L-s*D+i*k)*H,e[14]=(b*v-m*I-y*w)*H,e[15]=(h*I-f*v+u*w)*H,e):null}function P1(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],f=t[9],u=t[10],_=t[11],m=t[12],b=t[13],y=t[14],A=t[15],w=r*a-s*o,v=r*c-i*o,M=r*l-n*o,I=s*c-i*a,O=s*l-n*a,F=i*l-n*c,k=h*b-f*m,D=h*y-u*m,N=h*A-_*m,L=f*y-u*b,q=f*A-_*b,$=u*A-_*y;return e[0]=a*$-c*q+l*L,e[1]=i*q-s*$-n*L,e[2]=b*F-y*O+A*I,e[3]=u*O-f*F-_*I,e[4]=c*N-o*$-l*D,e[5]=r*$-i*N+n*D,e[6]=y*M-m*F-A*v,e[7]=h*F-u*M+_*v,e[8]=o*q-a*N+l*k,e[9]=s*N-r*q-n*k,e[10]=m*O-b*M+A*w,e[11]=f*M-h*O-_*w,e[12]=a*D-o*L-c*k,e[13]=r*L-s*D+i*k,e[14]=b*v-m*I-y*w,e[15]=h*I-f*v+u*w,e}function Ph(e){let t=e[0],r=e[1],s=e[2],i=e[3],n=e[4],o=e[5],a=e[6],c=e[7],l=e[8],h=e[9],f=e[10],u=e[11],_=e[12],m=e[13],b=e[14],y=e[15],A=t*o-r*n,w=t*a-s*n,v=r*a-s*o,M=l*m-h*_,I=l*b-f*_,O=h*b-f*m,F=t*O-r*I+s*M,k=n*O-o*I+a*M,D=l*v-h*w+f*A,N=_*v-m*w+b*A;return c*F-i*k+y*D-u*N}function Hi(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],f=t[8],u=t[9],_=t[10],m=t[11],b=t[12],y=t[13],A=t[14],w=t[15],v=r[0],M=r[1],I=r[2],O=r[3];return e[0]=v*s+M*a+I*f+O*b,e[1]=v*i+M*c+I*u+O*y,e[2]=v*n+M*l+I*_+O*A,e[3]=v*o+M*h+I*m+O*w,v=r[4],M=r[5],I=r[6],O=r[7],e[4]=v*s+M*a+I*f+O*b,e[5]=v*i+M*c+I*u+O*y,e[6]=v*n+M*l+I*_+O*A,e[7]=v*o+M*h+I*m+O*w,v=r[8],M=r[9],I=r[10],O=r[11],e[8]=v*s+M*a+I*f+O*b,e[9]=v*i+M*c+I*u+O*y,e[10]=v*n+M*l+I*_+O*A,e[11]=v*o+M*h+I*m+O*w,v=r[12],M=r[13],I=r[14],O=r[15],e[12]=v*s+M*a+I*f+O*b,e[13]=v*i+M*c+I*u+O*y,e[14]=v*n+M*l+I*_+O*A,e[15]=v*o+M*h+I*m+O*w,e}function Ih(e,t,r){let s=r[0],i=r[1],n=r[2],o,a,c,l,h,f,u,_,m,b,y,A;return t===e?(e[12]=t[0]*s+t[4]*i+t[8]*n+t[12],e[13]=t[1]*s+t[5]*i+t[9]*n+t[13],e[14]=t[2]*s+t[6]*i+t[10]*n+t[14],e[15]=t[3]*s+t[7]*i+t[11]*n+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],h=t[4],f=t[5],u=t[6],_=t[7],m=t[8],b=t[9],y=t[10],A=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=h,e[5]=f,e[6]=u,e[7]=_,e[8]=m,e[9]=b,e[10]=y,e[11]=A,e[12]=o*s+h*i+m*n+t[12],e[13]=a*s+f*i+b*n+t[13],e[14]=c*s+u*i+y*n+t[14],e[15]=l*s+_*i+A*n+t[15]),e}function Ch(e,t,r){let s=r[0],i=r[1],n=r[2];return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,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 Oh(e,t,r,s){let i=s[0],n=s[1],o=s[2],a=Math.sqrt(i*i+n*n+o*o),c,l,h,f,u,_,m,b,y,A,w,v,M,I,O,F,k,D,N,L,q,$,H,ct;return a<1e-6?null:(a=1/a,i*=a,n*=a,o*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,f=t[0],u=t[1],_=t[2],m=t[3],b=t[4],y=t[5],A=t[6],w=t[7],v=t[8],M=t[9],I=t[10],O=t[11],F=i*i*h+c,k=n*i*h+o*l,D=o*i*h-n*l,N=i*n*h-o*l,L=n*n*h+c,q=o*n*h+i*l,$=i*o*h+n*l,H=n*o*h-i*l,ct=o*o*h+c,e[0]=f*F+b*k+v*D,e[1]=u*F+y*k+M*D,e[2]=_*F+A*k+I*D,e[3]=m*F+w*k+O*D,e[4]=f*N+b*L+v*q,e[5]=u*N+y*L+M*q,e[6]=_*N+A*L+I*q,e[7]=m*N+w*L+O*q,e[8]=f*$+b*H+v*ct,e[9]=u*$+y*H+M*ct,e[10]=_*$+A*H+I*ct,e[11]=m*$+w*H+O*ct,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Nh(e,t,r){let s=Math.sin(r),i=Math.cos(r),n=t[4],o=t[5],a=t[6],c=t[7],l=t[8],h=t[9],f=t[10],u=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*i+l*s,e[5]=o*i+h*s,e[6]=a*i+f*s,e[7]=c*i+u*s,e[8]=l*i-n*s,e[9]=h*i-o*s,e[10]=f*i-a*s,e[11]=u*i-c*s,e}function Fh(e,t,r){let s=Math.sin(r),i=Math.cos(r),n=t[0],o=t[1],a=t[2],c=t[3],l=t[8],h=t[9],f=t[10],u=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*i-l*s,e[1]=o*i-h*s,e[2]=a*i-f*s,e[3]=c*i-u*s,e[8]=n*s+l*i,e[9]=o*s+h*i,e[10]=a*s+f*i,e[11]=c*s+u*i,e}function kh(e,t,r){let s=Math.sin(r),i=Math.cos(r),n=t[0],o=t[1],a=t[2],c=t[3],l=t[4],h=t[5],f=t[6],u=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*i+l*s,e[1]=o*i+h*s,e[2]=a*i+f*s,e[3]=c*i+u*s,e[4]=l*i-n*s,e[5]=h*i-o*s,e[6]=f*i-a*s,e[7]=u*i-c*s,e}function I1(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 C1(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 O1(e,t,r){let s=r[0],i=r[1],n=r[2],o=Math.sqrt(s*s+i*i+n*n),a,c,l;return o<1e-6?null:(o=1/o,s*=o,i*=o,n*=o,c=Math.sin(t),a=Math.cos(t),l=1-a,e[0]=s*s*l+a,e[1]=i*s*l+n*c,e[2]=n*s*l-i*c,e[3]=0,e[4]=s*i*l-n*c,e[5]=i*i*l+a,e[6]=n*i*l+s*c,e[7]=0,e[8]=s*n*l+i*c,e[9]=i*n*l-s*c,e[10]=n*n*l+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function N1(e,t){let r=Math.sin(t),s=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function F1(e,t){let r=Math.sin(t),s=Math.cos(t);return e[0]=s,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]=s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function k1(e,t){let r=Math.sin(t),s=Math.cos(t);return e[0]=s,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=s,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 cp(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=s+s,c=i+i,l=n+n,h=s*a,f=s*c,u=s*l,_=i*c,m=i*l,b=n*l,y=o*a,A=o*c,w=o*l;return e[0]=1-(_+b),e[1]=f+w,e[2]=u-A,e[3]=0,e[4]=f-w,e[5]=1-(h+b),e[6]=m+y,e[7]=0,e[8]=u+A,e[9]=m-y,e[10]=1-(h+_),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function D1(e,t){let r=new st(3),s=-t[0],i=-t[1],n=-t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],f=s*s+i*i+n*n+o*o;return f>0?(r[0]=(a*o+h*s+c*n-l*i)*2/f,r[1]=(c*o+h*i+l*s-a*n)*2/f,r[2]=(l*o+h*n+a*i-c*s)*2/f):(r[0]=(a*o+h*s+c*n-l*i)*2,r[1]=(c*o+h*i+l*s-a*n)*2,r[2]=(l*o+h*n+a*i-c*s)*2),cp(e,t,r),e}function B1(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function lp(e,t){let r=t[0],s=t[1],i=t[2],n=t[4],o=t[5],a=t[6],c=t[8],l=t[9],h=t[10];return e[0]=Math.sqrt(r*r+s*s+i*i),e[1]=Math.sqrt(n*n+o*o+a*a),e[2]=Math.sqrt(c*c+l*l+h*h),e}function U1(e,t){let r=new st(3);lp(r,t);let s=1/r[0],i=1/r[1],n=1/r[2],o=t[0]*s,a=t[1]*i,c=t[2]*n,l=t[4]*s,h=t[5]*i,f=t[6]*n,u=t[8]*s,_=t[9]*i,m=t[10]*n,b=o+h+m,y=0;return b>0?(y=Math.sqrt(b+1)*2,e[3]=.25*y,e[0]=(f-_)/y,e[1]=(u-c)/y,e[2]=(a-l)/y):o>h&&o>m?(y=Math.sqrt(1+o-h-m)*2,e[3]=(f-_)/y,e[0]=.25*y,e[1]=(a+l)/y,e[2]=(u+c)/y):h>m?(y=Math.sqrt(1+h-o-m)*2,e[3]=(u-c)/y,e[0]=(a+l)/y,e[1]=.25*y,e[2]=(f+_)/y):(y=Math.sqrt(1+m-o-h)*2,e[3]=(a-l)/y,e[0]=(u+c)/y,e[1]=(f+_)/y,e[2]=.25*y),e}function L1(e,t,r,s){t[0]=s[12],t[1]=s[13],t[2]=s[14];let i=s[0],n=s[1],o=s[2],a=s[4],c=s[5],l=s[6],h=s[8],f=s[9],u=s[10];r[0]=Math.sqrt(i*i+n*n+o*o),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(h*h+f*f+u*u);let _=1/r[0],m=1/r[1],b=1/r[2],y=i*_,A=n*m,w=o*b,v=a*_,M=c*m,I=l*b,O=h*_,F=f*m,k=u*b,D=y+M+k,N=0;return D>0?(N=Math.sqrt(D+1)*2,e[3]=.25*N,e[0]=(I-F)/N,e[1]=(O-w)/N,e[2]=(A-v)/N):y>M&&y>k?(N=Math.sqrt(1+y-M-k)*2,e[3]=(I-F)/N,e[0]=.25*N,e[1]=(A+v)/N,e[2]=(O+w)/N):M>k?(N=Math.sqrt(1+M-y-k)*2,e[3]=(O-w)/N,e[0]=(A+v)/N,e[1]=.25*N,e[2]=(I+F)/N):(N=Math.sqrt(1+k-y-M)*2,e[3]=(A-v)/N,e[0]=(O+w)/N,e[1]=(I+F)/N,e[2]=.25*N),e}function V1(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=t[3],c=i+i,l=n+n,h=o+o,f=i*c,u=i*l,_=i*h,m=n*l,b=n*h,y=o*h,A=a*c,w=a*l,v=a*h,M=s[0],I=s[1],O=s[2];return e[0]=(1-(m+y))*M,e[1]=(u+v)*M,e[2]=(_-w)*M,e[3]=0,e[4]=(u-v)*I,e[5]=(1-(f+y))*I,e[6]=(b+A)*I,e[7]=0,e[8]=(_+w)*O,e[9]=(b-A)*O,e[10]=(1-(f+m))*O,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function z1(e,t,r,s,i){let n=t[0],o=t[1],a=t[2],c=t[3],l=n+n,h=o+o,f=a+a,u=n*l,_=n*h,m=n*f,b=o*h,y=o*f,A=a*f,w=c*l,v=c*h,M=c*f,I=s[0],O=s[1],F=s[2],k=i[0],D=i[1],N=i[2],L=(1-(b+A))*I,q=(_+M)*I,$=(m-v)*I,H=(_-M)*O,ct=(1-(u+A))*O,jt=(y+w)*O,oe=(m+v)*F,di=(y-w)*F,uo=(1-(u+b))*F;return e[0]=L,e[1]=q,e[2]=$,e[3]=0,e[4]=H,e[5]=ct,e[6]=jt,e[7]=0,e[8]=oe,e[9]=di,e[10]=uo,e[11]=0,e[12]=r[0]+k-(L*k+H*D+oe*N),e[13]=r[1]+D-(q*k+ct*D+di*N),e[14]=r[2]+N-($*k+jt*D+uo*N),e[15]=1,e}function Dh(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=r+r,a=s+s,c=i+i,l=r*o,h=s*o,f=s*a,u=i*o,_=i*a,m=i*c,b=n*o,y=n*a,A=n*c;return e[0]=1-f-m,e[1]=h+A,e[2]=u-y,e[3]=0,e[4]=h-A,e[5]=1-l-m,e[6]=_+b,e[7]=0,e[8]=u+y,e[9]=_-b,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Bh(e,t,r,s,i,n,o){let a=1/(r-t),c=1/(i-s),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]=(i+s)*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 hp(e,t,r,s,i){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,i!=null&&i!==1/0){let o=1/(s-i);e[10]=(i+s)*o,e[14]=2*i*s*o}else e[10]=-1,e[14]=-2*s;return e}var Uh=hp;function W1(e,t,r,s,i){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,i!=null&&i!==1/0){let o=1/(s-i);e[10]=i*o,e[14]=i*s*o}else e[10]=-1,e[14]=-s;return e}function j1(e,t,r,s){let i=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/(i+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]=(i-n)*l*.5,e[10]=s/(r-s),e[11]=-1,e[12]=0,e[13]=0,e[14]=s*r/(r-s),e[15]=0,e}function fp(e,t,r,s,i,n,o){let a=1/(t-r),c=1/(s-i),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]=(i+s)*c,e[14]=(o+n)*l,e[15]=1,e}var Lh=fp;function H1(e,t,r,s,i,n,o){let a=1/(t-r),c=1/(s-i),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]=(i+s)*c,e[14]=n*l,e[15]=1,e}function Vh(e,t,r,s){let i,n,o,a,c,l,h,f,u,_,m=t[0],b=t[1],y=t[2],A=s[0],w=s[1],v=s[2],M=r[0],I=r[1],O=r[2];return Math.abs(m-M)<1e-6&&Math.abs(b-I)<1e-6&&Math.abs(y-O)<1e-6?ap(e):(f=m-M,u=b-I,_=y-O,i=1/Math.sqrt(f*f+u*u+_*_),f*=i,u*=i,_*=i,n=w*_-v*u,o=v*f-A*_,a=A*u-w*f,i=Math.sqrt(n*n+o*o+a*a),i?(i=1/i,n*=i,o*=i,a*=i):(n=0,o=0,a=0),c=u*a-_*o,l=_*n-f*a,h=f*o-u*n,i=Math.sqrt(c*c+l*l+h*h),i?(i=1/i,c*=i,l*=i,h*=i):(c=0,l=0,h=0),e[0]=n,e[1]=c,e[2]=f,e[3]=0,e[4]=o,e[5]=l,e[6]=u,e[7]=0,e[8]=a,e[9]=h,e[10]=_,e[11]=0,e[12]=-(n*m+o*b+a*y),e[13]=-(c*m+l*b+h*y),e[14]=-(f*m+u*b+_*y),e[15]=1,e)}function X1(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=s[0],c=s[1],l=s[2],h=i-r[0],f=n-r[1],u=o-r[2],_=h*h+f*f+u*u;_>0&&(_=1/Math.sqrt(_),h*=_,f*=_,u*=_);let m=c*u-l*f,b=l*h-a*u,y=a*f-c*h;return _=m*m+b*b+y*y,_>0&&(_=1/Math.sqrt(_),m*=_,b*=_,y*=_),e[0]=m,e[1]=b,e[2]=y,e[3]=0,e[4]=f*y-u*b,e[5]=u*m-h*y,e[6]=h*b-f*m,e[7]=0,e[8]=h,e[9]=f,e[10]=u,e[11]=0,e[12]=i,e[13]=n,e[14]=o,e[15]=1,e}function $1(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 Y1(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 q1(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 up(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 K1(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 Z1(e,t,r,s){return e[0]=t[0]+r[0]*s,e[1]=t[1]+r[1]*s,e[2]=t[2]+r[2]*s,e[3]=t[3]+r[3]*s,e[4]=t[4]+r[4]*s,e[5]=t[5]+r[5]*s,e[6]=t[6]+r[6]*s,e[7]=t[7]+r[7]*s,e[8]=t[8]+r[8]*s,e[9]=t[9]+r[9]*s,e[10]=t[10]+r[10]*s,e[11]=t[11]+r[11]*s,e[12]=t[12]+r[12]*s,e[13]=t[13]+r[13]*s,e[14]=t[14]+r[14]*s,e[15]=t[15]+r[15]*s,e}function Q1(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 J1(e,t){let r=e[0],s=e[1],i=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],f=e[9],u=e[10],_=e[11],m=e[12],b=e[13],y=e[14],A=e[15],w=t[0],v=t[1],M=t[2],I=t[3],O=t[4],F=t[5],k=t[6],D=t[7],N=t[8],L=t[9],q=t[10],$=t[11],H=t[12],ct=t[13],jt=t[14],oe=t[15];return Math.abs(r-w)<=1e-6*Math.max(1,Math.abs(r),Math.abs(w))&&Math.abs(s-v)<=1e-6*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(i-M)<=1e-6*Math.max(1,Math.abs(i),Math.abs(M))&&Math.abs(n-I)<=1e-6*Math.max(1,Math.abs(n),Math.abs(I))&&Math.abs(o-O)<=1e-6*Math.max(1,Math.abs(o),Math.abs(O))&&Math.abs(a-F)<=1e-6*Math.max(1,Math.abs(a),Math.abs(F))&&Math.abs(c-k)<=1e-6*Math.max(1,Math.abs(c),Math.abs(k))&&Math.abs(l-D)<=1e-6*Math.max(1,Math.abs(l),Math.abs(D))&&Math.abs(h-N)<=1e-6*Math.max(1,Math.abs(h),Math.abs(N))&&Math.abs(f-L)<=1e-6*Math.max(1,Math.abs(f),Math.abs(L))&&Math.abs(u-q)<=1e-6*Math.max(1,Math.abs(u),Math.abs(q))&&Math.abs(_-$)<=1e-6*Math.max(1,Math.abs(_),Math.abs($))&&Math.abs(m-H)<=1e-6*Math.max(1,Math.abs(m),Math.abs(H))&&Math.abs(b-ct)<=1e-6*Math.max(1,Math.abs(b),Math.abs(ct))&&Math.abs(y-jt)<=1e-6*Math.max(1,Math.abs(y),Math.abs(jt))&&Math.abs(A-oe)<=1e-6*Math.max(1,Math.abs(A),Math.abs(oe))}var G1=Hi,tb=up;var Nt={};rr(Nt,{add:()=>nb,ceil:()=>ob,clone:()=>eb,copy:()=>sb,create:()=>dp,cross:()=>mb,dist:()=>Mb,distance:()=>mp,div:()=>vb,divide:()=>_p,dot:()=>_b,equals:()=>Sb,exactEquals:()=>Ab,floor:()=>ab,forEach:()=>Ob,fromValues:()=>rb,inverse:()=>pb,len:()=>Ib,length:()=>yp,lerp:()=>Tb,max:()=>lb,min:()=>cb,mul:()=>Rb,multiply:()=>gp,negate:()=>db,normalize:()=>gb,random:()=>yb,round:()=>hb,scale:()=>fb,scaleAndAdd:()=>ub,set:()=>ib,sqrDist:()=>Pb,sqrLen:()=>Cb,squaredDistance:()=>Tp,squaredLength:()=>bp,str:()=>xb,sub:()=>wb,subtract:()=>pp,transformMat4:()=>zh,transformQuat:()=>bb,zero:()=>Eb});function dp(){let e=new st(4);return st!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function eb(e){let t=new st(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function rb(e,t,r,s){let i=new st(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=s,i}function sb(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ib(e,t,r,s,i){return e[0]=t,e[1]=r,e[2]=s,e[3]=i,e}function nb(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 pp(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 gp(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 _p(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 ob(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 ab(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 cb(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 lb(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 hb(e,t){return e[0]=Kt(t[0]),e[1]=Kt(t[1]),e[2]=Kt(t[2]),e[3]=Kt(t[3]),e}function fb(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 ub(e,t,r,s){return e[0]=t[0]+r[0]*s,e[1]=t[1]+r[1]*s,e[2]=t[2]+r[2]*s,e[3]=t[3]+r[3]*s,e}function mp(e,t){let r=t[0]-e[0],s=t[1]-e[1],i=t[2]-e[2],n=t[3]-e[3];return Math.sqrt(r*r+s*s+i*i+n*n)}function Tp(e,t){let r=t[0]-e[0],s=t[1]-e[1],i=t[2]-e[2],n=t[3]-e[3];return r*r+s*s+i*i+n*n}function yp(e){let t=e[0],r=e[1],s=e[2],i=e[3];return Math.sqrt(t*t+r*r+s*s+i*i)}function bp(e){let t=e[0],r=e[1],s=e[2],i=e[3];return t*t+r*r+s*s+i*i}function db(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function pb(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 gb(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=r*r+s*s+i*i+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=s*o,e[2]=i*o,e[3]=n*o,e}function _b(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function mb(e,t,r,s){let i=r[0]*s[1]-r[1]*s[0],n=r[0]*s[2]-r[2]*s[0],o=r[0]*s[3]-r[3]*s[0],a=r[1]*s[2]-r[2]*s[1],c=r[1]*s[3]-r[3]*s[1],l=r[2]*s[3]-r[3]*s[2],h=t[0],f=t[1],u=t[2],_=t[3];return e[0]=f*l-u*c+_*a,e[1]=-(h*l)+u*o-_*n,e[2]=h*c-f*o+_*i,e[3]=-(h*a)+f*n-u*i,e}function Tb(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=t[3];return e[0]=i+s*(r[0]-i),e[1]=n+s*(r[1]-n),e[2]=o+s*(r[2]-o),e[3]=a+s*(r[3]-a),e}function yb(e,t){t=t===void 0?1:t;let r,s,i,n,o,a;do r=Me()*2-1,s=Me()*2-1,o=r*r+s*s;while(o>=1);do i=Me()*2-1,n=Me()*2-1,a=i*i+n*n;while(a>=1);let c=Math.sqrt((1-o)/a);return e[0]=t*r,e[1]=t*s,e[2]=t*i*c,e[3]=t*n*c,e}function zh(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3];return e[0]=r[0]*s+r[4]*i+r[8]*n+r[12]*o,e[1]=r[1]*s+r[5]*i+r[9]*n+r[13]*o,e[2]=r[2]*s+r[6]*i+r[10]*n+r[14]*o,e[3]=r[3]*s+r[7]*i+r[11]*n+r[15]*o,e}function bb(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[0],a=r[1],c=r[2],l=r[3],h=l*s+a*n-c*i,f=l*i+c*s-o*n,u=l*n+o*i-a*s,_=-o*s-a*i-c*n;return e[0]=h*l+_*-o+f*-c-u*-a,e[1]=f*l+_*-a+u*-o-h*-c,e[2]=u*l+_*-c+h*-a-f*-o,e[3]=t[3],e}function Eb(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function xb(e){return`vec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}function Ab(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Sb(e,t){let r=e[0],s=e[1],i=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(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))&&Math.abs(i-c)<=1e-6*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var wb=pp,Rb=gp,vb=_p,Mb=mp,Pb=Tp,Ib=yp,Cb=bp,Ob=function(){let e=dp();return function(t,r,s,i,n,o){let a,c;for(r||(r=4),s||(s=0),i?c=Math.min(i*r+s,t.length):c=t.length,a=s;aMath.PI*2)throw Error("expected radians")}function Ub(e,t,r,s,i,n){let o=2*n/(r-t),a=2*n/(i-s),c=(r+t)/(r-t),l=(i+s)/(i-s),h=-1,f=-1,u=-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]=h,e[11]=f,e[12]=0,e[13]=0,e[14]=u,e[15]=0,e}var xp=1e-6,Lb=6371e3,he=class{constructor({phi:t=0,theta:r=0,radius:s=1,bearing:i,pitch:n,altitude:o,radiusScale:a=Lb}={}){this.phi=t,this.theta=r,this.radius=s||o||1,this.radiusScale=a||1,i!==void 0&&(this.bearing=i),n!==void 0&&(this.pitch=n),this.check()}toString(){return this.formatString(ht)}formatString({printTypes:t=!1}){let r=Wi;return`${t?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(t){return Vt(this.radius,t.radius)&&Vt(this.theta,t.theta)&&Vt(this.phi,t.phi)}exactEquals(t){return this.radius===t.radius&&this.theta===t.theta&&this.phi===t.phi}get bearing(){return 180-dr(this.phi)}set bearing(t){this.phi=Math.PI-Ds(t)}get pitch(){return dr(this.theta)}set pitch(t){this.theta=Ds(t)}get longitude(){return dr(this.phi)}get latitude(){return dr(this.theta)}get lng(){return dr(this.phi)}get lat(){return dr(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(t,r,s){return this.radius=t,this.phi=r,this.theta=s,this.check()}clone(){return new he().copy(this)}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this.check()}fromLngLatZ([t,r,s]){return this.radius=1+s/this.radiusScale,this.phi=Ds(r),this.theta=Ds(t),this.check()}fromVector3(t){return this.radius=oa(t),this.radius>0&&(this.theta=Math.atan2(t[0],t[1]),this.phi=Math.acos(J(t[2]/this.radius,-1,1))),this.check()}toVector3(){return new Z(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(xp,Math.min(Math.PI-xp,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 Xh=`#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 Vb={lightSources:{}};function $h(e={}){let{color:t=[0,0,0],intensity:r=1}=e;return t.map(s=>s*r/255)}function zb({ambientLight:e,pointLights:t=[],directionalLights:r=[]}){let s={};return e?s["lighting_uAmbientLight.color"]=$h(e):s["lighting_uAmbientLight.color"]=[0,0,0],t.forEach((i,n)=>{s[`lighting_uPointLight[${n}].color`]=$h(i),s[`lighting_uPointLight[${n}].position`]=i.position,s[`lighting_uPointLight[${n}].attenuation`]=i.attenuation||[1,0,0]}),s.lighting_uPointLightCount=t.length,r.forEach((i,n)=>{s[`lighting_uDirectionalLight[${n}].color`]=$h(i),s[`lighting_uDirectionalLight[${n}].direction`]=i.direction}),s.lighting_uDirectionalLightCount=r.length,s}function Ap(e=Vb){if("lightSources"in e){let{ambientLight:t,pointLights:r,directionalLights:s}=e.lightSources||{};return t||r&&r.length>0||s&&s.length>0?Object.assign({},zb({ambientLight:t,pointLights:r,directionalLights:s}),{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 Ap({lightSources:t})}return{}}var Yh={name:"lights",vs:Xh,fs:Xh,getUniforms:Ap,defines:{MAX_LIGHTS:3}};var qh=`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 Wb={};function jb(e){let{ambient:t=.35,diffuse:r=.6,shininess:s=32,specularColor:i=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:r,lighting_uShininess:s,lighting_uSpecularColor:i.map(n=>n/255)}}function Sp(e=Wb){if(!("material"in e))return{};let{material:t}=e;return t?jb(t):{lighting_uEnabled:!1}}var fa={name:"gouraud-lighting",dependencies:[Yh],vs:qh,defines:{LIGHTING_VERTEX:1},getUniforms:Sp},ua={name:"phong-lighting",dependencies:[Yh],fs:qh,defines:{LIGHTING_FRAGMENT:1},getUniforms:Sp};var da=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(t){this.id=t.id||ot("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&z(this.indices.usage===V.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 wp(e,t){if(t instanceof da)return t;let r=Hb(e,t),{attributes:s,bufferLayout:i}=Xb(e,t);return new da({topology:t.topology||"triangle-list",bufferLayout:i,vertexCount:t.vertexCount,indices:r,attributes:s})}function Hb(e,t){if(!t.indices)return;let r=t.indices.value;return e.createBuffer({usage:V.INDEX,data:r})}function Xb(e,t){let r=[],s={};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}s[a]=e.createBuffer({data:o.value,id:`${n}-buffer`});let{value:c,size:l,normalized:h}=o;r.push({name:a,format:gl(c,l,h)})}let i=t._calculateVertexCount(t.attributes,t.indices);return{attributes:s,bufferLayout:r,vertexCount:i}}var pa=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(t){let r=Lr(Object.values(t).filter(s=>s.dependencies));for(let s of r)t[s.name]=s;P.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[s,i]of Object.entries(t)){let n=s;this.moduleUniforms[n]=i.defaultUniforms||{},this.moduleBindings[n]={}}}destroy(){}setProps(t){for(let r of Object.keys(t)){let s=r,i=t[s],n=this.modules[s];if(!n){P.warn(`Module ${r} not found`)();continue}let o=this.moduleUniforms[s],a=this.moduleBindings[s],c=n.getUniforms?.(i,o)||i,{uniforms:l,bindings:h}=Br(c);this.moduleUniforms[s]={...o,...l},this.moduleBindings[s]={...a,...h}}}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,s]of Object.entries(this.moduleUniforms))for(let[i,n]of Object.entries(s))t[`${r}.${i}`]={type:this.modules[r].uniformTypes?.[i],value:String(n)};return t}};var Kh=class{device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new Kh(t),t._lumaData.defaultPipelineFactory}constructor(t){this.device=t}createRenderPipeline(t){let r={...ce.defaultProps,...t},s=this._hashRenderPipeline(r);if(!this._renderPipelineCache[s]){let i=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=s,this._renderPipelineCache[s]={pipeline:i,useCount:0}}return this._renderPipelineCache[s].useCount++,this._renderPipelineCache[s].pipeline}createComputePipeline(t){let r={...Dr.defaultProps,...t},s=this._hashComputePipeline(r);if(!this._computePipelineCache[s]){let i=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=s,this._computePipelineCache[s]={pipeline:i,useCount:0}}return this._computePipelineCache[s].useCount++,this._computePipelineCache[s].pipeline}release(t){let r=t.hash,s=t instanceof Dr?this._computePipelineCache:this._renderPipelineCache;s[r].useCount--,s[r].useCount===0&&(s[r].pipeline.destroy(),delete s[r])}_hashComputePipeline(t){return`${this._getHash(t.shader.source)}`}_hashRenderPipeline(t){let r=this._getHash(t.vs.source),s=t.fs?this._getHash(t.fs.source):0,i="-",n=this._getHash(JSON.stringify(t.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${s}V${i}BL${n}`;default:let o=this._getHash(JSON.stringify(t.parameters));return`${r}/${s}V${i}T${t.topology}P${o}BL${n}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}},Xi=Kh;B(Xi,"defaultProps",{...ce.defaultProps});var Zh=class{device;_cache={};static getDefaultShaderFactory(t){return t._lumaData.defaultShaderFactory||=new Zh(t),t._lumaData.defaultShaderFactory}constructor(t){this.device=t}createShader(t){let r=this._hashShader(t),s=this._cache[r];if(!s){let i=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[r]=s={shader:i,useCount:0}}return s.useCount++,s.shader}release(t){let r=this._hashShader(t),s=this._cache[r];s&&(s.useCount--,s.useCount===0&&(delete this._cache[r],s.shader.destroy()))}_hashShader(t){return`${t.stage}:${t.source}`}},$i=Zh;B($i,"defaultProps",{...ar.defaultProps});function Rp(e,t){let r={},s="Values";if(e.attributes.length===0&&!e.varyings?.length)return{"No attributes or varyings":{[s]:"N/A"}};for(let i of e.attributes)if(i){let n=`${i.location} ${i.name}: ${i.type}`;r[`in ${n}`]={[s]:i.stepMode||"vertex"}}for(let i of e.varyings||[]){let n=`${i.location} ${i.name}`;r[`out ${n}`]={[s]:JSON.stringify(i.accessor)}}return r}var gt=null,Qh=null;function vp(e,{id:t,minimap:r,opaque:s,top:i="0",left:n="0",rgbaScale:o=1}){gt||(gt=document.createElement("canvas"),gt.id=t,gt.title=t,gt.style.zIndex="100",gt.style.position="absolute",gt.style.top=i,gt.style.left=n,gt.style.border="blue 1px solid",gt.style.transform="scaleY(-1)",document.body.appendChild(gt),Qh=gt.getContext("2d")),(gt.width!==e.width||gt.height!==e.height)&&(gt.width=e.width/2,gt.height=e.height/2,gt.style.width="400px",gt.style.height="400px");let a=e.device.readPixelsToArrayWebGL(e),c=Qh.createImageData(e.width,e.height),l=0;for(let h=0;h[a.name,a])||[]);this.setShaderInputs(r.shaderInputs||new pa(s));let i=Yb(t),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=fh(this.props.source);let{source:a,getUniforms:c}=this.props.shaderAssembler.assembleShader({platformInfo:i,...this.props,modules:n});this.source=a,this._getModuleUniforms=c}else{let{vs:a,fs:c,getUniforms:l}=this.props.shaderAssembler.assembleShaderPair({platformInfo:i,...this.props,modules:n});this.vs=a,this.fs=c,this._getModuleUniforms=l}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||Xi.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||$i.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}),ir(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:s}=this.vertexArray,i=s?s.byteLength/(s.indexType==="uint32"?4:2):void 0;r=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:i,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(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&&wp(this.device,t);r&&(this.setTopology(r.topology||"triangle-list"),this.bufferLayout=Mp(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?Mp(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){Oi(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 Pi(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let s=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=s}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(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&&P.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[s,i]of Object.entries(t)){let n=this.bufferLayout.find(c=>Pp(c).includes(s));if(!n){P.warn(`Model(${this.id}): Missing layout for buffer "${s}".`)();continue}let o=Pp(n),a=!1;for(let c of o){let l=this._attributeInfos[c];l&&(this.vertexArray.setBuffer(l.location,i),a=!0)}!a&&!(r?.disableWarnings??this.props.disableWarnings)&&P.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${s}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,r){for(let[s,i]of Object.entries(t)){let n=this._attributeInfos[s];n?this.vertexArray.setConstantWebGL(n.location,i):(r?.disableWarnings??this.props.disableWarnings)||P.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${s}"`)()}this.setNeedsRedraw("constants")}setUniforms(t){ir(t)||(this.pipeline.setUniformsWebGL(t),Object.assign(this.uniforms,t)),this.setNeedsRedraw("uniforms")}updateModuleSettings(t){let{bindings:r,uniforms:s}=Br(this._getModuleUniforms(t));Object.assign(this.bindings,r),Object.assign(this.uniforms,s),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let t=0;for(let r of Object.values(this.bindings))r instanceof or?t=Math.max(t,r.texture.updateTimestamp):r instanceof V||r instanceof G?t=Math.max(t,r.updateTimestamp):r instanceof cr||(t=Math.max(t,r.buffer.updateTimestamp));return t}_setGeometryAttributes(t){let r={...t.attributes};for(let[s]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(i=>i.name===s)&&s!=="positions"&&delete r[s];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&&(P.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let s=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),i=null;this.source?i=s:this.fs&&(i=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:s,fs:i}),this._attributeInfos=Oo(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=P.level>3?0:$b;P.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:P.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Rp(this.pipeline.shaderLayout,this.id);P.table(Us,t)();let r=this.shaderInputs.getDebugTable();for(let[i,n]of Object.entries(this.uniforms))r[i]={value:n};P.table(Us,r)();let s=this._getAttributeDebugTable();P.table(Us,this._attributeInfos)(),P.table(Us,s)(),P.groupEnd(Us)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){let r=P.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let s=t.props.framebuffer;s&&vp(s,{id:s.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[r,s]of Object.entries(this._attributeInfos))t[s.location]={name:r,type:s.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[s.location],s.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,s=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);t.indices={name:"indices",type:r.indexType,values:s.toString()}}return t}_getBufferOrConstantValues(t,r){let s=Ii(r);return(t instanceof V?new s(t.debugData):t).toString()}},zt=Jh;B(zt,"defaultProps",{...ce.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:lr.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function Mp(e,t){let r=[...e];for(let s of t){let i=r.findIndex(n=>n.name===s.name);i<0?r.push(s):r[i]=s}return r}function Yb(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}function Pp(e){return e.attributes?e.attributes?.map(t=>t.attribute):[e.name]}var Zt=class{device;model;transformFeedback;static isSupported(t){return t?.info?.type==="webgl"}constructor(t,r=zt.defaultProps){z(Zt.isSupported(t),"BufferTransform not yet implemented on WebGPU"),this.device=t,this.model=new zt(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||Di(),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 V)return r.readAsync();let{buffer:s,byteOffset:i=0,byteLength:n=s.byteLength}=r;return s.readAsync(i,n)}};var qb="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 zt(this.device,{id:r.id||"texture-transform-model",fs:r.fs||Di({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:qb}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){}delete(){this.destroy()}run(t){let{framebuffer:r}=this.bindings[this.currentIndex],s=this.device.beginRenderPass({framebuffer:r,...t});this.model.draw(s),s.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:s,targetTexture:i}){if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,s),Object.assign(t.sourceBuffers,r),i){t.targetTexture=i;let{width:n,height:o}=i;t.framebuffer&&t.framebuffer.destroy(),t.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:o,colorAttachments:[i]}),t.framebuffer.resize({width:n,height:o})}return t}_setSourceTextureParameters(){let t=this.currentIndex,{sourceTextures:r}=this.bindings[t];for(let s in r)r[s].sampler=this.sampler}};var fe=class{id;topology;vertexCount;indices;attributes;userData={};constructor(t){let{attributes:r={},indices:s=null,vertexCount:i=null}=t;this.id=t.id||ot("geometry"),this.topology=t.topology,s&&(this.indices=ArrayBuffer.isView(s)?{value:s,size:1}:s),this.attributes={};for(let[n,o]of Object.entries(r)){let a=ArrayBuffer.isView(o)?{value:o}:o;z(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"?(z(!this.indices),this.indices=a):this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return`Geometry ${this.id} attribute ${t}`}_setAttributes(t,r){return this}_calculateVertexCount(t,r){if(r)return r.value.length;let s=1/0;for(let i of Object.values(t)){let{value:n,size:o,constant:a}=i;!a&&n&&o>=1&&(s=Math.min(s,n.length/o))}return z(Number.isFinite(s)),s}};var Kb=`#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; } `,Ip=[-1,-1,1,-1,-1,1,1,1],qi=class extends zt{constructor(t,r){let s=Ip.map(i=>i===-1?0:i);super(t,{...r,vs:Kb,vertexCount:4,geometry:new fe({topology:"triangle-strip",vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(Ip)},aTexCoord:{size:2,value:new Float32Array(s)},aCoordinate:{size:2,value:new Float32Array(s)}}})})}};var Pe=class{id;matrix=new Q;display=!0;position=new Z;rotation=new Z;scale=new Z(1,1,1);userData={};props={};constructor(t={}){let{id:r}=t;this.id=r||ot(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 z(t.length===3,"setPosition requires vector argument"),this.position=t,this}setRotation(t){return z(t.length===3,"setRotation requires vector argument"),this.rotation=t,this}setScale(t){return z(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:s,scale:i,update:n=!0}=t;return r&&this.setPosition(r),s&&this.setRotation(s),i&&this.setScale(i),n&&this.updateMatrix(),this}updateMatrix(){let t=this.position,r=this.rotation,s=this.scale;return this.matrix.identity(),this.matrix.translate(t),this.matrix.rotateXYZ(r),this.matrix.scale(s),this}update(t={}){let{position:r,rotation:s,scale:i}=t;return r&&this.setPosition(r),s&&this.setRotation(s),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(t,r){z(t),r=r||this.matrix;let s=new Q(t).multiplyRight(r),i=s.invert(),n=i.transpose();return{viewMatrix:t,modelMatrix:r,objectMatrix:r,worldMatrix:s,worldInverseMatrix:i,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 zr=class extends Pe{children;constructor(t={}){t=Array.isArray(t)?{children:t}:t;let{children:r=[]}=t;P.assert(r.every(s=>s instanceof Pe),"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:s})=>{let i=r.getBounds();if(!i)return;let[n,o]=i,a=new Z(n).add(o).divide([2,2,2]);s.transformAsPoint(a,a);let c=new Z(o).subtract(n).divide([2,2,2]);s.transformAsVector(c,c);for(let l=0;l<8;l++){let h=new Z(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],h[f]),t[1][f]=Math.max(t[1][f],h[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,s=r.indexOf(t);return s>-1&&r.splice(s,1),this}removeAll(){return this.children=[],this}traverse(t,{worldMatrix:r=new Q}={}){let s=new Q(r).multiplyRight(this.matrix);for(let i of this.children)i instanceof zr?i.traverse(t,{worldMatrix:s}):t(i,{worldMatrix:s})}};var Ki=class extends Pe{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 Zi=class extends fe{constructor(t={}){let{id:r=ot("cube-geometry"),indices:s=!0}=t;super(s?{...t,id:r,topology:"triangle-list",indices:{size:1,value:Zb},attributes:{...sE,...t.attributes}}:{...t,id:r,topology:"triangle-list",indices:void 0,attributes:{...iE,...t.attributes}})}},Zb=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]),Qb=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]),Jb=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]),Gb=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]),tE=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]),eE=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]),rE=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]),sE={POSITION:{size:3,value:Qb},NORMAL:{size:3,value:Jb},TEXCOORD_0:{size:2,value:Gb}},iE={POSITION:{size:3,value:tE},TEXCOORD_0:{size:2,value:eE},COLOR_0:{size:3,value:rE}};var Qi=class extends fe{constructor(t={}){let{id:r=ot("sphere-geometry")}=t,{indices:s,attributes:i}=nE(t);super({...t,id:r,topology:"triangle-list",indices:s,attributes:{...i,...t.attributes}})}};function nE(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),h=(A,w,v,M,I)=>e.radius||1,f=new Float32Array(l*3),u=new Float32Array(l*3),_=new Float32Array(l*2),m=l>65535?Uint32Array:Uint16Array,b=new m(t*r*6);for(let A=0;A<=t;A++)for(let w=0;w<=r;w++){let v=w/r,M=A/t,I=w+A*(r+1),O=I*2,F=I*3,k=c*v,D=n*M,N=Math.sin(k),L=Math.cos(k),q=Math.sin(D),$=Math.cos(D),H=L*q,ct=$,jt=N*q,oe=h(H,ct,jt,v,M);f[F+0]=oe*H,f[F+1]=oe*ct,f[F+2]=oe*jt,u[F+0]=H,u[F+1]=ct,u[F+2]=jt,_[O+0]=v,_[O+1]=1-M}let y=r+1;for(let A=0;Azs,load:()=>Tr,parse:()=>mr,registerLoaders:()=>on});function pr(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var Ie={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},pE=Ie.self||Ie.window||Ie.global||{},gE=Ie.window||Ie.self||Ie.global||{},_E=Ie.global||Ie.self||Ie.window||{},mE=Ie.document||{};var Wr=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Cp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),TE=Cp&&parseFloat(Cp[1])||0;function tf(e,t){return Op(e||{},t)}function Op(e,t,r=0){if(r>3)return t;let s={...e};for(let[i,n]of Object.entries(t))n&&typeof n=="object"&&!Array.isArray(n)?s[i]=Op(s[i]||{},t[i],r+1):s[i]=t[i];return s}var Np="latest";function yE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.0-beta.2"),globalThis._loadersgl_.version}var ef=yE();function wt(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}var Ce={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},lO=Ce.self||Ce.window||Ce.global||{},hO=Ce.window||Ce.self||Ce.global||{},fO=Ce.global||Ce.self||Ce.window||{},uO=Ce.document||{};var Qt=typeof process!="object"||String(process)!=="[object process]"||process.browser;var kp=typeof window<"u"&&typeof window.orientation<"u",Fp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),dO=Fp&&parseFloat(Fp[1])||0;var Ji=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(t,r){this.name=t,this.workerThread=r,this.result=new Promise((s,i)=>{this._resolve=s,this._reject=i})}postMessage(t,r){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:r})}done(t){wt(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){wt(this.isRunning),this.isRunning=!1,this._reject(t)}};var Ls=class{terminate(){}};var rf=new Map;function Dp(e){wt(e.source&&!e.url||!e.source&&e.url);let t=rf.get(e.source||e.url);return t||(e.url&&(t=bE(e.url),rf.set(e.url,t)),e.source&&(t=Bp(e.source),rf.set(e.source,t))),wt(t),t}function bE(e){if(!e.startsWith("http"))return e;let t=EE(e);return Bp(t)}function Bp(e){let t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function EE(e){return`try { importScripts('${e}'); } catch (error) { console.error(error); throw error; }`}function sf(e,t=!0,r){let s=r||new Set;if(e){if(Up(e))s.add(e);else if(Up(e.buffer))s.add(e.buffer);else if(!ArrayBuffer.isView(e)){if(t&&typeof e=="object")for(let i in e)sf(e[i],t,s)}}return r===void 0?Array.from(s):[]}function Up(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 nf=()=>{},gr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Qt||typeof Ls<"u"&&!Qt}constructor(t){let{name:r,source:s,url:i}=t;wt(s||i),this.name=r,this.source=s,this.url=i,this.onMessage=nf,this.onError=n=>console.log(n),this.worker=Qt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=nf,this.onError=nf,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,r){r=r||sf(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=Dp({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 s=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;t=new Ls(s,{eval:!1})}else if(this.source)t=new Ls(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 Gi=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return gr.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=(i,n,o)=>i.done(o),s=(i,n)=>i.error(n)){let i=new Promise(n=>(this.jobQueue.push({name:t,onMessage:r,onError:s,onStart:n}),this));return this._startQueuedJob(),await i}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 s=new Ji(r.name,t);t.onMessage=i=>r.onMessage(s,i.type,i.payload),t.onError=i=>r.onError(s,i),r.onStart(s);try{await s.result}catch(i){console.error(`Worker exception: ${i}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!Qt||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{}},jr=class{props;workerPools=new Map;static isSupported(){return gr.isSupported()}static getWorkerFarm(t={}){return jr._workerFarm=jr._workerFarm||new jr({}),jr._workerFarm.setProps(t),jr._workerFarm}constructor(t){this.props={...xE},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:s,url:i}=t,n=this.workerPools.get(r);return n||(n=new Gi({name:r,source:s,url:i}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},_r=jr;B(_r,"_workerFarm");function of(e,t={}){let r=t[e.id]||{},s=Qt?`${e.id}-worker.js`:`${e.id}-worker-node.js`,i=r.workerUrl;if(!i&&e.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(Qt?i=`modules/${e.module}/dist/${s}`:i=`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!i){let n=e.version;n==="latest"&&(n=Np);let o=n?`@${n}`:"";i=`https://unpkg.com/@loaders.gl/${e.module}${o}/dist/${s}`}return wt(i),i}function af(e,t=ef){wt(e,"no worker provided");let r=e.version;return!(!t||!r)}function cf(e,t){return!_r.isSupported()||!Qt&&!t?._nodeWorkers?!1:e.worker&&t?.worker}async function lf(e,t,r,s,i){let n=e.id,o=of(e,r),c=_r.getWorkerFarm(r).getWorkerPool({name:n,url:o});r=JSON.parse(JSON.stringify(r)),s=JSON.parse(JSON.stringify(s||{}));let l=await c.startJob("process-on-worker",AE.bind(null,i));return l.postMessage("process",{input:t,options:r,context:s}),await(await l.result).result}async function AE(e,t,r,s){switch(r){case"done":t.done(s);break;case"error":t.error(new Error(s.error));break;case"process":let{id:i,input:n,options:o}=s;try{let a=await e(n,o);t.postMessage("done",{id:i,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:i,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function hf(e,t,r){if(r=r||e.byteLength,e.byteLengthn instanceof ArrayBuffer?new Uint8Array(n):n),r=t.reduce((n,o)=>n+o.byteLength,0),s=new Uint8Array(r),i=0;for(let n of t)s.set(n,i),i+=n.byteLength;return s.buffer}async function uf(e){let t=[];for await(let r of e)t.push(r);return ff(...t)}var SE="",Vp={};function df(e){for(let t in Vp)if(e.startsWith(t)){let r=Vp[t];e=e.replace(t,r)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${SE}${e}`),e}function zp(e){return e&&typeof e=="object"&&e.isBuffer}function ga(e){if(zp(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 Hr={};rr(Hr,{dirname:()=>RE,filename:()=>wE,join:()=>vE,resolve:()=>ME});function Wp(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function wE(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function RE(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function vE(...e){let t="/";return e=e.map((r,s)=>(s&&(r=r.replace(new RegExp(`^${t}`),"")),s!==e.length-1&&(r=r.replace(new RegExp(`${t}$`),"")),r)),e.join(t)}function ME(...e){let t=[];for(let n=0;n=-1&&!s;n--){let o;n>=0?o=t[n]:(i===void 0&&(i=Wp()),o=i),o.length!==0&&(r=`${o}/${r}`,s=o.charCodeAt(0)===tn)}return r=PE(r,!s),s?`/${r}`:r.length>0?r:"."}var tn=47,pf=46;function PE(e,t){let r="",s=-1,i=0,n,o=!1;for(let a=0;a<=e.length;++a){if(a2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==tn;--l);if(l!==c){r=l===-1?"":r.slice(0,l),s=a,i=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",s=a,i=0,o=!1;continue}}t&&(r.length>0?r+="/..":r="..",o=!0)}else{let c=e.slice(s+1,a);r.length>0?r+=`/${c}`:r=c,o=!1}s=a,i=0}else n===pf&&i!==-1?++i:i=-1}return r}var IE=e=>typeof e=="boolean",en=e=>typeof e=="function",Xr=e=>e!==null&&typeof e=="object",gf=e=>Xr(e)&&e.constructor==={}.constructor;var jp=e=>Boolean(e)&&typeof e[Symbol.iterator]=="function",Hp=e=>e&&typeof e[Symbol.asyncIterator]=="function";var Jt=e=>typeof Response<"u"&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json;var Gt=e=>typeof Blob<"u"&&e instanceof Blob,Xp=e=>e&&typeof e=="object"&&e.isBuffer;var CE=e=>typeof ReadableStream<"u"&&e instanceof ReadableStream||Xr(e)&&en(e.tee)&&en(e.cancel)&&en(e.getReader);var OE=e=>Xr(e)&&en(e.read)&&en(e.pipe)&&IE(e.readable),_a=e=>CE(e)||OE(e);var ma=class extends Error{constructor(t,r){super(t),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var NE=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,FE=/^([-\w.]+\/[-\w.+]+)/;function _f(e,t){return e.toLowerCase()===t.toLowerCase()}function $p(e){let t=FE.exec(e);return t?t[1]:e}function mf(e){let t=NE.exec(e);return t?t[1]:""}var Yp=/\?.*/;function qp(e){let t=e.match(Yp);return t&&t[0]}function Vs(e){return e.replace(Yp,"")}function Kp(e){if(e.length<50)return e;let t=e.slice(e.length-15);return`${e.substr(0,32)}...${t}`}function $r(e){return Jt(e)?e.url:Gt(e)?e.name||"":typeof e=="string"?e:""}function rn(e){if(Jt(e)){let t=e,r=t.headers.get("content-type")||"",s=Vs(t.url);return $p(r)||mf(s)}return Gt(e)?e.type||"":typeof e=="string"?mf(e):""}function Zp(e){return Jt(e)?e.headers["content-length"]||-1:Gt(e)?e.size:typeof e=="string"?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}async function Ta(e){if(Jt(e))return e;let t={},r=Zp(e);r>=0&&(t["content-length"]=String(r));let s=$r(e),i=rn(e);i&&(t["content-type"]=i);let n=await DE(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:s}),o}async function Qp(e){if(!e.ok)throw await kE(e)}async function kE(e){let t=Kp(e.url),r=`Failed to fetch resource (${e.status}) ${e.statusText}: ${t}`;r=r.length>100?`${r.slice(0,100)}...`:r;let s={reason:e.statusText,url:e.url,response:e};try{let i=e.headers.get("Content-Type");s.reason=i?.includes("application/json")?await e.json():e.text()}catch{}return new ma(r,s)}async function DE(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(s=>{let i=new FileReader;i.onload=n=>s(n?.target?.result),i.readAsDataURL(r)})}if(e instanceof ArrayBuffer){let r=e.slice(0,5);return`data:base64,${BE(r)}`}return null}function BE(e){let t="",r=new Uint8Array(e);for(let s=0;s{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},ba=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 yf={fetch:null,mimeType:void 0,nothrow:!1,log:new ba,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Wr,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Jp={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 bf(){globalThis.loaders=globalThis.loaders||{};let{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function Ef(){let e=bf();return e.globalOptions=e.globalOptions||{...yf},e.globalOptions}function eg(e,t,r,s){return r=r||[],r=Array.isArray(r)?r:[r],zE(e,r),jE(t,e,s)}function zE(e,t){Gp(e,null,yf,Jp,t);for(let r of t){let s=e&&e[r.id]||{},i=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Gp(s,r.id,i,n,t)}}function Gp(e,t,r,s,i){let n=t||"Top level",o=t?`${t}.`:"";for(let a in e){let c=!t&&Xr(e[a]),l=a==="baseUri"&&!t,h=a==="workerUrl"&&t;if(!(a in r)&&!l&&!h){if(a in s)Tf.warn(`${n} loader option '${o}${a}' no longer supported, use '${s[a]}'`)();else if(!c){let f=WE(a,i);Tf.warn(`${n} loader option '${o}${a}' not recognized. ${f}`)()}}}}function WE(e,t){let r=e.toLowerCase(),s="";for(let i of t)for(let n in i.options){if(e===n)return`Did you mean '${i.id}.${n}'?`;let o=n.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(s=s||`Did you mean '${i.id}.${n}'?`)}return s}function jE(e,t,r){let i={...e.options||{}};return HE(i,r),i.log===null&&(i.log=new ya),tg(i,Ef()),tg(i,t),i}function tg(e,t){for(let r in t)if(r in t){let s=t[r];gf(s)&&gf(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function HE(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}function sn(e){return e?(Array.isArray(e)&&(e=e[0]),Array.isArray(e?.extensions)):!1}function nn(e){pr(e,"null loader"),pr(sn(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 rg=()=>{let e=bf();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function on(e){let t=rg();e=Array.isArray(e)?e:[e];for(let r of e){let s=nn(r);t.find(i=>s===i)||t.unshift(s)}}function sg(){return rg()}var ig=new Ct({id:"loaders.gl"});var XE=/\.([^.]+)$/;async function ag(e,t=[],r,s){if(!cg(e))return null;let i=ng(e,t,{...r,nothrow:!0},s);if(i)return i;if(Gt(e)&&(e=await e.slice(0,10).arrayBuffer(),i=ng(e,t,r,s)),!i&&!r?.nothrow)throw new Error(lg(e));return i}function ng(e,t=[],r,s){if(!cg(e))return null;if(t&&!Array.isArray(t))return nn(t);let i=[];t&&(i=i.concat(t)),r?.ignoreRegisteredLoaders||i.push(...sg()),YE(i);let n=$E(e,i,r,s);if(!n&&!r?.nothrow)throw new Error(lg(e));return n}function $E(e,t,r,s){let i=$r(e),n=rn(e),o=Vs(i)||s?.url,a=null,c="";return r?.mimeType&&(a=xf(t,r?.mimeType),c=`match forced by supplied MIME type ${r?.mimeType}`),a=a||qE(t,o),c=c||(a?`matched url ${o}`:""),a=a||xf(t,n),c=c||(a?`matched MIME type ${n}`:""),a=a||ZE(t,e),c=c||(a?`matched initial data ${hg(e)}`:""),r?.fallbackMimeType&&(a=a||xf(t,r?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&ig.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function cg(e){return!(e instanceof Response&&e.status===204)}function lg(e){let t=$r(e),r=rn(e),s="No valid loader found (";s+=t?`${Hr.filename(t)}, `:"no url provided, ",s+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let i=e?hg(e):"";return s+=i?` first bytes: "${i}"`:"first bytes: not available",s+=")",s}function YE(e){for(let t of e)nn(t)}function qE(e,t){let r=t&&XE.exec(t),s=r&&r[1];return s?KE(e,s):null}function KE(e,t){t=t.toLowerCase();for(let r of e)for(let s of r.extensions)if(s.toLowerCase()===t)return r;return null}function xf(e,t){for(let r of e)if(r.mimeTypes?.some(s=>_f(t,s))||_f(t,`application/x.${r.id}`))return r;return null}function ZE(e,t){if(!t)return null;for(let r of e)if(typeof t=="string"){if(QE(t,r))return r}else if(ArrayBuffer.isView(t)){if(og(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer&&og(t,0,r))return r;return null}function QE(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some(s=>e.startsWith(s))}function og(e,t,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(i=>JE(e,t,r,i))}function JE(e,t,r,s){if(s instanceof ArrayBuffer)return hf(s,e,s.byteLength);switch(typeof s){case"function":return s(e);case"string":let i=Af(e,t,s.length);return s===i;default:return!1}}function hg(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?Af(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?Af(e,0,t):""}function Af(e,t,r){if(e.byteLengthzs(i,s.fetch):t?.fetch?t?.fetch:zs}function mg(e,t,r){if(r)return r;let s={fetch:Ea(t,e),...e};if(s.url){let i=Vs(s.url);s.baseUrl=i,s.queryString=qp(s.url),s.filename=Hr.filename(i),s.baseUrl=Hr.dirname(i)}return Array.isArray(s.loaders)||(s.loaders=null),s}function Tg(e,t){if(e&&!Array.isArray(e))return e;let r;if(e&&(r=Array.isArray(e)?e:[e]),t&&t.loaders){let s=Array.isArray(t.loaders)?t.loaders:[t.loaders];r=r?[...r,...s]:s}return r&&r.length?r:void 0}async function mr(e,t,r,s){t&&!Array.isArray(t)&&!sn(t)&&(s=void 0,r=t,t=void 0),e=await e,r=r||{};let i=$r(e),o=Tg(t,s),a=await ag(e,o,r);return a?(r=eg(r,a,o,i),s=mg({url:i,_parse:mr,loaders:o},r,s||null),await rx(a,e,r,s)):null}async function rx(e,t,r,s){if(af(e),r=tf(e.options,r),Jt(t)){let n=t,{ok:o,redirected:a,status:c,statusText:l,type:h,url:f}=n,u=Object.fromEntries(n.headers.entries());s.response={headers:u,ok:o,redirected:a,status:c,statusText:l,type:h,url:f}}t=await _g(t,e,r);let i=e;if(i.parseTextSync&&typeof t=="string")return i.parseTextSync(t,r,s);if(cf(e,r))return await lf(e,t,r,s,mr);if(i.parseText&&typeof t=="string")return await i.parseText(t,r,s);if(i.parse)return await i.parse(t,r,s);throw wt(!i.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}async function Tr(e,t,r,s){let i,n;!Array.isArray(t)&&!sn(t)?(i=[],n=t,s=void 0):(i=t,n=r);let o=Ea(n),a=e;return typeof e=="string"&&(a=await o(e)),Gt(e)&&(a=await o(e)),Array.isArray(i)?await mr(a,i,n):await mr(a,i,n)}var yg="4.2.0-beta.2";var sx=globalThis.loaders?.parseImageNode,Rf=typeof Image<"u",vf=typeof ImageBitmap<"u",ix=Boolean(sx),Mf=Wr?!0:ix;function bg(e){switch(e){case"auto":return vf||Rf||Mf;case"imagebitmap":return vf;case"image":return Rf;case"data":return Mf;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function Eg(){if(vf)return"imagebitmap";if(Rf)return"image";if(Mf)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function nx(e){let t=ox(e);if(!t)throw new Error("Not an image");return t}function xg(e){switch(nx(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 ox(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 ax=/^data:image\/svg\+xml/,cx=/\.svg((\?|#).*)?$/;function xa(e){return e&&(ax.test(e)||cx.test(e))}function Ag(e,t){if(xa(t)){let s=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(s=unescape(encodeURIComponent(s)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(s)}`}return Pf(e,t)}function Pf(e,t){if(xa(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Aa(e,t,r){let s=Ag(e,r),i=self.URL||self.webkitURL,n=typeof s!="string"&&i.createObjectURL(s);try{return await lx(n||s,t)}finally{n&&i.revokeObjectURL(n)}}async function lx(e,t){let r=new Image;return r.src=e,t.image&&t.image.decode&&r.decode?(await r.decode(),r):await new Promise((s,i)=>{try{r.onload=()=>s(r),r.onerror=n=>{let o=n instanceof Error?n.message:"error";i(new Error(o))}}catch(n){i(n)}})}var hx={},Sg=!0;async function wg(e,t,r){let s;xa(r)?s=await Aa(e,t,r):s=Pf(e,r);let i=t&&t.imagebitmap;return await fx(s,i)}async function fx(e,t=null){if((ux(t)||!Sg)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(r){console.warn(r),Sg=!1}return await createImageBitmap(e)}function ux(e){for(let t in e||hx)return!1;return!0}function Rg(e){return!_x(e,"ftyp",4)||!(e[8]&96)?null:dx(e)}function dx(e){switch(px(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function px(e,t,r){return String.fromCharCode(...e.slice(t,r))}function gx(e){return[...e].map(t=>t.charCodeAt(0))}function _x(e,t,r=0){let s=gx(t);for(let i=0;i=24&&t.getUint32(0,Oe)===2303741511?{mimeType:"image/png",width:t.getUint32(16,Oe),height:t.getUint32(20,Oe)}:null}function yx(e){let t=cn(e);return t.byteLength>=10&&t.getUint32(0,Oe)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,an),height:t.getUint16(8,an)}:null}function bx(e){let t=cn(e);return t.byteLength>=14&&t.getUint16(0,Oe)===16973&&t.getUint32(2,an)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,an),height:t.getUint32(22,an)}:null}function Ex(e){let t=cn(e);if(!(t.byteLength>=3&&t.getUint16(0,Oe)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:s,sofMarkers:i}=xx(),n=2;for(;n+9Boolean(Sa(new DataView(e)))],options:Rx};var vx=new Ct({id:"deck"}),j=vx;var Cf={};function wa(e){Cf=e}function it(e,t,r,s){j.level>0&&Cf[e]&&Cf[e].call(null,t,r,s)}function Mx(e){let t=e[0],r=e[e.length-1];return t==="{"&&r==="}"||t==="["&&r==="]"}var Pg={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Mx,parseTextSync:JSON.parse};function Px(){let e="9.0.35",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(j.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:j,_registerLoggers:wa},on([Pg,[If,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}var Ra=Px();var Ig="#define SMOOTH_EDGE_RADIUS 0.5",Ix=` ${Ig} 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) ); `,Cx=` ${Ig} struct FragmentGeometry { vec2 uv; } geometry; float smoothedge(float edge, float x) { return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); } `,Cg={name:"geometry",vs:Ix,fs:Cx};var X={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(X,"IDENTITY",{get:()=>(j.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var bt={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},ln={common:0,meters:1,pixels:2},hn={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},Og={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};var Ox=Object.keys(X).map(e=>`const int COORDINATE_SYSTEM_${e} = ${X[e]};`).join(""),Nx=Object.keys(bt).map(e=>`const int PROJECTION_MODE_${e} = ${bt[e]};`).join(""),Fx=Object.keys(ln).map(e=>`const int UNIT_${e.toUpperCase()} = ${ln[e]};`).join(""),Ng=`${Ox} ${Nx} ${Fx} 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 kx(e,t){if(e===t)return!0;if(Array.isArray(e)){let r=e.length;if(!t||t.length!==r)return!1;for(let s=0;s{for(let i in s)if(!kx(s[i],t[i])){r=e(s),t=s;break}return r}}var Fg=[0,0,0,0],Dx=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],kg=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Bx=[0,0,0],Dg=[0,0,0],Ux=te(Vx);function Of(e,t,r=Dg){r.length<3&&(r=[r[0],r[1],0]);let s=r,i,n=!0;switch(t===X.LNGLAT_OFFSETS||t===X.METER_OFFSETS?i=r:i=e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case bt.WEB_MERCATOR:(t===X.LNGLAT||t===X.CARTESIAN)&&(i=[0,0,0],n=!1);break;case bt.WEB_MERCATOR_AUTO_OFFSET:t===X.LNGLAT?s=i:t===X.CARTESIAN&&(s=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],i=e.unprojectPosition(s),s[0]-=r[0],s[1]-=r[1],s[2]-=r[2]);break;case bt.IDENTITY:s=e.position.map(Math.fround),s[2]=s[2]||0;break;case bt.GLOBE:n=!1,i=null;break;default:n=!1}return{geospatialOrigin:i,shaderCoordinateOrigin:s,offsetMode:n}}function Lx(e,t,r){let{viewMatrixUncentered:s,projectionMatrix:i}=e,{viewMatrix:n,viewProjectionMatrix:o}=e,a=Fg,c=Fg,l=e.cameraPosition,{geospatialOrigin:h,shaderCoordinateOrigin:f,offsetMode:u}=Of(e,t,r);return u&&(c=e.projectPosition(h||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Nt.transformMat4([],c,o),n=s||n,o=ut.multiply([],i,n),o=ut.multiply([],o,Dx)),{viewMatrix:n,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:h}}function va({viewport:e,devicePixelRatio:t=1,modelMatrix:r=null,coordinateSystem:s=X.DEFAULT,coordinateOrigin:i=Dg,autoWrapLongitude:n=!1}){s===X.DEFAULT&&(s=e.isGeospatial?X.LNGLAT:X.CARTESIAN);let o=Ux({viewport:e,devicePixelRatio:t,coordinateSystem:s,coordinateOrigin:i});return o.project_uWrapLongitude=n,o.project_uModelMatrix=r||kg,o}function Vx({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:s}){let{projectionCenter:i,viewProjectionMatrix:n,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=Lx(e,r,s),h=e.getDistanceScales(),f=[e.width*t,e.height*t],u=Nt.transformMat4([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,_={project_uCoordinateSystem:r,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:c,project_uCommonOrigin:o.slice(0,3),project_uCenter:i,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:f,project_uDevicePixelRatio:t,project_uFocalDistance:u,project_uCommonUnitsPerMeter:h.unitsPerMeter,project_uCommonUnitsPerWorldUnit:h.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Bx,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:n,project_uModelMatrix:kg,project_uCameraPosition:a};if(l){let m=e.getDistanceScales(l);switch(r){case X.METER_OFFSETS:_.project_uCommonUnitsPerWorldUnit=m.unitsPerMeter,_.project_uCommonUnitsPerWorldUnit2=m.unitsPerMeter2;break;case X.LNGLAT:case X.LNGLAT_OFFSETS:e._pseudoMeters||(_.project_uCommonUnitsPerMeter=m.unitsPerMeter),_.project_uCommonUnitsPerWorldUnit=m.unitsPerDegree,_.project_uCommonUnitsPerWorldUnit2=m.unitsPerDegree2;break;case X.CARTESIAN:_.project_uCommonUnitsPerWorldUnit=[1,1,m.unitsPerMeter[2]],_.project_uCommonUnitsPerWorldUnit2=[0,0,m.unitsPerMeter2[2]];break;default:break}}return _}var zx={};function Wx(e=zx){return"viewport"in e?va(e):{}}var yr={name:"project",dependencies:[uh,Cg],vs:Ng,getUniforms:Wx};var jx=` 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); } `,Nf={name:"project32",dependencies:[yr],vs:jx};function Ff(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function br(e,t){let r=Nt.transformMat4([],t,e);return Nt.scale(r,r,1/r[3]),r}function kf(e,t){let r=e%t;return r<0?t+r:r}function Bg(e,t,r){return r*t+(1-r)*e}function fn(e,t,r){return er?r:e}function Hx(e){return Math.log(e)*Math.LOG2E}var Ws=Math.log2||Hx;function ue(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var de=Math.PI,Ug=de/4,ee=de/180,Df=180/de,js=512,Ma=4003e4,Hs=85.051129,Lg=1.5;function un(e){return Math.pow(2,e)}function Pa(e){return Ws(e)}function pe(e){let[t,r]=e;ue(Number.isFinite(t)),ue(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let s=t*ee,i=r*ee,n=js*(s+de)/(2*de),o=js*(de+Math.log(Math.tan(Ug+i*.5)))/(2*de);return[n,o]}function Ft(e){let[t,r]=e,s=t/js*(2*de)-de,i=2*(Math.atan(Math.exp(r/js*(2*de)-de))-Ug);return[s*Df,i*Df]}function dn(e){let{latitude:t}=e;ue(Number.isFinite(t));let r=Math.cos(t*ee);return Pa(Ma*r)-9}function pn(e){let t=Math.cos(e*ee);return js/Ma/t}function Xs(e){let{latitude:t,longitude:r,highPrecision:s=!1}=e;ue(Number.isFinite(t)&&Number.isFinite(r));let i=js,n=Math.cos(t*ee),o=i/360,a=o/n,c=i/Ma/n,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(s){let h=ee*Math.tan(t*ee)/n,f=o*h/2,u=i/Ma*h,_=u/a*c;l.unitsPerDegree2=[0,f,u],l.unitsPerMeter2=[_,0,_]}return l}function gn(e,t){let[r,s,i]=e,[n,o,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=Xs({longitude:r,latitude:s,highPrecision:!0}),h=pe(e);h[0]+=n*(c[0]+l[0]*o),h[1]+=o*(c[1]+l[1]*o);let f=Ft(h),u=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[f[0],f[1],u]:f}function Ia(e){let{height:t,pitch:r,bearing:s,altitude:i,scale:n,center:o}=e,a=Ff();ut.translate(a,a,[0,0,-i]),ut.rotateX(a,a,-r*ee),ut.rotateZ(a,a,s*ee);let c=n/t;return ut.scale(a,a,[c,c,c]),o&&ut.translate(a,a,St.negate([],o)),a}function Bf(e){let{width:t,height:r,altitude:s,pitch:i=0,offset:n,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e,{fovy:h=Yr(Lg)}=e;s!==void 0&&(h=Yr(s));let f=h*ee,u=i*ee,_=qr(h),m=_;o&&(m+=o[2]*a/Math.cos(u)/r);let b=f*(.5+(n?n[1]:0)/r),y=Math.sin(b)*m/Math.sin(fn(Math.PI/2-u-b,.01,Math.PI-.01)),A=Math.sin(u)*y+m,w=m*10,v=Math.min(A*l,w);return{fov:f,aspect:t/r,focalDistance:_,near:c,far:v}}function Yr(e){return 2*Math.atan(.5/e)*Df}function qr(e){return .5/Math.tan(.5*e*ee)}function $s(e,t){let[r,s,i=0]=e;return ue(Number.isFinite(r)&&Number.isFinite(s)&&Number.isFinite(i)),br(t,[r,s,i,1])}function re(e,t,r=0){let[s,i,n]=e;if(ue(Number.isFinite(s)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(n))return br(t,[s,i,n,1]);let o=br(t,[s,i,0,1]),a=br(t,[s,i,1,1]),c=o[2],l=a[2],h=c===l?0:((r||0)-c)/(l-c);return ft.lerp([],o,a,h)}function Ca(e){let{width:t,height:r,bounds:s,minExtent:i=0,maxZoom:n=24,offset:o=[0,0]}=e,[[a,c],[l,h]]=s,f=Xx(e.padding),u=pe([a,fn(h,-Hs,Hs)]),_=pe([l,fn(c,-Hs,Hs)]),m=[Math.max(Math.abs(_[0]-u[0]),i),Math.max(Math.abs(_[1]-u[1]),i)],b=[t-f.left-f.right-Math.abs(o[0])*2,r-f.top-f.bottom-Math.abs(o[1])*2];ue(b[0]>0&&b[1]>0);let y=b[0]/m[0],A=b[1]/m[1],w=(f.right-f.left)/2/y,v=(f.top-f.bottom)/2/A,M=[(_[0]+u[0])/2+w,(_[1]+u[1])/2+v],I=Ft(M),O=Math.min(n,Ws(Math.abs(Math.min(y,A))));return ue(Number.isFinite(O)),{longitude:I[0],latitude:I[1],zoom:O}}function Xx(e=0){return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:(ue(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var Vg=Math.PI/180;function Oa(e,t=0){let{width:r,height:s,unproject:i}=e,n={targetZ:t},o=i([0,s],n),a=i([r,s],n),c,l,h=e.fovy?.5*e.fovy*Vg:Math.atan(.5/e.altitude),f=(90-e.pitch)*Vg;return h>f-.01?(c=zg(e,0,t),l=zg(e,r,t)):(c=i([0,0],n),l=i([r,0],n)),[o,a,l,c]}function zg(e,t,r){let{pixelUnprojectionMatrix:s}=e,i=br(s,[t,0,1,1]),n=br(s,[t,e.height,1,1]),a=(r*e.distanceScales.unitsPerMeter[2]-i[2])/(n[2]-i[2]),c=ft.lerp([],i,n,a),l=Ft(c);return l.push(r),l}var Wg=512;function Uf(e){let{width:t,height:r,pitch:s=0}=e,{longitude:i,latitude:n,zoom:o,bearing:a=0}=e;(i<-180||i>180)&&(i=kf(i+180,360)-180),(a<-180||a>180)&&(a=kf(a+180,360)-180);let c=Ws(r/Wg);if(o<=c)o=c,n=0;else{let l=r/2/Math.pow(2,o),h=Ft([0,l])[1];if(nf&&(n=f)}}return{width:t,height:r,longitude:i,latitude:n,zoom:o,pitch:s,bearing:a}}var jg=.01,Yx=["longitude","latitude","zoom"],Hg={curve:1.414,speed:1.2};function Lf(e,t,r,s){let{startZoom:i,startCenterXY:n,uDelta:o,w0:a,u1:c,S:l,rho:h,rho2:f,r0:u}=Xg(e,t,s);if(co?0:h}function Xg(e,t,r){r=Object.assign({},Hg,r);let s=r.curve,i=e.zoom,n=[e.longitude,e.latitude],o=un(i),a=t.zoom,c=[t.longitude,t.latitude],l=un(a-i),h=pe(n),f=pe(c),u=ft.sub([],f,h),_=Math.max(e.width,e.height),m=_/l,b=ft.length(u)*o,y=Math.max(b,jg),A=s*s,w=(m*m-_*_+A*A*y*y)/(2*_*A*y),v=(m*m-_*_-A*A*y*y)/(2*m*A*y),M=Math.log(Math.sqrt(w*w+1)-w),I=Math.log(Math.sqrt(v*v+1)-v),O=(I-M)/s;return{startZoom:i,startCenterXY:h,uDelta:u,w0:_,u1:b,S:O,rho:s,rho2:A,r0:M,r1:I}}var Kx=` 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; } `,Zx=` 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; } `,Qx=te(rA),Jx=te(sA),Gx=[0,0,0,1],tA=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function eA(e,t){let[r,s,i]=e,n=re([r,s,i],t);return Number.isFinite(i)?n:[n[0],n[1],0]}function rA({viewport:e,center:t}){return new Q(e.viewProjectionMatrix).invert().transform(t)}function sA({viewport:e,shadowMatrices:t}){let r=[],s=e.pixelUnprojectionMatrix,i=e.isGeospatial?void 0:1,n=[[0,0,i],[e.width,0,i],[0,e.height,i],[e.width,e.height,i],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(o=>eA(o,s));for(let o of t){let a=o.clone().translate(new Z(e.center).negate()),c=n.map(h=>a.transform(h)),l=new Q().ortho({left:Math.min(...c.map(h=>h[0])),right:Math.max(...c.map(h=>h[0])),bottom:Math.min(...c.map(h=>h[1])),top:Math.max(...c.map(h=>h[1])),near:Math.min(...c.map(h=>-h[2])),far:Math.max(...c.map(h=>-h[2]))});r.push(l.multiplyRight(o))}return r}function iA(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 s={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:e.shadowMaps?e.shadowMaps.length>0:!1,shadow_uColor:e.shadowColor||Gx,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},i=Qx({viewport:e.viewport,center:t.project_uCenter}),n=[],o=Jx({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let a=0;a"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?iA(e,t):{}};var zf={...ea,defaultUniforms:{...ea.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 nA=[yr],oA=["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 Na(){let e=lr.getDefaultShaderAssembler();for(let t of nA)e.addDefaultModule(t);for(let t of oA)e.addShaderHook(t);return e}var aA=[255,255,255],cA=1,lA=0,qs=class{constructor(t={}){this.type="ambient";let{color:r=aA}=t,{intensity:s=cA}=t;this.id=t.id||`ambient-${lA++}`,this.color=r,this.intensity=s}};var hA=[255,255,255],fA=1,uA=[0,0,-1],dA=0,$e=class{constructor(t={}){this.type="directional";let{color:r=hA}=t,{intensity:s=fA}=t,{direction:i=uA}=t,{_shadow:n=!1}=t;this.id=t.id||`directional-${dA++}`,this.color=r,this.intensity=s,this.type="directional",this.direction=new Z(i).normalize().toArray(),this.shadow=n}getProjectedLight(t){return this}};var Kr=class{constructor(t,r={id:"pass"}){let{id:s}=r;this.id=s,this.device=t,this.props={...r}}setProps(t){Object.assign(this.props,t)}render(t){}cleanup(){}};var ge=class extends Kr{constructor(){super(...arguments),this._lastRenderIndex=-1}render(t){let[r,s]=this.device.canvasContext.getDrawingBufferSize(),i=t.clearCanvas??!0,n=t.clearColor??(i?[0,0,0,0]:!1),o=i?1:!1,a=i?0:!1,c=t.colorMask??15,l={viewport:[0,0,r,s]};t.colorMask&&(l.colorMask=c),t.scissorRect&&(l.scissorRect=t.scissorRect);let h=this.device.beginRenderPass({framebuffer:t.target,parameters:l,clearColor:n,clearDepth:o,clearStencil:a});try{return this._drawLayers(h,t)}finally{h.end()}}_drawLayers(t,r){let{target:s,moduleParameters:i,viewports:n,views:o,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let h of n){let f=o&&o[h.id];a?.(h);let u=this._getDrawLayerParams(h,r),_=h.subViewports||[h];for(let m of _){let b=this._drawLayersInViewport(t,{target:s,moduleParameters:i,viewport:m,view:f,pass:r.pass,layers:r.layers},u);l.push(b)}}return l}_getDrawLayerParams(t,{layers:r,pass:s,isPicking:i=!1,layerFilter:n,cullRect:o,effects:a,moduleParameters:c},l=!1){let h=[],f=$g(this._lastRenderIndex+1),u={layer:r[0],viewport:t,isPicking:i,renderPass:s,cullRect:o},_={};for(let m=0;mthis.device.clearWebGL(f))}let h={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};t.setParameters({viewport:l});for(let f=0;f{let o=i.props._offset,a=i.id,c=i.parent&&i.parent.id,l;if(c&&!(c in t)&&s(i.parent,!1),c in r){let h=r[c]=r[c]||$g(t[c],t);l=h(i,n),r[a]=h}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 s}function pA(e,{moduleParameters:t,target:r,viewport:s}){let i=t&&t.devicePixelRatio||e.canvasContext.cssToDeviceRatio(),[,n]=e.canvasContext.getDrawingBufferSize(),o=r?r.height:n,a=s;return[a.x*i,o-(a.y+a.height)*i,a.width*i,a.height*i]}var _n=class extends ge{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,s=this.device.canvasContext.cssToDeviceRatio(),i=t.viewports[0],n=i.width*s,o=i.height*s,a=[1,1,1,1];(n!==r.width||o!==r.height)&&r.resize({width:n,height:o}),super.render({...t,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(t,r,s){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 gA={color:[255,255,255],intensity:1},Yg=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],_A=[0,0,0,200/255],Er=class{constructor(t={}){this.id="lighting-effect",this.shadowColor=_A,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:s}=t;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),s._addDefaultShaderModule(Ys),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(t){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(let r in t){let s=t[r];switch(s.type){case"ambient":this.ambientLight=s;break;case"directional":this.directionalLights.push(s);break;case"point":this.pointLights.push(s);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=t}preRender({layers:t,layerFilter:r,viewports:s,onViewportActive:i,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;os.getProjectedLight({layer:t})),pointLights:this.pointLights.map(s=>s.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(Ys))}_calculateMatrices(){let t=[];for(let r of this.directionalLights){let s=new Q().lookAt({eye:new Z(r.direction).negate()});t.push(s)}return t}_createShadowPasses(t){for(let r=0;ri&&(n=i);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 s&&l.fill(0),l}return new t(n)}_release(t){if(!ArrayBuffer.isView(t))return;let r=this._pool,{buffer:s}=t,{byteLength:i}=s,n=r.findIndex(o=>o.byteLength>=i);n<0?r.push(s):(n>0||r.lengththis.opts.poolSize&&r.shift()}},_e=new Wf;function Zs(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Zr(e,t){let r=e%t;return r<0?t+r:r}function Kg(e){return[e[12],e[13],e[14]]}function Zg(e){return{left:Ks(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:Ks(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:Ks(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:Ks(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:Ks(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:Ks(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}var qg=new Z;function Ks(e,t,r,s){qg.set(e,t,r);let i=qg.len();return{distance:s/i,normal:new Z(-e/i,-t/i,-r/i)}}function jf(e){return e-Math.fround(e)}var mn;function Fa(e,t){let{size:r=1,startIndex:s=0}=t,i=t.endIndex!==void 0?t.endIndex:e.length,n=(i-s)/r;mn=_e.allocate(mn,n,{type:Float32Array,size:r*2});let o=s,a=0;for(;o0){let[i,n,o]=Ba(this.timestamp,0,0);this.direction=[i,-o,n]}else{let{latitude:i,longitude:n}=r;this.direction=Ba(this.timestamp,i,n)}return this}};var bn=class extends Kr{constructor(t,r){super(t,r);let{module:s,fs:i,id:n}=r,o={depthWriteEnabled:!1,depthCompare:"always"};this.model=new qi(t,{id:n,fs:i,modules:[s],parameters:o})}render(t){this._renderPass(this.device,t)}delete(){this.model.destroy(),this.model=null}_renderPass(t,r){let{clearCanvas:s,inputBuffer:i,outputBuffer:n}=r,o=[i.width,i.height];this.model.shaderInputs.setProps(r.moduleSettings),this.model.setBindings({texSrc:i.colorAttachments[0]}),this.model.setUniforms({texSize:o});let a=this.device.beginRenderPass({framebuffer:n,parameters:{viewport:[0,0,...o]},clearColor:s?[0,0,0,0]:!1,clearDepth:1});this.model.draw(a),a.end()}};var En=class{constructor(t,r){this.id=`${t.name}-pass`,this.props=r,Ml(t),this.module=t}setup({device:t}){this.passes=XA(t,this.module,this.id)}setProps(t){this.props=t}preRender(){}postRender(t){let r=this.passes,{target:s}=t,i=t.inputBuffer,n=t.swapBuffer;for(let o=0;o{let n=qA(t,s),o=`${r}-${i}`;return new bn(e,{id:o,module:t,fs:n})})}var e_=`#version 300 es uniform sampler2D texSrc; uniform vec2 texSize; in vec2 position; in vec2 coordinate; in vec2 uv; out vec4 fragColor; `,$A=e=>`${e_} void main() { fragColor = texture(texSrc, coordinate); fragColor = ${e}(fragColor, texSize, coordinate); } `,YA=e=>`${e_} void main() { fragColor = ${e}(texSrc, texSize, coordinate); } `;function qA(e,t){if(t.filter){let r=typeof t.filter=="string"?t.filter:`${e.name}_filterColor`;return $A(r)}if(t.sampler){let r=typeof t.sampler=="string"?t.sampler:`${e.name}_sampleColor`;return YA(r)}return""}var KA={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"},Ye=class extends ge{constructor(){super(...arguments),this._colorEncoderState=null}render(t){return"pickingFBO"in t?this._drawPickingBuffer(t):super.render(t)}_drawPickingBuffer({layers:t,layerFilter:r,views:s,viewports:i,onViewportActive:n,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:h},cullRect:f,effects:u,pass:_="picking",pickZ:m,moduleParameters:b}){this.pickZ=m;let y=this._resetColorEncoder(m),A=[a,c,l,h],w=super.render({target:o,layers:t,layerFilter:r,views:s,viewports:i,onViewportActive:n,cullRect:f,effects:u?.filter(M=>M.useInPicking),pass:_,isPicking:!0,moduleParameters:b,clearColor:[0,0,0,0],colorMask:15,scissorRect:A});return this._colorEncoderState=null,{decodePickingColor:y&&QA.bind(null,y),stats:w}}shouldDrawLayer(t){let{pickable:r,operation:s}=t.props;return r&&s.includes("draw")||s.includes("terrain")||s.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(t,r,s){let i={depthMask:!0,depthTest:!0,depthRange:[0,1],...t.props.parameters},{pickable:n,operation:o}=t.props;return!this._colorEncoderState||o.includes("terrain")?i.blend=!1:n&&o.includes("draw")&&(Object.assign(i,KA),i.blend=!0,i.blendColor=ZA(this._colorEncoderState,t,s)),i}_resetColorEncoder(t){return this._colorEncoderState=t?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function ZA(e,t,r){let{byLayer:s,byAlpha:i}=e,n,o=s.get(t);return o?(o.viewports.push(r),n=o.a):(n=s.size+1,n<=255?(o={a:n,layer:t,viewports:[r]},s.set(t,o),i[n]=o):(j.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function QA(e,t){let r=e.byAlpha[t[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(t)}}var xr={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"},ti=Symbol.for("component"),se=Symbol.for("propTypes"),Ua=Symbol.for("deprecatedProps"),qe=Symbol.for("asyncPropDefaults"),Ne=Symbol.for("asyncPropOriginal"),me=Symbol.for("asyncPropResolved");function Ar(e,t=()=>!0){return Array.isArray(e)?r_(e,t,[]):t(e)?[e]:[]}function r_(e,t,r){let s=-1;for(;++s0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(t,r){if(t===this._data&&!r)return;this._data=t;let s=++this._loadCount,i=t;typeof t=="string"&&(i=Tr(t)),i instanceof Promise?(this.isLoaded=!1,this._loader=i.then(n=>{this._loadCount===s&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===s&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=t);for(let n of this._subscribers)n.onChange(this.getData())}};var An=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:s=!1,persistent:i=!0}){let n=this._resources[t];n?n.setData(r,s):(n=new xn(t,r,this._context),this._resources[t]=n),n.persistent=i}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 s in r){let i=r[s],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[t],this.prune()}}subscribe({resourceId:t,onChange:r,consumerId:s,requestId:i="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(s,i,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,s,i){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()),s&&(a?(a.onChange=i,a.resourceId=s.id):a={onChange:i,resourceId:s.id},o[r]=a,s.subscribe(a))}_prune(){this._pruneRequest=null;for(let t of Object.keys(this._resources)){let r=this._resources[t];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[t])}}};var JA="layerManager.setLayers",GA="layerManager.activateViewport",Gr=class{constructor(t,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{it(GA,this,a),a&&(this.context.viewport=a)};let{deck:s,stats:i,viewport:n,timeline:o}=r||{};this.layers=[],this.resourceManager=new An({device:t,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:t,gl:t?.gl,deck:s,shaderAssembler:Na(),defaultShaderModules:[],renderPass:void 0,stats:i||new $t({id:"deck.gl"}),viewport:n||new kt({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Ur,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 s of this.layers){let i=s.getNeedsRedraw(t);r=r||i}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(s=>r.id.indexOf(s)===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){it(JA,this,r,t),this._lastRenderedLayers=t;let s=Ar(t,Boolean);for(let i of s)i.context=this.context;this._updateLayers(this.layers,s)}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(s=>s.name===t.name)||(r.push(t),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(t){let{defaultShaderModules:r}=this.context,s=r.findIndex(i=>i.name===t.name);s>=0&&(r.splice(s,1),this._defaultShaderModulesChanged=!0)}_handleError(t,r,s){s.raiseError(r,`${t} of ${s}`)}_updateLayers(t,r){let s={};for(let o of t)s[o.id]?j.warn(`Multiple old layers with same id ${o.id}`)():s[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of t)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let i=[];this._updateSublayersRecursively(r,s,i),this._finalizeOldLayers(s);let n=!1;for(let o of i)if(o.hasUniformTransition()){n=`Uniform transition in ${o}`;break}this._needsUpdate=n,this.layers=i}_updateSublayersRecursively(t,r,s){for(let i of t){i.context=this.context;let n=r[i.id];n===null&&j.warn(`Multiple new layers with same id ${i.id}`)(),r[i.id]=null;let o=null;try{this._debug&&n!==i&&i.validateProps(),n?(this._transferLayerState(n,i),this._updateLayer(i)):this._initializeLayer(i),s.push(i),o=i.isComposite?i.getSubLayers():null}catch(a){this._handleError("matching",a,i)}o&&this._updateSublayersRecursively(o,r,s)}}_finalizeOldLayers(t){for(let r in t){let s=t[r];s&&this._finalizeLayer(s)}}_initializeLayer(t){try{t._initialize(),t.lifecycle=xr.INITIALIZED}catch(r){this._handleError("initialization",r,t)}}_transferLayerState(t,r){r._transferState(t),r.lifecycle=xr.MATCHED,r!==t&&(t.lifecycle=xr.AWAITING_GC)}_updateLayer(t){try{t._update()}catch(r){this._handleError("update",r,t)}}_finalizeLayer(t){this._needsRedraw=this._needsRedraw||`finalized ${t}`,t.lifecycle=xr.AWAITING_FINALIZATION;try{t._finalize(),t.lifecycle=xr.FINALIZED}catch(r){this._handleError("finalization",r,t)}}};function at(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 s=0;sr.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,s=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(s):s}getViewport(t){return this._viewportMap[t]}unproject(t,r){let s=this.getViewports(),i={x:t[0],y:t[1]};for(let n=s.length-1;n>=0;--n){let o=s[n];if(o.containsPixel(i)){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=Ar(t,Boolean),this._diffViews(t,this.views)&&this.setNeedsUpdate("views changed"),this.views=t}_setViewState(t){t?(!at(t,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=t):j.warn("missing `viewState` or `initialViewState`")()}_createController(t,r){let s=r.type;return new s({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(t.id)?.makeViewport({viewState:n,width:this.width,height:this.height})})}_updateController(t,r,s,i){let n=t.controller;if(n&&s){let o={...r,...n,id:t.id,x:s.x,y:s.y,width:s.width,height:s.height};return(!i||i.constructor!==n.type)&&(i=this._createController(t,o)),i&&i.setProps(o),i}return null}_rebuildViewports(){let{views:t}=this,r=this.controllers;this._viewports=[],this.controllers={};let s=!1;for(let i=t.length;i--;){let n=t[i],o=this.getViewState(n),a=n.makeViewport({viewState:o,width:this.width,height:this.height}),c=r[n.id],l=Boolean(n.controller);l&&!c&&(s=!0),(s||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,o,a,c),a&&this._viewports.unshift(a)}for(let i in r){let n=r[i];n&&!this.controllers[i]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(t=>{t.id&&(this._viewportMap[t.id]=this._viewportMap[t.id]||t)})}_diffViews(t,r){return t.length!==r.length?!0:t.some((s,i)=>!t[i].equals(r[i]))}};var tS=/([0-9]+\.?[0-9]*)(%|px)/;function Ke(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":let t=tS.exec(e);if(t&&t.length>=3){let r=t[2]==="%",s=parseFloat(t[1]);return{position:r?s/100:s,relative:r}}default:throw new Error(`Could not parse position string ${e}`)}}function Ze(e,t){return e.relative?Math.round(e.position*t):e.position}var Rt=class{constructor(t){let{id:r,x:s=0,y:i=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=Ke(s),this._y=Ke(i),this._width=Ke(n),this._height=Ke(o),this._padding=a&&{left:Ke(a.left||0),right:Ke(a.right||0),top:Ke(a.top||0),bottom:Ke(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t?!0:this.ViewportType===t.ViewportType&&at(this.props,t.props,2)}makeViewport({width:t,height:r,viewState:s}){s=this.filterViewState(s);let i=this.getDimensions({width:t,height:r});return!i.height||!i.width?null:new this.ViewportType({...s,...this.props,...i})}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 s in this.props.viewState)s!=="id"&&(r[s]=this.props.viewState[s]);return r}return t}getDimensions({width:t,height:r}){let s={x:Ze(this._x,t),y:Ze(this._y,r),width:Ze(this._width,t),height:Ze(this._height,r)};return this._padding&&(s.padding={left:Ze(this._padding.left,t),top:Ze(this._padding.top,r),right:Ze(this._padding.right,t),bottom:Ze(this._padding.bottom,r)}),s}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 Te=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 s_=()=>{},wn={BREAK:1,SNAP_TO_END:2,IGNORE:3},eS=e=>e,rS=wn.BREAK,Rn=class{constructor(t){this._onTransitionUpdate=r=>{let{time:s,settings:{interpolator:i,startProps:n,endProps:o,duration:a,easing:c}}=r,l=c(s/a),h=i.interpolateProps(n,o,l);this.propsInTransition=this.getControllerState({...this.props,...h}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new Te(t.timeline),this.onViewStateChange=t.onViewStateChange||s_,this.onStateChange=t.onStateChange||s_}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let r=!1,s=this.props;if(this.props=t,!s||this._shouldIgnoreViewportChange(s,t))return!1;if(this._isTransitionEnabled(t)){let i=s;if(this.transition.inProgress){let{interruption:n,endProps:o}=this.transition.settings;i={...s,...n===wn.SNAP_TO_END?o:this.propsInTransition||s}}this._triggerTransition(i,t),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(t){let{transitionDuration:r,transitionInterpolator:s}=t;return(r>0||r==="auto")&&Boolean(s)}_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===wn.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(t,r):!0}_triggerTransition(t,r){let s=this.getControllerState(t),i=this.getControllerState(r).shortestPathFrom(s),n=r.transitionInterpolator,o=n.getDuration?n.getDuration(t,r):r.transitionDuration;if(o===0)return;let a=n.initializeProps(t,i);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||eS,interpolator:n,interruption:r.transitionInterruption||rS,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 rt(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}var Qe=class{constructor(t){let{compare:r,extract:s,required:i}=t;this._propsToCompare=r,this._propsToExtract=s||r,this._requiredProps=i}arePropsEqual(t,r){for(let s of this._propsToCompare)if(!(s in t)||!(s in r)||!Vt(t[s],r[s]))return!1;return!0}initializeProps(t,r){let s={},i={};for(let n of this._propsToExtract)(n in t||n in r)&&(s[n]=t[n],i[n]=r[n]);return this._checkRequiredProps(s),this._checkRequiredProps(i),{start:s,end:i}}getDuration(t,r){return r.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach(r=>{let s=t[r];rt(Number.isFinite(s)||Array.isArray(s),`${r} is required for transition`)})}};var sS=["longitude","latitude","zoom","bearing","pitch"],iS=["longitude","latitude","zoom"],mt=class extends Qe{constructor(t={}){let r=Array.isArray(t)?t:t.transitionProps,s=Array.isArray(t)?{}:t;s.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:sS,required:iS},super(s.transitionProps),this.opts=s}initializeProps(t,r){let s=super.initializeProps(t,r),{makeViewport:i,around:n}=this.opts;if(i&&n){let o=i(t),a=i(r),c=o.unproject(n);s.start.around=n,Object.assign(s.end,{around:a.project(c),aroundPosition:c,width:r.width,height:r.height})}return s}interpolateProps(t,r,s){let i={};for(let n of this._propsToExtract)i[n]=Xe(t[n]||0,r[n]||0,s);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...i});Object.assign(i,n.panByPosition(r.aroundPosition,Xe(t.around,r.around,s)))}return i}};var Sr={transitionDuration:0},nS=300,Va=e=>1-(1-e)*(1-e),ei={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},ts={},vt=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 Rn({...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:s}=this.props,{offsetCenter:i}=t;return[i.x-r,i.y-s]}isPointInBounds(t,r){let{width:s,height:i}=this.props;if(r&&r.handled)return!1;let n=t[0]>=0&&t[0]<=s&&t[1]>=0&&t[1]<=i;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?nS:0;let{scrollZoom:s=!0,dragPan:i=!0,dragRotate:n=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=t,h=Boolean(this.onViewStateChange);this.toggleEvents(ei.WHEEL,h&&s),this.toggleEvents(ei.PAN,h),this.toggleEvents(ei.PINCH,h&&(a||c)),this.toggleEvents(ei.TRIPLE_PAN,h&&c),this.toggleEvents(ei.DOUBLE_TAP,h&&o),this.toggleEvents(ei.KEYBOARD,h&&l),this.scrollZoom=s,this.dragPan=i,this.dragRotate=n,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,r){this.eventManager&&t.forEach(s=>{this._events[s]!==r&&(this._events[s]=r,r?this.eventManager.on(s,this.handleEvent):this.eventManager.off(s,this.handleEvent))})}updateViewport(t,r=null,s={}){let i={...t.getViewportProps(),...r},n=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(s),n){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:i,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(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 s=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(s=!s);let i=this.controllerState[s?"panStart":"rotateStart"]({pos:r});return this._panMove=s,this.updateViewport(i,Sr,{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),s=this.controllerState.pan({pos:r});return this.updateViewport(s,Sr,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){let{inertia:r}=this;if(this.dragPan&&r&&t.velocity){let s=this.getCenter(t),i=[s[0]+t.velocityX*r/2,s[1]+t.velocityY*r/2],n=this.controllerState.pan({pos:i}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isPanning:!0})}else{let s=this.controllerState.panEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;let r=this.getCenter(t),s=this.controllerState.rotate({pos:r});return this.updateViewport(s,Sr,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){let{inertia:r}=this;if(this.dragRotate&&r&&t.velocity){let s=this.getCenter(t),i=[s[0]+t.velocityX*r/2,s[1]+t.velocityY*r/2],n=this.controllerState.rotate({pos:i}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isRotating:!0})}else{let s=this.controllerState.rotateEnd();this.updateViewport(s,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:s=.01,smooth:i=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=t,o=2/(1+Math.exp(-Math.abs(n*s)));n<0&&o!==0&&(o=1/o);let a=this.controllerState.zoom({pos:r,scale:o});return this.updateViewport(a,{...this._getTransitionProps({around:r}),transitionDuration:i?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let s=this.controllerState.rotateStart({pos:r});return this.updateViewport(s,Sr,{isDragging:!0}),!0}_onTriplePan(t){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(t);r[0]-=t.deltaX;let s=this.controllerState.rotate({pos:r});return this.updateViewport(s,Sr,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(t){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&t.velocityY){let s=this.getCenter(t),i=[s[0],s[1]+=t.velocityY*r/2],n=this.controllerState.rotate({pos:i});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let s=this.controllerState.rotateEnd();this.updateViewport(s,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let s=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return ts._startPinchRotation=t.rotation,ts._lastPinchEvent=t,this.updateViewport(s,Sr,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:s}=t,i=this.getCenter(t);r=r.zoom({pos:i,scale:s})}if(this.touchRotate){let{rotation:s}=t;r=r.rotate({deltaAngleX:ts._startPinchRotation-s})}return this.updateViewport(r,Sr,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ts._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:s}=ts;if(this.touchZoom&&r&&s&&t.scale!==s.scale){let i=this.getCenter(t),n=this.controllerState.rotateEnd(),o=Math.log2(t.scale),a=(o-Math.log2(s.scale))/(t.deltaTime-s.deltaTime),c=Math.pow(2,o+a*r/2);n=n.zoom({pos:i,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:i}),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let i=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return ts._startPinchRotation=null,ts._lastPinchEvent=null,!0}_onDoubleTap(t){if(!this.doubleClickZoom)return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let s=this.isFunctionKeyPressed(t),i=this.controllerState.zoom({pos:r,scale:s?.5:2});return this.updateViewport(i,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(t),{zoomSpeed:s,moveSpeed:i,rotateSpeedX:n,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(t.srcEvent.code){case"Minus":c=r?a.zoomOut(s).zoomOut(s):a.zoomOut(s),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(s).zoomIn(s):a.zoomIn(s),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(i),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(i),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(i),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(i),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(t){let{transition:r}=this;return!r||!r.transitionInterpolator?Sr:t?{...r,transitionInterpolator:new mt({...t,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Je=class{constructor(t,r){this._viewportProps=this.applyConstraints(t),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var i_=5,oS=1.2,vn=class extends Je{constructor(t){let{width:r,height:s,latitude:i,longitude:n,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:h=[0,0,0],maxZoom:f=20,minZoom:u=0,maxPitch:_=60,minPitch:m=0,startPanLngLat:b,startZoomLngLat:y,startRotatePos:A,startBearing:w,startPitch:v,startZoom:M,normalize:I=!0}=t;rt(Number.isFinite(n)),rt(Number.isFinite(i)),rt(Number.isFinite(o)),super({width:r,height:s,latitude:i,longitude:n,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:u,maxPitch:_,minPitch:m,normalize:I,position:h},{startPanLngLat:b,startZoomLngLat:y,startRotatePos:A,startBearing:w,startPitch:v,startZoom:M}),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanLngLat:this._unproject(t)})}pan({pos:t,startPos:r}){let s=this.getState().startPanLngLat||this._unproject(r);if(!s)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(s,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:s=0}){let{startRotatePos:i,startBearing:n,startPitch:o}=this.getState();if(!i||n===void 0||o===void 0)return this;let a;return t?a=this._getNewRotation(t,i,o,n):a={bearing:n+r,pitch:o+s},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:s}){let{startZoom:i,startZoomLngLat:n}=this.getState();if(n||(i=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(t)),!n)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=i+Math.log2(s);c=J(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(),s={...this.getViewportProps()},{bearing:i,longitude:n}=s;return Math.abs(i-r.bearing)>180&&(s.bearing=i<0?i+360:i-360),Math.abs(n-r.longitude)>180&&(s.longitude=n<0?n+360:n-360),s}applyConstraints(t){let{maxZoom:r,minZoom:s,zoom:i}=t;t.zoom=J(i,s,r);let{maxPitch:n,minPitch:o,pitch:a}=t;t.pitch=J(a,o,n);let{normalize:c=!0}=t;return c&&Object.assign(t,Uf(t)),t}_zoomFromCenter(t){let{width:r,height:s}=this.getViewportProps();return this.zoom({pos:[r/2,s/2],scale:t})}_panFromCenter(t){let{width:r,height:s}=this.getViewportProps();return this.pan({startPos:[r/2,s/2],pos:[r/2+t[0],s/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,s,i){let n=t[0]-r[0],o=t[1]-r[1],a=t[1],c=r[1],{width:l,height:h}=this.getViewportProps(),f=n/l,u=0;o>0?Math.abs(h-c)>i_&&(u=o/(c-h)*oS):o<0&&c>i_&&(u=1-a/c),u=J(u,-1,1);let{minPitch:_,maxPitch:m}=this.getViewportProps(),b=i+180*f,y=s;return u>0?y=s+u*(m-s):u<0&&(y=s-u*(_-s)),{pitch:y,bearing:b}}},es=class extends vt{constructor(){super(...arguments),this.ControllerState=vn,this.transition={transitionDuration:300,transitionInterpolator:new mt({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 za=class extends Rt{constructor(t={}){super(t)}get ViewportType(){return Js}get ControllerType(){return es}};za.displayName="MapView";var Wa=za;var aS=new Er;function cS(e,t){let r=e.order??1/0,s=t.order??1/0;return r-s}var Mn=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(s=>s.id===t.id)){let s=r.findIndex(i=>cS(i,t)>0);s<0?r.push(t):r.splice(s,0,t),t.setup(this._context),this._setEffects(this.effects)}}setProps(t){"effects"in t&&(at(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 i of this.effects)r[i.id]=i;let s=[];for(let i of t){let n=r[i.id],o=i;n&&n!==i?n.setProps?(n.setProps(i.props),o=n):n.cleanup(this._context):n||i.setup(this._context),s.push(o),delete r[i.id]}for(let i in r)r[i].cleanup(this._context);this.effects=s,this._resolvedEffects=s.concat(this._defaultEffects),t.some(i=>i instanceof Er)||this._resolvedEffects.push(aS),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 Pn=class extends ge{shouldDrawLayer(t){let{operation:r}=t.props;return r.includes("draw")||r.includes("terrain")}};var lS="deckRenderer.renderLayers",rs=class{constructor(t){this.device=t,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Pn(t),this.pickLayersPass=new Ye(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,s={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...t};s.effects&&this._preRender(s.effects,s);let i=this.lastPostProcessEffect?this.renderBuffers[0]:s.target;this.lastPostProcessEffect&&(s.clearColor=[0,0,0,0],s.clearCanvas=!0);let n=r.render({...s,target:i});s.effects&&this._postRender(s.effects,s),this.renderCount++,it(lS,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 s of t)r.preRenderStats[s.id]=s.preRender(r),s.postRender&&(this.lastPostProcessEffect=s.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:t}=this,r=this.device.canvasContext.getDrawingBufferSize();t.length===0&&[0,1].map(s=>{let i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});t.push(this.device.createFramebuffer({id:`deck-renderbuffer-${s}`,colorAttachments:[i]}))});for(let s of t)s.resize(r)}_postRender(t,r){let{renderBuffers:s}=this,i={...r,inputBuffer:s[0],swapBuffer:s[1]};for(let n of t)if(n.postRender){i.target=n.id===this.lastPostProcessEffect?r.target:void 0;let o=n.postRender(i);i.inputBuffer=o,i.swapBuffer=o===s[0]?s[1]:s[0]}}};var hS={pickedColor:null,pickedObjectIndex:-1};function n_({pickedColors:e,decodePickingColor:t,deviceX:r,deviceY:s,deviceRadius:i,deviceRect:n}){let{x:o,y:a,width:c,height:l}=n,h=i*i,f=-1,u=0;for(let _=0;_h)u+=4*c;else for(let y=0;y=0){let w=y+o-r,v=w*w+b;v<=h&&(h=v,f=u)}u+=4}}if(f>=0){let _=e.slice(f,f+4),m=t(_);if(m){let b=Math.floor(f/4/c),y=f/4-b*c;return{...m,pickedColor:_,pickedX:o+y,pickedY:a+b}}j.error("Picked non-existent layer. Is picking buffer corrupt?")()}return hS}function o_({pickedColors:e,decodePickingColor:t}){let r=new Map;if(e){for(let s=0;s=0){let n=e.slice(s,s+4),o=n.join(",");if(!r.has(o)){let a=t(n);a?r.set(o,{...a,color:n}):j.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function $f({pickInfo:e,viewports:t,pixelRatio:r,x:s,y:i,z:n}){let o=t[0];t.length>1&&(o=fS(e?.pickedViewports||t,{x:s,y:i}));let a;if(o){let c=[s-o.x,i-o.y];n!==void 0&&(c[2]=n),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:s,y:i,pixel:[s,i],coordinate:a,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:r}}function a_(e){let{pickInfo:t,lastPickedInfo:r,mode:s,layers:i}=e,{pickedColor:n,pickedLayer:o,pickedObjectIndex:a}=t,c=o?[o]:[];if(s==="hover"){let f=r.index,u=r.layerId,_=o?o.props.id:null;if(_!==u||a!==f){if(_!==u){let m=i.find(b=>b.props.id===u);m&&c.unshift(m)}r.layerId=_,r.index=a,r.info=null}}let l=$f(e),h=new Map;return h.set(null,l),c.forEach(f=>{let u={...l};f===o&&(u.color=n,u.index=a,u.picked=!0),u=Yf({layer:f,info:u,mode:s});let _=u.layer;f===o&&s==="hover"&&(r.info=u),h.set(_.id,u),s==="hover"&&_.updateAutoHighlight(u)}),h}function Yf({layer:e,info:t,mode:r}){for(;e&&t;){let s=t.layer||null;t.sourceLayer=s,t.layer=e,t=e.getPickingInfo({info:t,mode:r,sourceLayer:s}),e=e.parent}return t}function fS(e,t){for(let r=e.length-1;r>=0;r--){let s=e[r];if(s.containsPixel(t))return s}return e[0]}var In=class{constructor(t){this._pickable=!0,this.device=t,this.pickLayersPass=new Ye(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:s,viewports:i},n=this.lastPickedInfo.info){let o=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=o?s.find(u=>u.id===o):null,l=a&&i.find(u=>u.id===a)||i[0],h=l&&l.unproject([t-l.x,r-l.y]);return{...n,...{x:t,y:r,viewport:l,coordinate:h,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let r=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=r}let{canvas:t}=this.device.getCanvasContext();this.pickingFBO?.resize({width:t.width,height:t.height}),this.depthFBO?.resize({width:t.width,height:t.height})}_getPickable(t){if(this._pickable===!1)return null;let r=t.filter(s=>this.pickLayersPass.shouldDrawLayer(s)&&!s.isComposite);return r.length?r:null}_pickClosestObject({layers:t,views:r,viewports:s,x:i,y:n,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:h,effects:f}){let u=this.device.canvasContext.cssToDeviceRatio(),_=this._getPickable(t);if(!_||s.length===0)return{result:[],emptyInfo:$f({viewports:s,x:i,y:n,pixelRatio:u})};this._resizeBuffer();let m=this.device.canvasContext.cssToDevicePixels([i,n],!0),b=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],y=Math.round(o*u),{width:A,height:w}=this.pickingFBO,v=this._getPickingRect({deviceX:b[0],deviceY:b[1],deviceRadius:y,deviceWidth:A,deviceHeight:w}),M={x:i-o,y:n-o,width:o*2+1,height:o*2+1},I,O=[],F=new Set;for(let k=0;k=l);N++){let L=O[N],q={color:L.pickedColor,layer:null,index:L.pickedObjectIndex,picked:!0,x:i,y:n,pixelRatio:_};q=Yf({layer:L.pickedLayer,info:q,mode:c});let $=q.layer.id;F.has($)||F.set($,new Set);let H=F.get($),ct=q.object??q.index;H.has(ct)||(H.add(ct),k.push(q))}return k}_drawAndSample({layers:t,views:r,viewports:s,onViewportActive:i,deviceRect:n,cullRect:o,effects:a,pass:c},l=!1){let h=l?this.depthFBO:this.pickingFBO,f={layers:t,layerFilter:this.layerFilter,views:r,viewports:s,onViewportActive:i,pickingFBO:h,deviceRect:n,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{}};for(let w of a)w.useInPicking&&(f.preRenderStats[w.id]=w.preRender(f));let{decodePickingColor:u}=this.pickLayersPass.render(f),{x:_,y:m,width:b,height:y}=n,A=new(l?Float32Array:Uint8Array)(b*y*4);return this.device.readPixelsToArrayWebGL(h,{sourceX:_,sourceY:m,sourceWidth:b,sourceHeight:y,target:A}),{pickedColors:A,decodePickingColor:u}}_getPickingRect({deviceX:t,deviceY:r,deviceRadius:s,deviceWidth:i,deviceHeight:n}){let o=Math.max(0,t-s),a=Math.max(0,r-s),c=Math.min(i,t+s+1)-o,l=Math.min(n,r+s+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var uS={"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}},dS="top-left",c_="__root",ja=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&&!at(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 s of this.resolvedWidgets)r[s.id]=s;this.resolvedWidgets.length=0;for(let s of this.defaultWidgets)r[s.id]=null,this.resolvedWidgets.push(s);for(let s of t){let i=r[s.id];i?i.viewId!==s.viewId||i.placement!==s.placement?(this._remove(i),this._add(s)):s!==i&&(i.setProps(s.props),s=i):this._add(s),r[s.id]=null,this.resolvedWidgets.push(s)}for(let s in r){let i=r[s];i&&this._remove(i)}this.widgets=t}_add(t){let{viewId:r=null,placement:s=dS}=t,i=t.onAdd({deck:this.deck,viewId:r});i&&this._getContainer(r,s).append(i),t._element=i}_remove(t){t.onRemove(),t._element&&t._element.remove(),t._element=void 0}_getContainer(t,r){let s=t||c_,i=this.containers[s];i||(i=document.createElement("div"),i.style.pointerEvents="none",i.style.position="absolute",i.style.overflow="hidden",this.parentElement?.append(i),this.containers[s]=i);let n=i.querySelector(`.${r}`);return n||(n=document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,uS[r]),i.append(n)),n}_updateContainers(){let t=this.deck.width,r=this.deck.height;for(let s in this.containers){let i=this.lastViewports[s]||null,n=s===c_||i,o=this.containers[s];n?(o.style.display="block",o.style.left=`${i?i.x:0}px`,o.style.top=`${i?i.y:0}px`,o.style.width=`${i?i.width:t}px`,o.style.height=`${i?i.height:r}px`):o.style.display="none"}}onRedraw({viewports:t,layers:r}){let s=t.reduce((n,o)=>(n[o.id]=o,n),{}),{lastViewports:i}=this;for(let n of this.getWidgets()){let{viewId:o}=n;if(o){let a=s[o];a&&(n.onViewportChange&&!a.equals(i[o])&&n.onViewportChange(a),n.onRedraw?.({viewports:[a],layers:r}))}else{if(n.onViewportChange)for(let a of t)a.equals(i[a.id])||n.onViewportChange(a);n.onRedraw?.({viewports:t,layers:r})}}this.lastViewports=s,this._updateContainers()}onHover(t,r){for(let s of this.getWidgets()){let{viewId:i}=s;(!i||i===t.viewport?.id)&&s.onHover?.(t,r)}}onEvent(t,r){let s=hn[r.type];if(s)for(let i of this.getWidgets()){let{viewId:n}=i;(!n||n===t.viewport?.id)&&i[s.handler]?.(t,r)}}};var pS={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Cn=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,pS),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,s=r&&r.props.getTooltip;if(!s)return;let i=s(t);this.lastViewport=t.viewport,this.setTooltip(i,t.x,t.y)}setTooltip(t,r,s){let i=this.element;if(i){if(typeof t=="string")i.innerText=t;else if(t)t.text&&(i.innerText=t.text),t.html&&(i.innerHTML=t.html),t.className&&(i.className=t.className);else{this.isVisible=!1,i.style.display="none";return}this.isVisible=!0,i.style.display="block",i.style.transform=`translate(${r}px, ${s}px)`,t&&typeof t=="object"&&"style"in t&&Object.assign(i.style,t.style)}}};var wr;(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"})(wr||(wr={}));var Nn={[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},dt=(e,t,r)=>t?e.enable(r):e.disable(r),l_=(e,t,r)=>e.hint(r,t),Wt=(e,t,r)=>e.pixelStorei(r,t),h_=(e,t,r)=>{let s=r===36006?36009:36008;return e.bindFramebuffer(s,t)},On=(e,t,r)=>{let i={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];e.bindBuffer(i,t)};function qf(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var f_={[3042]:dt,[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]:dt,[2885]:(e,t)=>e.cullFace(t),[2929]:dt,[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]:dt,[35723]:l_,[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]:h_,[36010]:h_,[34964]:On,[36662]:On,[36663]:On,[35053]:On,[35055]:On,[2886]:(e,t)=>e.frontFace(t),[33170]:l_,[2849]:(e,t)=>e.lineWidth(t),[32823]:dt,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:dt,[32926]:dt,[32928]:dt,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:dt,[3088]:(e,t)=>e.scissor(...t),[2960]:dt,[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]:dt,[10754]:dt,[12288]:dt,[12289]:dt,[12290]:dt,[12291]:dt,[12292]:dt,[12293]:dt,[12294]:dt,[12295]:dt,[3333]:Wt,[3317]:Wt,[37440]:Wt,[37441]:Wt,[37443]:Wt,[3330]:Wt,[3332]:Wt,[3331]:Wt,[3314]:Wt,[32878]:Wt,[3316]:Wt,[3315]:Wt,[32877]:Wt,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=qf(t)?t:[t,t];let[r,s]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,s)},stencilFunc:(e,t)=>{t=qf(t)&&t.length===3?[...t,...t]:t;let[r,s,i,n,o,a]=t;e.stencilFuncSeparate(1028,r,s,i),e.stencilFuncSeparate(1029,n,o,a)},stencilOp:(e,t)=>{t=qf(t)&&t.length===3?[...t,...t]:t;let[r,s,i,n,o,a]=t;e.stencilOpSeparate(1028,r,s,i),e.stencilOpSeparate(1029,n,o,a)},viewport:(e,t)=>e.viewport(...t)};function nt(e,t,r){return t[e]!==void 0?t[e]:r[e]}var u_={blendEquation:(e,t,r)=>e.blendEquationSeparate(nt(32777,t,r),nt(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(nt(32969,t,r),nt(32968,t,r),nt(32971,t,r),nt(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(nt(32824,t,r),nt(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(nt(32938,t,r),nt(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,nt(2962,t,r),nt(2967,t,r),nt(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,nt(34816,t,r),nt(36003,t,r),nt(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,nt(2964,t,r),nt(2965,t,r),nt(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,nt(34817,t,r),nt(34818,t,r),nt(34819,t,r))},Kf={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 s={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[t];return s?e({[s]:r}):{valueChanged:!0}},blendColor:(e,t,r,s,i)=>e({[32773]:new Float32Array([t,r,s,i])}),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,s,i)=>e({[32969]:t,[32968]:r,[32971]:s,[32970]:i}),clearColor:(e,t,r,s,i)=>e({[3106]:new Float32Array([t,r,s,i])}),clearDepth:(e,t)=>e({[2931]:t}),clearStencil:(e,t)=>e({[2961]:t}),colorMask:(e,t,r,s,i)=>e({[3107]:[t,r,s,i]}),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,s,i)=>e({[3088]:new Int32Array([t,r,s,i])}),stencilMask:(e,t)=>e({[2968]:t,[36005]:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,s)=>e({[2962]:t,[2967]:r,[2963]:s,[34816]:t,[36003]:r,[36004]:s}),stencilFuncSeparate:(e,t,r,s,i)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:s,[t===1028?2963:36004]:i}),stencilOp:(e,t,r,s)=>e({[2964]:t,[2965]:r,[2966]:s,[34817]:t,[34818]:r,[34819]:s}),stencilOpSeparate:(e,t,r,s,i)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:s,[t===1028?2966:34819]:i}),viewport:(e,t,r,s,i)=>e({[2978]:[t,r,s,i]})},Fe=(e,t)=>e.isEnabled(t),Zf={[3042]:Fe,[2884]:Fe,[2929]:Fe,[3024]:Fe,[32823]:Fe,[32926]:Fe,[32928]:Fe,[3089]:Fe,[2960]:Fe,[35977]:Fe},d_=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 ye(e,t){if(gS(t))return;let r={};for(let i in t){let n=Number(i),o=f_[i];o&&(typeof o=="string"?r[o]=!0:o(e,t[i],n))}let s=e.state&&e.state.cache;if(s)for(let i in r){let n=u_[i];n(e,t,s)}}function Ha(e,t=Nn){if(typeof t=="number"){let i=t,n=Zf[i];return n?n(e,i):e.getParameter(i)}let r=Array.isArray(t)?t:Object.keys(t),s={};for(let i of r){let n=Zf[i];s[i]=n?n(e,Number(i)):e.getParameter(Number(i))}return s}function p_(e){ye(e,Nn)}function gS(e){for(let t in e)return!1;return!0}function g_(e,t){if(e===t)return!0;let r=Array.isArray(e)||ArrayBuffer.isView(e),s=Array.isArray(t)||ArrayBuffer.isView(t);if(r&&s&&e.length===t.length){for(let i=0;i{}}={}){this.gl=t,this.cache=r?Ha(t):Object.assign({},Nn),this.log=s,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(t={}){this.stateStack.push({})}pop(){z(this.stateStack.length>0);let t=this.stateStack[this.stateStack.length-1];ye(this.gl,t),this.stateStack.pop()}_updateCache(t){let r=!1,s,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in t){z(n!==void 0);let o=t[n],a=this.cache[n];g_(o,a)||(r=!0,s=a,i&&!(n in i)&&(i[n]=a),this.cache[n]=o)}return{valueChanged:r,oldValue:s}}};function ss(e){return e.state}function Jf(e,t){let{enable:r=!0,copyState:s}=t;if(z(s!==void 0),!e.state){e.state=new Qf(e,{copyState:s}),mS(e);for(let n in Kf){let o=Kf[n];_S(e,n,o)}__(e,"getParameter"),__(e,"isEnabled")}let i=ss(e);return i.enable=r,e}function Rr(e){let t=ss(e);t||(Jf(e,{copyState:!1}),t=ss(e)),t.push()}function Ge(e){let t=ss(e);z(t),t.pop()}function __(e,t){let r=e[t].bind(e);e[t]=function(i){if(i===void 0||d_.has(i))return r(i);let n=ss(e);return i in n.cache||(n.cache[i]=r(i)),n.enable?n.cache[i]:r(i)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function _S(e,t,r){if(!e[t])return;let s=e[t].bind(e);e[t]=function(...n){let o=ss(e),{valueChanged:a,oldValue:c}=r(o._updateCache,...n);return a&&s(...n),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function mS(e){let t=e.useProgram.bind(e);e.useProgram=function(s){let i=ss(e);i.program!==s&&(t(s),i.program=s)}}var TS={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function m_(e,t){t={...TS,...t};let r=null,s=n=>r=n.statusMessage||r;e.addEventListener("webglcontextcreationerror",s,!1);let i=null;if(i||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",s,!1),!i)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 i}function ie(e,t,r){return r[t]===void 0&&(r[t]=e.getExtension(t)||null),r[t]}function T_(e,t){let r=e.getParameter(7936),s=e.getParameter(7937);ie(e,"WEBGL_debug_renderer_info",t);let i=t.WEBGL_debug_renderer_info,n=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=o||s,l=e.getParameter(7938),h=y_(a,c),f=yS(a,c),u=bS(a,c);return{type:"webgl",gpu:h,gpuType:u,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function y_(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 yS(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function bS(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(y_(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function Xa(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 Et="texture-compression-bc",tt="texture-compression-astc",ke="texture-compression-etc2",ES="texture-compression-etc1-webgl",$a="texture-compression-pvrtc-webgl",Gf="texture-compression-atc-webgl",Fn="float32-renderable-webgl",tu="float16-renderable-webgl",xS="rgb9e5ufloat_renderable-webgl",eu="snorm8-renderable-webgl",kn="norm16-renderable-webgl",ru="snorm16-renderable-webgl",Ya="float32-filterable",b_="float16-filterable-webgl",Dn="WEBGL_compressed_texture_s3tc",Bn="WEBGL_compressed_texture_s3tc_srgb",ri="EXT_texture_compression_rgtc",si="EXT_texture_compression_bptc",AS="WEBGL_compressed_texture_etc",SS="WEBGL_compressed_texture_astc",wS="WEBGL_compressed_texture_etc1",RS="WEBGL_compressed_texture_pvrtc",vS="WEBGL_compressed_texture_atc",E_="EXT_texture_norm16",x_="EXT_render_snorm",MS="EXT_color_buffer_float",qa={"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":[x_],"norm16-renderable-webgl":[E_],"snorm16-renderable-webgl":[E_,x_],"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":[Dn,Bn,ri,si],"texture-compression-bc5-webgl":[ri],"texture-compression-bc7-webgl":[si],"texture-compression-etc2":[AS],"texture-compression-astc":[SS],"texture-compression-etc1-webgl":[wS],"texture-compression-pvrtc-webgl":[RS],"texture-compression-atc-webgl":[vS]};function A_(e){return e in qa}function S_(e,t,r){return(qa[t]||[]).every(i=>ie(e,i,r))}var Ka={"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:eu},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:eu},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:tu,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:kn,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:ru},"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:eu},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:tu,filter:b_,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:kn},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:ru},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:Fn,filter:Ya},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:xS},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Fn,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:kn},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:kn},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:Fn,filter:Ya,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:tu,filter:b_},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:kn,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:ru},"rgb32float-webgl":{gl:34837,render:Fn,filter:Ya,gl2ext:MS,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:Fn,filter:Ya,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:Dn,f:Et},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Bn,f:Et},"bc1-rgba-unorm":{gl:33777,x:Dn,f:Et},"bc1-rgba-unorm-srgb":{gl:35916,x:Bn,f:Et},"bc2-rgba-unorm":{gl:33778,x:Dn,f:Et},"bc2-rgba-unorm-srgb":{gl:35918,x:Bn,f:Et},"bc3-rgba-unorm":{gl:33779,x:Dn,f:Et},"bc3-rgba-unorm-srgb":{gl:35919,x:Bn,f:Et},"bc4-r-unorm":{gl:36283,x:ri,f:Et},"bc4-r-snorm":{gl:36284,x:ri,f:Et},"bc5-rg-unorm":{gl:36285,x:ri,f:Et},"bc5-rg-snorm":{gl:36286,x:ri,f:Et},"bc6h-rgb-ufloat":{gl:36495,x:si,f:Et},"bc6h-rgb-float":{gl:36494,x:si,f:Et},"bc7-rgba-unorm":{gl:36492,x:si,f:Et},"bc7-rgba-unorm-srgb":{gl:36493,x:si,f:Et},"etc2-rgb8unorm":{gl:37492,f:ke},"etc2-rgb8unorm-srgb":{gl:37494,f:ke},"etc2-rgb8a1unorm":{gl:37496,f:ke},"etc2-rgb8a1unorm-srgb":{gl:37497,f:ke},"etc2-rgba8unorm":{gl:37493,f:ke},"etc2-rgba8unorm-srgb":{gl:37495,f:ke},"eac-r11unorm":{gl:37488,f:ke},"eac-r11snorm":{gl:37489,f:ke},"eac-rg11unorm":{gl:37490,f:ke},"eac-rg11snorm":{gl:37491,f:ke},"astc-4x4-unorm":{gl:37808,f:tt},"astc-4x4-unorm-srgb":{gl:37840,f:tt},"astc-5x4-unorm":{gl:37809,f:tt},"astc-5x4-unorm-srgb":{gl:37841,f:tt},"astc-5x5-unorm":{gl:37810,f:tt},"astc-5x5-unorm-srgb":{gl:37842,f:tt},"astc-6x5-unorm":{gl:37811,f:tt},"astc-6x5-unorm-srgb":{gl:37843,f:tt},"astc-6x6-unorm":{gl:37812,f:tt},"astc-6x6-unorm-srgb":{gl:37844,f:tt},"astc-8x5-unorm":{gl:37813,f:tt},"astc-8x5-unorm-srgb":{gl:37845,f:tt},"astc-8x6-unorm":{gl:37814,f:tt},"astc-8x6-unorm-srgb":{gl:37846,f:tt},"astc-8x8-unorm":{gl:37815,f:tt},"astc-8x8-unorm-srgb":{gl:37847,f:tt},"astc-10x5-unorm":{gl:37819,f:tt},"astc-10x5-unorm-srgb":{gl:37851,f:tt},"astc-10x6-unorm":{gl:37817,f:tt},"astc-10x6-unorm-srgb":{gl:37849,f:tt},"astc-10x8-unorm":{gl:37818,f:tt},"astc-10x8-unorm-srgb":{gl:37850,f:tt},"astc-10x10-unorm":{gl:37819,f:tt},"astc-10x10-unorm-srgb":{gl:37851,f:tt},"astc-12x10-unorm":{gl:37820,f:tt},"astc-12x10-unorm-srgb":{gl:37852,f:tt},"astc-12x12-unorm":{gl:37821,f:tt},"astc-12x12-unorm-srgb":{gl:37853,f:tt},"pvrtc-rgb4unorm-webgl":{gl:35840,f:$a},"pvrtc-rgba4unorm-webgl":{gl:35842,f:$a},"pvrtc-rbg2unorm-webgl":{gl:35841,f:$a},"pvrtc-rgba2unorm-webgl":{gl:35843,f:$a},"etc1-rbg-unorm-webgl":{gl:36196,f:ES},"atc-rgb-unorm-webgl":{gl:35986,f:Gf},"atc-rgba-unorm-webgl":{gl:35986,f:Gf},"atc-rgbai-unorm-webgl":{gl:34798,f:Gf}},PS={[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},IS={[5126]:4,[5125]:4,[5124]:4,[5123]:2,[5122]:2,[5131]:2,[5120]:1,[5121]:1};function Za(e,t,r){let s=Ka[t];if(!s||s.gl===void 0)return!1;let i=s.x||s.gl2ext;return i?Boolean(ie(e,i,r)):!0}function su(e){let r=Ka[e]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${e}`);return r}function w_(e,t,r){if(!Za(e,t,r)||t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if(Io(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(ie(e,"OES_texture_float_linear, extensions",r)):t.endsWith("16float")?Boolean(ie(e,"OES_texture_half_float_linear, extensions",r)):!0}function R_(e,t,r){return!(!Za(e,t,r)||typeof t=="number")}function ii(e){let t=Ka[e],r=su(e),s=Io(e);return{format:r,dataFormat:t?.dataFormat||CS(s.format,s.integer,s.normalized,r),type:s.dataType?Xa(s.dataType):t?.types?.[0]||5121,compressed:s.compressed}}function v_(e){let t=Ka[e];if(!t?.attachment)throw new Error(`${e} is not a depth stencil format`);return t.attachment}function iu(e){let t=ii(e),r=PS[t.dataFormat]||4,s=IS[t.type]||1;return r*s}function CS(e,t,r,s){if(s===6408||s===6407)return s;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 M_={"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"},Qa=class extends vi{gl;extensions;testedFeatures=new Set;constructor(t,r,s){super([],s),this.gl=t,this.extensions=r,ie(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),A_(t)&&S_(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(M_),...Object.keys(qa)]}getWebGLFeature(t){let r=M_[t];return Boolean(typeof r=="string"?ie(this.gl,r,this.extensions):r)}};var Ja=class extends Ri{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 ne(e,t,r){if(OS(t))return r(e);let{nocatch:s=!0}=t;Rr(e),ye(e,t);let i;if(s)i=r(e),Ge(e);else try{i=r(e)}finally{Ge(e)}return i}function OS(e){for(let t in e)return!1;return!0}function I_(e,t,r,s){if(ir(t))return s(e);let i=e;Rr(i.gl);try{return NS(e,t),ye(i.gl,r),s(e)}finally{Ge(i.gl)}}function NS(e,t){let r=e,{gl:s}=r;if(t.cullMode)switch(t.cullMode){case"none":s.disable(2884);break;case"front":s.enable(2884),s.cullFace(1028);break;case"back":s.enable(2884),s.cullFace(1029);break}if(t.frontFace&&s.frontFace(is("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&s.enable(34383),t.depthBias!==void 0&&(s.enable(32823),s.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=is("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=is("polygonMode",t.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,o),n?.polygonModeWEBGL(1029,o)}t.polygonOffsetLine&&s.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&s.enable(12288),t.clipDistance1&&s.enable(12289),t.clipDistance2&&s.enable(12290),t.clipDistance3&&s.enable(12291),t.clipDistance4&&s.enable(12292),t.clipDistance5&&s.enable(12293),t.clipDistance6&&s.enable(12294),t.clipDistance7&&s.enable(12295)),t.depthWriteEnabled!==void 0&&s.depthMask(kS("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?s.enable(2929):s.disable(2929),s.depthFunc(tc("depthCompare",t.depthCompare))),t.stencilWriteMask){let i=t.stencilWriteMask;s.stencilMaskSeparate(1028,i),s.stencilMaskSeparate(1029,i)}if(t.stencilReadMask&&P.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let i=t.stencilReadMask||4294967295,n=tc("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?s.enable(2960):s.disable(2960),s.stencilFuncSeparate(1028,n,0,i),s.stencilFuncSeparate(1029,n,0,i)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let i=nu("stencilPassOperation",t.stencilPassOperation),n=nu("stencilFailOperation",t.stencilFailOperation),o=nu("stencilDepthFailOperation",t.stencilDepthFailOperation);s.stencilOpSeparate(1028,n,o,i),s.stencilOpSeparate(1029,n,o,i)}if(t.blendColorOperation||t.blendAlphaOperation){s.enable(3042);let i=P_("blendColorOperation",t.blendColorOperation||"add"),n=P_("blendAlphaOperation",t.blendAlphaOperation||"add");s.blendEquationSeparate(i,n);let o=Ga("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=Ga("blendColorDstFactor",t.blendColorDstFactor||"zero"),c=Ga("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=Ga("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");s.blendFuncSeparate(o,a,c,l)}}function tc(e,t){return is(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function nu(e,t){return is(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function P_(e,t){return is(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Ga(e,t){return is(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 FS(e,t){return`Illegal parameter ${t} for ${e}`}function is(e,t,r){if(!(t in r))throw new Error(FS(e,t));return r[t]}function kS(e,t){return t}function ec(e){let t={};return e.addressModeU&&(t[10242]=ou(e.addressModeU)),e.addressModeV&&(t[10243]=ou(e.addressModeV)),e.addressModeW&&(t[32882]=ou(e.addressModeW)),e.magFilter&&(t[10240]=C_(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=DS(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]=tc("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function ou(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function C_(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function DS(e,t){if(!t)return C_(e);switch(e){case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var Mt=class extends V{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(t,r={}){super(t,r),this.device=t,this.gl=this.device.gl;let s=typeof r=="object"?r.handle:void 0;this.handle=s||this.gl.createBuffer(),t.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=BS(this.props.usage),this.glUsage=US(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,s=t.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,s,this.glUsage),this.gl.bufferSubData(i,r,t),this.gl.bindBuffer(i,null),this.bytesUsed=s,this.byteLength=s,this._setDebugData(t,r,s),this.trackAllocatedMemory(s)}_initWithByteLength(t){z(t>=0);let r=t;t===0&&(r=new Float32Array(0));let s=this.glTarget;return this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,r,this.glUsage),this.gl.bindBuffer(s,null),this.bytesUsed=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 s=new Uint8Array(r),i=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,s,i,r),this.gl.bindBuffer(36662,null),this._setDebugData(s,t,r),s}};function BS(e){return e&V.INDEX?34963:e&V.VERTEX?34962:e&V.UNIFORM?35345:34962}function US(e){return e&V.INDEX||e&V.VERTEX?35044:e&V.UNIFORM?35048:35044}var ns=class extends cr{device;handle;parameters;constructor(t,r){super(t,r),this.device=t,this.parameters=ec(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,s]of Object.entries(t)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,s);break;default:this.device.gl.samplerParameteri(this.handle,i,s);break}}}};var be=class extends or{device;gl;handle;texture;constructor(t,r){super(t,{...G.defaultProps,...r}),this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var LS={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},rc=class extends G{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,{...LS,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=VS(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:ml(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 be(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(y=>this.initialize(Object.assign({},t,{pixels:y,data:y}))),this;let s=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(s&&r.readyStatethis.initialize(t)),this;let{parameters:i={}}=t,{pixels:n=null,pixelStore:o={},textureUnit:a=void 0,mipmaps:c=!0}=t;r||(r=n);let{width:l,height:h,dataFormat:f,type:u,compressed:_=!1}=t,{depth:m=0}=t,b=su(t.format);return{width:l,height:h,compressed:_,dataFormat:f,type:u}=this._deduceParameters({format:t.format,type:u,dataFormat:f,compressed:_,data:r,width:l,height:h}),this.width=l,this.height=h,this.glFormat=b,this.type=u,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:h,depth:m,format:t.format,type:u,dataFormat:f,parameters:o,compressed:_}),this.setSampler(t.sampler),this._setSamplerParameters(i),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),c&&this.device.isTextureFormatFilterable(t.format)&&this.generateMipmap(),s&&(this._video={video:r,parameters:i,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(t){let{mipmaps:r=!0,parameters:s={}}=t;return this.setCubeMapImageData(t).then(()=>{this.loaded=!0,r&&this.generateMipmap(t),this.setSampler(t.sampler),this._setSamplerParameters(s)}),this}setSampler(t={}){let r;t instanceof ns?(this.sampler=t,r=t.props):(this.sampler=new ns(this.device,t),r=t);let s=ec(r);return this._setSamplerParameters(s),this}resize(t){let{height:r,width:s,mipmaps:i=!1}=t;return s!==this.width||r!==this.height?this.initialize({width:s,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:t,parameters:r,lastTime:s}=this._video;if(s===t.currentTime||t.readyState{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:s=null,level:i=0,glFormat:n=this.glFormat,offset:o=0,parameters:a={}}=t,{data:c=null,type:l=this.type,width:h=this.width,height:f=this.height,dataFormat:u=this.dataFormat,compressed:_=!1}=t;c||(c=s),{type:l,dataFormat:u,compressed:_,width:h,height:f}=this._deduceParameters({format:this.props.format,type:l,dataFormat:u,compressed:_,data:c,width:h,height:f});let{gl:m}=this;m.bindTexture(this.target,this.handle);let b=null;if({data:c,dataType:b}=this._getDataType({data:c,compressed:_}),ne(this.gl,a,()=>{switch(b){case"null":m.texImage2D(r,i,n,h,f,0,u,l,c);break;case"typed-array":m.texImage2D(r,i,n,h,f,0,u,l,c,o);break;case"buffer":this.device.gl.bindBuffer(35052,c.handle||c),this.device.gl.texImage2D(r,i,n,h,f,0,u,l,o),this.device.gl.bindBuffer(35052,null);break;case"browser-object":m.texImage2D(r,i,n,h,f,0,u,l,c);break;case"compressed":for(let[y,A]of c.entries())m.compressedTexImage2D(r,y,A.format,A.width,A.height,0,A.data);break;default:z(!1,"Unknown image data type")}}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let y=iu(this.props.format);this.trackAllocatedMemory(this.width*this.height*y,"Texture")}return this.loaded=!0,this}setSubImageData({target:t=this.target,pixels:r=null,data:s=null,x:i=0,y:n=0,width:o=this.width,height:a=this.height,level:c=0,glFormat:l=this.glFormat,type:h=this.type,dataFormat:f=this.dataFormat,compressed:u=!1,offset:_=0,parameters:m={}}){if({type:h,dataFormat:f,compressed:u,width:o,height:a}=this._deduceParameters({format:this.props.format,type:h,dataFormat:f,compressed:u,data:s,width:o,height:a}),z(this.depth===1,"texSubImage not supported for 3D textures"),s||(s=r),s&&s.data){let b=s;s=b.data,o=b.shape[0],a=b.shape[1]}s instanceof Mt&&(s=s.handle),this.gl.bindTexture(this.target,this.handle),ne(this.gl,m,()=>{u?this.gl.compressedTexSubImage2D(t,c,i,n,o,a,l,s):s===null?this.gl.texSubImage2D(t,c,i,n,o,a,f,h,null):ArrayBuffer.isView(s)?this.gl.texSubImage2D(t,c,i,n,o,a,f,h,s,_):typeof WebGLBuffer<"u"&&s instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,s),this.device.gl.texSubImage2D(t,c,i,n,o,a,f,h,_),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(t,c,i,n,o,a,f,h,s)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(t={}){return P.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 Mt?{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:s}=t,{width:i,height:n,dataFormat:o,type:a,compressed:c}=t,l=ii(r);return o=o||l.dataFormat,a=a||l.type,c=c||l.compressed,{width:i,height:n}=this._deduceImageSize(s,i,n),{dataFormat:o,type:a,compressed:c,width:i,height:n,format:r,data:s}}_deduceImageSize(t,r,s){let i;return typeof ImageData<"u"&&t instanceof ImageData?i={width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?i={width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?i={width:t.width,height:t.height}:typeof ImageBitmap<"u"&&t instanceof ImageBitmap?i={width:t.width,height:t.height}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?i={width:t.videoWidth,height:t.videoHeight}:t?i={width:r,height:s}:i={width:r>=0?r:1,height:s>=0?s:1},z(i,"Could not deduced texture size"),z(r===void 0||i.width===r,"Deduced texture width does not match supplied width"),z(s===void 0||i.height===s,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(t){let{gl:r}=this,{width:s,height:i,pixels:n,data:o,format:a=6408,type:c=5121}=t,l=n||o,h=await Promise.all(rc.FACES.map(f=>{let u=l[f];return Promise.all(Array.isArray(u)?u:[u])}));this.bind(),rc.FACES.forEach((f,u)=>{h[u].length>1&&this.props.mipmaps!==!1&&P.warn(`${this.id} has mipmap and multiple LODs.`)(),h[u].forEach((_,m)=>{s&&i?r.texImage2D(f,m,a,s,i,0,a,c,_):r.texImage2D(f,m,a,a,c,_)})}),this.unbind()}setImageDataForFace(t){let{face:r,width:s,height:i,pixels:n,data:o,format:a=6408,type:c=5121}=t,{gl:l}=this,h=n||o;return this.bind(),h instanceof Promise?h.then(f=>this.setImageDataForFace(Object.assign({},t,{face:r,data:f,pixels:f}))):this.width||this.height?l.texImage2D(r,0,a,s,i,0,a,c,h):l.texImage2D(r,0,a,a,c,h),this}setImageData3D(t){let{level:r=0,dataFormat:s,format:i,type:n,width:o,height:a,depth:c=1,offset:l=0,data:h,parameters:f={}}=t;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let u=ii(i);if(ne(this.gl,f,()=>{ArrayBuffer.isView(h)&&this.gl.texImage3D(this.target,r,u.format,o,a,c,0,u.dataFormat,u.type,h),h instanceof Mt&&(this.gl.bindBuffer(35052,h.handle),this.gl.texImage3D(this.target,r,s,o,a,c,0,i,n,l))}),h&&h.byteLength)this.trackAllocatedMemory(h.byteLength,"Texture");else{let _=iu(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*_,"Texture")}return this.loaded=!0,this}_setSamplerParameters(t){if(!ir(t)){zS(t),this.gl.bindTexture(this.target,this.handle);for(let[r,s]of Object.entries(t)){let i=Number(r),n=s;switch(i){case 33082:case 33083:this.gl.texParameterf(this.target,i,n);break;default:this.gl.texParameteri(this.target,i,n);break}}this.gl.bindTexture(this.target,null)}}},Pt=rc;B(Pt,"FACES",[34069,34070,34071,34072,34073,34074]);function VS(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 zS(e){P.log(1,"texture sampler parameters",e)()}var De=class extends Re{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(t,r){super(t,r);let s=r.handle===null;if(this.device=t,this.gl=t.gl,this.handle=this.props.handle||s?this.props.handle:this.gl.createFramebuffer(),!s){t.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let i=this.gl.bindFramebuffer(36160,this.handle);for(let n=0;nP.info("Spector capture started:",t)()),Dt?.onCapture.add(t=>{P.info("Spector capture complete:",t)(),Dt?.getResultUI(),Dt?.resultView.display(),Dt?.resultView.addCapture(t)})),e?.canvas){if(typeof e.spector=="string"&&e.spector!==e.canvas.id)return Dt;Dt?.startCapture(e?.canvas,500),new Promise(t=>setTimeout(t,2e3)).then(t=>{P.info("Spector capture stopped after 2 seconds")(),Dt?.stopCapture()})}return Dt}var YS="https://unpkg.com/webgl-debug@2.0.1/index.js";function k_(e){return e.luma=e.luma||{},e.luma}async function D_(){Tt()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Ci(YS))}function B_(e,t={}){return e?t.debug?KS(e,t):qS(e):null}function qS(e){let t=k_(e);return t.realContext?t.realContext:e}function KS(e,t){if(!globalThis.WebGLDebugUtils)return P.warn("webgl-debug not loaded")(),e;let r=k_(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...wr,...e});let s=globalThis.WebGLDebugUtils.makeDebugContext(e,ZS.bind(null,t),QS.bind(null,t));for(let o in wr)!(o in s)&&typeof wr[o]=="number"&&(s[o]=wr[o]);class i{}Object.setPrototypeOf(s,Object.getPrototypeOf(e)),Object.setPrototypeOf(i,s);let n=Object.create(i);return r.realContext=e,r.debugContext=n,n.debug=!0,n}function au(e,t){t=Array.from(t).map(s=>s===void 0?"undefined":s);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function ZS(e,t,r,s){s=Array.from(s).map(a=>a===void 0?"undefined":a);let i=globalThis.WebGLDebugUtils.glEnumToString(t),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,s),o=`${i} in gl.${r}(${n})`;P.error(o)();debugger;if(e.throwOnError)throw new Error(o)}function QS(e,t,r){let s="";if(P.level>=1&&(s=au(t,r),P.log(1,s)()),e.break&&e.break.length>0&&(s=s||au(t,r),e.break.every(n=>s.indexOf(n)!==-1)))debugger;for(let i of r)if(i===void 0){if(s=s||au(t,r),e.throwOnError)throw new Error(`Undefined argument: ${s}`);P.error(`Undefined argument: ${s}`)();debugger}}function L_(e){let t=e.split(/\r?\n/),r=[];for(let s of t){if(s.length<=1)continue;let i=s.split(":");if(i.length===2){let[f,u]=i;r.push({message:u.trim(),type:U_(f),lineNum:0,linePos:0});continue}let[n,o,a,...c]=i,l=parseInt(a,10);isNaN(l)&&(l=0);let h=parseInt(o,10);isNaN(h)&&(h=0),r.push({message:c.join(":").trim(),type:U_(n),lineNum:l,linePos:h})}return r}function U_(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var ic=class extends ar{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 L_(t)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(t){t=(i=>i.startsWith("#version ")?i:`#version 100 ${i}`)(t);let{gl:s}=this.device;if(s.shaderSource(this.handle,t),s.compileShader(this.handle),P.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}P.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),P.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let t=async i=>await new Promise(n=>setTimeout(n,i));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:s}=this.device;for(;;){if(s.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var JS=256,GS=1024,tw=16384,cu=6144,ew=[1,2,4,8],nc=class extends As{device;glParameters;constructor(t,r){super(t,r),this.device=t,Rr(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Ge(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=ew.map(s=>Boolean(s&t.colorMask))),this.glParameters=r,ye(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|=tw,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=JS,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=GS,t.clearStencil=this.props.clearStencil),r!==0&&ne(this.device.gl,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(t=0,r=[0,0,0,0]){ne(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(cu,t,r);break;case Uint32Array:this.device.gl.clearBufferuiv(cu,t,r);break;case Float32Array:default:this.device.gl.clearBufferfv(cu,t,r);break}})}};var rw="Failed to deduce GL constant from typed array";function V_(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(rw)}}function Un(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 sw={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},iw={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},vr=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(t){return Un(t.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(t){return z(t.size),Un(t.type||5126).BYTES_PER_ELEMENT*t.size}static resolve(...t){return new vr(sw,...t)}constructor(...t){t.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return vr.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return vr.getBytesPerVertex(this)}_assign(t={}){return t=_l("Accessor",t,iw),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 z_(e){return nw.includes(e)}var nw=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],W_={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2","float32x2"],[35665]:[5126,3,"vec3","vec3","float32x3"],[35666]:[5126,4,"vec4","vec4","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2","sint32x2"],[35668]:[5124,3,"ivec3","vec3","sint32x3"],[35669]:[5124,4,"ivec4","vec4","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2","uint32x2"],[36295]:[5125,3,"uvec3","vec3","uint32x3"],[36296]:[5125,4,"uvec4","vec4","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2","float32x2"],[35672]:[5126,3,"bvec3","vec3","float32x3"],[35673]:[5126,4,"bvec4","vec4","float32x4"],[35674]:[5126,8,"mat2","mat2x2"],[35685]:[5126,8,"mat2x3","mat2x3"],[35686]:[5126,8,"mat2x4","mat2x4"],[35687]:[5126,12,"mat3x2","mat3x2"],[35675]:[5126,12,"mat3","mat3x3"],[35688]:[5126,12,"mat3x4","mat3x4"],[35689]:[5126,16,"mat4x2","mat4x2"],[35690]:[5126,16,"mat4x3","mat4x3"],[35676]:[5126,16,"mat4","mat4x4"]};function lu(e){let t=W_[e];if(!t)throw new Error("uniform");let[r,s,,i]=t;return{format:i,components:s,glType:r}}function j_(e){let t=W_[e];if(!t)throw new Error("attribute");let[,r,,s,i]=t;return{attributeType:s,vertexFormat:i,components:r}}function H_(e,t){let r={attributes:[],bindings:[]};r.attributes=ow(e,t);let s=lw(e,t);for(let a of s){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let i=cw(e,t),n=0;for(let a of i)if(z_(a.type)){let{viewDimension:c,sampleType:l}=fw(a.type);r.bindings.push({type:"texture",name:a.name,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}i.length&&(r.uniforms=i);let o=aw(e,t);return o?.length&&(r.varyings=o),r}function ow(e,t){let r=[],s=e.getProgramParameter(t,35721);for(let i=0;i=0){let{attributeType:l}=j_(a),h=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:h,type:l})}}return r.sort((i,n)=>i.location-n.location),r}function aw(e,t){let r=[],s=e.getProgramParameter(t,35971);for(let i=0;ii.location-n.location),r}function cw(e,t){let r=[],s=e.getProgramParameter(t,35718);for(let i=0;i1)for(let _=0;_e.getActiveUniformBlockParameter(t,n,o),s=[],i=e.getProgramParameter(t,35382);for(let n=0;nn.location-o.location),s}var hw={[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 fw(e){let t=hw[e];if(!t)throw new Error("sampler");let[r,s]=t;return{viewDimension:r,sampleType:s}}function uw(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 X_(e,t,r,s){let i=e,n=s;n===!0&&(n=1),n===!1&&(n=0);let o=typeof n=="number"?[n]:n;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof s!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,s);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 i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.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 i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}function $_(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 Y_(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 q_=4,oc=class extends ce{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:s,bufferMode:i=35981}=r;switch(s&&s.length>0&&(this.varyings=s,this.device.gl.transformFeedbackVaryings(this.handle,s,i)),this._linkShaders(),P.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=H_(this.device.gl,this.handle),P.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=ll(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":P.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[s,i]of Object.entries(t)){let n=this.shaderLayout.bindings.find(o=>o.name===s)||this.shaderLayout.bindings.find(o=>o.name===`${s}Uniforms`);if(!n){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||P.warn(`Unknown binding "${s}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(i||P.warn(`Unsetting binding "${s}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(i instanceof Mt)&&!(i.buffer instanceof Mt))throw new Error("buffer value");break;case"texture":if(!(i instanceof be||i instanceof Pt||i instanceof De))throw new Error("texture value");break;case"sampler":P.warn(`Ignoring sampler ${s}`)();break;default:throw new Error(n.type)}this.bindings[s]=i}}draw(t){let{renderPass:r,parameters:s=this.props.parameters,topology:i=this.props.topology,vertexArray:n,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:h}=t,f=$_(i),u=Boolean(n.indexBuffer),_=n.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return P.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||o===0)return P.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(o===0)return P.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),h&&h.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let m=r;return I_(this.device,s,m.glParameters,()=>{u&&c?this.device.gl.drawElementsInstanced(f,o||0,_,l,a||0):u?this.device.gl.drawElements(f,o||0,_,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,a||0):this.device.gl.drawArrays(f,l,o||0),h&&h.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(t){let{bindings:r}=Br(t);Object.keys(r).forEach(s=>{P.warn(`Unsupported value "${JSON.stringify(r[s])}" used in setUniforms() for key ${s}. 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),P.time(q_,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),P.timeEnd(q_,`linkProgram for ${this.id}`)(),P.level,!this.device.features.has("compilation-status-async-webgl")){let s=this._getLinkStatus();this._reportLinkStatus(s);return}P.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),P.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 i=>await new Promise(n=>setTimeout(n,i));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:s}=this.device;for(;;){if(s.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(let[,r]of Object.entries(this.bindings))r instanceof Pt&&(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,s=0;for(let i of this.shaderLayout.bindings){let n=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:o}=i,a=t.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);t.uniformBlockBinding(this.handle,s,a),n instanceof Mt?t.bindBufferBase(35345,s,n.handle):t.bindBufferRange(35345,s,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),s+=1;break;case"texture":if(!(n instanceof be||n instanceof Pt||n instanceof De))throw new Error("texture");let c;if(n instanceof be)c=n.texture;else if(n instanceof Pt)c=n;else if(n instanceof De&&n.colorAttachments[0]instanceof be)P.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 '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let t of this.shaderLayout.uniforms||[]){let{name:r,location:s,type:i,textureUnit:n}=t,o=this.uniforms[r]??n;o!==void 0&&X_(this.device.gl,s,i,o)}}};var ac=class extends ws{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":dw(this.device,r.options);break;case"copy-buffer-to-texture":pw(this.device,r.options);break;case"copy-texture-to-buffer":gw(this.device,r.options);break;case"copy-texture-to-texture":_w(this.device,r.options);break}}};function dw(e,t){let r=t.source,s=t.destination;e.gl.bindBuffer(36662,r.handle),e.gl.bindBuffer(36663,s.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 pw(e,t){throw new Error("Not implemented")}function gw(e,t){let{source:r,mipLevel:s=0,aspect:i="all",width:n=t.source.width,height:o=t.source.height,depthOrArrayLayers:a=0,origin:c=[0,0],destination:l,byteOffset:h=0,bytesPerRow:f,rowsPerImage:u}=t;if(i!=="all")throw new Error("not supported");if(s!==0||a!==0||f||u)throw new Error("not implemented");let{framebuffer:_,destroyFramebuffer:m}=K_(r),b;try{let y=l,A=n||_.width,w=o||_.height,v=ii(_.texture.props.format),M=v.dataFormat,I=v.type;e.gl.bindBuffer(35051,y.handle),b=e.gl.bindFramebuffer(36160,_.handle),e.gl.readPixels(c[0],c[1],A,w,M,I,h)}finally{e.gl.bindBuffer(35051,null),b!==void 0&&e.gl.bindFramebuffer(36160,b),m&&_.destroy()}}function _w(e,t){let{source:r,destinationMipLevel:s=0,origin:i=[0,0],destinationOrigin:n=[0,0],destination:o}=t,{width:a=t.destination.width,height:c=t.destination.height}=t,{framebuffer:l,destroyFramebuffer:h}=K_(r),[f,u]=i,[_,m,b]=n,y=e.gl.bindFramebuffer(36160,l.handle),A=null,w;if(o instanceof Pt)A=o,a=Number.isFinite(a)?a:A.width,c=Number.isFinite(c)?c:A.height,A.bind(0),w=A.target;else throw new Error("invalid destination");switch(w){case 3553:case 34067:e.gl.copyTexSubImage2D(w,s,_,m,f,u,a,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(w,s,_,m,b,f,u,a,c);break;default:}A&&A.unbind(),e.gl.bindFramebuffer(36160,y),h&&l.destroy()}function K_(e){if(e instanceof G){let{width:t,height:r,id:s}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${s}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var cc=class extends Ss{device;commandBuffer;constructor(t,r){super(t,r),this.device=t,this.commandBuffer=new ac(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,s){}};var ni=class extends Rs{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(t){return Xc()==="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 s=r;if(s.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:n,stride:o,offset:a,normalized:c,integer:l,divisor:h}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,s.handle),l?this.device.gl.vertexAttribIPointer(t,i,n,o,a):this.device.gl.vertexAttribPointer(t,i,n,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,h||0),this.attributes[t]=s,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{for(let r in t)this.setBuffer(r,t[r])})}setBuffer(t,r){let s=this._getVaryingIndex(t),{buffer:i,byteLength:n,byteOffset:o}=this._getBufferRange(r);if(s<0){this.unusedBuffers[t]=i,P.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[s]={buffer:i,byteLength:n,byteOffset:o},this.bindOnUse||this._bindBuffer(s,i,o,n)}getBuffer(t){if(Z_(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 Mt)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:s=0,byteLength:i=t.buffer.byteLength}=t;return{buffer:r,byteOffset:s,byteLength:i}}_getVaryingIndex(t){if(Z_(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:s,byteOffset:i}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),r,i,s)}}_unbindBuffers(){for(let t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r,s=0,i){let n=r&&r.handle;!n||i===void 0?this.gl.bindBufferBase(35982,t,n):this.gl.bindBufferRange(35982,t,n,s,i)}};function Z_(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var hc=class extends Ms{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((s,i)=>{let n=()=>{this.isResultAvailable()?(s(this.getResult()),this._pollingPromise=null):r++>t?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}};function hu(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 z(!1),0}}function Q_(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return z(!1),0}}function J_(e,t){let{sourceX:r=0,sourceY:s=0,sourceFormat:i=6408,sourceAttachment:n=36064}=t||{},{target:o=null,sourceWidth:a,sourceHeight:c,sourceType:l}=t||{},{framebuffer:h,deleteFramebuffer:f}=tm(e);z(h);let{gl:u,handle:_}=h;a=a||h.width,c=c||h.height;let m=n-36064;l=l||h.colorAttachments[m]?.texture?.type||5121,o=bw(o,l,i,a,c),l=l||V_(o);let b=u.bindFramebuffer(36160,_);return u.readPixels(r,s,a,c,i,l,o),u.bindFramebuffer(36160,b||null),f&&h.destroy(),o}function G_(e,t){let{target:r,sourceX:s=0,sourceY:i=0,sourceFormat:n=6408,targetByteOffset:o=0}=t||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=t||{},{framebuffer:h,deleteFramebuffer:f}=tm(e);z(h),a=a||h.width,c=c||h.height;let u=h;l=l||5121;let _=r;if(!_){let b=hu(n),y=Q_(l),A=o+a*c*b*y;_=u.device.createBuffer({byteLength:A})}let m=e.device.createCommandEncoder();return m.copyTextureToBuffer({source:e,width:a,height:c,origin:[s,i],destination:_,byteOffset:o}),m.destroy(),f&&h.destroy(),_}function tm(e){return e instanceof Re?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:yw(e),deleteFramebuffer:!0}}function yw(e,t){let{device:r,width:s,height:i,id:n}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${n}`,width:s,height:i,colorAttachments:[e]})}function bw(e,t,r,s,i){if(e)return e;t=t||5121;let n=Un(t,{clamped:!1}),o=hu(r);return new n(s*i*o)}var Ew=256,xw=1024,Aw=16384;var Sw="clear: bad arguments";function em(e,t){let{framebuffer:r=null,color:s=null,depth:i=null,stencil:n=null}=t||{},o={};r&&(o.framebuffer=r);let a=0;s&&(a|=Aw,s!==!0&&(o.clearColor=s)),i&&(a|=Ew,i!==!0&&(o.clearDepth=i)),n&&(a|=xw,i!==!0&&(o.clearStencil=i)),z(a!==0,Sw);let c=e.gl;ne(c,o,()=>{c.clear(a)})}var Ln=1,oi=class extends Bt{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(t){if(t instanceof oi)return t;if(t?.device instanceof Bt)return t.device;if(!ww(t))throw new Error("Invalid WebGL2RenderingContext");return new oi({gl:t})}static async create(t={}){P.groupCollapsed(Ln,"WebGLDevice created")();let r=[];t.debug&&r.push(D_()),t.spector&&r.push(N_()),typeof t.canvas=="string"&&r.push(nr.pageLoaded);let s=await Promise.allSettled(r);for(let o of s)o.status==="rejected"&&P.error(`Failed to initialize debug libraries ${o.reason}`)();if(P.probe(Ln+1,"DOM is loaded")(),t.gl?.device)return P.warn("reattaching existing device")(),oi.attach(t.gl);let i=new oi(t),n=`Created ${i.type}${i.debug?" debug":""} context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return P.probe(Ln,n)(),P.table(Ln,i.info)(),P.groupEnd(Ln)(),i}constructor(t){super({...t,id:t.id||ot("webgl-device")});let r=t.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let s=t.gl?.canvas||t.canvas;this.canvasContext=new sc(this,{...t,canvas:s}),this.lost=new Promise(a=>{this._resolveContextLost=a});let i=t.gl||null;if(i||=m_(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."})}),!i)throw new Error("WebGL context creation failed");this.handle=i,this.gl=i,this.gl.device=this,this.gl._version=2,t.spector&&(this.spectorJS=F_({...this.props,canvas:this.handle.canvas})),this.info=T_(this.gl,this._extensions),this.limits=new Ja(this.gl),this.features=new Qa(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:n=!0,copyState:o=!1}=t;Jf(this.gl,{enable:n,copyState:o,log:(...a)=>P.log(1,...a)()}),t.debug&&(this.gl=B_(this.gl,{...t,throwOnError:!0}),this.debug=!0,P.level=Math.max(P.level,1),P.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 Za(this.gl,t,this._extensions)}isTextureFormatFilterable(t){return w_(this.gl,t,this._extensions)}isTextureFormatRenderable(t){return R_(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 Mt(this,r)}_createTexture(t){return new Pt(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new ns(this,t)}createShader(t){return new ic(this,t)}createFramebuffer(t){return new De(this,t)}createVertexArray(t){return new ni(this,t)}createTransformFeedback(t){return new lc(this,t)}createQuerySet(t){return new hc(this,t)}createRenderPipeline(t){return new oc(this,t)}beginRenderPass(t){return new nc(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 cc(this,t)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(t,r){return J_(t,r)}readPixelsToBufferWebGL(t,r){return G_(t,r)}setParametersWebGL(t){ye(this.gl,t)}getParametersWebGL(t){return Ha(this.gl,t)}withParametersWebGL(t,r){return ne(this.gl,t,r)}clearWebGL(t){em(this,t)}resetWebGL(){P.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),p_(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let t=!1,s=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return s&&(t=!0,s.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){Rr(this.gl)}popState(){Ge(this.gl)}setSpectorMetadata(t,r){t.__SPECTOR_Metadata=r}getGLKey(t,r){r=r||this.gl2||this.gl;let s=Number(t);for(let i in r)if(r[i]===s)return`GL.${i}`;return String(t)}_constants;setConstantAttributeWebGL(t,r){let s=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(s).fill(null);let i=this._constants[t];switch(i&&Pw(i,r)&&P.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:Rw(this,t,r);break;case Int32Array:vw(this,t,r);break;case Uint32Array:Mw(this,t,r);break;default:z(!1)}}getExtension(t){return ie(this.gl,t,this._extensions),this._extensions}},Mr=oi;B(Mr,"type","webgl");function ww(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function Rw(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:z(!1)}}function vw(e,t,r){e.gl.vertexAttribI4iv(t,r)}function Mw(e,t,r){e.gl.vertexAttribI4uiv(t,r)}function Pw(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r0&&s.type==="pointerdown"&&(Cw(i,n=>n.pointerId===s.pointerId)||i.push(s)),t.call(this,s)}}function im(e){e.prototype.handler=function(r){let s=Iw[r.type];s&1&&r.button>=0&&(this.pressed=!0),s&2&&r.which===0&&(s=4),this.pressed&&(s&4&&(this.pressed=!1),this.callback(this.manager,s,{pointers:[r],changedPointers:[r],pointerType:"mouse",srcEvent:r}))}}sm(os.PointerEventInput);im(os.MouseInput);var nm=os.Manager,Ee=os;var xe=class{constructor(t,r,s){this.element=t,this.callback=r,this.options={enable:!0,...s}}};var om=Ee?[[Ee.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Ee.Rotate,{enable:!1}],[Ee.Pinch,{enable:!1}],[Ee.Swipe,{enable:!1}],[Ee.Pan,{threshold:0,enable:!1}],[Ee.Press,{enable:!1}],[Ee.Tap,{event:"doubletap",taps:2,enable:!1}],[Ee.Tap,{event:"anytap",enable:!1}],[Ee.Tap,{enable:!1}]]:null,fu={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},am={doubletap:["tap"]},cm={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},ai={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},lm={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"},uu={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var hm=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",as=typeof window<"u"?window:global;var uc=!1;try{let e={get passive(){return uc=!0,!0}};as.addEventListener("test",null,e),as.removeEventListener("test",null)}catch{uc=!1}var Ow=hm.indexOf("firefox")!==-1,{WHEEL_EVENTS:Nw}=ai,fm="wheel",um=4.000244140625,Fw=40,kw=.25,Vn=class extends xe{constructor(t,r,s){super(t,r,s),this.handleEvent=i=>{if(!this.options.enable)return;let n=i.deltaY;as.WheelEvent&&(Ow&&i.deltaMode===as.WheelEvent.DOM_DELTA_PIXEL&&(n/=as.devicePixelRatio),i.deltaMode===as.WheelEvent.DOM_DELTA_LINE&&(n*=Fw)),n!==0&&n%um===0&&(n=Math.floor(n/um)),i.shiftKey&&n&&(n=n*kw),this.callback({type:fm,center:{x:i.clientX,y:i.clientY},delta:-n,srcEvent:i,pointerType:"mouse",target:i.target})},this.events=(this.options.events||[]).concat(Nw),this.events.forEach(i=>t.addEventListener(i,this.handleEvent,uc?{passive:!1}:!1))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,r){t===fm&&(this.options.enable=r)}};var{MOUSE_EVENTS:Dw}=ai,dm="pointermove",pm="pointerover",gm="pointerout",_m="pointerenter",mm="pointerleave",zn=class extends xe{constructor(t,r,s){super(t,r,s),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:i}=this.options;this.enableMoveEvent=i,this.enableLeaveEvent=i,this.enableEnterEvent=i,this.enableOutEvent=i,this.enableOverEvent=i,this.events=(this.options.events||[]).concat(Dw),this.events.forEach(n=>t.addEventListener(n,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,r){t===dm&&(this.enableMoveEvent=r),t===pm&&(this.enableOverEvent=r),t===gm&&(this.enableOutEvent=r),t===_m&&(this.enableEnterEvent=r),t===mm&&(this.enableLeaveEvent=r)}handleOverEvent(t){this.enableOverEvent&&t.type==="mouseover"&&this._emit(pm,t)}handleOutEvent(t){this.enableOutEvent&&t.type==="mouseout"&&this._emit(gm,t)}handleEnterEvent(t){this.enableEnterEvent&&t.type==="mouseenter"&&this._emit(_m,t)}handleLeaveEvent(t){this.enableLeaveEvent&&t.type==="mouseleave"&&this._emit(mm,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(dm,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:Bw}=ai,Tm="keydown",ym="keyup",Wn=class extends xe{constructor(t,r,s){super(t,r,s),this.handleEvent=i=>{let n=i.target||i.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&i.type==="keydown"&&this.callback({type:Tm,srcEvent:i,key:i.key,target:i.target}),this.enableUpEvent&&i.type==="keyup"&&this.callback({type:ym,srcEvent:i,key:i.key,target:i.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(Bw),t.tabIndex=this.options.tabIndex||0,t.style.outline="none",this.events.forEach(i=>t.addEventListener(i,this.handleEvent))}destroy(){this.events.forEach(t=>this.element.removeEventListener(t,this.handleEvent))}enableEventType(t,r){t===Tm&&(this.enableDownEvent=r),t===ym&&(this.enableUpEvent=r)}};var bm="contextmenu",jn=class extends xe{constructor(t,r,s){super(t,r,s),this.handleEvent=i=>{this.options.enable&&this.callback({type:bm,center:{x:i.clientX,y:i.clientY},srcEvent:i,pointerType:"mouse",target:i.target})},t.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(t,r){t===bm&&(this.options.enable=r)}};var Uw={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},Lw=1,Vw=2,zw=3,Ww=0,jw=1,Hw=2,Xw=1,$w=2,Yw=4;function Em(e){let t=Uw[e.srcEvent.type];if(!t)return null;let{buttons:r,button:s,which:i}=e.srcEvent,n=!1,o=!1,a=!1;return t===4||t===2&&!Number.isFinite(r)?(n=i===Lw,o=i===Vw,a=i===zw):t===2?(n=Boolean(r&Xw),o=Boolean(r&Yw),a=Boolean(r&$w)):t===1&&(n=s===Ww,o=s===jw,a=s===Hw),{leftButton:n,middleButton:o,rightButton:a}}function xm(e,t){let r=e.center;if(!r)return null;let s=t.getBoundingClientRect(),i=s.width/t.offsetWidth||1,n=s.height/t.offsetHeight||1,o={x:(r.x-s.left-t.clientLeft)/i,y:(r.y-s.top-t.clientTop)/n};return{center:r,offsetCenter:o}}var du={srcElement:"root",priority:0},Hn=class{constructor(t){this.handleEvent=r=>{if(this.isEmpty())return;let s=this._normalizeEvent(r),i=r.srcEvent.target;for(;i&&i!==s.rootElement;){if(this._emit(s,i),s.handled)return;i=i.parentNode}this._emit(s,"root")},this.eventManager=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(t,r,s,i=!1,n=!1){let{handlers:o,handlersByElement:a}=this,c=du;typeof s=="string"||s&&s.addEventListener?c={...du,srcElement:s}:s&&(c={...du,...s});let l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let h={type:t,handler:r,srcElement:c.srcElement,priority:c.priority};i&&(h.once=!0),n&&(h.passive=!0),o.push(h),this._active=this._active||!h.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=h.priority);)f--;l.splice(f+1,0,h)}remove(t,r){let{handlers:s,handlersByElement:i}=this;for(let n=s.length-1;n>=0;n--){let o=s[n];if(o.type===t&&o.handler===r){s.splice(n,1);let a=i.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&i.delete(o.srcElement)}}this._active=s.some(n=>!n.passive)}_emit(t,r){let s=this.handlersByElement.get(r);if(s){let i=!1,n=()=>{t.handled=!0},o=()=>{t.handled=!0,i=!0},a=[];for(let c=0;c{t.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};var qw={events:null,recognizers:null,recognizerOptions:{},Manager:nm,touchAction:"none",tabIndex:0},ci=class{constructor(t=null,r){this._onBasicInput=i=>{let{srcEvent:n}=i,o=cm[n.type];o&&this.manager.emit(o,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={...qw,...r},this.events=new Map,this.setElement(t);let{events:s}=this.options;s&&this.on(s)}getElement(){return this.element}setElement(t){if(this.element&&this.destroy(),this.element=t,!t)return;let{options:r}=this,s=r.Manager;this.manager=new s(t,{touchAction:r.touchAction,recognizers:r.recognizers||om}).on("hammer.input",this._onBasicInput),r.recognizers||Object.keys(fu).forEach(i=>{let n=this.manager.get(i);n&&fu[i].forEach(o=>{n.recognizeWith(o)})});for(let i in r.recognizerOptions){let n=this.manager.get(i);if(n){let o=r.recognizerOptions[i];delete o.enable,n.set(o)}}this.wheelInput=new Vn(t,this._onOtherEvent,{enable:!1}),this.moveInput=new zn(t,this._onOtherEvent,{enable:!1}),this.keyInput=new Wn(t,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new jn(t,this._onOtherEvent,{enable:!1});for(let[i,n]of this.events)n.isEmpty()||(this._toggleRecognizer(n.recognizerName,!0),this.manager.on(i,n.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(t,r,s){this._addEventHandler(t,r,s,!1)}once(t,r,s){this._addEventHandler(t,r,s,!0)}watch(t,r,s){this._addEventHandler(t,r,s,!1,!0)}off(t,r){this._removeEventHandler(t,r)}_toggleRecognizer(t,r){let{manager:s}=this;if(!s)return;let i=s.get(t);if(i&&i.options.enable!==r){i.set({enable:r});let n=am[t];n&&!this.options.recognizers&&n.forEach(o=>{let a=s.get(o);r?(a.requireFailure(t),i.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,s,i,n){if(typeof t!="string"){s=r;for(let h in t)this._addEventHandler(h,t[h],s,i,n);return}let{manager:o,events:a}=this,c=uu[t]||t,l=a.get(c);l||(l=new Hn(this),a.set(c,l),l.recognizerName=lm[c]||c,o&&o.on(c,l.handleEvent)),l.add(t,r,s,i,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:s}=this,i=uu[t]||t,n=s.get(i);if(n&&(n.remove(t,r),n.isEmpty())){let{recognizerName:o}=n,a=!1;for(let c of s.values())if(c.recognizerName===o&&!c.isEmpty()){a=!0;break}a||this._toggleRecognizer(o,!1)}}};function Pr(){}var Kw=({isDragging:e})=>e?"grabbing":"grab",Am={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:Pr,onWebGLInitialized:Pr,onResize:Pr,onViewStateChange:Pr,onInteractionStateChange:Pr,onBeforeRender:Pr,onAfterRender:Pr,onLoad:Pr,onError:e=>j.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:Kw,getTooltip:null,debug:!1,drawPickingColors:!1},Xn=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 $t({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=s=>{let{_pickRequest:i}=this;if(s.type==="pointerleave")i.x=-1,i.y=-1,i.radius=0;else{if(s.leftButton||s.rightButton)return;{let n=s.offsetCenter;if(!n)return;i.x=n.x,i.y=n.y,i.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:i.x,y:i.y}),i.event=s},this._onEvent=s=>{let i=hn[s.type],n=s.offsetCenter;if(!i||!n||!this.layerManager)return;let o=this.layerManager.getLayers(),a=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:o,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:c}=a,l=c&&(c[i.handler]||c.props[i.handler]),h=this.props[i.handler],f=!1;l&&(f=l.call(c,a,s)),f||(h?.(a,s),this.widgetManager.onEvent(a,s))},this._onPointerDown=s=>{let i=s.offsetCenter,n=this._pick("pickObject","pickObject Time",{x:i.x,y:i.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=n.result[0]||n.emptyInfo},this.props={...Am,...t},t=this.props,t.viewState&&t.initialViewState&&j.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&&j.error("WebGL1 context not supported.")(),this.device=Mr.attach(t.gl));let r=this.device;r||(Ot.registerDevices([Mr]),r=Ot.createDevice({...t.deviceProps,canvas:this._createCanvas(t)})),this.animationLoop=this._createAnimationLoop(r,t),this.setProps(t),t._typedArrayManagerProps&&_e.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&&j.removed("onLayerHover","onHover")(),"onLayerClick"in t&&j.removed("onLayerClick","onClick")(),t.initialViewState&&!at(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 s=this.viewManager.needsRedraw(t),i=this.layerManager.needsRedraw(t),n=this.effectManager.needsRedraw(t),o=this.deckRenderer.needsRedraw(t);return r=r||s||i||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 rt(this.viewManager),this.viewManager.views}getViewports(t){return rt(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 s in t)this.layerManager.resourceManager.add({resourceId:s,data:t[s],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,s){rt(this.deckPicker);let{stats:i}=this;i.get("Pick Count").incrementCount(),i.get(r).timeStart();let n=this.deckPicker[t]({layers:this.layerManager.getLayers(s),views:this.viewManager.getViews(),viewports:this.getViewports(s),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...s});return i.get(r).timeEnd(),n}_createCanvas(t){let r=t.canvas;return typeof r=="string"&&(r=document.getElementById(r),rt(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:s}=t;if(r||r===0){let i=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=i}if(s||s===0){let i=Number.isFinite(s)?`${s}px`:s;this.canvas.style.position=t.style?.position||"absolute",this.canvas.style.height=i}}_updateCanvasSize(){let{canvas:t}=this;if(!t)return;let r=t.clientWidth??t.width,s=t.clientHeight??t.height;(r!==this.width||s!==this.height)&&(this.width=r,this.height=s,this.viewManager?.setProps({width:r,height:s}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:s}))}_createAnimationLoop(t,r){let{gl:s,onError:i,useDevicePixels:n}=r;return new Ni({device:t,useDevicePixels:n,autoResizeDrawingBuffer:!s,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:i})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:t}=this.props,r=Array.isArray(t)?t:t?[t]:[new Wa({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:s}=this._pick("pickObject","pickObject Time",t);this.cursorState.isHovering=r.length>0;let i=s,n=!1;for(let o of r)i=o,n=o.layer?.onHover(o,t.event)||n;n||(this.props.onHover?.(i,t.event),this.widgetManager.onHover(i,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 Mr&&this.props.onWebGLInitialized(this.device.gl);let r=new Ur;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new ci(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let i in hn)this.eventManager.on(i,this._onEvent);this.viewManager=new Sn({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let s=this.viewManager.getViewports()[0];this.layerManager=new Gr(this.device,{deck:this,stats:this.stats,viewport:s,timeline:r}),this.effectManager=new Mn({deck:this,device:this.device}),this.deckRenderer=new rs(this.device),this.deckPicker=new In(this.device),this.widgetManager=new ja({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Cn),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(t,r){let{device:s,gl:i}=this.layerManager.context;this.props.onBeforeRender({device:s,gl:i});let n={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(n),n.pass==="screen"&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:s,gl:i})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),j.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 s=Ot.stats.get("Memory Usage");t.bufferMemory=s.get("Buffer Memory").count,t.textureMemory=s.get("Texture Memory").count,t.renderbufferMemory=s.get("Renderbuffer Memory").count,t.gpuMemory=s.get("GPU Memory").count}};Xn.defaultProps=Am;Xn.VERSION=Ra;var dc=Xn;function Sm(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Ii(e)}}var wm=Bo;function $n(e,t){return{attribute:e,format:t.size>1?`${t.type}x${t.size}`:t.type,byteOffset:t.offset||0}}function Ir(e){return e.stride||e.size*e.bytesPerElement}function Rm(e,t){return e.type===t.type&&e.size===t.size&&Ir(e)===Ir(t)&&(e.offset||0)===(t.offset||0)}function pu(e,t){t.offset&&j.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Ir(e),s=t.vertexOffset!==void 0?t.vertexOffset:e.vertexOffset||0,i=t.elementOffset||0,n=s*r+i*e.bytesPerElement+(e.offset||0);return{...t,offset:n,stride:r}}function Zw(e,t){let r=pu(e,t);return{high:r,low:{...r,offset:r.offset+e.size*4}}}var Yn=class{constructor(t,r,s){this._buffer=null,this.device=t,this.id=r.id||"",this.size=r.size||1;let i=r.logicalType||r.type,n=i==="float64",{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;n?a="float32":!i&&r.isIndexed?a="uint32":a=i||"float32";let c=Sm(i||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:o,logicalType:i,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...s,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let t=this.getAccessor();return t.vertexOffset?t.vertexOffset*Ir(t):0}get numInstances(){return this.state.numInstances}set numInstances(t){this.state.numInstances=t}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),_e.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(t=this.id,r=null){let s={};if(this.state.constant){let i=this.value;if(r){let n=pu(this.getAccessor(),r),o=n.offset/i.BYTES_PER_ELEMENT,a=n.size||this.size;s[t]=i.subarray(o,o+a)}else s[t]=i}else s[t]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?s[`${t}64Low`]=s[t]:s[`${t}64Low`]=new Float32Array(this.size)),s}_getBufferLayout(t=this.id,r=null){let s=this.getAccessor(),i=[],n={name:this.id,byteStride:Ir(s),attributes:i};if(this.doublePrecision){let o=Zw(s,r||{});i.push($n(t,{...s,...o.high}),$n(`${t}64Low`,{...s,...o.low}))}else if(r){let o=pu(s,r);i.push($n(t,{...s,...o}))}else i.push($n(t,s));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:s,size:i}=this,n=s*i;if(r&&n&&r.length>=n){let o=new Array(i).fill(1/0),a=new Array(i).fill(-1/0);for(let c=0;ca[l]&&(a[l]=h)}t=[o,a]}}return this.state.bounds=t,t}setData(t){let{state:r}=this,s;ArrayBuffer.isView(t)?s={value:t}:t instanceof V?s={buffer:t}:s=t;let i={...this.settings,...s};if(ArrayBuffer.isView(s.value)){if(!s.type)if(this.doublePrecision&&s.value instanceof Float64Array)i.type="float32";else{let o=wm(s.value);i.type=i.normalized?o.replace("int","norm"):o}i.bytesPerElement=s.value.BYTES_PER_ELEMENT,i.stride=Ir(i)}if(r.bounds=null,s.constant){let n=s.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(s.buffer){let n=s.buffer;r.externalBuffer=n,r.constant=!1,this.value=s.value||null}else if(s.value){this._checkExternalBuffer(s);let n=s.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:o}=this,a=Ir(i),c=(i.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=Fa(n,i)),this.settings.isIndexed){let h=this.settings.defaultType;n.constructor!==h&&(n=new h(n))}let l=n.byteLength+c+a*2;(!o||o.byteLength(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,s){let{defaultValue:i,size:n}=this.settings;if(Number.isFinite(t))return r[s]=t,r;if(!t){let o=n;for(;--o>=0;)r[s+o]=i[o];return r}switch(n){case 4:r[s+3]=Number.isFinite(t[3])?t[3]:i[3];case 3:r[s+2]=Number.isFinite(t[2])?t[2]:i[2];case 2:r[s+1]=Number.isFinite(t[1])?t[1]:i[1];case 1:r[s+0]=Number.isFinite(t[0])?t[0]:i[0];break;default:let o=n;for(;--o>=0;)r[s+o]=Number.isFinite(t[o])?t[o]:i[o]}return r}_areValuesEqual(t,r){if(!t||!r)return!1;let{size:s}=this;for(let i=0;i0&&(Mm.length=e.length,s=Mm):s=vm,(t>0||Number.isFinite(r))&&(s=(Array.isArray(s)?s:Array.from(s)).slice(t,r),i.index=t-1),{iterable:s,objectInfo:i}}function pc(e){return e&&e[Symbol.asyncIterator]}function gc(e,t){let{size:r,stride:s,offset:i,startIndices:n,nested:o}=t,a=e.BYTES_PER_ELEMENT,c=s?s/a:r,l=i?i/a:0,h=Math.floor((e.length-l)/c);return(f,{index:u,target:_})=>{if(!n){let A=u*c+l;for(let w=0;w=t[1]))return e;let r=[],s=e.length,i=0;for(let n=0;nt[1]?r.push(o):t=[Math.min(o[0],t[0]),Math.max(o[1],t[1])]}return r.splice(i,0,t),r}var Jw={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function _c(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});let r=e.type||"interpolation";return{...Jw[r],...t,...e,type:r}}var tr=class extends Yn{constructor(t,r){super(t,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:qn}),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){var r;(r=this.state).layoutChanged||(r.layoutChanged=!Rm(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,s=this.settings.transition,i=Array.isArray(r)?t[r.find(n=>t[n])]:t[r];return _c(i,s)}setNeedsUpdate(t=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||t,this.setNeedsRedraw(t),r){let{startRow:s=0,endRow:i=1/0}=r;this.state.updateRanges=Im(this.state.updateRanges,[s,i])}else this.state.updateRanges=qn}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=Pm}setNeedsRedraw(t=this.id){this.state.needsRedraw=this.state.needsRedraw||t}allocate(t){let{state:r,settings:s}=this;return s.noAlloc?!1:s.update?(super.allocate(t,r.updateRanges!==qn),!0):!1}updateBuffer({numInstances:t,data:r,props:s,context:i}){if(!this.needsUpdate())return!1;let{state:{updateRanges:n},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,h]of n)o.call(i,this,{data:r,startRow:l,endRow:h,props:s,numInstances:t});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthh?l.set(v,b):(t._normalizeValue(v,A.target,0),La({target:l,source:A.target,start:b,count:M}));b+=M*h}else t._normalizeValue(v,l,b),b+=h}}_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 s=!0;switch(r){case 4:s=s&&Number.isFinite(t[3]);case 3:s=s&&Number.isFinite(t[2]);case 2:s=s&&Number.isFinite(t[1]);case 1:s=s&&Number.isFinite(t[0]);break;default:s=!1}if(!s)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function gu(e){let{source:t,target:r,start:s=0,size:i,getData:n}=e,o=e.end||r.length,a=t.length,c=o-s;if(a>c){r.set(t.subarray(0,c),s);return}if(r.set(t,s),!n)return;let l=a;for(;ls(h+a,f)),l=Math.min(i.length,n.length);for(let h=1;ha}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,h=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,f=r.startIndices,u=n&&f,_=r.isConstant;if(!u&&t&&s>=i)return t;let m=r.value instanceof Float64Array?Float32Array:r.value.constructor,b=_?r.value:new m(r.getBuffer().readSyncWebGL(l,i*m.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!_){let v=o;o=(M,I)=>r.normalizeConstant(v(M,I))}let y=_?(v,M)=>o(b,M):(v,M)=>o(b.subarray(v+l,v+l+c),M),A=t?new Float32Array(t.readSyncWebGL(h,s*4).buffer):new Float32Array(0),w=new Float32Array(i);return Cm({source:A,target:w,sourceStartIndices:n,targetStartIndices:f,size:c,getData:y}),(!t||t.byteLength0||i.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},rR=`#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; } `,sR=`#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 iR(e,t){let r=mc(t.size),s=Tc(t.size);return new Zt(e,{vs:rR,fs:sR,bufferLayout:[{name:"aPrev",format:s},{name:"aCur",format:s},{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 nR(e){return e.createTexture({data:new Uint8Array(4),format:"rgba8unorm",mipmaps:!1,width:1,height:1})}function oR(e,t){return e.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[t]})}var aR={interpolation:Kn,spring:Zn},Qn=class{constructor(t,{id:r,timeline:s}){if(!t)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=t,this.timeline=s,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let t in this.transitions)this._removeTransition(t)}update({attributes:t,transitions:r,numInstances:s}){this.numInstances=s||1;for(let i in t){let n=t[i],o=n.getTransitionSetting(r);o&&this._updateAttribute(i,n,o)}for(let i in this.transitions){let n=t[i];(!n||!n.getTransitionSetting(r))&&this._removeTransition(i)}}hasAttribute(t){let r=this.transitions[t];return r&&r.inProgress}getAttributes(){let t={};for(let r in this.transitions){let s=this.transitions[r];s.inProgress&&(t[r]=s.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,s){let i=this.transitions[t],n=!i||i.type!==s.type;if(n){i&&this._removeTransition(t);let o=aR[s.type];o?this.transitions[t]=new o({attribute:r,timeline:this.timeline,device:this.device}):(j.error(`unsupported transition type '${s.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[t].start(s,this.numInstances))}};var km="attributeManager.invalidate",cR="attributeManager.updateStart",lR="attributeManager.updateEnd",hR="attribute.updateStart",fR="attribute.allocate",uR="attribute.updateEnd",cs=class{constructor(t,{id:r="attribute-manager",stats:s,timeline:i}={}){this.mergeBoundsMemoized=te(Qg),this.id=r,this.device=t,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=s,this.attributeTransitionManager=new Qn(t,{id:`${r}-transitions`,timeline:i}),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 s=this._invalidateTrigger(t,r);it(km,this,t,s)}invalidateAll(t){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,t);it(km,this,"all")}update({data:t,numInstances:r,startIndices:s=null,transitions:i,props:n={},buffers:o={},context:a={}}){let c=!1;it(cR,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let h=this.attributes[l],f=h.settings.accessor;h.startIndices=s,h.numInstances=r,n[l]&&j.removed(`props.${l}`,`data.attributes.${l}`)(),h.setExternalBuffer(o[l])||h.setBinaryValue(typeof f=="string"?o[f]:void 0,t.startIndices)||typeof f=="string"&&!o[f]&&h.setConstantValue(n[f])||h.needsUpdate()&&(c=!0,this._updateAttribute({attribute:h,numInstances:r,data:t,props:n,context:a})),this.needsRedraw=this.needsRedraw||h.needsRedraw()}c&&it(lR,this,r),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:i})}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(s=>this.attributes[s]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(t={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:s}=this,i={...s.getAttributes()};for(let n in r){let o=r[n];o.needsRedraw(t)&&!s.hasAttribute(n)&&(i[n]=o)}return i}getBufferLayouts(t){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(t))}_add(t,r){for(let s in t){let i=t[s],n={...i,id:s,size:i.isIndexed&&1||i.size||1,...r};this.attributes[s]=new tr(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let t={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(i=>{t[i]||(t[i]=[]),t[i].push(r)});this.updateTriggers=t}_invalidateTrigger(t,r){let{attributes:s,updateTriggers:i}=this,n=i[t];return n&&n.forEach(o=>{let a=s[o];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(t){let{attribute:r,numInstances:s}=t;if(it(hR,r),r.constant){r.setConstantValue(r.value);return}r.allocate(s)&&it(fR,r,s),r.updateBuffer(t)&&(this.needsRedraw=!0,it(uR,r,s))}};var Jn=class extends Te{get value(){return this._value}_onUpdate(){let{time:t,settings:{fromValue:r,toValue:s,duration:i,easing:n}}=this,o=n(t/i);this._value=Xe(r,s,o)}};var Dm=1e-5;function Bm(e,t,r,s,i){let n=t-e,a=(r-t)*i,c=-n*s;return a+c+n+t}function dR(e,t,r,s,i){if(Array.isArray(r)){let n=[];for(let o=0;o0}add(t,r,s,i){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(i=_c(i),!i)return;let o=pR[i.type];if(!o){j.error(`unsupported transition type '${i.type}'`)();return}let a=new o(this.timeline);a.start({...i,fromValue:r,toValue:s}),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,s]of this.transitions)s.update(),t[r]=s.value,s.inProgress||this.remove(r);return t}clear(){for(let t of this.transitions.keys())this.remove(t)}};function Vm(e){let t=e[se];for(let r in t){let s=t[r],{validate:i}=s;if(i&&!i(e[r],s))throw new Error(`Invalid prop ${r}: ${e[r]}`)}}function zm(e,t){let r=xc({newProps:e,oldProps:t,propTypes:e[se],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),s=_R(e,t),i=!1;return s||(i=mR(e,t)),{dataChanged:s,propsChanged:r,updateTriggersChanged:i,extensionsChanged:TR(e,t),transitionsChanged:gR(e,t)}}function gR(e,t){if(!e.transitions)return!1;let r={},s=e[se],i=!1;for(let n in e.transitions){let o=s[n],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&_u(e[n],t[n],o)&&(r[n]=!0,i=!0)}return i?r:!1}function xc({newProps:e,oldProps:t,ignoreProps:r={},propTypes:s={},triggerName:i="props"}){if(t===e)return!1;if(typeof e!="object"||e===null)return`${i} changed shallowly`;if(typeof t!="object"||t===null)return`${i} changed shallowly`;for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${i}.${n} added`;let o=_u(e[n],t[n],s[n]);if(o)return`${i}.${n} ${o}`}for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${i}.${n} dropped`;if(!Object.hasOwnProperty.call(e,n)){let o=_u(e[n],t[n],s[n]);if(o)return`${i}.${n} ${o}`}}return!1}function _u(e,t,r){let s=r&&r.equal;return s&&!s(e,t,r)||!s&&(s=e&&t&&e.equals,s&&!s.call(e,t))?"changed deeply":!s&&t!==e?"changed shallowly":null}function _R(e,t){if(t===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:s,_dataDiff:i}=e;return s?s(e.data,t.data)||(r="Data comparator detected a change"):e.data!==t.data&&(r="A new data container was supplied"),r&&i&&(r=i(e.data,t.data)||r),r}function mR(e,t){if(t===null)return{all:!0};if("all"in e.updateTriggers&&Lm(e,t,"all"))return{all:!0};let r={},s=!1;for(let i in e.updateTriggers)i!=="all"&&Lm(e,t,i)&&(r[i]=!0,s=!0);return s?r:!1}function TR(e,t){if(t===null)return!0;let r=t.extensions,{extensions:s}=e;if(s===r)return!1;if(!r||!s||s.length!==r.length)return!0;for(let i=0;is.name==="project64"))){let s=r.modules.findIndex(i=>i.name==="project32");s>=0&&r.modules.splice(s,1)}if("inject"in t)if(!e.inject)r.inject=t.inject;else{let s={...e.inject};for(let i in t.inject)s[i]=(s[i]||"")+t.inject[i];r.inject=s}return r}var AR={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},mu={};function Wm(e,t,r,s){if(r instanceof G)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let i=null;r.compressed&&(i={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let n=t.createTexture({...r,sampler:{...AR,...i,...s}});return mu[n.id]=e,n}function jm(e,t){!t||!(t instanceof G)||mu[t.id]===e&&(t.delete(),delete mu[t.id])}var SR={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||Tu(e)&&(e.length===3||e.length===4)},equal(e,t,r){return at(e,t,1)}},accessor:{validate(e,t){let r=Sc(e);return r==="function"||r===Sc(t.value)},equal(e,t,r){return typeof t=="function"?!0:at(e,t,1)}},array:{validate(e,t){return t.optional&&!e||Tu(e)},equal(e,t,r){let{compare:s}=r,i=Number.isInteger(s)?s:s?1:0;return s?at(e,t,i):e===t}},object:{equal(e,t,r){if(r.ignore)return!0;let{compare:s}=r,i=Number.isInteger(s)?s:s?1:0;return s?at(e,t,i):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:s}=r.props;return s?s(e):typeof e.shape=="string"&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,r)=>{let s=r.context;return!s||!s.device?null:Wm(r.id,s.device,e,{...t.parameters,...r.props.textureParameters})},release:(e,t,r)=>{jm(r.id,e)}}};function Hm(e){let t={},r={},s={};for(let[i,n]of Object.entries(e)){let o=n?.deprecatedFor;if(o)s[i]=Array.isArray(o)?o:[o];else{let a=wR(i,n);t[i]=a,r[i]=a.value}}return{propTypes:t,defaultProps:r,deprecatedProps:s}}function wR(e,t){switch(Sc(t)){case"object":return ro(e,t);case"array":return ro(e,{type:"array",value:t,compare:!1});case"boolean":return ro(e,{type:"boolean",value:t});case"number":return ro(e,{type:"number",value:t});case"function":return ro(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function ro(e,t){return"type"in t?{name:e,...SR[t.type],...t}:"value"in t?{name:e,type:Sc(t.value),...t}:{name:e,type:"object",value:t}}function Tu(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function Sc(e){return Tu(e)?"array":e===null?"null":typeof e}function Xm(e,t){let r;for(let n=t.length-1;n>=0;n--){let o=t[n];"extensions"in o&&(r=o.extensions)}let s=yu(e.constructor,r),i=Object.create(s);i[ti]=e,i[Ne]={},i[me]={};for(let n=0;n{},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||FR}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[ti]||this.component;let r=t[me]||{},s=t[Ne]||t,i=t[qe]||{};for(let n in r){let o=r[n];this._createAsyncPropData(n,i[n]),this._updateAsyncProp(n,o),r[n]=this.getAsyncProp(n)}for(let n in s){let o=s[n];this._createAsyncPropData(n,i[n]),this._updateAsyncProp(n,o)}}_fetch(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(pc(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 s=this.asyncProps[t];return r===s.resolvedValue||r===s.lastValue?!1:(s.lastValue=r,!0)}_setPropValue(t,r){this._freezeAsyncOldProps();let s=this.asyncProps[t];s&&(r=this._postProcessValue(s,r),s.resolvedValue=r,s.pendingLoadCount++,s.resolvedLoadCount=s.pendingLoadCount)}_setAsyncPropValue(t,r,s){let i=this.asyncProps[t];i&&s>=i.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),i.resolvedValue=r,i.resolvedLoadCount=s,this.onAsyncPropUpdated(t,r))}_watchPromise(t,r){let s=this.asyncProps[t];if(s){s.pendingLoadCount++;let i=s.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(s,n),this._setAsyncPropValue(t,n,i),this._onResolve(t,n))}).catch(n=>{this._onError(t,n)})}}async _resolveAsyncIterable(t,r){if(t!=="data"){this._setPropValue(t,r);return}let s=this.asyncProps[t];if(!s)return;s.pendingLoadCount++;let i=s.pendingLoadCount,n=[],o=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:o,endRow:n.length}]}),o=n.length,this._setAsyncPropValue(t,n,i)}this._onResolve(t,n)}_postProcessValue(t,r){let s=t.type;return s&&this.component&&(s.release&&s.release(t.resolvedValue,s,this.component),s.transform)?s.transform(r,s,this.component):r}_createAsyncPropData(t,r){if(!this.asyncProps[t]){let i=this.component&&this.component.props[se];this.asyncProps[t]={type:i&&i[t],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var io=class extends ls{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 s=this.layer,i=s?.props.fetch;return i?i(r,{propName:t,layer:s}):super._fetch(t,r)}_onResolve(t,r){let s=this.layer;if(s){let i=s.props.onDataLoad;t==="data"&&i&&i(r,{propName:t,layer:s})}}_onError(t,r){let s=this.layer;s&&s.raiseError(r,`loading ${t} of ${this.layer}`)}};var kR="layer.changeFlag",DR="layer.initialize",BR="layer.update",UR="layer.finalize",LR="layer.matched",Ym=2**24-1,VR=Object.freeze([]),zR=te(({oldViewport:e,viewport:t})=>e.equals(t)),Be=new Uint8ClampedArray(0),WR={data:{type:"data",value:VR,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:s,loadOptions:i,signal:n})=>{let{resourceManager:o}=r.context;i=i||r.getLoadOptions(),s=s||r.props.loaders,n&&(i={...i,fetch:{...i?.fetch,signal:n}});let a=o.contains(e);return!a&&!i&&(o.add({resourceId:e,data:Tr(e,s),persistent:!1}),a=!0),a?o.subscribe({resourceId:e,onChange:c=>r.internalState?.reloadAsyncProp(t,c),consumerId:r.id,requestId:t}):Tr(e,s,i)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:X.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:e})=>[0,-e*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},no=class extends fi{constructor(){super(...arguments),this.internalState=null,this.lifecycle=xr.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){rt(this.internalState);let r=this.internalState.viewport||this.context.viewport,s=Xf(t,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[i,n,o]=$s(s,r.pixelProjectionMatrix);return t.length===2?[i,n]:[i,n,o]}unproject(t){return rt(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(t)}projectPosition(t,r){rt(this.internalState);let s=this.internalState.viewport||this.context.viewport;return ka(t,{viewport:s,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){rt(t instanceof Uint8Array);let[r,s,i]=t;return r+s*256+i*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Ac(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=eo(t,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)t=eo(t,r.getShaders.call(this,r));return t}shouldUpdateState(t){return t.changeFlags.propsOrDataChanged}updateState(t){let r=this.getAttributeManager(),{dataChanged:s}=t.changeFlags;if(s&&r)if(Array.isArray(s))for(let i of s)r.invalidateAll(i);else r.invalidateAll();if(r){let{props:i}=t,n=this.internalState.hasPickingBuffer,o=Number.isInteger(i.highlightedObjectIndex)||i.pickable||i.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(t){for(let s of this.getModels())s.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(t){for(let r of this.getModels())r.draw(t)}getPickingInfo({info:t,mode:r,sourceLayer:s}){let{index:i}=t;return i>=0&&Array.isArray(this.props.data)&&(t.object=this.props.data[i]),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||!zR({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 s in t)t[s].layoutChanged()&&(r=!0);for(let s of this.getModels())this._setModelAttributes(s,t,r)}_updateAttributes(){let t=this.getAttributeManager();if(!t)return;let r=this.props,s=this.getNumInstances(),i=this.getStartIndices();t.update({data:r.data,numInstances:s,startIndices:i,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(),s=Object.create(this.props);for(let i in r)Object.defineProperty(s,i,{value:r[i]});return s}return this.props}calculateInstancePickingColors(t,{numInstances:r}){if(t.constant)return;let s=Math.floor(Be.length/4);if(this.internalState.usesPickingColorCache=!0,sYm&&j.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Be=_e.allocate(Be,r,{size:4,copy:!0,maxCount:Math.max(r,Ym)});let i=Math.floor(Be.length/4),n=[];for(let o=s;o(j.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),t)}),this.internalState.uniformTransitions=new to(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){it(LR,this,this===t);let{state:r,internalState:s}=t;this!==t&&(this.internalState=s,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let t=this.needsUpdate();if(it(BR,this,t),!t)return;let r=this.props,s=this.context,i=this.internalState,n=s.viewport,o=this._updateUniformTransition();i.propsInTransition=o,s.viewport=i.viewport||n,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(s.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let h of this.props.extensions)h.updateState.call(this,a,h);let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{s.viewport=n,this.props=r,this._clearChangeFlags(),i.needsUpdate=!1,i.resetOldProps()}}_finalize(){it(UR,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:s={},parameters:i={}}){this._updateAttributeTransition();let n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;let a=this.props.opacity;s.opacity=Math.pow(a,1/2.2);try{if(r){let{isActive:h,isAttribute:f}=r.picking;this.setModuleParameters(r),this.setShaderModuleProps({picking:{isActive:h,isAttribute:f}})}let{getPolygonOffset:c}=this.props,l=c&&c(s)||[0,0];o.device.setParametersWebGL({polygonOffset:l});for(let h of this.getModels())h.setParameters(i);o.device.withParametersWebGL(i,()=>{let h={renderPass:t,moduleParameters:r,uniforms:s,parameters:i,context:o};for(let f of this.props.extensions)f.draw.call(this,h,f);this.draw(h)})}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(t){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let i in t)if(t[i]){let n=!1;switch(i){case"dataChanged":let o=t[i],a=r[i];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,n=!0);default:r[i]||(r[i]=t[i],n=!0)}n&&it(kR,this,i,t)}let s=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=s,r.somethingChanged=s||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(t,r){let s=zm(t,r);if(s.updateTriggersChanged)for(let i in s.updateTriggersChanged)s.updateTriggersChanged[i]&&this.invalidateAttribute(i);if(s.transitionsChanged)for(let i in s.transitionsChanged)this.internalState.uniformTransitions.add(i,r[i],t[i],t.transitions?.[i]);return this.setChangeFlags(s)}validateProps(){Vm(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:s}=this.props;t.picked&&typeof s=="function"&&(r.highlightColor=s(t)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let t=this.context;return new cs(t.device,{id:this.props.id,stats:t.stats,timeline:t.timeline})}_postUpdate(t,r){let{props:s,oldProps:i}=t;this.setNeedsRedraw(),this._updateAttributes();let n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=s;if(r||i.autoHighlight!==o||i.highlightedObjectIndex!==a||i.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||i.autoHighlight!==o||a!==i.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(t){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let s=this.getAttributeManager(),i=s?s.getNeedsRedraw(t):!1;if(r=r||i,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!t.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};no.defaultProps=WR;no.layerName="Layer";var wc=no;var jR="compositeLayer.renderLayers",Rc=class extends wc{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:s}=this.props;return s&&s[t]&&s[t].type||r}getSubLayerRow(t,r,s){return t.__source={parent:this,object:r,index:s},t}getSubLayerAccessor(t){if(typeof t=="function"){let r={index:-1,data:this.props.data,target:[]};return(s,i)=>s&&s.__source?(r.index=s.__source.index,t(s.__source.object,r)):t(s,i)}return t}getSubLayerProps(t={}){let{opacity:r,pickable:s,visible:i,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:h,coordinateOrigin:f,wrapLongitude:u,positionFormat:_,modelMatrix:m,extensions:b,fetch:y,operation:A,_subLayerProps:w}=this.props,v={id:"",updateTriggers:{},opacity:r,pickable:s,visible:i,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:h,coordinateOrigin:f,wrapLongitude:u,positionFormat:_,modelMatrix:m,extensions:b,fetch:y,operation:A},M=w&&t.id&&w[t.id],I=M&&M.updateTriggers,O=t.id||"sublayer";if(M){let F=this.props[se],k=t.type?t.type._propTypes:{};for(let D in M){let N=k[D]||F[D];N&&N.type==="accessor"&&(M[D]=this.getSubLayerAccessor(M[D]))}}Object.assign(v,t,M),v.id=`${this.props.id}-${O}`,v.updateTriggers={all:this.props.updateTriggers?.all,...t.updateTriggers,...I};for(let F of b){let k=F.getSubLayerProps.call(this,F);k&&Object.assign(v,k,{updateTriggers:Object.assign(v.updateTriggers,k.updateTriggers)})}return v}_updateAutoHighlight(t){for(let r of this.getSubLayers())r.updateAutoHighlight(t)}_getAttributeManager(){return null}_postUpdate(t,r){let s=this.internalState.subLayers,i=!s||this.needsUpdate();if(i){let n=this.renderLayers();s=Ar(n,Boolean),this.internalState.subLayers=s}it(jR,this,i,s);for(let n of s)n.parent=this}};Rc.layerName="CompositeLayer";var qm=Rc;var vc=Math.PI/180,Km=180/Math.PI,Mc=6370972,ui=256;function HR(){let e=ui/Mc,t=Math.PI/180*ui;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 hs=class extends kt{constructor(t={}){let{latitude:r=0,longitude:s=0,zoom:i=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 h=new Q().lookAt({eye:[0,-l,0],up:[0,0,1]}),f=Math.pow(2,i);h.rotateX(r*vc),h.rotateZ(-s*vc),h.scale(f/c);let u=Math.atan(.5/l),_=ui*2*f/c;super({...t,height:c,viewMatrix:h,longitude:s,latitude:r,zoom:i,distanceScales:HR(),fovyRadians:u*2,focalDistance:l,near:n,far:Math.min(2,1/_+1)*l*o}),this.latitude=r,this.longitude=s,this.resolution=a}get projectionMode(){return bt.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(t={}){let r={targetZ:t.z||0},s=this.unproject([0,this.height/2],r),i=this.unproject([this.width/2,0],r),n=this.unproject([this.width,this.height/2],r),o=this.unproject([this.width/2,this.height],r);return n[0]this.longitude&&(s[0]-=360),[Math.min(s[0],n[0],i[0],o[0]),Math.min(s[1],n[1],i[1],o[1]),Math.max(s[0],n[0],i[0],o[0]),Math.max(s[1],n[1],i[1],o[1])]}unproject(t,{topLeft:r=!0,targetZ:s}={}){let[i,n,o]=t,a=r?n:this.height-n,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(o))l=Eu(c,[i,a,o,1]);else{let _=Eu(c,[i,a,-1,1]),m=Eu(c,[i,a,1,1]),b=((s||0)/Mc+1)*ui,y=St.sqrLen(St.sub([],_,m)),A=St.sqrLen(_),w=St.sqrLen(m),M=4*((4*A*w-(y-A-w)**2)/16)/y,I=Math.sqrt(A-M),O=Math.sqrt(Math.max(0,b*b-M)),F=(I-O)/Math.sqrt(y);l=St.lerp([],_,m,F)}let[h,f,u]=this.unprojectPosition(l);return Number.isFinite(o)?[h,f,u]:Number.isFinite(s)?[h,f,s]:[h,f]}projectPosition(t){let[r,s,i=0]=t,n=r*vc,o=s*vc,a=Math.cos(o),c=(i/Mc+1)*ui;return[Math.sin(n)*a*c,-Math.cos(n)*a*c,Math.sin(o)*c]}unprojectPosition(t){let[r,s,i]=t,n=St.len(t),o=Math.asin(i/n),c=Math.atan2(r,-s)*Km,l=o*Km,h=(n/ui-1)*Mc;return[c,l,h]}projectFlat(t){return t}unprojectFlat(t){return t}panByPosition(t,r){let s=this.unproject(r);return{longitude:t[0]-s[0]+this.longitude,latitude:t[1]-s[1]+this.latitude}}};function Eu(e,t){let r=Nt.transformMat4([],t,e);return Nt.scale(r,r,1/r[3]),r}var xu=Math.PI/180;function XR({height:e,focalDistance:t,orbitAxis:r,rotationX:s,rotationOrbit:i,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(s*xu),r==="Z"?c.rotateZ(i*xu):c.rotateY(i*xu);let l=Math.pow(2,n)/e;return c.scale(l),c}var fs=class extends kt{constructor(t){let{height:r,projectionMatrix:s,fovy:i=50,orbitAxis:n="Z",target:o=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=t,h=s?s[5]/2:qr(i);super({...t,longitude:void 0,viewMatrix:XR({height:r||1,focalDistance:h,orbitAxis:n,rotationX:a,rotationOrbit:c,zoom:l}),fovy:i,focalDistance:h,position:o,zoom:l}),this.projectedCenter=this.project(this.center)}unproject(t,{topLeft:r=!0}={}){let[s,i,n=this.projectedCenter[2]]=t,o=r?i:this.height-i,[a,c,l]=re([s,o,n],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(t,r){let s=this.project(t),i=[this.width/2+s[0]-r[0],this.height/2+s[1]-r[1],this.projectedCenter[2]];return{target:this.unproject(i)}}};var $R=new Q().lookAt({eye:[0,0,1]});function YR({width:e,height:t,near:r,far:s,padding:i}){let n=-e/2,o=e/2,a=-t/2,c=t/2;if(i){let{left:l=0,right:h=0,top:f=0,bottom:u=0}=i,_=J((l+e-h)/2,0,e)-e/2,m=J((f+t-u)/2,0,t)-t/2;n-=_,o-=_,a+=m,c+=m}return new Q().ortho({left:n,right:o,bottom:a,top:c,near:r,far:s})}var us=class extends kt{constructor(t){let{width:r,height:s,near:i=.1,far:n=1e3,zoom:o=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=t,h=Array.isArray(o)?o[0]:o,f=Array.isArray(o)?o[1]:o,u=Math.min(h,f),_=Math.pow(2,u),m;if(h!==f){let b=Math.pow(2,h),y=Math.pow(2,f);m={unitsPerMeter:[b/_,y/_,1],metersPerUnit:[_/b,_/y,1]}}super({...t,longitude:void 0,position:a,viewMatrix:$R.clone().scale([_,_*(l?-1:1),_]),projectionMatrix:YR({width:r||1,height:s||1,padding:c,near:i,far:n}),zoom:u,distanceScales:m})}projectFlat([t,r]){let{unitsPerMeter:s}=this.distanceScales;return[t*s[0],r*s[1]]}unprojectFlat([t,r]){let{metersPerUnit:s}=this.distanceScales;return[t*s[0],r*s[1]]}panByPosition(t,r){let s=re(r,this.pixelUnprojectionMatrix),i=this.projectFlat(t),n=ft.add([],i,ft.negate([],s)),o=ft.add([],this.center,n);return{target:this.unprojectFlat(o)}}};var ds=class extends kt{constructor(t){let{longitude:r,latitude:s,modelMatrix:i,bearing:n=0,pitch:o=0,up:a=[0,0,1]}=t,l=new he({bearing:n,pitch:o===-90?1e-4:90+o}).toVector3().normalize(),h=i?new Q(i).transformAsVector(l):l,f=Number.isFinite(s)?dn({latitude:s}):0,u=Math.pow(2,f),_=new Q().lookAt({eye:[0,0,0],center:h,up:a}).scale(u);super({...t,zoom:f,viewMatrix:_}),this.latitude=s,this.longitude=r}};var ps=20,Zm=500,oo=class extends Je{constructor(t){let{width:r,height:s,position:i=[0,0,0],bearing:n=0,pitch:o=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:h=-90,startRotatePos:f,startBearing:u,startPitch:_,startZoomPosition:m,startPanPos:b,startPanPosition:y}=t;super({width:r,height:s,position:i,bearing:n,pitch:o,longitude:a,latitude:c,maxPitch:l,minPitch:h},{startRotatePos:f,startBearing:u,startPitch:_,startZoomPosition:m,startPanPos:b,startPanPosition:y}),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:s=[0,0]}=this.getState(),{width:i,height:n,bearing:o,pitch:a}=this.getViewportProps(),c=Zm*(t[0]-r[0])/i,l=Zm*(t[1]-r[1])/n,h=new he({bearing:o,pitch:a}),f=new he({bearing:o,pitch:-90}),u=h.toVector3().normalize(),_=f.toVector3().cross(u).normalize();return this._getUpdatedState({position:new Z(s).add(_.scale(c)).add(u.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:s=0}){let{startRotatePos:i,startBearing:n,startPitch:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!i||n===void 0||o===void 0)return this;let l;if(t){let h=(t[0]-i[0])/a,f=(t[1]-i[1])/c;l={bearing:n-h*180,pitch:o-f*90}}else l={bearing:n-r,pitch:o-s};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:t,scale:r}){let s=this.getViewportProps(),i=this.getState().startZoomPosition||s.position,n=this.makeViewport(s),{projectionMatrix:o,width:a}=n,l=2*Math.atan(1/o[0])*(t[0]/a-.5),h=this.getDirection(!0);return this._move(h.rotateZ({radians:-l}),Math.log2(r)*ps,i)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(t=ps){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),t)}moveRight(t=ps){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),t)}moveUp(t=ps){let r=this.getDirection(!0);return this._move(r,t)}moveDown(t=ps){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=ps){return this._move(new Z(0,0,1),t)}zoomOut(t=ps){return this._move(new Z(0,0,-1),t)}shortestPathFrom(t){let r=t.getViewportProps(),s={...this.getViewportProps()},{bearing:i,longitude:n}=s;return Math.abs(i-r.bearing)>180&&(s.bearing=i<0?i+360:i-360),n!==null&&r.longitude!==null&&Math.abs(n-r.longitude)>180&&(s.longitude=n<0?n+360:n-360),s}_move(t,r,s=this.getViewportProps().position){let i=t.scale(r);return this._getUpdatedState({position:new Z(s).add(i)})}getDirection(t=!1){return new he({bearing:this.getViewportProps().bearing,pitch:t?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(t){return new oo({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}applyConstraints(t){let{pitch:r,maxPitch:s,minPitch:i,longitude:n,bearing:o}=t;return t.pitch=J(r,i,s),n!==null&&(n<-180||n>180)&&(t.longitude=Zr(n+180,360)-180),(o<-180||o>180)&&(t.bearing=Zr(o+180,360)-180),t}},gs=class extends vt{constructor(){super(...arguments),this.ControllerState=oo,this.transition={transitionDuration:300,transitionInterpolator:new mt(["position","pitch","bearing"])}}};var Pc=class extends Rt{constructor(t={}){super(t)}get ViewportType(){return ds}get ControllerType(){return gs}};Pc.displayName="FirstPersonView";var Qm=Pc;var ao=class extends Je{constructor(t){let{width:r,height:s,rotationX:i=0,rotationOrbit:n=0,target:o=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:h=-1/0,maxZoom:f=1/0,startPanPosition:u,startRotatePos:_,startRotationX:m,startRotationOrbit:b,startZoomPosition:y,startZoom:A}=t;super({width:r,height:s,rotationX:i,rotationOrbit:n,target:o,zoom:a,minRotationX:c,maxRotationX:l,minZoom:h,maxZoom:f},{startPanPosition:u,startRotatePos:_,startRotationX:m,startRotationOrbit:b,startZoomPosition:y,startZoom:A}),this.makeViewport=t.makeViewport}panStart({pos:t}){return this._getUpdatedState({startPanPosition:this._unproject(t)})}pan({pos:t,startPosition:r}){let s=this.getState().startPanPosition||r;if(!s)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(s,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:s=0}){let{startRotatePos:i,startRotationX:n,startRotationOrbit:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!i||n===void 0||o===void 0)return this;let l;if(t){let h=(t[0]-i[0])/a,f=(t[1]-i[1])/c;(n<-90||n>90)&&(h*=-1),l={rotationX:n+f*180,rotationOrbit:o+h*180}}else l={rotationX:n+s,rotationOrbit:o+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(t){let r=t.getViewportProps(),s={...this.getViewportProps()},{rotationOrbit:i}=s;return Math.abs(i-r.rotationOrbit)>180&&(s.rotationOrbit=i<0?i+360:i-360),s}zoomStart({pos:t}){return this._getUpdatedState({startZoomPosition:this._unproject(t),startZoom:this.getViewportProps().zoom})}zoom({pos:t,startPos:r,scale:s}){let{startZoom:i,startZoomPosition:n}=this.getState();if(n||(i=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(t)),!n)return this;let o=this._calculateNewZoom({scale:s,startZoom:i}),a=this.makeViewport({...this.getViewportProps(),zoom:o});return this._getUpdatedState({zoom:o,...a.panByPosition(n,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:s,minZoom:i}=this.getViewportProps();r===void 0&&(r=this.getViewportProps().zoom);let n=r+Math.log2(t);return J(n,i,s)}_panFromCenter(t){let{width:r,height:s,target:i}=this.getViewportProps();return this.pan({startPosition:i,pos:[r/2+t[0],s/2+t[1]]})}_getUpdatedState(t){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t})}applyConstraints(t){let{maxZoom:r,minZoom:s,zoom:i,maxRotationX:n,minRotationX:o,rotationOrbit:a}=t;return t.zoom=Array.isArray(i)?[J(i[0],s,r),J(i[1],s,r)]:J(i,s,r),t.rotationX=J(t.rotationX,o,n),(a<-180||a>180)&&(t.rotationOrbit=Zr(a+180,360)-180),t}},_s=class extends vt{constructor(){super(...arguments),this.ControllerState=ao,this.transition={transitionDuration:300,transitionInterpolator:new mt({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})}}};var Ic=class extends Rt{constructor(t={}){super(t),this.props.orbitAxis=t.orbitAxis||"Z"}get ViewportType(){return fs}get ControllerType(){return _s}};Ic.displayName="OrbitView";var Jm=Ic;var Au=class extends ao{constructor(t){super(t),this.zoomAxis=t.zoomAxis||"all"}_calculateNewZoom({scale:t,startZoom:r}){let{maxZoom:s,minZoom:i}=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=J(o+n,i,s);break;case"Y":a=J(a+n,i,s);break;default:let c=Math.min(o+n,a+n);cs&&(n+=s-c),o+=n,a+=n}return[o,a]}return J(r+n,i,s)}},ms=class extends vt{constructor(){super(...arguments),this.ControllerState=Au,this.transition={transitionDuration:300,transitionInterpolator:new mt(["target","zoom"])},this.dragMode="pan"}_onPanRotate(){return!1}};var Cc=class extends Rt{constructor(t={}){super(t)}get ViewportType(){return us}get ControllerType(){return ms}};Cc.displayName="OrthographicView";var Gm=Cc;var Su=class extends vn{applyConstraints(t){let{maxZoom:r,minZoom:s,zoom:i}=t;t.zoom=J(i,s,r);let{longitude:n,latitude:o}=t;return(n<-180||n>180)&&(t.longitude=Zr(n+180,360)-180),t.latitude=J(o,-89,89),t}},Ts=class extends vt{constructor(){super(...arguments),this.ControllerState=Su,this.transition={transitionDuration:300,transitionInterpolator:new mt(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(t){super.setProps(t),this.dragRotate=!1,this.touchRotate=!1}};var Oc=class extends Rt{constructor(t={}){super(t)}get ViewportType(){return hs}get ControllerType(){return Ts}};Oc.displayName="GlobeView";var t0=Oc;var co=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&&at(this.opts,t.opts,1)}getShaders(t){return null}getSubLayerProps(t){let{defaultProps:r}=t.constructor,s={updateTriggers:{}};for(let i in r)if(i in this.props){let n=r[i],o=this.props[i];s[i]=o,n&&n.type==="accessor"&&(s.updateTriggers[i]=this.props.updateTriggers[i],typeof o=="function"&&(s[i]=this.getSubLayerAccessor(o)))}return s}initializeState(t,r){}updateState(t,r){}onNeedsRedraw(t){}getNeedsPickingBuffer(t){return!1}draw(t,r){}finalizeState(t,r){}};co.defaultProps={};co.extensionName="LayerExtension";var e0=co;var wu={bearing:0,pitch:0,position:[0,0,0]},qR={speed:1.2,curve:1.414},lo=class extends Qe{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={...qR,...t}}interpolateProps(t,r,s){let i=Lf(t,r,s,this.opts);for(let n in wu)i[n]=Xe(t[n]||wu[n],r[n]||wu[n],s);return i}getDuration(t,r){let{transitionDuration:s}=r;return s==="auto"&&(s=Vf(t,r,this.opts)),s}};var ho=class{constructor(t){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=t;this.typedArrayManager=_e,this.attributes={},this._attributeDefs=r,this.opts=t,this.updateGeometry(t)}updateGeometry(t){Object.assign(this.opts,t);let{data:r,buffers:s={},getGeometry:i,geometryBuffer:n,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=i,this.positionSize=n&&n.size||(o==="XY"?2:3),this.buffers=s,this.normalize=c,n&&(rt(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(s.vertexPositions=n)),this.geometryBuffer=s.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:t,endRow:r}){this._rebuildGeometry({startRow:t,endRow:r})}getGeometryFromBuffer(t){let r=t.value||t;return ArrayBuffer.isView(r)?gc(r,{size:this.positionSize,offset:t.offset,stride:t.stride,startIndices:this.data.startIndices}):null}_allocate(t,r){let{attributes:s,buffers:i,_attributeDefs:n,typedArrayManager:o}=this;for(let a in n)if(a in i)o.release(s[a]),s[a]=null;else{let c=n[a];c.copy=r,s[a]=o.allocate(s[a],t,c)}}_forEachGeometry(t,r,s){let{data:i,getGeometry:n}=this,{iterable:o,objectInfo:a}=li(i,r,s);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:s,instanceCount:i}=this,{data:n,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=t||{},l={};if(t||(r=[0],s=[0]),this.normalize||!o)this._forEachGeometry((f,u)=>{let _=f&&this.normalizeGeometry(f);l[u]=_,s[u+1]=s[u]+(_?this.getGeometrySize(_):0)},a,c),i=s[s.length-1];else if(s=n.startIndices,i=s[n.length]||0,ArrayBuffer.isView(o))i=i||o.length/this.positionSize;else if(o instanceof V){let f=this.positionSize*4;i=i||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;i=i||o.buffer.byteLength/f}else if(o.value){let f=o.value,u=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;i=i||f.length/u}this._allocate(i,Boolean(t)),this.indexStarts=r,this.vertexStarts=s,this.instanceCount=i;let h={};this._forEachGeometry((f,u)=>{let _=l[u]||f;h.vertexStart=s[u],h.indexStart=r[u];let m=uthis.width}),Object.defineProperty(s,"clientWidth",{get:()=>this.width}),Object.defineProperty(s,"offsetHeight",{get:()=>this.height}),Object.defineProperty(s,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(t,r){t.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let i=t.width!==r.width||t.height!==r.height;i&&(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(r0(o)),i||a}};function r0(e){return{center:[e.longitude,e.latitude],zoom:e.zoom,bearing:e.bearing??0,pitch:e.pitch??0}}var s0={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function KR(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 s=document.createElement("div");t.appendChild(s),Object.assign(s.style,s0);let i=document.createElement("canvas");return t.appendChild(i),Object.assign(i.style,s0),{container:t,mapCanvas:s,deckCanvas:i}}var fo=class extends dc{constructor(t){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:s}=KR(t),i=t.viewState||t.initialViewState,n=Number.isFinite(i&&i.latitude),{map:o=globalThis.mapboxgl||globalThis.maplibregl}=t;super({canvas:s,...t}),o&&o.Map?this._map=n&&new Nc({...t,width:0,height:0,viewState:i,container:r,mapLib:o}):this._map=o}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(t){"mapStyle"in t&&this._map&&this._map.setProps({mapStyle:t.mapStyle}),super.setProps(t)}_drawLayers(t,r){if(this._map){let s=this.getViewports()[0];s&&this._map.setProps({width:s.width,height:s.height,viewState:s})}super._drawLayers(t,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,Gh);Object.assign(globalThis.loaders,wf);return j0(ZR);})(); return __exports__; });