@deck.gl/core 9.3.0-alpha.2 → 9.3.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/terrain-controller.d.ts +30 -0
- package/dist/controllers/terrain-controller.d.ts.map +1 -0
- package/dist/controllers/terrain-controller.js +127 -0
- package/dist/controllers/terrain-controller.js.map +1 -0
- package/dist/dist.dev.js +3137 -1160
- package/dist/index.cjs +584 -181
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/attribute/gl-utils.d.ts +1 -2
- package/dist/lib/attribute/gl-utils.d.ts.map +1 -1
- package/dist/lib/attribute/gl-utils.js +2 -2
- package/dist/lib/attribute/gl-utils.js.map +1 -1
- package/dist/lib/deck-picker.d.ts +3 -2
- package/dist/lib/deck-picker.d.ts.map +1 -1
- package/dist/lib/deck-picker.js +74 -17
- package/dist/lib/deck-picker.js.map +1 -1
- package/dist/lib/deck.d.ts +62 -0
- package/dist/lib/deck.d.ts.map +1 -1
- package/dist/lib/deck.js +219 -77
- package/dist/lib/deck.js.map +1 -1
- package/dist/lib/init.js +2 -2
- package/dist/lib/layer.d.ts.map +1 -1
- package/dist/lib/layer.js +60 -9
- package/dist/lib/layer.js.map +1 -1
- package/dist/lib/view-manager.js +1 -1
- package/dist/lib/view-manager.js.map +1 -1
- package/dist/passes/pick-layers-pass.d.ts.map +1 -1
- package/dist/passes/pick-layers-pass.js +7 -2
- package/dist/passes/pick-layers-pass.js.map +1 -1
- package/dist/passes/screen-pass-uniforms.d.ts +1 -1
- package/dist/passes/screen-pass-uniforms.js +1 -1
- package/dist/shaderlib/color/color.d.ts +1 -4
- package/dist/shaderlib/color/color.d.ts.map +1 -1
- package/dist/shaderlib/color/color.js +0 -12
- package/dist/shaderlib/color/color.js.map +1 -1
- package/dist/shaderlib/misc/layer-uniforms.d.ts +3 -2
- package/dist/shaderlib/misc/layer-uniforms.d.ts.map +1 -1
- package/dist/shaderlib/misc/layer-uniforms.js +10 -1
- package/dist/shaderlib/misc/layer-uniforms.js.map +1 -1
- package/dist/shaderlib/picking/picking.d.ts +3 -2
- package/dist/shaderlib/picking/picking.d.ts.map +1 -1
- package/dist/shaderlib/picking/picking.js +29 -0
- package/dist/shaderlib/picking/picking.js.map +1 -1
- package/dist/shaderlib/project/project.glsl.js +1 -1
- package/dist/shaderlib/project/project.wgsl.d.ts.map +1 -1
- package/dist/shaderlib/project/project.wgsl.js +4 -6
- package/dist/shaderlib/project/project.wgsl.js.map +1 -1
- package/dist/shaderlib/shadow/shadow.d.ts +2 -2
- package/dist/shaderlib/shadow/shadow.js +1 -1
- package/dist/transitions/gpu-interpolation-transition.js +2 -2
- package/dist/transitions/gpu-interpolation-transition.js.map +1 -1
- package/dist/transitions/gpu-spring-transition.js +1 -1
- package/dist/transitions/gpu-transition-utils.d.ts.map +1 -1
- package/dist/transitions/gpu-transition-utils.js +3 -4
- package/dist/transitions/gpu-transition-utils.js.map +1 -1
- package/dist/utils/typed-array-manager.js.map +1 -1
- package/dist.min.js +506 -234
- package/package.json +6 -7
- package/src/controllers/terrain-controller.ts +155 -0
- package/src/index.ts +1 -0
- package/src/lib/attribute/gl-utils.ts +2 -2
- package/src/lib/deck-picker.ts +98 -17
- package/src/lib/deck.ts +334 -86
- package/src/lib/layer.ts +98 -8
- package/src/lib/view-manager.ts +1 -1
- package/src/passes/pick-layers-pass.ts +6 -2
- package/src/passes/screen-pass-uniforms.ts +1 -1
- package/src/shaderlib/color/color.ts +0 -12
- package/src/shaderlib/misc/layer-uniforms.ts +11 -1
- package/src/shaderlib/picking/picking.ts +30 -0
- package/src/shaderlib/project/project.glsl.ts +1 -1
- package/src/shaderlib/project/project.wgsl.ts +4 -6
- package/src/shaderlib/shadow/shadow.ts +1 -1
- package/src/transitions/gpu-interpolation-transition.ts +2 -2
- package/src/transitions/gpu-spring-transition.ts +1 -1
- package/src/transitions/gpu-transition-utils.ts +4 -5
- package/src/utils/typed-array-manager.ts +3 -3
package/dist.min.js
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['deck'] = factory();
|
|
6
6
|
else root['deck'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Wo=Object.defineProperty;var Ay=Object.getOwnPropertyDescriptor;var Sy=Object.getOwnPropertyNames;var Ey=Object.prototype.hasOwnProperty;var wy=(t,e,r)=>e in t?Wo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var At=(t,e)=>{for(var r in e)Wo(t,r,{get:e[r],enumerable:!0})},Ry=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Sy(e))!Ey.call(t,s)&&s!==r&&Wo(t,s,{get:()=>e[s],enumerable:!(i=Ay(e,s))||i.enumerable});return t};var Py=t=>Ry(Wo({},"__esModule",{value:!0}),t);var P=(t,e,r)=>(wy(t,typeof e!="symbol"?e+"":e,r),r);function zi(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var kc=E(()=>{});var gr,Vc=E(()=>{kc();gr=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=zi(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(zi()-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 Oe,Fu=E(()=>{Vc();Oe=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,s=this.stats[r];return s||(e instanceof gr?s=e:s=new gr(r,i),this.stats[r]=s),s}}});var Wi=E(()=>{Fu();Vc();kc()});function Cy(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let s=Object.keys(r).length,o=Bu.get(t);if(!i&&o?.orderedStatNames===e&&o.statCount===s)return;let n={},a=Lu.get(e);a||(a=new Set(e),Lu.set(e,a));for(let c of e)r[c]&&(n[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(n[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,n),Bu.set(t,{orderedStatNames:e,statCount:s})}var vy,My,Bu,Lu,zc,jo,Wc=E(()=>{Wi();vy="GPU Time and Memory",My=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],Bu=new WeakMap,Lu=new WeakMap,zc=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Oe({id:e}));let r=this.stats.get(e);return e===vy&&Cy(r,My),r}},jo=new zc});var Ho,Iy,$o,Oy,Uu,jc=E(()=>{Ho=globalThis,Iy=globalThis.document||{},$o=globalThis.process||{},Oy=globalThis.console,Uu=globalThis.navigator||{}});function Xo(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}var Hc=E(()=>{});function he(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Xo()}var $c=E(()=>{Hc()});function Xc(t){return!t&&!he()?"Node":Xo(t)?"Electron":(t||Uu.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var ku=E(()=>{$c();Hc();jc()});var Yc,Wt=E(()=>{jc();$c();ku();Yc="4.1.1"});function qr(t,e){if(!t)throw new Error(e||"Assertion failed")}var Zc=E(()=>{});function Kc(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return qr(Number.isFinite(e)&&e>=0),e}function Vu(t){let{logLevel:e,message:r}=t;t.logLevel=Kc(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return qr(s==="string"||s==="object"),Object.assign(t,{args:i},t.opts)}var zu=E(()=>{Zc()});var mr,Yo,Wu=E(()=>{zu();mr=()=>{},Yo=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...i){return this._log("log",e,r,i)}info(e,r,...i){return this._log("info",e,r,i)}once(e,r,...i){return this._log("once",e,r,i,{once:!0})}_log(e,r,i,s,o={}){let n=Vu({logLevel:r,message:i,args:this._buildArgs(r,i,s),opts:o});return this._createLogFunction(e,n,o)}_buildArgs(e,r,i){return[e,r,...i]}_createLogFunction(e,r,i){if(!this._shouldLog(r.logLevel))return mr;let s=this._getOnceTag(i.tag??r.tag??r.message);if((i.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return mr;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=Kc(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function Dy(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Zo,ju=E(()=>{Zo=class{constructor(e,r,i="sessionStorage"){this.storage=Dy(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}});function Hu(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function $u(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Xu=E(()=>{});function Yu(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ko[t]||Ko.WHITE)}function Zu(t,e,r){return!he&&typeof t=="string"&&(e&&(t=`\x1B[${Yu(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Yu(r)+Fy}m${t}\x1B[49m`)),t}var Ko,Fy,Ku=E(()=>{Wt();(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ko||(Ko={}));Fy=10});function qu(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),s=t;for(let o of i){let n=s[o];typeof n=="function"&&(e.find(a=>o===a)||(s[o]=n.bind(t)))}}var Qu=E(()=>{});function Qr(){let t;if(he()&&Ho.performance)t=Ho?.performance?.now?.();else if("hrtime"in $o){let e=$o?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Gu=E(()=>{Wt()});function By(t,e,r){if(typeof e=="string"){let i=r.time?$u(Hu(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=Zu(e,r.color,r.background)}return e}function Ly(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var Gr,qc,ue,Qc=E(()=>{Wt();Wu();ju();Xu();Ku();Qu();Zc();Gu();Gr={debug:he()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},qc={enabled:!0,level:0},ue=class extends Yo{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Yc,this._startTs=Qr(),this._deltaTs=Qr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Zo(`__probe-${this.id}__`,{[this.id]:qc}),this.timeStamp(`${this.id} started`),qu(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Qr()-this._startTs).toPrecision(10))}getDelta(){return Number((Qr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:Gr.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:Gr.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...i){return this._log("log",e,r,i,{method:Gr.log,time:!0,once:!0})}log(e,r,...i){return this._log("log",e,r,i,{method:Gr.debug})}info(e,r,...i){return this._log("info",e,r,i,{method:console.info})}once(e,r,...i){return this._log("once",e,r,i,{method:Gr.debug||Gr.info,once:!0})}table(e,r,i){return r?this._log("table",e,r,i&&[i]||[],{method:console.table||mr,tag:Ly(r)}):mr}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||mr})}group(e,r,i={collapsed:!1}){let s=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||mr})}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let i=r.method;qr(i),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Qr();let s=By(this.id,r.message,r);return i.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(qc),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...qc};this._storage.setConfiguration({[this.id]:{...r,...e}})}};ue.VERSION=Yc});var Ju=E(()=>{globalThis.probe={}});var Cv,ji=E(()=>{Qc();Qc();Ju();Cv=new ue({id:"@probe.gl/log"})});var b,St=E(()=>{ji();b=new ue({id:"luma.gl"})});function jt(t="id"){Gc[t]=Gc[t]||1;let e=Gc[t]++;return`${t}-${e}`}var Gc,Hi=E(()=>{Gc={}});function jy(t,e){let r={...e};for(let i in t)t[i]!==void 0&&(r[i]=t[i]);return r}function od(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let s=Object.keys(r).length,o=id.get(t);if(!i&&o?.orderedStatNames===e&&o.statCount===s)return;let n={},a=sd.get(e);a||(a=new Set(e),sd.set(e,a));for(let c of e)r[c]&&(n[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(n[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,n),id.set(t,{orderedStatNames:e,statCount:s})}function nd(t){return t.type==="webgl"?Wy:zy}function $i(t){let e=t.userData[Uy];return e?.enabled?e:null}function Ht(){return globalThis.performance?.now?.()??Date.now()}function Hy(t,e){let r=$i(t);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,e){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function $y(t){let e=Object.getPrototypeOf(t);for(;e;){let r=Object.getPrototypeOf(e);if(!r||r===N.prototype)return Xy(e)||t[Symbol.toStringTag]||t.constructor.name;e=r}return t[Symbol.toStringTag]||t.constructor.name}function Xy(t){let e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(t):typeof e?.value=="string"?e.value:null}var Uy,ed,td,rd,ky,Vy,zy,Wy,id,sd,N,ae=E(()=>{Hi();Uy="cpu-hotspot-profiler",ed="GPU Resource Counts",td="Resource Counts",rd="GPU Time and Memory",ky=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],Vy=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],zy=ky.flatMap(t=>[`${t} Created`,`${t} Active`]),Wy=Vy.flatMap(t=>[`${t} Created`,`${t} Active`]),id=new WeakMap,sd=new WeakMap,N=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,r,i){if(!e)throw new Error("no device");this._device=e,this.props=jy(r,i);let s=this.props.id!=="undefined"?this.props.id:jt(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=$i(this._device),r=e?Ht():0,i=[this._device.statsManager.getStats(ed),this._device.statsManager.getStats(td)],s=nd(this._device);for(let n of i)od(n,s);let o=this.getStatsName();for(let n of i)n.get("Resources Active").decrementCount(),n.get(`${o}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(Ht()-r))}trackAllocatedMemory(e,r=this.getStatsName()){let i=$i(this._device),s=i?Ht():0,o=this._device.statsManager.getStats(rd);this.allocatedBytes>0&&this.allocatedBytesName&&(o.get("GPU Memory").subtractCount(this.allocatedBytes),o.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),o.get("GPU Memory").addCount(e),o.get(`${r} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(Ht()-s)),this.allocatedBytes=e,this.allocatedBytesName=r}trackReferencedMemory(e,r=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${r}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=$i(this._device),i=r?Ht():0,s=this._device.statsManager.getStats(rd);s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(Ht()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),r=$i(this._device),i=r?Ht():0,s=[this._device.statsManager.getStats(ed),this._device.statsManager.getStats(td)],o=nd(this._device);for(let n of s)od(n,o);for(let n of s)n.get("Resources Created").incrementCount(),n.get("Resources Active").incrementCount(),n.get(`${e}s Created`).incrementCount(),n.get(`${e}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(Ht()-i)),Hy(this._device,e)}getStatsName(){return $y(this)}};P(N,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var Xi,D,qo=E(()=>{ae();Xi=class extends N{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let i={...r};(r.usage||0)&Xi.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array?i.indexType="uint16":r.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,Xi.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,r,i){let s=null,o;ArrayBuffer.isView(e)?(s=e,o=e.buffer):o=e;let n=Math.min(e?e.byteLength:i,Xi.DEBUG_DATA_MAX_LENGTH);if(o===null)this.debugData=new ArrayBuffer(n);else{let a=Math.min(s?.byteOffset||0,o.byteLength),c=Math.max(0,o.byteLength-a),l=Math.min(n,c);this.debugData=new Uint8Array(o,a,l).slice().buffer}}},D=Xi;P(D,"INDEX",16),P(D,"VERTEX",32),P(D,"UNIFORM",64),P(D,"STORAGE",128),P(D,"INDIRECT",256),P(D,"QUERY_RESOLVE",512),P(D,"MAP_READ",1),P(D,"MAP_WRITE",2),P(D,"COPY_SRC",4),P(D,"COPY_DST",8),P(D,"DEBUG_DATA_MAX_LENGTH",32),P(D,"defaultProps",{...N.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});function Yi(t){let e=t.includes("norm"),r=!e&&!t.startsWith("float"),i=t.startsWith("s"),s=el[t],[o,n,a]=s||["uint8 ","i32",1];return{signedType:o,primitiveType:n,byteLength:a,normalized:e,integer:r,signed:i}}function Jc(t){let e=t;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Qo(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function _r(t){let e=ArrayBuffer.isView(t)?t.constructor:t;if(e===Uint8ClampedArray)return"uint8";let r=Object.values(el).find(i=>e===i[4]);if(!r)throw new Error(e.name);return r[0]}function Et(t){let[,,,,e]=el[t];return e}var el,Zi=E(()=>{el={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});function Jr(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,i]=t.split("x"),s=r,o=i?parseInt(i):1,n=Yi(s),a={type:s,components:o,byteLength:n.byteLength*o,integer:n.integer,signed:n.signed,normalized:n.normalized};return e&&(a.webglOnly=!0),a}function ad(t,e,r){let i=r?Jc(t):t;switch(i){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${i}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${i}x${e}`;default:return e===1?i:`${i}x${e}`}}function tl(t,e,r){if(!e||e>4)throw new Error(`size ${e}`);let i=e,s=_r(t);return ad(s,i,r)}function cd(t){let e;switch(t.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return t.components<=2?"float16x2":"float16x4"}return t.components===1?e:`${e}x${t.components}`}var Go=E(()=>{Zi()});function al(t){let e=hd[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function fd(){return hd}var le,X,tt,Yy,Jo,rl,en,il,Zy,sl,$t,ol,nl,tn,ld,Ky,qy,hd,cl=E(()=>{le="texture-compression-bc",X="texture-compression-astc",tt="texture-compression-etc2",Yy="texture-compression-etc1-webgl",Jo="texture-compression-pvrtc-webgl",rl="texture-compression-atc-webgl",en="float32-renderable-webgl",il="float16-renderable-webgl",Zy="rgb9e5ufloat-renderable-webgl",sl="snorm8-renderable-webgl",$t="norm16-webgl",ol="norm16-renderable-webgl",nl="snorm16-renderable-webgl",tn="float32-filterable",ld="float16-filterable-webgl";Ky={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:sl},rg8snorm:{render:sl},"rgb8snorm-webgl":{},rgba8snorm:{render:sl},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:$t,render:ol},rg16unorm:{f:$t,render:ol},"rgb16unorm-webgl":{f:$t,render:!1},rgba16unorm:{f:$t,render:ol},r16snorm:{f:$t,render:nl},rg16snorm:{f:$t,render:nl},"rgb16snorm-webgl":{f:$t,render:!1},rgba16snorm:{f:$t,render:nl},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:il,filter:"float16-filterable-webgl"},rg16float:{render:il,filter:ld},rgba16float:{render:il,filter:ld},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:en,filter:tn},rg32float:{render:!1,filter:tn},"rgb32float-webgl":{render:en,filter:tn},rgba32float:{render:en,filter:tn},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Zy},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:en},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},qy={"bc1-rgb-unorm-webgl":{f:le},"bc1-rgb-unorm-srgb-webgl":{f:le},"bc1-rgba-unorm":{f:le},"bc1-rgba-unorm-srgb":{f:le},"bc2-rgba-unorm":{f:le},"bc2-rgba-unorm-srgb":{f:le},"bc3-rgba-unorm":{f:le},"bc3-rgba-unorm-srgb":{f:le},"bc4-r-unorm":{f:le},"bc4-r-snorm":{f:le},"bc5-rg-unorm":{f:le},"bc5-rg-snorm":{f:le},"bc6h-rgb-ufloat":{f:le},"bc6h-rgb-float":{f:le},"bc7-rgba-unorm":{f:le},"bc7-rgba-unorm-srgb":{f:le},"etc2-rgb8unorm":{f:tt},"etc2-rgb8unorm-srgb":{f:tt},"etc2-rgb8a1unorm":{f:tt},"etc2-rgb8a1unorm-srgb":{f:tt},"etc2-rgba8unorm":{f:tt},"etc2-rgba8unorm-srgb":{f:tt},"eac-r11unorm":{f:tt},"eac-r11snorm":{f:tt},"eac-rg11unorm":{f:tt},"eac-rg11snorm":{f:tt},"astc-4x4-unorm":{f:X},"astc-4x4-unorm-srgb":{f:X},"astc-5x4-unorm":{f:X},"astc-5x4-unorm-srgb":{f:X},"astc-5x5-unorm":{f:X},"astc-5x5-unorm-srgb":{f:X},"astc-6x5-unorm":{f:X},"astc-6x5-unorm-srgb":{f:X},"astc-6x6-unorm":{f:X},"astc-6x6-unorm-srgb":{f:X},"astc-8x5-unorm":{f:X},"astc-8x5-unorm-srgb":{f:X},"astc-8x6-unorm":{f:X},"astc-8x6-unorm-srgb":{f:X},"astc-8x8-unorm":{f:X},"astc-8x8-unorm-srgb":{f:X},"astc-10x5-unorm":{f:X},"astc-10x5-unorm-srgb":{f:X},"astc-10x6-unorm":{f:X},"astc-10x6-unorm-srgb":{f:X},"astc-10x8-unorm":{f:X},"astc-10x8-unorm-srgb":{f:X},"astc-10x10-unorm":{f:X},"astc-10x10-unorm-srgb":{f:X},"astc-12x10-unorm":{f:X},"astc-12x10-unorm-srgb":{f:X},"astc-12x12-unorm":{f:X},"astc-12x12-unorm-srgb":{f:X},"pvrtc-rgb4unorm-webgl":{f:Jo},"pvrtc-rgba4unorm-webgl":{f:Jo},"pvrtc-rgb2unorm-webgl":{f:Jo},"pvrtc-rgba2unorm-webgl":{f:Jo},"etc1-rbg-unorm-webgl":{f:Yy},"atc-rgb-unorm-webgl":{f:rl},"atc-rgba-unorm-webgl":{f:rl},"atc-rgbai-unorm-webgl":{f:rl}},hd={...Ky,...qy}});function tT({format:t,width:e,height:r,depth:i,byteAlignment:s}){let o=de.getInfo(t),{bytesPerPixel:n,bytesPerBlock:a=n,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=o,h=f?Math.ceil(e/c):e,u=f?Math.ceil(r/l):r,d=h*a,p=Math.ceil(d/s)*s,g=u,m=p*g*i;return{bytesPerPixel:n,bytesPerRow:p,rowsPerImage:g,depthOrArrayLayers:i,bytesPerImage:p*g,byteLength:m}}function rT(t){let e=al(t),r={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=ud(t),s=t.startsWith("depth")||t.startsWith("stencil"),o=i?.signed,n=i?.integer,a=i?.webgl,c=Boolean(i?.compressed);return r.render&&=!s&&!c,r.filter&&=!s&&!o&&!n&&!a,r}function ud(t){let e=iT(t);if(de.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=oT(t);let i=sT(t);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let r=Qy.exec(t);if(r){let[,i,s,o,n,a]=r,c=`${o}${s}`,l=Yi(c),f=l.byteLength*8,h=i?.length??1,u=[f,h>=2?f:0,h>=3?f:0,h>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:h,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:u,bytesPerPixel:l.byteLength*h,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),n==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function iT(t){let e=al(t),r=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:r,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function sT(t){let r=/.*-(\d+)x(\d+)-.*/.exec(t);if(r){let[,i,s]=r;return{blockWidth:Number(i),blockHeight:Number(s)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function oT(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}var Qy,Gy,Jy,eT,rn,de,sn=E(()=>{Zi();cl();Qy=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,Gy=["rgb","rgba","bgra"],Jy=["depth","stencil"],eT=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],rn=class{isColor(e){return Gy.some(r=>e.startsWith(r))}isDepthStencil(e){return Jy.some(r=>e.startsWith(r))}isCompressed(e){return eT.some(r=>e.startsWith(r))}getInfo(e){return ud(e)}getCapabilities(e){return rT(e)}computeMemoryLayout(e){return tT(e)}},de=new rn});function ei(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function Ki(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWidth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}var ll=E(()=>{});function nT(t,e){return t!=null?Boolean(t):e!==void 0?e!=="production":!1}function aT(){return nT(b.get("debug"),cT())}function cT(){let t=globalThis.process;if(t?.env)return t.env.NODE_ENV}var qi,Qi,fl,be,hl=E(()=>{Wc();St();Hi();qo();Go();sn();cl();ll();qi=class{},Qi=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},fl=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=jo;timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...fl.defaultProps,...e},this.id=this.props.id||jt(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Jr(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return de.getInfo(e)}getTextureFormatCapabilities(e){let r=this._textureCaps[e];if(!r){let i=this._getDeviceTextureFormatCapabilities(e);r=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=r}return r}getMipLevelCount(e,r,i=1){let s=Math.max(e,r,i);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return ei(e)}getExternalImageSize(e){return Ki(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return de.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let r of Object.keys(fd()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&e.push(r);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,r,...i){return this.props.onError(e,r)?()=>{}:b.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,r,...i)}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
8
|
-
or create a device with the 'debug: true' prop.`;b.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let r=de.getCapabilities(e),i=o=>(typeof o=="string"?this.features.has(o):o)??!0,s=i(r.create);return{format:e,create:s,render:s&&i(r.render),filter:s&&i(r.filter),blend:s&&i(r.blend),store:s&&i(r.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};if((e.usage||0)&D.INDEX&&(e.indexType||(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":e.data instanceof Uint8Array&&(r.data=new Uint16Array(e.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}},be=fl;P(be,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,r)=>{},onResize:(e,r)=>{let[i,s]=e.getDevicePixelSize();b.log(1,`${e} resized => ${i}x${s}px`)()},onPositionChange:(e,r)=>{let[i,s]=e.getPosition();b.log(1,`${e} repositioned => ${i},${s}`)()},onVisibilityChange:e=>b.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,r)=>b.log(1,`${e} DPR changed ${r.oldRatio} => ${e.devicePixelRatio}`)(),debug:aT(),debugGPUTime:!1,debugShaders:b.get("debug-shaders")||void 0,debugFramebuffers:Boolean(b.get("debug-framebuffers")),debugFactories:Boolean(b.get("debug-factories")),debugWebGL:Boolean(b.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var lT,dd,nn,on,Xt,pd=E(()=>{hl();Wc();St();lT="set luma.log.level=1 (or higher) to trace rendering",dd="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",nn=class{stats=jo;log=b;VERSION="9.3.0-alpha.6";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw b.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),b.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");b.error("This version of luma.gl has already been initialized")()}b.log(1,`${this.VERSION} - ${lT}`)(),globalThis.luma=this}async createDevice(e={}){let r={...nn.defaultProps,...e},i=this.selectAdapter(r.type,r.adapters);if(!i)throw new Error(dd);return r.waitForPageLoad&&await i.pageLoaded,await i.create(r)}async attachDevice(e,r){let i=this._getTypeFromHandle(e,r.adapters),s=i&&this.selectAdapter(i,r.adapters);if(!s)throw new Error(dd);return await s?.attach?.(e,r)}registerAdapters(e){for(let r of e)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(e=[]){let r=this._getAdapterMap(e);return Array.from(r).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let r=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let s of r)if(i.get(s)?.isSupported?.())return s;return null}selectAdapter(e,r=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(r));let s=this._getAdapterMap(r);return i&&s.get(i)||null}enforceWebGL2(e=!0,r=[]){let s=this._getAdapterMap(r).get("webgl");s||b.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(nn.defaultProps,e)}_getAdapterMap(e=[]){let r=new Map(this.preregisteredAdapters);for(let i of e)r.set(i.type,i);return r}_getTypeFromHandle(e,r=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?b.warn("WebGL1 is not supported",e)():b.warn("Unknown handle type",e)(),null)}},on=nn;P(on,"defaultProps",{...be.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});Xt=new on});function uT(){return an||(hT()||typeof window>"u"?an=Promise.resolve():an=new Promise(t=>window.addEventListener("load",()=>t()))),an}var Gi,fT,hT,an,gd=E(()=>{Wt();Gi=class{get pageLoaded(){return uT()}},fT=he()&&typeof document<"u",hT=()=>fT&&document.readyState==="complete",an=null});var cn,md=E(()=>{cn=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function _d(){let t,e;return{promise:new Promise((i,s)=>{t=i,e=s}),resolve:t,reject:e}}var yd=E(()=>{});function ul(t,e){if(!t){let r=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,ul),r}}function yr(t,e){return ul(t,e),t}var dl=E(()=>{});function dT(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function pT(t){let e=document.getElementById(t);if(!wt.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function gT(t){let{width:e,height:r}=t,i=document.createElement("canvas");i.id=jt("lumagl-auto-created-canvas"),i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",t?.visible||(i.style.visibility="hidden");let s=dT(t?.container||null);return s.insertBefore(i,s.firstChild),i}function mT(t,e,r,i,s){let o=t,n=Td(o[0],e,r),a=bd(o[1],e,i,s),c=Td(o[0]+1,e,r),l=c===r-1?c:c-1;c=bd(o[1]+1,e,i,s);let f;return s?(c=c===0?c:c+1,f=a,a=c):f=c===i-1?c:c-1,{x:n,y:a,width:Math.max(l-n+1,1),height:Math.max(f-a+1,1)}}function Td(t,e,r){return Math.min(Math.round(t*e),r-1)}function bd(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var Ji,wt,pl=E(()=>{Wt();md();Hi();yd();dl();Ji=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=_d();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...Ji.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,he()?e.canvas?typeof e.canvas=="string"?this.canvas=pT(e.canvas):this.canvas=e.canvas:this.canvas=gT(e):this.canvas={width:e.width||1,height:e.height||1},Ji.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Ji.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new cn({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,r){e=Math.floor(e),r=Math.floor(r),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[s,o]=this.getDrawingBufferSize();return mT(e,i,s,o,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,r]=this.getDrawingBufferSize();return e>0&&r>0?e/r:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?e/r:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let r=e.find(s=>s.target===this.canvas);if(!r)return;let i=r.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let r=e.find(l=>l.target===this.canvas);if(!r)return;let i=yr(r.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let s=this.getDevicePixelSize(),o=r.devicePixelContentBoxSize?.[0]?.inlineSize||i.inlineSize*devicePixelRatio,n=r.devicePixelContentBoxSize?.[0]?.blockSize||i.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(o,a)),this.devicePixelHeight=Math.max(1,Math.min(n,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:s})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let r=[e.left,e.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let s=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:s})}}}},wt=Ji;P(wt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1})});var ti,xd=E(()=>{pl();ti=class extends wt{};P(ti,"defaultProps",wt.defaultProps)});var es,Ad=E(()=>{pl();es=class extends wt{}});var ln,Ne,gl=E(()=>{ae();ln=class extends N{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=ln.normalizeProps(e,r),super(e,r,ln.defaultProps)}static normalizeProps(e,r){return r}},Ne=ln;P(Ne,"defaultProps",{...N.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1})});var _T,Ee,U,ml=E(()=>{ae();gl();St();sn();_T={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ee=class extends N{dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,r,i){if(r=Ee.normalizeProps(e,r),super(e,r,Ee.defaultProps),this.dimension=this.props.dimension,this.baseDimension=_T[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(r.data)){let s=e.getExternalImageSize(r.data);this.width=s?.width||1,this.height=s?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&b.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Ne?e:this.device.createSampler(e)}copyImageData(e){let{data:r,depth:i,...s}=e;this.writeData(r,{...s,depthOrArrayLayers:s.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let r=this._normalizeTextureReadOptions(e),{width:i=this.width,height:s=this.height,depthOrArrayLayers:o=this.depth}=r,{format:n,byteAlignment:a}=this;return de.computeMemoryLayout({format:n,width:i,height:s,depth:o,byteAlignment:a})}readBuffer(e,r){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,r){throw new Error("readBuffer not implemented")}writeData(e,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,r){let i={...r},{width:s,height:o}=i;return typeof s=="number"&&(i.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(i.height=Math.max(1,Math.ceil(o))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:r,depth:i,...s}=e,o=this._normalizeTextureWriteOptions({...s,depthOrArrayLayers:s.depthOrArrayLayers??i});return{data:r,depth:o.depthOrArrayLayers,...o}}_normalizeCopyExternalImageOptions(e){let r=Ee._omitUndefined(e),i=r.mipLevel??0,s=this._getMipLevelSize(i),o=this.device.getExternalImageSize(e.image),n={...Ee.defaultCopyExternalImageOptions,...s,...o,...r};return n.width=Math.min(n.width,s.width-n.x),n.height=Math.min(n.height,s.height-n.y),n.depth=Math.min(n.depth,s.depthOrArrayLayers-n.z),n}_normalizeTextureReadOptions(e){let r=Ee._omitUndefined(e),i=r.mipLevel??0,s=this._getMipLevelSize(i),o={...Ee.defaultTextureReadOptions,...s,...r};return o.width=Math.min(o.width,s.width-o.x),o.height=Math.min(o.height,s.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,s.depthOrArrayLayers-o.z),o}_getSupportedColorReadOptions(e){let r=this._normalizeTextureReadOptions(e),i=de.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let r=Ee._omitUndefined(e),i=r.mipLevel??0,s=this._getMipLevelSize(i),o={...Ee.defaultTextureWriteOptions,...s,...r};o.width=Math.min(o.width,s.width-o.x),o.height=Math.min(o.height,s.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,s.depthOrArrayLayers-o.z);let n=de.computeMemoryLayout({format:this.format,width:o.width,height:o.height,depth:o.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=n.bytesPerPixel*o.width;if(o.bytesPerRow=r.bytesPerRow??n.bytesPerRow,o.rowsPerImage=r.rowsPerImage??o.height,o.bytesPerRow<a)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be at least ${a} for ${this.format}`);if(o.rowsPerImage<o.height)throw new Error(`rowsPerImage (${o.rowsPerImage}) must be at least ${o.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&o.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return o}_getMipLevelSize(e){let r=Math.max(1,this.width>>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),s=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:r,height:i,depthOrArrayLayers:s}}getAllocatedByteLength(){let e=0;for(let r=0;r<this.mipLevels;r++){let{width:i,height:s,depthOrArrayLayers:o}=this._getMipLevelSize(r);e+=de.computeMemoryLayout({format:this.format,width:i,height:s,depth:o,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}},U=Ee;P(U,"SAMPLE",4),P(U,"STORAGE",8),P(U,"RENDER",16),P(U,"COPY_SRC",1),P(U,"COPY_DST",2),P(U,"TEXTURE",4),P(U,"RENDER_ATTACHMENT",16),P(U,"defaultProps",{...N.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Ee.SAMPLE|Ee.RENDER|Ee.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),P(U,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),P(U,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}),P(U,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),P(U,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"})});var _l,Yt,Sd=E(()=>{ae();_l=class extends N{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,_l.defaultProps)}},Yt=_l;P(Yt,"defaultProps",{...N.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function Ed(t,e,r){let i="",s=e.split(/\r?\n/),o=t.slice().sort((n,a)=>n.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let n=0;for(let a=1;a<=s.length;a++){let c=s[a-1],l=o[n];for(c&&l&&(i+=wd(c,a,r));o.length>n&&l.lineNum===a;){let f=o[n++];f&&(i+=yl(f,s,f.lineNum,{...r,inlineSource:!1}))}}for(;o.length>n;){let a=o[n++];a&&(i+=yl(a,[],0,{...r,inlineSource:!1}))}return i;case"issues":case"no":for(let a of t)i+=yl(a,s,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function yl(t,e,r,i){if(i?.inlineSource){let o=yT(e,r),n=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
|
|
7
|
+
"use strict";var __exports__=(()=>{var Yo=Object.defineProperty;var m0=Object.getOwnPropertyDescriptor;var _0=Object.getOwnPropertyNames;var y0=Object.prototype.hasOwnProperty;var b0=(t,e,r)=>e in t?Yo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var Rt=(t,e)=>{for(var r in e)Yo(t,r,{get:e[r],enumerable:!0})},T0=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of _0(e))!y0.call(t,s)&&s!==r&&Yo(t,s,{get:()=>e[s],enumerable:!(i=m0(e,s))||i.enumerable});return t};var x0=t=>T0(Yo({},"__esModule",{value:!0}),t);var P=(t,e,r)=>(b0(t,typeof e!="symbol"?e+"":e,r),r);function Zi(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Zc=E(()=>{});var Tr,qc=E(()=>{Zc();Tr=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Zi(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Zi()-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 Ne,ad=E(()=>{qc();Ne=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,s=this.stats[r];return s||(e instanceof Tr?s=e:s=new Tr(r,i),this.stats[r]=s),s}}});var qi=E(()=>{ad();qc();Zc()});function E0(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let s=Object.keys(r).length,o=cd.get(t);if(!i&&o?.orderedStatNames===e&&o.statCount===s)return;let n={},a=ld.get(e);a||(a=new Set(e),ld.set(e,a));for(let c of e)r[c]&&(n[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(n[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,n),cd.set(t,{orderedStatNames:e,statCount:s})}var A0,S0,cd,ld,Gc,Ko,Qc=E(()=>{qi();A0="GPU Time and Memory",S0=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],cd=new WeakMap,ld=new WeakMap,Gc=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Ne({id:e}));let r=this.stats.get(e);return e===A0&&E0(r,S0),r}},Ko=new Gc});var Zo,w0,qo,R0,fd,Jc=E(()=>{Zo=globalThis,w0=globalThis.document||{},qo=globalThis.process||{},R0=globalThis.console,fd=globalThis.navigator||{}});function Go(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}var el=E(()=>{});function he(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Go()}var tl=E(()=>{el()});function rl(t){return!t&&!he()?"Node":Go(t)?"Electron":(t||fd.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var hd=E(()=>{tl();el();Jc()});var il,Xt=E(()=>{Jc();tl();hd();il="4.1.1"});function Qr(t,e){if(!t)throw new Error(e||"Assertion failed")}var sl=E(()=>{});function ol(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return Qr(Number.isFinite(e)&&e>=0),e}function ud(t){let{logLevel:e,message:r}=t;t.logLevel=ol(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return Qr(s==="string"||s==="object"),Object.assign(t,{args:i},t.opts)}var dd=E(()=>{sl()});var xr,Qo,pd=E(()=>{dd();xr=()=>{},Qo=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...i){return this._log("log",e,r,i)}info(e,r,...i){return this._log("info",e,r,i)}once(e,r,...i){return this._log("once",e,r,i,{once:!0})}_log(e,r,i,s,o={}){let n=ud({logLevel:r,message:i,args:this._buildArgs(r,i,s),opts:o});return this._createLogFunction(e,n,o)}_buildArgs(e,r,i){return[e,r,...i]}_createLogFunction(e,r,i){if(!this._shouldLog(r.logLevel))return xr;let s=this._getOnceTag(i.tag??r.tag??r.message);if((i.once||r.once)&&s!==void 0){if(this._onceCache.has(s))return xr;this._onceCache.add(s)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=ol(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function v0(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Jo,gd=E(()=>{Jo=class{constructor(e,r,i="sessionStorage"){this.storage=v0(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}});function md(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function _d(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var yd=E(()=>{});function bd(t){return typeof t!="string"?t:(t=t.toUpperCase(),en[t]||en.WHITE)}function Td(t,e,r){return!he&&typeof t=="string"&&(e&&(t=`\x1B[${bd(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${bd(r)+M0}m${t}\x1B[49m`)),t}var en,M0,xd=E(()=>{Xt();(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(en||(en={}));M0=10});function Ad(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),s=t;for(let o of i){let n=s[o];typeof n=="function"&&(e.find(a=>o===a)||(s[o]=n.bind(t)))}}var Sd=E(()=>{});function Jr(){let t;if(he()&&Zo.performance)t=Zo?.performance?.now?.();else if("hrtime"in qo){let e=qo?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Ed=E(()=>{Xt()});function C0(t,e,r){if(typeof e=="string"){let i=r.time?_d(md(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=Td(e,r.color,r.background)}return e}function I0(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var ei,nl,ue,al=E(()=>{Xt();pd();gd();yd();xd();Sd();sl();Ed();ei={debug:he()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},nl={enabled:!0,level:0},ue=class extends Qo{constructor({id:e}={id:""}){super({level:0}),this.VERSION=il,this._startTs=Jr(),this._deltaTs=Jr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Jo(`__probe-${this.id}__`,{[this.id]:nl}),this.timeStamp(`${this.id} started`),Ad(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Jr()-this._startTs).toPrecision(10))}getDelta(){return Number((Jr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:ei.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:ei.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...i){return this._log("log",e,r,i,{method:ei.log,time:!0,once:!0})}log(e,r,...i){return this._log("log",e,r,i,{method:ei.debug})}info(e,r,...i){return this._log("info",e,r,i,{method:console.info})}once(e,r,...i){return this._log("once",e,r,i,{method:ei.debug||ei.info,once:!0})}table(e,r,i){return r?this._log("table",e,r,i&&[i]||[],{method:console.table||xr,tag:I0(r)}):xr}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||xr})}group(e,r,i={collapsed:!1}){let s=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:s})}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||xr})}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let i=r.method;Qr(i),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Jr();let s=C0(this.id,r.message,r);return i.bind(console,s,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(nl),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...nl};this._storage.setConfiguration({[this.id]:{...r,...e}})}};ue.VERSION=il});var wd=E(()=>{globalThis.probe={}});var gM,Gi=E(()=>{al();al();wd();gM=new ue({id:"@probe.gl/log"})});var x,De=E(()=>{Gi();x=new ue({id:"luma.gl"})});function st(t="id"){cl[t]=cl[t]||1;let e=cl[t]++;return`${t}-${e}`}var cl,ti=E(()=>{cl={}});function L0(t,e){let r={...e};for(let i in t)t[i]!==void 0&&(r[i]=t[i]);return r}function Id(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let s=Object.keys(r).length,o=Md.get(t);if(!i&&o?.orderedStatNames===e&&o.statCount===s)return;let n={},a=Cd.get(e);a||(a=new Set(e),Cd.set(e,a));for(let c of e)r[c]&&(n[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(n[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,n),Md.set(t,{orderedStatNames:e,statCount:s})}function Od(t){return t.type==="webgl"?F0:B0}function Qi(t){let e=t.userData[O0];return e?.enabled?e:null}function Yt(){return globalThis.performance?.now?.()??Date.now()}function U0(t,e){let r=Qi(t);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,e){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function k0(t){let e=Object.getPrototypeOf(t);for(;e;){let r=Object.getPrototypeOf(e);if(!r||r===D.prototype)return V0(e)||t[Symbol.toStringTag]||t.constructor.name;e=r}return t[Symbol.toStringTag]||t.constructor.name}function V0(t){let e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(t):typeof e?.value=="string"?e.value:null}var O0,Rd,Pd,vd,N0,D0,B0,F0,Md,Cd,D,ae=E(()=>{ti();O0="cpu-hotspot-profiler",Rd="GPU Resource Counts",Pd="Resource Counts",vd="GPU Time and Memory",N0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],D0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],B0=N0.flatMap(t=>[`${t} Created`,`${t} Active`]),F0=D0.flatMap(t=>[`${t} Created`,`${t} Active`]),Md=new WeakMap,Cd=new WeakMap,D=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,r,i){if(!e)throw new Error("no device");this._device=e,this.props=L0(r,i);let s=this.props.id!=="undefined"?this.props.id:st(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Qi(this._device),r=e?Yt():0,i=[this._device.statsManager.getStats(Rd),this._device.statsManager.getStats(Pd)],s=Od(this._device);for(let n of i)Id(n,s);let o=this.getStatsName();for(let n of i)n.get("Resources Active").decrementCount(),n.get(`${o}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(Yt()-r))}trackAllocatedMemory(e,r=this.getStatsName()){let i=Qi(this._device),s=i?Yt():0,o=this._device.statsManager.getStats(vd);this.allocatedBytes>0&&this.allocatedBytesName&&(o.get("GPU Memory").subtractCount(this.allocatedBytes),o.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),o.get("GPU Memory").addCount(e),o.get(`${r} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(Yt()-s)),this.allocatedBytes=e,this.allocatedBytesName=r}trackReferencedMemory(e,r=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${r}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=Qi(this._device),i=r?Yt():0,s=this._device.statsManager.getStats(vd);s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(Yt()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),r=Qi(this._device),i=r?Yt():0,s=[this._device.statsManager.getStats(Rd),this._device.statsManager.getStats(Pd)],o=Od(this._device);for(let n of s)Id(n,o);for(let n of s)n.get("Resources Created").incrementCount(),n.get("Resources Active").incrementCount(),n.get(`${e}s Created`).incrementCount(),n.get(`${e}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(Yt()-i)),U0(this._device,e)}getStatsName(){return k0(this)}};P(D,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var Ji,I,tn=E(()=>{ae();Ji=class extends D{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let i={...r};(r.usage||0)&Ji.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array?i.indexType="uint16":r.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,Ji.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,r,i){let s=null,o;ArrayBuffer.isView(e)?(s=e,o=e.buffer):o=e;let n=Math.min(e?e.byteLength:i,Ji.DEBUG_DATA_MAX_LENGTH);if(o===null)this.debugData=new ArrayBuffer(n);else{let a=Math.min(s?.byteOffset||0,o.byteLength),c=Math.max(0,o.byteLength-a),l=Math.min(n,c);this.debugData=new Uint8Array(o,a,l).slice().buffer}}},I=Ji;P(I,"INDEX",16),P(I,"VERTEX",32),P(I,"UNIFORM",64),P(I,"STORAGE",128),P(I,"INDIRECT",256),P(I,"QUERY_RESOLVE",512),P(I,"MAP_READ",1),P(I,"MAP_WRITE",2),P(I,"COPY_SRC",4),P(I,"COPY_DST",8),P(I,"DEBUG_DATA_MAX_LENGTH",32),P(I,"defaultProps",{...D.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});var fl,de,ll,rn=E(()=>{fl=class{getDataTypeInfo(e){let[r,i,s]=ll[e],o=e.includes("norm"),n=!o&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:r,primitiveType:i,byteLength:s,normalized:o,integer:n,signed:a}}getNormalizedDataType(e){let r=e;switch(r){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return r}}alignTo(e,r){switch(r){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let r=ArrayBuffer.isView(e)?e.constructor:e;if(r===Uint8ClampedArray)return"uint8";let i=Object.values(ll).find(s=>r===s[4]);if(!i)throw new Error(r.name);return i[0]}getTypedArrayConstructor(e){let[,,,,r]=ll[e];return r}},de=new fl,ll={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});var hl,Pt,sn=E(()=>{rn();hl=class{getVertexFormatInfo(e){let r;e.endsWith("-webgl")&&(e.replace("-webgl",""),r=!0);let[i,s]=e.split("x"),o=i,n=s?parseInt(s):1,a=de.getDataTypeInfo(o),c={type:o,components:n,byteLength:a.byteLength*n,integer:a.integer,signed:a.signed,normalized:a.normalized};return r&&(c.webglOnly=!0),c}makeVertexFormat(e,r,i){let s=i?de.getNormalizedDataType(e):e;switch(s){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${s}x${r}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(r===1||r===3)throw new Error(`size: ${r}`);return`${s}x${r}`;default:return r===1?s:`${s}x${r}`}}getVertexFormatFromAttribute(e,r,i){if(!r||r>4)throw new Error(`size ${r}`);let s=r,o=de.getDataType(e);return this.makeVertexFormat(o,s,i)}getCompatibleVertexFormat(e){let r;switch(e.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?r:`${r}x${e.components}`}},Pt=new hl});function _l(t){let e=Bd[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function Dd(){return Bd}var le,X,ot,z0,on,ul,nn,dl,W0,pl,Kt,gl,ml,an,Nd,j0,H0,Bd,yl=E(()=>{le="texture-compression-bc",X="texture-compression-astc",ot="texture-compression-etc2",z0="texture-compression-etc1-webgl",on="texture-compression-pvrtc-webgl",ul="texture-compression-atc-webgl",nn="float32-renderable-webgl",dl="float16-renderable-webgl",W0="rgb9e5ufloat-renderable-webgl",pl="snorm8-renderable-webgl",Kt="norm16-webgl",gl="norm16-renderable-webgl",ml="snorm16-renderable-webgl",an="float32-filterable",Nd="float16-filterable-webgl";j0={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:pl},rg8snorm:{render:pl},"rgb8snorm-webgl":{},rgba8snorm:{render:pl},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Kt,render:gl},rg16unorm:{f:Kt,render:gl},"rgb16unorm-webgl":{f:Kt,render:!1},rgba16unorm:{f:Kt,render:gl},r16snorm:{f:Kt,render:ml},rg16snorm:{f:Kt,render:ml},"rgb16snorm-webgl":{f:Kt,render:!1},rgba16snorm:{f:Kt,render:ml},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:dl,filter:"float16-filterable-webgl"},rg16float:{render:dl,filter:Nd},rgba16float:{render:dl,filter:Nd},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:nn,filter:an},rg32float:{render:!1,filter:an},"rgb32float-webgl":{render:nn,filter:an},rgba32float:{render:nn,filter:an},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:W0},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:nn},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},H0={"bc1-rgb-unorm-webgl":{f:le},"bc1-rgb-unorm-srgb-webgl":{f:le},"bc1-rgba-unorm":{f:le},"bc1-rgba-unorm-srgb":{f:le},"bc2-rgba-unorm":{f:le},"bc2-rgba-unorm-srgb":{f:le},"bc3-rgba-unorm":{f:le},"bc3-rgba-unorm-srgb":{f:le},"bc4-r-unorm":{f:le},"bc4-r-snorm":{f:le},"bc5-rg-unorm":{f:le},"bc5-rg-snorm":{f:le},"bc6h-rgb-ufloat":{f:le},"bc6h-rgb-float":{f:le},"bc7-rgba-unorm":{f:le},"bc7-rgba-unorm-srgb":{f:le},"etc2-rgb8unorm":{f:ot},"etc2-rgb8unorm-srgb":{f:ot},"etc2-rgb8a1unorm":{f:ot},"etc2-rgb8a1unorm-srgb":{f:ot},"etc2-rgba8unorm":{f:ot},"etc2-rgba8unorm-srgb":{f:ot},"eac-r11unorm":{f:ot},"eac-r11snorm":{f:ot},"eac-rg11unorm":{f:ot},"eac-rg11snorm":{f:ot},"astc-4x4-unorm":{f:X},"astc-4x4-unorm-srgb":{f:X},"astc-5x4-unorm":{f:X},"astc-5x4-unorm-srgb":{f:X},"astc-5x5-unorm":{f:X},"astc-5x5-unorm-srgb":{f:X},"astc-6x5-unorm":{f:X},"astc-6x5-unorm-srgb":{f:X},"astc-6x6-unorm":{f:X},"astc-6x6-unorm-srgb":{f:X},"astc-8x5-unorm":{f:X},"astc-8x5-unorm-srgb":{f:X},"astc-8x6-unorm":{f:X},"astc-8x6-unorm-srgb":{f:X},"astc-8x8-unorm":{f:X},"astc-8x8-unorm-srgb":{f:X},"astc-10x5-unorm":{f:X},"astc-10x5-unorm-srgb":{f:X},"astc-10x6-unorm":{f:X},"astc-10x6-unorm-srgb":{f:X},"astc-10x8-unorm":{f:X},"astc-10x8-unorm-srgb":{f:X},"astc-10x10-unorm":{f:X},"astc-10x10-unorm-srgb":{f:X},"astc-12x10-unorm":{f:X},"astc-12x10-unorm-srgb":{f:X},"astc-12x12-unorm":{f:X},"astc-12x12-unorm-srgb":{f:X},"pvrtc-rgb4unorm-webgl":{f:on},"pvrtc-rgba4unorm-webgl":{f:on},"pvrtc-rgb2unorm-webgl":{f:on},"pvrtc-rgba2unorm-webgl":{f:on},"etc1-rbg-unorm-webgl":{f:z0},"atc-rgb-unorm-webgl":{f:ul},"atc-rgba-unorm-webgl":{f:ul},"atc-rgbai-unorm-webgl":{f:ul}},Bd={...j0,...H0}});function Z0({format:t,width:e,height:r,depth:i,byteAlignment:s}){let o=pe.getInfo(t),{bytesPerPixel:n,bytesPerBlock:a=n,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=o,h=f?Math.ceil(e/c):e,u=f?Math.ceil(r/l):r,d=h*a,p=Math.ceil(d/s)*s,g=u,m=p*g*i;return{bytesPerPixel:n,bytesPerRow:p,rowsPerImage:g,depthOrArrayLayers:i,bytesPerImage:p*g,byteLength:m}}function q0(t){let e=_l(t),r={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=Fd(t),s=t.startsWith("depth")||t.startsWith("stencil"),o=i?.signed,n=i?.integer,a=i?.webgl,c=Boolean(i?.compressed);return r.render&&=!s&&!c,r.filter&&=!s&&!o&&!n&&!a,r}function Fd(t){let e=G0(t);if(pe.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=J0(t);let i=Q0(t);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let r=e.packed?null:$0.exec(t);if(r){let[,i,s,o,n,a]=r,c=`${o}${s}`,l=de.getDataTypeInfo(c),f=l.byteLength*8,h=i?.length??1,u=[f,h>=2?f:0,h>=3?f:0,h>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:h,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:u,bytesPerPixel:l.byteLength*h,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),n==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function G0(t){let e=_l(t),r=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:r,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function Q0(t){let r=/.*-(\d+)x(\d+)-.*/.exec(t);if(r){let[,i,s]=r;return{blockWidth:Number(i),blockHeight:Number(s)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function J0(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}var $0,X0,Y0,K0,bl,pe,cn=E(()=>{rn();yl();$0=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,X0=["rgb","rgba","bgra"],Y0=["depth","stencil"],K0=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],bl=class{isColor(e){return X0.some(r=>e.startsWith(r))}isDepthStencil(e){return Y0.some(r=>e.startsWith(r))}isCompressed(e){return K0.some(r=>e.startsWith(r))}getInfo(e){return Fd(e)}getCapabilities(e){return q0(e)}computeMemoryLayout(e){return Z0(e)}},pe=new bl});function ri(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function es(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWidth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}var Tl=E(()=>{});function eT(t,e){let r=xl(t),i=e.map(xl).filter(s=>s!==void 0);return[r,...i].filter(s=>s!==void 0)}function xl(t){if(t!==void 0){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(t instanceof Error)return t.message;if(Array.isArray(t))return t.map(xl);if(typeof t=="object"){if(tT(t)){let e=String(t);if(e!=="[object Object]")return e}return rT(t)?iT(t):t.constructor?.name||"Object"}return String(t)}}function tT(t){return"toString"in t&&typeof t.toString=="function"&&t.toString!==Object.prototype.toString}function rT(t){return"message"in t&&"type"in t}function iT(t){let e=typeof t.type=="string"?t.type:"message",r=typeof t.message=="string"?t.message:"",i=typeof t.lineNum=="number"?t.lineNum:null,s=typeof t.linePos=="number"?t.linePos:null,o=i!==null&&s!==null?` @ ${i}:${s}`:i!==null?` @ ${i}`:"";return`${e}${o}: ${r}`.trim()}function sT(t,e){return t!=null?Boolean(t):e!==void 0?e!=="production":!1}function oT(){return sT(x.get("debug"),nT())}function nT(){let t=globalThis.process;if(t?.env)return t.env.NODE_ENV}var ts,rs,Al,xe,Sl=E(()=>{Qc();De();ti();tn();sn();cn();Tl();yl();ts=class{};rs=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},Al=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=Ko;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...Al.defaultProps,...e},this.id=this.props.id||st(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Pt.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return pe.getInfo(e)}getTextureFormatCapabilities(e){let r=this._textureCaps[e];if(!r){let i=this._getDeviceTextureFormatCapabilities(e);r=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=r}return r}getMipLevelCount(e,r,i=1){let s=Math.max(e,r,i);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return ri(e)}getExternalImageSize(e){return es(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return pe.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let r of Object.keys(Dd()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&e.push(r);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,r,...i){if(!this.props.onError(e,r)){let o=eT(r,i);return x.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...o)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
|
|
8
|
+
or create a device with the 'debug: true' prop.`;x.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,r,i,s){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let r=pe.getCapabilities(e),i=o=>(typeof o=="string"?this.features.has(o):o)??!0,s=i(r.create);return{format:e,create:s,render:s&&i(r.render),filter:s&&i(r.filter),blend:s&&i(r.blend),store:s&&i(r.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};if((e.usage||0)&I.INDEX&&(e.indexType||(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":e.data instanceof Uint8Array&&(r.data=new Uint16Array(e.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}},xe=Al;P(xe,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,r)=>{},onResize:(e,r)=>{let[i,s]=e.getDevicePixelSize();x.log(1,`${e} resized => ${i}x${s}px`)()},onPositionChange:(e,r)=>{let[i,s]=e.getPosition();x.log(1,`${e} repositioned => ${i},${s}`)()},onVisibilityChange:e=>x.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,r)=>x.log(1,`${e} DPR changed ${r.oldRatio} => ${e.devicePixelRatio}`)(),debug:oT(),debugGPUTime:!1,debugShaders:x.get("debug-shaders")||void 0,debugFramebuffers:Boolean(x.get("debug-framebuffers")),debugFactories:Boolean(x.get("debug-factories")),debugWebGL:Boolean(x.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var aT,Ld,fn,ln,Zt,Ud=E(()=>{Sl();Qc();De();aT="set luma.log.level=1 (or higher) to trace rendering",Ld="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",fn=class{stats=Ko;log=x;VERSION="9.3.0-alpha.10";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw x.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),x.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");x.error("This version of luma.gl has already been initialized")()}x.log(1,`${this.VERSION} - ${aT}`)(),globalThis.luma=this}async createDevice(e={}){let r={...fn.defaultProps,...e},i=this.selectAdapter(r.type,r.adapters);if(!i)throw new Error(Ld);return r.waitForPageLoad&&await i.pageLoaded,await i.create(r)}async attachDevice(e,r){let i=this._getTypeFromHandle(e,r.adapters),s=i&&this.selectAdapter(i,r.adapters);if(!s)throw new Error(Ld);return await s?.attach?.(e,r)}registerAdapters(e){for(let r of e)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(e=[]){let r=this._getAdapterMap(e);return Array.from(r).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let r=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let s of r)if(i.get(s)?.isSupported?.())return s;return null}selectAdapter(e,r=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(r));let s=this._getAdapterMap(r);return i&&s.get(i)||null}enforceWebGL2(e=!0,r=[]){let s=this._getAdapterMap(r).get("webgl");s||x.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(fn.defaultProps,e)}_getAdapterMap(e=[]){let r=new Map(this.preregisteredAdapters);for(let i of e)r.set(i.type,i);return r}_getTypeFromHandle(e,r=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?x.warn("WebGL1 is not supported",e)():x.warn("Unknown handle type",e)(),null)}},ln=fn;P(ln,"defaultProps",{...xe.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});Zt=new ln});function fT(){return hn||(lT()||typeof window>"u"?hn=Promise.resolve():hn=new Promise(t=>window.addEventListener("load",()=>t()))),hn}var is,cT,lT,hn,kd=E(()=>{Xt();is=class{get pageLoaded(){return fT()}},cT=he()&&typeof document<"u",lT=()=>cT&&document.readyState==="complete",hn=null});var un,Vd=E(()=>{un=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function zd(){let t,e;return{promise:new Promise((i,s)=>{t=i,e=s}),resolve:t,reject:e}}var Wd=E(()=>{});function El(t,e){if(!t){let r=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,El),r}}function Ar(t,e){return El(t,e),t}var wl=E(()=>{});function hT(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function uT(t){let e=document.getElementById(t);if(!vt.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function dT(t){let{width:e,height:r}=t,i=document.createElement("canvas");i.id=st("lumagl-auto-created-canvas"),i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",t?.visible||(i.style.visibility="hidden");let s=hT(t?.container||null);return s.insertBefore(i,s.firstChild),i}function pT(t,e,r,i,s){let o=t,n=jd(o[0],e,r),a=Hd(o[1],e,i,s),c=jd(o[0]+1,e,r),l=c===r-1?c:c-1;c=Hd(o[1]+1,e,i,s);let f;return s?(c=c===0?c:c+1,f=a,a=c):f=c===i-1?c:c-1,{x:n,y:a,width:Math.max(l-n+1,1),height:Math.max(f-a+1,1)}}function jd(t,e,r){return Math.min(Math.round(t*e),r-1)}function Hd(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var ss,vt,Rl=E(()=>{Xt();Vd();ti();Wd();wl();ss=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=zd();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...ss.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,he()?e.canvas?typeof e.canvas=="string"?this.canvas=uT(e.canvas):this.canvas=e.canvas:this.canvas=dT(e):this.canvas={width:e.width||1,height:e.height||1},ss.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):ss.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new un({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,r){e=Math.floor(e),r=Math.floor(r),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[s,o]=this.getDrawingBufferSize();return pT(e,i,s,o,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,r]=this.getDrawingBufferSize();return e>0&&r>0?e/r:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?e/r:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let r=e.find(s=>s.target===this.canvas);if(!r)return;let i=r.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let r=e.find(l=>l.target===this.canvas);if(!r)return;let i=Ar(r.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let s=this.getDevicePixelSize(),o=r.devicePixelContentBoxSize?.[0]?.inlineSize||i.inlineSize*devicePixelRatio,n=r.devicePixelContentBoxSize?.[0]?.blockSize||i.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(o,a)),this.devicePixelHeight=Math.max(1,Math.min(n,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:s})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let r=[e.left,e.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let s=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:s})}}}},vt=ss;P(vt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1})});var ii,$d=E(()=>{Rl();ii=class extends vt{};P(ii,"defaultProps",vt.defaultProps)});var os,Xd=E(()=>{Rl();os=class extends vt{}});var dn,Be,Pl=E(()=>{ae();dn=class extends D{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=dn.normalizeProps(e,r),super(e,r,dn.defaultProps)}static normalizeProps(e,r){return r}},Be=dn;P(Be,"defaultProps",{...D.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1})});var gT,we,B,vl=E(()=>{ae();Pl();De();cn();gT={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},we=class extends D{dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,r,i){if(r=we.normalizeProps(e,r),super(e,r,we.defaultProps),this.dimension=this.props.dimension,this.baseDimension=gT[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(r.data)){let s=e.getExternalImageSize(r.data);this.width=s?.width||1,this.height=s?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&x.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Be?e:this.device.createSampler(e)}copyImageData(e){let{data:r,depth:i,...s}=e;this.writeData(r,{...s,depthOrArrayLayers:s.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let r=this._normalizeTextureReadOptions(e),{width:i=this.width,height:s=this.height,depthOrArrayLayers:o=this.depth}=r,{format:n,byteAlignment:a}=this;return pe.computeMemoryLayout({format:n,width:i,height:s,depth:o,byteAlignment:a})}readBuffer(e,r){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,r){throw new Error("readBuffer not implemented")}writeData(e,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,r){let i={...r},{width:s,height:o}=i;return typeof s=="number"&&(i.width=Math.max(1,Math.ceil(s))),typeof o=="number"&&(i.height=Math.max(1,Math.ceil(o))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:r,depth:i,...s}=e,o=this._normalizeTextureWriteOptions({...s,depthOrArrayLayers:s.depthOrArrayLayers??i});return{data:r,depth:o.depthOrArrayLayers,...o}}_normalizeCopyExternalImageOptions(e){let r=we._omitUndefined(e),i=r.mipLevel??0,s=this._getMipLevelSize(i),o=this.device.getExternalImageSize(e.image),n={...we.defaultCopyExternalImageOptions,...s,...o,...r};return n.width=Math.min(n.width,s.width-n.x),n.height=Math.min(n.height,s.height-n.y),n.depth=Math.min(n.depth,s.depthOrArrayLayers-n.z),n}_normalizeTextureReadOptions(e){let r=we._omitUndefined(e),i=r.mipLevel??0,s=this._getMipLevelSize(i),o={...we.defaultTextureReadOptions,...s,...r};return o.width=Math.min(o.width,s.width-o.x),o.height=Math.min(o.height,s.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,s.depthOrArrayLayers-o.z),o}_getSupportedColorReadOptions(e){let r=this._normalizeTextureReadOptions(e),i=pe.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let r=we._omitUndefined(e),i=r.mipLevel??0,s=this._getMipLevelSize(i),o={...we.defaultTextureWriteOptions,...s,...r};o.width=Math.min(o.width,s.width-o.x),o.height=Math.min(o.height,s.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,s.depthOrArrayLayers-o.z);let n=pe.computeMemoryLayout({format:this.format,width:o.width,height:o.height,depth:o.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=n.bytesPerPixel*o.width;if(o.bytesPerRow=r.bytesPerRow??n.bytesPerRow,o.rowsPerImage=r.rowsPerImage??o.height,o.bytesPerRow<a)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be at least ${a} for ${this.format}`);if(o.rowsPerImage<o.height)throw new Error(`rowsPerImage (${o.rowsPerImage}) must be at least ${o.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&o.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return o}_getMipLevelSize(e){let r=Math.max(1,this.width>>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),s=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:r,height:i,depthOrArrayLayers:s}}getAllocatedByteLength(){let e=0;for(let r=0;r<this.mipLevels;r++){let{width:i,height:s,depthOrArrayLayers:o}=this._getMipLevelSize(r);e+=pe.computeMemoryLayout({format:this.format,width:i,height:s,depth:o,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}},B=we;P(B,"SAMPLE",4),P(B,"STORAGE",8),P(B,"RENDER",16),P(B,"COPY_SRC",1),P(B,"COPY_DST",2),P(B,"TEXTURE",4),P(B,"RENDER_ATTACHMENT",16),P(B,"defaultProps",{...D.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:we.SAMPLE|we.RENDER|we.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),P(B,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),P(B,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}),P(B,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),P(B,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"})});var Ml,qt,Yd=E(()=>{ae();Ml=class extends D{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,Ml.defaultProps)}},qt=Ml;P(qt,"defaultProps",{...D.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function Kd(t,e,r){let i="",s=e.split(/\r?\n/),o=t.slice().sort((n,a)=>n.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let n=0;for(let a=1;a<=s.length;a++){let c=s[a-1],l=o[n];for(c&&l&&(i+=Zd(c,a,r));o.length>n&&l.lineNum===a;){let f=o[n++];f&&(i+=Cl(f,s,f.lineNum,{...r,inlineSource:!1}))}}for(;o.length>n;){let a=o[n++];a&&(i+=Cl(a,[],0,{...r,inlineSource:!1}))}return i;case"issues":case"no":for(let a of t)i+=Cl(a,s,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function Cl(t,e,r,i){if(i?.inlineSource){let o=mT(e,r),n=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
|
|
9
9
|
`:"";return`
|
|
10
10
|
${o}${n}${t.type.toUpperCase()}: ${t.message}
|
|
11
11
|
|
|
12
|
-
`}let s=t.type==="error"?"red":"orange";return i?.html?`<div class='luma-compiler-log-${t.type}' style="color:${s};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function
|
|
13
|
-
`}`}function
|
|
12
|
+
`}let s=t.type==="error"?"red":"orange";return i?.html?`<div class='luma-compiler-log-${t.type}' style="color:${s};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function mT(t,e,r){let i="";for(let s=e-2;s<=e;s++){let o=t[s-1];o!==void 0&&(i+=Zd(o,e,r))}return i}function Zd(t,e,r){let i=r?.html?yT(t):t;return`${_T(String(e),4)}: ${i}${r?.html?"<br/>":`
|
|
13
|
+
`}`}function _T(t,e){let r="";for(let i=t.length;i<e;++i)r+=" ";return r+t}function yT(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var qd=E(()=>{});function bT(t){return TT(t.source)||t.id||st(`unnamed ${t.stage}-shader`)}function TT(t,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t)?.[1]??e}var Il,Gt,Ol=E(()=>{ae();ti();qd();Il=class extends D{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){r={...r,debugShaders:r.debugShaders||e.props.debugShaders||"errors"},super(e,{id:bT(r),...r},Il.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();e==="warnings"&&r?.length===0||this._displayShaderLog(r,this.id)}_displayShaderLog(e,r){if(typeof document>"u"||!document?.createElement)return;let i=r,s=`${this.stage} shader "${i}"`,o=Kd(e,this.source,{showSourceCode:"all",html:!0}),n=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`<h1>Compilation error in ${s}</h1>
|
|
14
14
|
<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">
|
|
15
15
|
<button id="copy">Copy source</button><br/>
|
|
16
16
|
<button id="close">Close</button>
|
|
17
17
|
</div>
|
|
18
|
-
<code><pre>${o}</pre></code>`,n&&(a.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${n}</pre></code>`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}},Zt=Tl;P(Zt,"defaultProps",{...N.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var bl,rt,vd=E(()=>{ae();ml();St();bl=class extends N{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,bl.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(s=>s.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:r,depthStencilAttachment:i})}resize(e){let r=!e;if(e){let[i,s]=Array.isArray(e)?e:[e.width,e.height];r=r||s!==this.height||i!==this.width,this.width=i,this.height=s}r&&(b.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,i)=>{if(typeof r=="string"){let s=this.createColorTexture(r,i);return this.attachResource(s),s.view}return r instanceof U?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof U?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:U.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:U.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){if(this.colorAttachments.forEach((i,s)=>{let o=i.texture.clone({width:e,height:r});this.destroyAttachedResource(i),this.colorAttachments[s]=o.view,this.attachResource(o.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}},rt=bl;P(rt,"defaultProps",{...N.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var xl,we,Md=E(()=>{ae();xl=class extends N{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,r){super(e,r,xl.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}},we=xl;P(we,"defaultProps",{...N.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0})});var ts,Cd=E(()=>{ae();ts=class extends N{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,r){super(e,r,{...N.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Tr,Rt,Id=E(()=>{ae();Tr=class extends N{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=Tr.normalizeProps(e,r),super(e,r,Tr.defaultProps)}static normalizeProps(e,r){return r}},Rt=Tr;P(Rt,"defaultClearColor",[0,0,0,1]),P(Rt,"defaultClearDepth",1),P(Rt,"defaultClearStencil",0),P(Rt,"defaultProps",{...N.defaultProps,framebuffer:null,parameters:void 0,clearColor:Tr.defaultClearColor,clearColors:void 0,clearDepth:Tr.defaultClearDepth,clearStencil:Tr.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var Al,br,Od=E(()=>{ae();Al=class extends N{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,Al.defaultProps),this.shaderLayout=r.shaderLayout}},br=Al;P(br,"defaultProps",{...N.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var Sl,ri,Nd=E(()=>{ae();Sl=class extends N{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,r){super(e,r,Sl.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let r=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),s=0n;for(let o=0;o<r;o+=2)s+=i[o+1]-i[o];this._gpuTimeMs=Number(s)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let r=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||r.timestampQuerySet!==void 0||r.beginTimestampIndex!==void 0||r.endTimestampIndex!==void 0)return r;let i=this._timeProfilingSlotCount;return i+1>=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}},ri=Sl;P(ri,"defaultProps",{...N.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0})});var El,ii,Dd=E(()=>{ae();El=class extends N{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,El.defaultProps)}},ii=El;P(ii,"defaultProps",{...N.defaultProps})});function rs(t){let e=ET(t),r=PT[e];if(!r)throw new Error(`Unsupported variable shader type: ${t}`);return r}function wl(t){let e=ST(t),r=RT[e];if(!r)throw new Error(`Unsupported attribute shader type: ${t}`);let[i,s]=r,o=i==="i32"||i==="u32",n=i!=="u32",a=wT[i]*s;return{primitiveType:i,components:s,byteLength:a,integer:o,signed:n}}function ST(t){return Fd[t]||t}function ET(t){return vT[t]||t}var wT,RT,PT,Fd,vT,fn=E(()=>{wT={f32:4,f16:2,i32:4,u32:4},RT={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},PT={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},Fd={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},vT={...Fd,mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"}});function hn(t,e){let r={};for(let i of t.attributes){let s=MT(t,e,i.name);s&&(r[i.name]=s)}return r}function Bd(t,e,r=16){let i=hn(t,e),s=new Array(r).fill(null);for(let o of Object.values(i))s[o.location]=o;return s}function MT(t,e,r){let i=CT(t,r),s=IT(e,r);if(!i)return null;let o=wl(i.type),n=cd(o),a=s?.vertexFormat||n,c=Jr(a);return{attributeName:s?.attributeName||i.name,bufferName:s?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:o.primitiveType,shaderComponents:o.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:o.integer,stepMode:s?.stepMode||i.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function CT(t,e){let r=t.attributes.find(i=>i.name===e);return r||b.warn(`shader layout attribute "${e}" not present in shader`),r||null}function IT(t,e){OT(t);let r=NT(t,e);return r||(r=DT(t,e),r)?r:(b.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function OT(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&b.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function NT(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function DT(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let o of r.attributes||[]){let n=Jr(o.format);i+=n.byteLength}let s=r.attributes?.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:i}}return null}var Rl=E(()=>{St();fn();Go()});var Pl,si,Ld=E(()=>{Rl();ae();Pl=class extends N{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,Pl.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Bd(r.shaderLayout,r.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"),this)()}},si=Pl;P(si,"defaultProps",{...N.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var vl,oi,Ud=E(()=>{ae();vl=class extends N{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,vl.defaultProps)}},oi=vl;P(oi,"defaultProps",{...N.defaultProps,layout:void 0,buffers:{}})});var Ml,ni,kd=E(()=>{ae();Ml=class extends N{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,Ml.defaultProps)}},ni=Ml;P(ni,"defaultProps",{...N.defaultProps,type:void 0,count:void 0})});var Cl,ai,Vd=E(()=>{ae();Cl=class extends N{get[Symbol.toStringTag](){return"Fence"}constructor(e,r={}){super(e,r,Cl.defaultProps)}},ai=Cl;P(ai,"defaultProps",{...N.defaultProps})});function Il(t){return(!un||un.byteLength<t)&&(un=new ArrayBuffer(t)),un}function Ol(t,e){let r=Il(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}var un,Nl=E(()=>{});var FT,dn,zd=E(()=>{Zi();fn();Nl();St();FT=1024,dn=class{layout={};byteLength;constructor(e,r={}){let i=0;for(let[s,o]of Object.entries(e))i=this._addToLayout(s,o,i,r?.[s]);i+=(4-i%4)%4,this.byteLength=Math.max(i*4,FT)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}getData(e){let r=Il(this.byteLength),i={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)};for(let[s,o]of Object.entries(e))this._writeCompositeValue(i,s,o);return new Uint8Array(r,0,this.byteLength)}_addToLayout(e,r,i,s=1){if(typeof r=="string"){let o=rs(r),n=o.components*s,a=Qo(i,o.components);return this.layout[e]={offset:a,size:n,type:o.type},a+n}if(Array.isArray(r)){let o=r[0],n=s>1?s:r.length>1?r[1]:1,a=Qo(i,4);for(let c=0;c<n;c++)a=this._addToLayout(`${e}[${c}]`,o,a);return a}if(typeof r=="object"){let o=Qo(i,4);for(let[n,a]of Object.entries(r))o=this._addToLayout(`${e}.${n}`,a,o);return o}throw new Error(`Unsupported CompositeShaderType for ${e}`)}_writeCompositeValue(e,r,i){if(this.layout[r]){this._writeToBuffer(e,r,i);return}if(Array.isArray(i)){for(let s=0;s<i.length;s++){let o=i[s],n=`${r}[${s}]`;this._writeCompositeValue(e,n,o)}return}if(typeof i=="object"&&i!==null){for(let[s,o]of Object.entries(i)){let n=`${r}.${s}`;this._writeCompositeValue(e,n,o)}return}b.warn(`Unsupported uniform value for ${r}:`,i)()}_writeToBuffer(e,r,i){let s=this.layout[r];if(!s){b.warn(`Uniform ${r} not found in layout`)();return}let{type:o,size:n,offset:a}=s,c=e[o];n===1?c[a]=Number(i):c.set(i,a)}}});function BT(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function pn(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":BT(t)}var Wd=E(()=>{});function jd(t,e,r=16){if(t===e)return!0;let i=t,s=e;if(!pn(i)||!pn(s)||i.length!==s.length)return!1;let o=Math.min(r,LT);if(i.length>o)return!1;for(let n=0;n<i.length;++n)if(s[n]!==i[n])return!1;return!0}function Hd(t){return pn(t)?t.slice():t}var LT,$d=E(()=>{Wd();LT=128});var gn,Xd=E(()=>{$d();gn=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let r=e?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let s of i.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){jd(this.uniforms[e],r)||(this.uniforms[e]=Hd(r),this.modifiedUniforms[e]=!0,this.modified=!0)}}});var is,Yd=E(()=>{qo();St();Xd();zd();is=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[r,i]of Object.entries(e)){let s=r,o=new dn(i.uniformTypes??{},i.uniformSizes??{});this.uniformBufferLayouts.set(s,o);let n=new gn({name:r});n.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(s,n)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e))this.uniformBlocks.get(r)?.setUniforms(i);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){let r=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(r)}createUniformBuffer(e,r,i){i&&this.setUniforms(i);let s=this.getUniformBufferByteLength(r),o=e.createBuffer({usage:D.UNIFORM|D.COPY_DST,byteLength:s}),n=this.getUniformBufferData(r);return o.write(n),o}getManagedUniformBuffer(e,r){if(!this.uniformBuffers.get(r)){let i=this.getUniformBufferByteLength(r),s=e.createBuffer({usage:D.UNIFORM|D.COPY_DST,byteLength:i});this.uniformBuffers.set(r,s)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&b.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),s=!1;if(i&&r?.needsRedraw){s||=r.needsRedraw;let o=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(o);let n=this.uniformBlocks.get(e)?.getAllUniforms();b.log(4,`Writing to uniform buffer ${String(e)}`,o,n)()}return s}}});var F=E(()=>{pd();gd();hl();xd();Ad();qo();ml();Sd();Pd();gl();vd();Md();Cd();Id();Od();Nd();Dd();Ld();Ud();kd();Vd();Yd();Zi();fn();Go();sn();ll();St();dl();Nl();Rl()});var ur,__=E(()=>{(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(ur||(ur={}))});var y_=E(()=>{__()});function T_(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(r,i){if(r==="webgl"||r==="experimental-webgl"){let s=this.originalGetContext("webgl2",i);return s instanceof HTMLElement&&PR(s),s}return this.originalGetContext(r,i)}}function PR(t){t.getExtension("EXT_color_buffer_float");let e={...SR,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:ER(t),OES_vertex_array_object:wR(t),ANGLE_instanced_arrays:RR(t)},r=t.getExtension;t.getExtension=function(s){let o=r.call(t,s);return o||(s in e?e[s]:null)};let i=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(i.apply(t)||[])?.concat(Object.keys(e))}}var SR,ER,wR,RR,b_=E(()=>{SR={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},ER=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),wR=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),RR=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}})});async function Ia(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((s,o)=>{i.onload=s,i.onerror=n=>o(new Error(`Unable to load script '${t}': ${n}`)),r.appendChild(i)})}var Zh=E(()=>{});function zr(t){let e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},t.luma=e,e}var Oa=E(()=>{});async function A_(t){if(!globalThis.SPECTOR)try{await Ia(t.debugSpectorJSUrl||Na.debugSpectorJSUrl)}catch(e){b.warn(String(e))}}function S_(t){if(t={...Na,...t},!t.debugSpectorJS)return null;if(!Ce&&globalThis.SPECTOR&&!globalThis.luma?.spector){b.probe(vR,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;Ce=new e,globalThis.luma&&(globalThis.luma.spector=Ce)}if(!Ce)return null;if(x_||(x_=!0,Ce.spyCanvases(),Ce?.onCaptureStarted.add(e=>b.info("Spector capture started:",e)()),Ce?.onCapture.add(e=>{b.info("Spector capture complete:",e)(),Ce?.getResultUI(),Ce?.resultView.display(),Ce?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=zr(e),i=r.device;Ce?.startCapture(t.gl,500),r.device=i,new Promise(s=>setTimeout(s,2e3)).then(s=>{b.info("Spector capture stopped after 2 seconds")(),Ce?.stopCapture()})}return Ce}var vR,Ce,x_,Na,Kh=E(()=>{F();Zh();Oa();vR=1,Ce=null,x_=!1,Na={debugSpectorJS:b.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function w_(t){return t.luma=t.luma||{},t.luma}async function R_(){he()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Ia(MR))}function P_(t,e={}){return e.debugWebGL||e.traceWebGL?IR(t,e):CR(t)}function CR(t){let e=w_(t);return e.realContext?e.realContext:t}function IR(t,e){if(!globalThis.WebGLDebugUtils)return b.warn("webgl-debug not loaded")(),t;let r=w_(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...ur,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,OR.bind(null,e),NR.bind(null,e));for(let n in ur)!(n in i)&&typeof ur[n]=="number"&&(i[n]=ur[n]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(s,i);let o=Object.create(s);return r.realContext=t,r.debugContext=o,o.luma=r,o.debug=!0,o}function E_(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function OR(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(e),o=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),n=`${s} in gl.${r}(${o})`;b.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",n)();debugger;throw new Error(n)}function NR(t,e,r){let i="";t.traceWebGL&&b.level>=1&&(i=E_(e,r),b.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)());for(let s of r)if(s===void 0){i=i||E_(e,r);debugger}}var MR,qh=E(()=>{F();y_();Wt();Zh();MR="https://unpkg.com/webgl-debug@2.0.1/index.js"});function Qh(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function G(t,e,r){return e[t]!==void 0?e[t]:r[t]}var go,se,v_,Ie,M_,po,C_,I_,Gh,pt,Jh,O_,eu=E(()=>{go={[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},se=(t,e,r)=>e?t.enable(r):t.disable(r),v_=(t,e,r)=>t.hint(r,e),Ie=(t,e,r)=>t.pixelStorei(r,e),M_=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},po=(t,e,r)=>{let s={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(s,e)};C_={[3042]:se,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:se,[2885]:(t,e)=>t.cullFace(e),[2929]:se,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:se,[35723]:v_,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:M_,[36010]:M_,[34964]:po,[36662]:po,[36663]:po,[35053]:po,[35055]:po,[2886]:(t,e)=>t.frontFace(e),[33170]:v_,[2849]:(t,e)=>t.lineWidth(e),[32823]:se,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:se,[32926]:se,[32928]:se,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:se,[3088]:(t,e)=>t.scissor(...e),[2960]:se,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.stencilMaskSeparate(1029,e),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(t,e)=>t.viewport(...e),[34383]:se,[10754]:se,[12288]:se,[12289]:se,[12290]:se,[12291]:se,[12292]:se,[12293]:se,[12294]:se,[12295]:se,[3333]:Ie,[3317]:Ie,[37440]:Ie,[37441]:Ie,[37443]:Ie,[3330]:Ie,[3332]:Ie,[3331]:Ie,[3314]:Ie,[32878]:Ie,[3316]:Ie,[3315]:Ie,[32877]:Ie,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Qh(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=Qh(e)&&e.length===3?[...e,...e]:e;let[r,i,s,o,n,a]=e;t.stencilFuncSeparate(1028,r,i,s),t.stencilFuncSeparate(1029,o,n,a)},stencilOp:(t,e)=>{e=Qh(e)&&e.length===3?[...e,...e]:e;let[r,i,s,o,n,a]=e;t.stencilOpSeparate(1028,r,i,s),t.stencilOpSeparate(1029,o,n,a)},viewport:(t,e)=>t.viewport(...e)};I_={blendEquation:(t,e,r)=>t.blendEquationSeparate(G(32777,e,r),G(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(G(32969,e,r),G(32968,e,r),G(32971,e,r),G(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(G(32824,e,r),G(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(G(32938,e,r),G(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,G(2962,e,r),G(2967,e,r),G(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,G(34816,e,r),G(36003,e,r),G(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,G(2964,e,r),G(2965,e,r),G(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,G(34817,e,r),G(34818,e,r),G(34819,e,r))},Gh={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,s)=>t({[32773]:new Float32Array([e,r,i,s])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,i,s)=>t({[32969]:e,[32968]:r,[32971]:i,[32970]:s}),clearColor:(t,e,r,i,s)=>t({[3106]:new Float32Array([e,r,i,s])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,i,s)=>t({[3107]:[e,r,i,s]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,i,s)=>t({[3088]:new Int32Array([e,r,i,s])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({[2962]:e,[2967]:r,[2963]:i,[34816]:e,[36003]:r,[36004]:i}),stencilFuncSeparate:(t,e,r,i,s)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:s}),stencilOp:(t,e,r,i)=>t({[2964]:e,[2965]:r,[2966]:i,[34817]:e,[34818]:r,[34819]:i}),stencilOpSeparate:(t,e,r,i,s)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:s}),viewport:(t,e,r,i,s)=>t({[2978]:[e,r,i,s]})},pt=(t,e)=>t.isEnabled(e),Jh={[3042]:pt,[2884]:pt,[2929]:pt,[3024]:pt,[32823]:pt,[32926]:pt,[32928]:pt,[3089]:pt,[2960]:pt,[35977]:pt},O_=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 qe(t,e){if(DR(e))return;let r={};for(let s in e){let o=Number(s),n=C_[s];n&&(typeof n=="string"?r[n]=!0:n(t,e[s],o))}let i=t.lumaState?.cache;if(i)for(let s in r){let o=I_[s];o(t,e,i)}}function Da(t,e=go){if(typeof e=="number"){let s=e,o=Jh[s];return o?o(t,s):t.getParameter(s)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let s of r){let o=Jh[s];i[s]=o?o(t,Number(s)):t.getParameter(Number(s))}return i}function N_(t){qe(t,go)}function DR(t){for(let e in t)return!1;return!0}var Ni=E(()=>{eu()});function F_(t,e){if(t===e)return!0;if(D_(t)&&D_(e)&&t.length===e.length){for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}return!1}function D_(t){return Array.isArray(t)||ArrayBuffer.isView(t)}var B_=E(()=>{});function L_(t,e){let r=t[e].bind(t);t[e]=function(s){if(s===void 0||O_.has(s))return r(s);let o=Qe.get(t);return s in o.cache||(o.cache[s]=r(s)),o.enable?o.cache[s]:r(s)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function FR(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...o){let n=Qe.get(t),{valueChanged:a,oldValue:c}=r(n._updateCache,...o);return a&&i(...o),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function BR(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let s=Qe.get(t);s.program!==i&&(e(i),s.program=i)}}var Qe,tu=E(()=>{Ni();B_();eu();Qe=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,r){this.gl=e,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];qe(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r?.copyState?Da(e):Object.assign({},go),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,BR(e);for(let i in Gh){let s=Gh[i];FR(e,i,s)}L_(e,"getParameter"),L_(e,"isEnabled")}_updateCache(e){let r=!1,i,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let o in e){let n=e[o],a=this.cache[o];F_(n,a)||(r=!0,i=a,s&&!(o in s)&&(s[o]=a),this.cache[o]=n)}return{valueChanged:r,oldValue:i}}}});function U_(t,e,r){let i="",s=c=>{let l=c.statusMessage;l&&(i||=l)};t.addEventListener("webglcontextcreationerror",s,!1);let o=r.failIfMajorPerformanceCaveat!==!0,n={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=t.getContext("webgl2",n),!a&&n.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&o&&(n.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",n),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=zr(a);l.softwareRenderer=c;let{onContextLost:f,onContextRestored:h}=e;return t.addEventListener("webglcontextlost",u=>f(u),!1),t.addEventListener("webglcontextrestored",u=>h(u),!1),a}finally{t.removeEventListener("webglcontextcreationerror",s,!1)}}var k_=E(()=>{Oa()});function Ge(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}var mo=E(()=>{});function V_(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);Ge(t,"WEBGL_debug_renderer_info",e);let s=e.WEBGL_debug_renderer_info,o=t.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),n=t.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=o||r,c=n||i,l=t.getParameter(7938),f=z_(a,c),h=LR(a,c),u=UR(a,c);return{type:"webgl",gpu:f,gpuType:u,gpuBackend:h,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function z_(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function LR(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function UR(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(z_(t,e)){case"apple":return kR(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function kR(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}var W_=E(()=>{mo()});function Fa(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}var ru=E(()=>{});function $_(t){return t in La}function au(t,e,r){return X_(t,e,r,new Set)}function X_(t,e,r,i){let s=La[e];if(!s||i.has(e))return!1;i.add(e);let o=(s.features||[]).every(n=>X_(t,n,r,i));return i.delete(e),o?(s.extensions||[]).every(n=>Boolean(Ge(t,n,r))):!1}function Y_(t,e,r){let i=e.create,s=Ua[e.format];s?.gl===void 0&&(i=!1),s?.x&&(i=i&&Boolean(Ge(t,s.x,r))),e.format==="stencil8"&&(i=!1);let o=s?.r===!1?!1:s?.r===void 0||au(t,s.r,r),n=i&&e.render&&o&&YR(t,e.format,r);return{format:e.format,create:i&&e.create,render:n,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function YR(t,e,r){let i=Ua[e],s=i?.gl;if(s===void 0||i?.x&&!Ge(t,i.x,r))return!1;let o=t.getParameter(32873),n=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;let l=Number(0),f=Number(t.getError());for(;f!==l;)f=t.getError();let h=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,s,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),h=Number(t.checkFramebufferStatus(36160))===Number(36053)&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,n),t.deleteFramebuffer(c),t.bindTexture(3553,o),t.deleteTexture(a)}return h}function ka(t){let e=Ua[t],r=KR(t),i=de.getInfo(t);return i.compressed&&(e.dataFormat=r),{internalFormat:r,format:e?.dataFormat||ZR(i.channels,i.integer,i.normalized,r),type:i.dataType?Fa(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function Z_(t){switch(de.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function ZR(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function KR(t){let r=Ua[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var _o,yo,Di,Fi,VR,zR,WR,jR,HR,$R,j_,H_,iu,su,ou,nu,Ba,XR,La,Ua,Bi=E(()=>{F();mo();ru();_o="WEBGL_compressed_texture_s3tc",yo="WEBGL_compressed_texture_s3tc_srgb",Di="EXT_texture_compression_rgtc",Fi="EXT_texture_compression_bptc",VR="WEBGL_compressed_texture_etc",zR="WEBGL_compressed_texture_astc",WR="WEBGL_compressed_texture_etc1",jR="WEBGL_compressed_texture_pvrtc",HR="WEBGL_compressed_texture_atc",$R="EXT_texture_norm16",j_="EXT_render_snorm",H_="EXT_color_buffer_float",iu="snorm8-renderable-webgl",su="norm16-renderable-webgl",ou="snorm16-renderable-webgl",nu="float16-renderable-webgl",Ba="float32-renderable-webgl",XR="rgb9e5ufloat-renderable-webgl",La={"float32-renderable-webgl":{extensions:[H_]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[j_]},"norm16-webgl":{extensions:[$R]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[j_]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[_o,yo,Di,Fi]},"texture-compression-bc5-webgl":{extensions:[Di]},"texture-compression-bc7-webgl":{extensions:[Fi]},"texture-compression-etc2":{extensions:[VR]},"texture-compression-astc":{extensions:[zR]},"texture-compression-etc1-webgl":{extensions:[WR]},"texture-compression-pvrtc-webgl":{extensions:[jR]},"texture-compression-atc-webgl":{extensions:[HR]}};Ua={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:iu},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:iu},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:nu},r16unorm:{gl:33322,rb:!0,r:su},r16snorm:{gl:36760,r:ou},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:iu},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:nu},rg16unorm:{gl:33324,r:su},rg16snorm:{gl:36761,r:ou},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Ba},rgb9e5ufloat:{gl:35901,r:XR},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Ba},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:nu},rgba16unorm:{gl:32859,rb:!0,r:su},rgba16snorm:{gl:36763,r:ou},"rgb32float-webgl":{gl:34837,x:H_,r:Ba,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Ba},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:_o},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:yo},"bc1-rgba-unorm":{gl:33777,x:_o},"bc1-rgba-unorm-srgb":{gl:35916,x:yo},"bc2-rgba-unorm":{gl:33778,x:_o},"bc2-rgba-unorm-srgb":{gl:35918,x:yo},"bc3-rgba-unorm":{gl:33779,x:_o},"bc3-rgba-unorm-srgb":{gl:35919,x:yo},"bc4-r-unorm":{gl:36283,x:Di},"bc4-r-snorm":{gl:36284,x:Di},"bc5-rg-unorm":{gl:36285,x:Di},"bc5-rg-snorm":{gl:36286,x:Di},"bc6h-rgb-ufloat":{gl:36495,x:Fi},"bc6h-rgb-float":{gl:36494,x:Fi},"bc7-rgba-unorm":{gl:36492,x:Fi},"bc7-rgba-unorm-srgb":{gl:36493,x:Fi},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var K_,Va,q_=E(()=>{F();mo();Bi();K_={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"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"},Va=class extends Qi{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,Ge(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),$_(e)&&au(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(K_),...Object.keys(La)]}getWebGLFeature(e){let r=K_[e];return Boolean(typeof r=="string"?Ge(this.gl,r,this.extensions):r)}}});var za,Q_=E(()=>{F();za=class extends qi{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 maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function qR(t){return t<34069?t+34069:t}function QR(t){switch(t){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${t}`}}var gt,Wa=E(()=>{F();Bi();gt=class extends rt{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let i=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),i||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r<this.colorAttachments.length;++r){let i=this.colorAttachments[r];if(i){let s=36064+r;this._attachTextureView(s,i)}}if(this.depthStencilAttachment){let r=Z_(this.depthStencilAttachment.props.format);this._attachTextureView(r,this.depthStencilAttachment)}if(this.device.props.debug){let r=this.gl.checkFramebufferStatus(36160);if(r!==36053)throw new Error(`Framebuffer ${QR(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:i}=this.device,{texture:s}=r,o=r.props.baseMipLevel,n=r.props.baseArrayLayer;switch(i.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:i.framebufferTextureLayer(36160,e,s.handle,o,n);break;case 34067:let a=qR(n);i.framebufferTexture2D(36160,e,a,s.handle,o);break;case 3553:i.framebufferTexture2D(36160,e,3553,s.handle,o);break;default:throw new Error("Illegal texture type")}i.bindTexture(s.glTarget,null)}}});var ja,G_=E(()=>{F();Wa();ja=class extends ti{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new gt(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Ha,J_=E(()=>{F();Ha=class extends es{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,r={}){super(r),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let o=this.canvas.getContext("2d");if(!o)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=o,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[r,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(r!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(e)}}});function e0(t="id"){cu[t]=cu[t]||1;let e=cu[t]++;return`${t}-${e}`}var cu,t0=E(()=>{cu={}});function GR(t){return t&D.INDEX?34963:t&D.VERTEX?34962:t&D.UNIFORM?35345:34962}function JR(t){return t&D.INDEX||t&D.VERTEX?35044:t&D.UNIFORM?35048:35044}var Je,$a=E(()=>{F();Je=class extends D{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=GR(this.props.usage),this.glUsage=JR(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)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,r=0,i=e.byteLength+r){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,i,this.glUsage),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,r=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),s=0,o=void 0,n=36663;this.gl.bindBuffer(n,this.handle),s!==0||o!==void 0?this.gl.bufferSubData(n,r,i,s,o):this.gl.bufferSubData(n,r,i),this.gl.bindBuffer(n,null),this._setDebugData(e,r,e.byteLength)}async mapAndWriteAsync(e,r=0,i=this.byteLength-r){let s=new ArrayBuffer(i);await e(s,"copied"),this.write(s,r)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}async mapAndReadAsync(e,r=0,i){let s=await this.readAsync(r,i);return await e(s.buffer,"copied")}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,s,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}}});function r0(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let s=i.trim(),o=i.split(":"),n=o[0]?.trim();if(o.length===2){let[d,p]=o;if(!d||!p){r.push({message:s,type:Xa(n||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:Xa(d),lineNum:0,linePos:0});continue}let[a,c,l,...f]=o;if(!a||!c||!l){r.push({message:o.slice(1).join(":").trim()||s,type:Xa(n||"info"),lineNum:0,linePos:0});continue}let h=parseInt(l,10);isNaN(h)&&(h=0);let u=parseInt(c,10);isNaN(u)&&(u=0),r.push({message:f.join(":").trim(),type:Xa(a),lineNum:h,linePos:u})}return r}function Xa(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var i0=E(()=>{});var Ya,s0=E(()=>{F();i0();Ya=class extends Zt{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?r0(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}async _compile(e){e=e.startsWith("#version ")?e:`#version 300 es
|
|
19
|
-
${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(this.handle),!this.device.props.debug){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}b.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),b.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function n0(t,e,r,i){if(i3(e))return i(t);let s=t;s.pushState();try{return e3(t,e),qe(s.gl,r),i(t)}finally{s.popState()}}function e3(t,e){let r=t,{gl:i}=r;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Wr("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let o=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,n=Wr("provokingVertex",e.provokingVertex,{first:36429,last:36430});o?.provokingVertexWEBGL(n)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let o=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,n=Wr("polygonMode",e.polygonMode,{fill:6914,line:6913});o?.polygonModeWEBGL(1028,n),o?.polygonModeWEBGL(1029,n)}e.polygonOffsetLine&&i.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(r3("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(Ka("depthCompare",e.depthCompare))),e.stencilWriteMask){let s=e.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&b.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let s=e.stencilReadMask||4294967295,o=Ka("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,o,0,s),i.stencilFuncSeparate(1029,o,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let s=lu("stencilPassOperation",e.stencilPassOperation),o=lu("stencilFailOperation",e.stencilFailOperation),n=lu("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,o,n,s),i.stencilOpSeparate(1029,o,n,s)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let s=o0("blendColorOperation",e.blendColorOperation||"add"),o=o0("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(s,o);let n=Za("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Za("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=Za("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=Za("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(n,a,c,l)}}function Ka(t,e){return Wr(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function lu(t,e){return Wr(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function o0(t,e){return Wr(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Za(t,e,r="color"){return Wr(t,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function t3(t,e){return`Illegal parameter ${e} for ${t}`}function Wr(t,e,r){if(!(e in r))throw new Error(t3(t,e));return r[e]}function r3(t,e){return e}function i3(t){let e=!0;for(let r in t){e=!1;break}return e}var fu=E(()=>{F();Ni()});function qa(t){let e={};return t.addressModeU&&(e[10242]=hu(t.addressModeU)),t.addressModeV&&(e[10243]=hu(t.addressModeV)),t.addressModeW&&(e[32882]=hu(t.addressModeW)),t.magFilter&&(e[10240]=uu(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=s3(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=Ka("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function hu(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function uu(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function s3(t,e="none"){if(!e)return uu(t);switch(e){case"none":return uu(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}var du=E(()=>{fu()});var Qa,a0=E(()=>{F();du();Qa=class extends Ne{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=qa(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,i]of Object.entries(e)){let s=Number(r);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,i);break;default:this.device.gl.samplerParameteri(this.handle,s,i);break}}}}});function mt(t,e,r){if(o3(e))return r(t);let{nocatch:i=!0}=e,s=Qe.get(t);s.push(),qe(t,e);let o;if(i)o=r(t),s.pop();else try{o=r(t)}finally{s.pop()}return o}function o3(t){for(let e in t)return!1;return!0}var Ga=E(()=>{Ni();tu()});var _t,pu=E(()=>{F();_t=class extends Yt{device;gl;handle;texture;constructor(e,r){super(e,{...U.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function Ja(t){return n3[t]}var n3,gu=E(()=>{n3={[5124]:"sint32",[5125]:"uint32",[5122]:"sint16",[5123]:"uint16",[5120]:"sint8",[5121]:"uint8",[5126]:"float32",[5131]:"float16",[33635]:"uint16",[32819]:"uint16",[32820]:"uint16",[33640]:"uint32",[35899]:"uint32",[35902]:"uint32",[34042]:"uint32",[36269]:"uint32"}});function a3(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function c3(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function l3(t){switch(t){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(t)}function ec(t,e,r){return e==="cube"?34069+r:t}var yt,tc=E(()=>{F();Bi();du();Ga();pu();gu();F();yt=class extends U{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,r){super(e,r,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=ka(this.props.format);this.glTarget=l3(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:s,width:o,height:n,depth:a,mipLevels:c,glTarget:l,glInternalFormat:f}=this;if(!this.compressed)switch(s){case"2d":case"cube":this.gl.texStorage2D(l,c,f,o,n);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,f,o,n,a);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new _t(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new _t(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let r=qa(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(e){let r=this._normalizeCopyExternalImageOptions(e);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:s}=this,{image:o,depth:n,mipLevel:a,x:c,y:l,z:f,width:h,height:u}=r,d=ec(this.glTarget,this.dimension,f),p=r.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),mt(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,h,u,i,s,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,f,h,u,n,i,s,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},r){let i=this._getSupportedColorReadOptions(e),s=this.computeMemoryLayout(i),o=r||this.device.createBuffer({byteLength:s.byteLength,usage:D.COPY_DST|D.MAP_READ});if(o.byteLength<s.byteLength)throw new Error(`${this} readBuffer target is too small (${o.byteLength} < ${s.byteLength})`);let n=o;this.gl.bindBuffer(35051,n.handle);try{this._readColorTextureLayers(i,s,a=>{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,a)})}finally{this.gl.bindBuffer(35051,null)}return o}async readDataAsync(e={}){let r=this.readBuffer(e),i=await r.readAsync();return r.destroy(),i.buffer}writeBuffer(e,r={}){let i=this._normalizeTextureWriteOptions(r),{width:s,height:o,depthOrArrayLayers:n,mipLevel:a,byteOffset:c,x:l,y:f,z:h}=i,{glFormat:u,glType:d,compressed:p}=this,g=ec(this.glTarget,this.dimension,h);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),_=m?i.bytesPerRow/m:void 0,T={[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),mt(this.gl,T,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,f,s,o,u,d,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,f,h,s,o,n,u,d,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,r={}){let i=this._normalizeTextureWriteOptions(r),s=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:o,height:n,depthOrArrayLayers:a,mipLevel:c,x:l,y:f,z:h,byteOffset:u}=i,{glFormat:d,glType:p,compressed:g}=this,m=ec(this.glTarget,this.dimension,h),_;if(!g){let{bytesPerPixel:w}=this.device.getTextureFormatInfo(this.format);w&&(_=i.bytesPerRow/w)}let T=this.compressed?{}:{[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage},y=c3(s,u),x=g?a3(s,u):s,S=this._getMipLevelSize(c),A=l===0&&f===0&&h===0&&o===S.width&&n===S.height&&a===S.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),mt(this.gl,T,()=>{switch(this.dimension){case"2d":case"cube":g?A?this.gl.compressedTexImage2D(m,c,d,o,n,0,x):this.gl.compressedTexSubImage2D(m,c,l,f,o,n,d,x):this.gl.texSubImage2D(m,c,l,f,o,n,d,p,s,y);break;case"2d-array":case"3d":g?A?this.gl.compressedTexImage3D(m,c,d,o,n,a,0,x):this.gl.compressedTexSubImage3D(m,c,l,f,h,o,n,a,d,x):this.gl.texSubImage3D(m,c,l,f,h,o,n,a,d,p,s,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let r=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(r),s=Ja(this.glType),o=Et(s),n=new o(i.byteLength/o.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,i,a=>{let c=new o(n.buffer,n.byteOffset+a,i.bytesPerImage/o.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),n.buffer}_readColorTextureLayers(e,r,i){let s=this._getFramebuffer(),o=r.bytesPerRow/r.bytesPerPixel,n={[3333]:this.byteAlignment,...o!==e.width?{[3330]:o}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,s.handle);try{this.gl.readBuffer(36064),mt(this.gl,n,()=>{for(let l=0;l<e.depthOrArrayLayers;l++)this._attachReadSubresource(s,e.mipLevel,e.z+l),i(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,r,i){let s=`${r}:${i}`;if(this._framebufferAttachmentKey!==s){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,ec(this.glTarget,this.dimension,i),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,i);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let o=Number(this.gl.checkFramebufferStatus(36160));if(o!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${o})`)}this._framebufferAttachmentKey=s}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(b.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(i){b.warn(`Error generating mipmap for ${this}: ${i.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){b.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,i]of Object.entries(e)){let s=Number(r),o=i;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,null),e}}});function c0(t,e,r,i){let s=t,o=i;o===!0&&(o=1),o===!1&&(o=0);let n=typeof o=="number"?[o]:o;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,i);case 5126:return t.uniform1fv(e,n);case 35664:return t.uniform2fv(e,n);case 35665:return t.uniform3fv(e,n);case 35666:return t.uniform4fv(e,n);case 5124:return t.uniform1iv(e,n);case 35667:return t.uniform2iv(e,n);case 35668:return t.uniform3iv(e,n);case 35669:return t.uniform4iv(e,n);case 35670:return t.uniform1iv(e,n);case 35671:return t.uniform2iv(e,n);case 35672:return t.uniform3iv(e,n);case 35673:return t.uniform4iv(e,n);case 5125:return s.uniform1uiv(e,n,1);case 36294:return s.uniform2uiv(e,n,2);case 36295:return s.uniform3uiv(e,n,3);case 36296:return s.uniform4uiv(e,n,4);case 35674:return t.uniformMatrix2fv(e,!1,n);case 35675:return t.uniformMatrix3fv(e,!1,n);case 35676:return t.uniformMatrix4fv(e,!1,n);case 35685:return s.uniformMatrix2x3fv(e,!1,n);case 35686:return s.uniformMatrix2x4fv(e,!1,n);case 35687:return s.uniformMatrix3x2fv(e,!1,n);case 35688:return s.uniformMatrix3x4fv(e,!1,n);case 35689:return s.uniformMatrix4x2fv(e,!1,n);case 35690:return s.uniformMatrix4x3fv(e,!1,n)}throw new Error("Illegal uniform")}var l0=E(()=>{});function f0(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(t)}}function h0(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(t)}}var mu=E(()=>{});function f3(t,e){let r={...t,attributes:t.attributes.map(i=>({...i}))};for(let i of e?.attributes||[]){let s=r.attributes.find(o=>o.name===i.name);s?(s.type=i.type||s.type,s.stepMode=i.stepMode||s.stepMode):b.warn(`shader layout attribute ${i.name} not present in shader`)}return r}var rc,u0=E(()=>{F();fu();l0();$a();Wa();tc();pu();mu();rc=class extends we{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,r){super(e,r),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=i.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?f3(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,r){for(let[i,s]of Object.entries(e)){let o=this.shaderLayout.bindings.find(n=>n.name===i)||this.shaderLayout.bindings.find(n=>n.name===`${i}Uniforms`);if(!o){let n=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||b.warn(`No binding "${i}" in render pipeline "${this.id}", expected one of ${n}`,s)();continue}switch(s||b.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof Je)&&!(s.buffer instanceof Je))throw new Error("buffer value");break;case"texture":if(!(s instanceof _t||s instanceof yt||s instanceof gt))throw new Error(`${this} Bad texture binding for ${i}`);break;case"sampler":b.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(o.type)}this.bindings[i]=s}}draw(e){this._syncLinkStatus();let{renderPass:r,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:n,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:f,bindings:h=this.bindings,uniforms:u=this.uniforms}=e,d=f0(s),p=Boolean(o.indexBuffer),g=o.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return b.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(h))return b.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(r),f&&f.begin(this.props.topology),this._applyBindings(h,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(u);let m=r;return n0(this.device,i,m.glParameters,()=>{p&&c?this.device.gl.drawElementsInstanced(d,n||0,g,l,a||0):p?this.device.gl.drawElements(d,n||0,g,l):c?this.device.gl.drawArraysInstanced(d,l,n||0,a||0):this.device.gl.drawArrays(d,l,n||0),f&&f.end()}),o.unbindAfterRender(r),!0}_areTexturesRenderable(e){let r=!0;for(let i of this.shaderLayout.bindings)!e[i.name]&&!e[i.name.replace(/Uniforms$/,"")]&&(b.warn(`Binding ${i.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(e,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let s=0,o=0;for(let n of this.shaderLayout.bindings){let a=e[n.name]||e[n.name.replace(/Uniforms$/,"")];if(!a)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":let{name:c}=n,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);i.uniformBlockBinding(this.handle,l,o),a instanceof Je?i.bindBufferBase(35345,o,a.handle):i.bindBufferRange(35345,o,a.buffer.handle,a.offset||0,a.size||a.buffer.byteLength-a.offset),o+=1;break;case"texture":if(!(a instanceof _t||a instanceof yt||a instanceof gt))throw new Error("texture");let f;if(a instanceof _t)f=a.texture;else if(a instanceof yt)f=a;else if(a instanceof gt&&a.colorAttachments[0]instanceof _t)b.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+s),i.bindTexture(f.glTarget,f.handle),s+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let r of this.shaderLayout.uniforms||[]){let{name:i,location:s,type:o,textureUnit:n}=r,a=e[i]??n;a!==void 0&&c0(this.device.gl,s,o,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function d0(t){return u3[t]}function ic(t){return h3[t]}function sc(t){return Boolean(g0[t])}function p0(t){return g0[t]}var h3,g0,u3,oc=E(()=>{h3={[5126]:"f32",[35664]:"vec2<f32>",[35665]:"vec3<f32>",[35666]:"vec4<f32>",[5124]:"i32",[35667]:"vec2<i32>",[35668]:"vec3<i32>",[35669]:"vec4<i32>",[5125]:"u32",[36294]:"vec2<u32>",[36295]:"vec3<u32>",[36296]:"vec4<u32>",[35670]:"f32",[35671]:"vec2<f32>",[35672]:"vec3<f32>",[35673]:"vec4<f32>",[35674]:"mat2x2<f32>",[35685]:"mat2x3<f32>",[35686]:"mat2x4<f32>",[35687]:"mat3x2<f32>",[35675]:"mat3x3<f32>",[35688]:"mat3x4<f32>",[35689]:"mat4x2<f32>",[35690]:"mat4x3<f32>",[35676]:"mat4x4<f32>"},g0={[35678]:{viewDimension:"2d",sampleType:"float"},[35680]:{viewDimension:"cube",sampleType:"float"},[35679]:{viewDimension:"3d",sampleType:"float"},[35682]:{viewDimension:"3d",sampleType:"depth"},[36289]:{viewDimension:"2d-array",sampleType:"float"},[36292]:{viewDimension:"2d-array",sampleType:"depth"},[36293]:{viewDimension:"cube",sampleType:"float"},[36298]:{viewDimension:"2d",sampleType:"sint"},[36299]:{viewDimension:"3d",sampleType:"sint"},[36300]:{viewDimension:"cube",sampleType:"sint"},[36303]:{viewDimension:"2d-array",sampleType:"uint"},[36306]:{viewDimension:"2d",sampleType:"uint"},[36307]:{viewDimension:"3d",sampleType:"uint"},[36308]:{viewDimension:"cube",sampleType:"uint"},[36311]:{viewDimension:"2d-array",sampleType:"uint"}},u3={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function m0(t,e){let r={attributes:[],bindings:[]};r.attributes=d3(t,e);let i=m3(t,e);for(let a of i){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let s=g3(t,e),o=0;for(let a of s)if(sc(a.type)){let{viewDimension:c,sampleType:l}=p0(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:o,viewDimension:c,sampleType:l}),a.textureUnit=o,o+=1}s.length&&(r.uniforms=s);let n=p3(t,e);return n?.length&&(r.varyings=n),r}function d3(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let s=0;s<i;s++){let o=t.getActiveAttrib(e,s);if(!o)throw new Error("activeInfo");let{name:n,type:a}=o,c=t.getAttribLocation(e,n);if(c>=0){let l=ic(a),f=/instance/i.test(n)?"instance":"vertex";r.push({name:n,location:c,stepMode:f,type:l})}}return r.sort((s,o)=>s.location-o.location),r}function p3(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let s=0;s<i;s++){let o=t.getTransformFeedbackVarying(e,s);if(!o)throw new Error("activeInfo");let{name:n,type:a,size:c}=o,l=ic(a),{type:f,components:h}=rs(l);r.push({location:s,name:n,type:f,size:c*h})}return r.sort((s,o)=>s.location-o.location),r}function g3(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let s=0;s<i;s++){let o=t.getActiveUniform(e,s);if(!o)throw new Error("activeInfo");let{name:n,size:a,type:c}=o,{name:l,isArray:f}=_3(n),h=t.getUniformLocation(e,l),u={location:h,name:l,size:a,type:c,isArray:f};if(r.push(u),u.size>1)for(let d=0;d<u.size;d++){let p=`${l}[${d}]`;h=t.getUniformLocation(e,p);let g={...u,name:p,location:h};r.push(g)}}return r}function m3(t,e){let r=(o,n)=>t.getActiveUniformBlockParameter(e,o,n),i=[],s=t.getProgramParameter(e,35382);for(let o=0;o<s;o++){let n={name:t.getActiveUniformBlockName(e,o)||"",location:r(o,35391),byteLength:r(o,35392),vertex:r(o,35396),fragment:r(o,35398),uniformCount:r(o,35394),uniforms:[]},a=r(o,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),h=t.getActiveUniforms(e,a,35388);for(let u=0;u<n.uniformCount;++u){let d=a[u];if(d!==void 0){let p=t.getActiveUniform(e,d);if(!p)throw new Error("activeInfo");let g=ic(c[u]);n.uniforms.push({name:p.name,format:g,type:c[u],arrayLength:l[u],byteOffset:f[u],byteStride:h[u]})}}i.push(n)}return i.sort((o,n)=>o.location-n.location),i}function _3(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:yr(r?.[1],`Failed to parse GLSL uniform name ${t}`),length:r?.[2]?1:0,isArray:Boolean(r?.[2])}}var _0=E(()=>{F();oc()});var y0,nc,T0=E(()=>{F();_0();oc();y0=4,nc=class extends ts{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(e,r){super(e,r),this.device=e,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders(),b.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=m0(this.device.gl,this.handle),b.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),b.time(y0,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),b.timeEnd(y0,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}b.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),b.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(e){switch(e){case"success":return;default:let r=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=e.getProgramParameter(this.handle,35718);for(let s=0;s<i;s++){let o=e.getActiveUniform(this.handle,s);if(o&&sc(o.type)){let n=o.name.endsWith("[0]"),a=n?o.name.slice(0,-3):o.name,c=e.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,o,n,r))}}}_assignSamplerUniform(e,r,i,s){let{gl:o}=this.device;if(i&&r.size>1){let n=Int32Array.from({length:r.size},(a,c)=>s+c);return o.uniform1iv(e,n),s+r.size}return o.uniform1i(e,s),s+1}async _waitForLinkComplete(){let e=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function y3(t,e){let r=e.sourceBuffer,i=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function T3(t,e){throw new Error("Not implemented")}function b3(t,e){let{sourceTexture:r,mipLevel:i=0,aspect:s="all",width:o=e.sourceTexture.width,height:n=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:h,rowsPerImage:u}=e;if(s!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==0||h||u)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=b0(r),g;try{let m=l,_=o||d.width,T=n||d.height,y=yr(d.colorAttachments[0]),x=ka(y.texture.props.format),S=x.format,A=x.type;t.gl.bindBuffer(35051,m.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],_,T,S,A,f)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function x3(t,e){let{sourceTexture:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:o=[0,0,0],destinationTexture:n}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:f}=b0(r),[h=0,u=0]=s,[d,p,g]=o,m=t.gl.bindFramebuffer(36160,l.handle),_,T;if(n instanceof yt)_=n,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),T=_.glTarget;else throw new Error("invalid destination");switch(T){case 3553:case 34067:t.gl.copyTexSubImage2D(T,i,d,p,h,u,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(T,i,d,p,g,h,u,a,c);break;default:}_&&_._unbind(),t.gl.bindFramebuffer(36160,m),f&&l.destroy()}function b0(t){if(t instanceof U){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var ac,x0=E(()=>{F();tc();Bi();ac=class extends ii{device;handle=null;commands=[];constructor(e,r={}){super(e,r),this.device=e}_executeCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":y3(this.device,r.options);break;case"copy-buffer-to-texture":T3(this.device,r.options);break;case"copy-texture-to-buffer":b3(this.device,r.options);break;case"copy-texture-to-texture":x3(this.device,r.options);break;default:throw new Error(r.name)}}}});var A3,cc,A0=E(()=>{F();Ga();Ni();A3=[1,2,4,8],cc=class extends Rt{device;handle=null;glParameters={};constructor(e,r){super(e,r),this.device=e,r?.framebuffer||e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let i;if(!r?.parameters?.viewport)if(r?.framebuffer){let{width:o,height:n}=r.framebuffer;i=[0,0,o,n]}else{let[o,n]=e.getDefaultCanvasContext().getDrawingBufferSize();i=[0,0,o,n]}this.device.pushState(),this.setParameters({viewport:i,...this.props.parameters});let s=this.props.framebuffer;if(this.props.framebuffer&&s?.handle){let o=this.props.framebuffer.colorAttachments.map((n,a)=>36064+a);this.device.gl.drawBuffers(o)}else this.props.framebuffer||this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference!==void 0&&(r[2967]=e.stencilReference,r[36003]=e.stencilReference),"colorMask"in e&&(r.colorMask=A3.map(i=>Boolean(i&e.colorMask))),this.glParameters=r,qe(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((i,s)=>{i&&this.clearColorBuffer(s,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,e.clearStencil=this.props.clearStencil),r!==0&&mt(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){mt(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var To,S0=E(()=>{F();x0();A0();To=class extends ri{device;handle=null;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new ac(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new cc(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,i){}writeTimestamp(e,r){e.writeTimestamp(r)}}});function E0(t){let{target:e,source:r,start:i=0,count:s=1}=t,o=r.length,n=s*o,a=0;for(let c=i;a<o;a++)e[c++]=r[a]??0;for(;a<n;)a<n-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+n-a),a=n);return t.target}var w0=E(()=>{});function S3(t){return Array.isArray(t)?new Float32Array(t):t}function E3(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Li,R0=E(()=>{F();Wt();ru();w0();Li=class extends si{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Xc()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:o,stride:n,offset:a,normalized:c,integer:l,divisor:f}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,s,o,n,a):this.device.gl.vertexAttribPointer(e,s,o,c,n,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,f||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let i=Fa(r.bufferDataType);return{size:r.bufferComponents,type:i,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let s=Li.isConstantAttributeZeroSupported(this.device)||e!==0;(r||s)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let i=S3(r),s=i.byteLength*e,o=i.length*e;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let n=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),n||=!E3(i,this.bufferValue),n){let a=Ol(r.constructor,o);E0({target:a,source:i,start:0,count:o}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function P0(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var lc,v0=E(()=>{F();fc();mu();lc=class extends oi{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(h0(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,i]of Object.entries(e))this.setBuffer(r,i)})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:s,byteLength:o,byteOffset:n}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=s,b.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:s,byteLength:o,byteOffset:n},this.bindOnUse||this._bindBuffer(i,s,n,o)}getBuffer(e){if(P0(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return this.buffers[r]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Je)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:s}}_getVaryingIndex(e){if(P0(e))return Number(e);for(let r of this.layout.varyings||[])if(e===r.name)return r.location;return-1}_bindBuffers(){for(let[e,r]of Object.entries(this.buffers)){let{buffer:i,byteLength:s,byteOffset:o}=this._getBufferRange(r);this._bindBuffer(Number(e),i,o,s)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,s){let o=r&&r.handle;!o||s===void 0?this.gl.bindBufferBase(35982,e,o):this.gl.bindBufferRange(35982,e,o,i,s)}}});var hc,M0=E(()=>{F();hc=class extends ni{device;handle;_timestampPairs=[];_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){if(super(e,r),this.device=e,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&this.device.gl.deleteQuery(e.activeQuery.handle);for(let r of e.completedQueries)this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&this.device.gl.deleteQuery(this._occlusionQuery.handle),this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((r,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let r=e?.firstQuery||0,i=e?.queryCount||this.props.count-r;if(this._validateRange(r,i),this.props.type==="timestamp"){let s=new Array(i).fill(0n),o=Math.floor(r/2),n=Math.floor((r+i-1)/2);for(let a=o;a<=n;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,f=l+1;l>=r&&l<r+i&&(s[l-r]=0n),f>=r&&f<r+i&&(s[f-r]=c)}return s}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||r>=this.props.count||r<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||r!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(e),i=this._timestampPairs[r];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let s=this.device.gl.createQuery();if(!s)throw new Error("WebGL query not supported");let o={handle:s,promise:null,result:null,disjoint:!1};this.device.gl.beginQuery(35007,s),i.activeQuery=o;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,r){if(e<0||r<0||e+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let r=this._timestampPairs[e];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(e){if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=Boolean(this.device.gl.getParameter(36795));return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let r=this._timestampPairs[e];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=r.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(e.promise=new Promise((r,i)=>{let s=()=>{if(!this._pollQueryAvailability(e)){requestAnimationFrame(s);return}e.promise=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):r(e.result||0n)};s()})),e.promise}}});var uc,C0=E(()=>{F();uc=class extends ai{device;gl;handle;signaled;_signaled=!1;constructor(e,r={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(s=>{let o=()=>{let n=this.gl.clientWaitSync(this.handle,0,0);n===this.gl.ALREADY_SIGNALED||n===this.gl.CONDITION_SATISFIED?(this._signaled=!0,s()):setTimeout(o,1)};o()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function _u(t){switch(t){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function I0(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var O0=E(()=>{});function N0(t,e){let{sourceX:r=0,sourceY:i=0,sourceAttachment:s=0}=e||{},{target:o=null,sourceWidth:n,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{},{framebuffer:h,deleteFramebuffer:u}=F0(t),{gl:d,handle:p}=h;n||=h.width,a||=h.height;let g=h.colorAttachments[s]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${s}`);c=g?.depth||1,l||=g?.glFormat||6408,f||=g?.glType||5121,o=R3(o,f,l,n,a,c);let m=_r(o);f=f||d0(m);let _=d.bindFramebuffer(36160,p);return d.readBuffer(36064+s),d.readPixels(r,i,n,a,l,f,o),d.readBuffer(36064),d.bindFramebuffer(36160,_||null),u&&h.destroy(),o}function D0(t,e){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:o=6408,targetByteOffset:n=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:f,deleteFramebuffer:h}=F0(t);a=a||f.width,c=c||f.height;let u=f;l=l||5121;let d=r;if(!d){let g=_u(o),m=I0(l),_=n+a*c*g*m;d=u.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[i,s],destinationBuffer:d,byteOffset:n}),p.destroy(),h&&f.destroy(),d}function F0(t){return t instanceof rt?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:w3(t),deleteFramebuffer:!0}}function w3(t,e){let{device:r,width:i,height:s,id:o}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${o}`,width:i,height:s,colorAttachments:[t]})}function R3(t,e,r,i,s,o){if(t)return t;e||=5121;let n=Ja(e),a=Et(n),c=_u(r);return new a(i*s*c)}var B0=E(()=>{F();oc();O0();gu()});var yu={};At(yu,{WebGLDevice:()=>Tt});function P3(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:}}function v3(t,e,r){t.gl.vertexAttribI4iv(e,r)}function M3(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function C3(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Tt,dc=E(()=>{F();tu();k_();Oa();W_();q_();Q_();G_();J_();Kh();qh();Bi();t0();$a();s0();a0();tc();Wa();u0();T0();S0();R0();v0();M0();C0();B0();Ni();Ga();mo();Tt=class extends be{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||e0("webgl-device")});let r=be._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=r.canvas?.gl??null,s=Tt.getDeviceFromContext(i);if(s)throw new Error(`WebGL context already attached to device ${s.id}`);this.canvasContext=new ja(this,r),this.lost=new Promise(f=>{this._resolveContextLost=f});let o={...e.webgl};r.alphaMode==="premultiplied"&&(o.premultipliedAlpha=!0),e.powerPreference!==void 0&&(o.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(o.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||U_(this.canvasContext.canvas,{onContextLost:f=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:f=>console.log("WebGL context restored")},o);if(!a)throw new Error("WebGL context creation failed");if(s=Tt.getDeviceFromContext(a),s){if(e._reuseDevices)return b.log(1,`Not creating a new Device, instead returning a reference to Device ${s.id} already attached to WebGL context`,s)(),this.canvasContext.destroy(),s._reused=!0,s;throw new Error(`WebGL context already attached to device ${s.id}`)}this.handle=a,this.gl=a,this.spectorJS=S_({...this.props,gl:this.handle});let c=zr(this.handle);c.device=this,this.extensions=c.extensions||(c.extensions={}),this.info=V_(this.gl,this.extensions),this.limits=new za(this.gl),this.features=new Va(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Qe(this.gl,{log:(...f)=>b.log(1,...f)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=P_(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),b.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(b.level=Math.max(b.level,1)),this.commandEncoder=new To(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=zr(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new Ha(this,e||{})}createBuffer(e){let r=this._normalizeBufferProps(e);return new Je(this,r)}createTexture(e){return new yt(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new Qa(this,e)}createShader(e){return new Ya(this,e)}createFramebuffer(e){return new gt(this,e)}createVertexArray(e){return new Li(this,e)}createTransformFeedback(e){return new lc(this,e)}createQuerySet(e){return new hc(this,e)}createFence(){return new uc(this)}createRenderPipeline(e){return new rc(this,e)}_createSharedRenderPipelineWebGL(e){return new nc(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new To(this,e)}submit(e){let r=null;e||(r=this.commandEncoder,e=r.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:r.props.id,timeProfilingQuerySet:r.getTimeProfilingQuerySet()}));try{e._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}readPixelsToArrayWebGL(e,r){return N0(e,r)}readPixelsToBufferWebGL(e,r){return D0(e,r)}setParametersWebGL(e){qe(this.gl,e)}getParametersWebGL(e){return Da(this.gl,e)}withParametersWebGL(e,r){return mt(this.gl,e,r)}resetWebGL(){b.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),N_(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return Y_(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Qe.get(this.gl).push()}popState(){Qe.get(this.gl).pop()}getGLKey(e,r){let i=Number(e);for(let s in this.gl)if(this.gl[s]===i)return`GL.${s}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[s,o])=>(i[`${s}:${this.getGLKey(s,r)}`]=`${o}:${this.getGLKey(o,r)}`,i),{})}setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let s=this._constants[e];switch(s&&C3(s,r)&&b.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:P3(this,e,r);break;case Int32Array:v3(this,e,r);break;case Uint32Array:M3(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return Ge(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,r,i){e.luma=r;let s={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=s}}});function I3(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&typeof t.createVertexArray=="function")}var bo,Tu,xo,L0=E(()=>{F();b_();Kh();qh();bo=1,Tu=class extends Gi{type="webgl";constructor(){super(),be.defaultProps={...be.defaultProps,...Na}}enforceWebGL2(e){T_(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&b.warn("WebGL1 is not supported",e)(),!1)}async attach(e,r={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(dc(),yu));if(e instanceof i)return e;let s=i.getDeviceFromContext(e);if(s)return s;if(!I3(e))throw new Error("Invalid WebGL2RenderingContext");let o=r.createCanvasContext===!0?{}:r.createCanvasContext;return new i({...r,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...o}})}async create(e={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(dc(),yu)),i=[];(e.debugWebGL||e.debug)&&i.push(R_()),e.debugSpectorJS&&i.push(A_(e));let s=await Promise.allSettled(i);for(let o of s)o.status==="rejected"&&b.error(`Failed to initialize debug libraries ${o.reason}`)();try{let o=new r(e);b.groupCollapsed(bo,`WebGLDevice ${o.id} created`)();let n=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return b.probe(bo,n)(),b.table(bo,o.info)(),o}finally{b.groupEnd(bo)(),b.info(bo,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};xo=new Tu});var fc=E(()=>{L0();dc();$a()});var BP={};At(BP,{AmbientLight:()=>wi,Attribute:()=>zt,AttributeManager:()=>jr,COORDINATE_SYSTEM:()=>k,CompositeLayer:()=>fy,Controller:()=>Te,Deck:()=>pc,DeckGL:()=>zo,DeckRenderer:()=>Vr,DirectionalLight:()=>Nt,FirstPersonController:()=>Xr,FirstPersonView:()=>uy,FirstPersonViewport:()=>Nc,FlyToInterpolator:()=>ko,Layer:()=>Rc,LayerExtension:()=>Ty,LayerManager:()=>Lr,LightingEffect:()=>ar,LinearInterpolator:()=>ce,MapController:()=>kr,MapView:()=>Ra,OPERATION:()=>Nm,OrbitController:()=>Yr,OrbitView:()=>dy,OrbitViewport:()=>Mc,OrthographicController:()=>Zr,OrthographicView:()=>gy,OrthographicViewport:()=>Ic,PointLight:()=>Mi,PostProcessEffect:()=>to,TRANSITION_EVENTS:()=>oo,Tesselator:()=>Vo,TransitionInterpolator:()=>Ut,UNIT:()=>sr,VERSION:()=>Zn,View:()=>ye,Viewport:()=>Se,WebMercatorViewport:()=>cr,Widget:()=>hr,_CameraLight:()=>Gs,_Component:()=>Vi,_ComponentState:()=>Hr,_GlobeController:()=>Kr,_GlobeView:()=>yy,_GlobeViewport:()=>Ii,_LayersPass:()=>$e,_PickLayersPass:()=>Dt,_SunLight:()=>Js,_applyStyles:()=>ho,_compareProps:()=>Sc,_count:()=>Ec,_deepEqual:()=>K,_fillArray:()=>Ta,_flatten:()=>fr,_memoize:()=>Be,_mergeShaders:()=>Oo,_registerLoggers:()=>Yn,_removeStyles:()=>Ca,assert:()=>Y,color:()=>bh,createIterable:()=>Ui,fp64LowPart:()=>kh,getShaderAssembler:()=>da,gouraudMaterial:()=>us,log:()=>L,phongMaterial:()=>ds,picking:()=>Lh,project:()=>or,project32:()=>Ih,shadow:()=>Ei});var Uf={};At(Uf,{Buffer:()=>D,BufferTransform:()=>ze,CubeGeometry:()=>xs,Device:()=>be,Framebuffer:()=>rt,Geometry:()=>We,GroupNode:()=>Qt,Model:()=>Pe,ModelNode:()=>bs,ScenegraphNode:()=>st,SphereGeometry:()=>As,Texture:()=>U,TextureTransform:()=>ys,attachDevice:()=>MA,createDevice:()=>CA,enforceWebGL2:()=>IA,getSupportedAdapters:()=>PA,setDefaultDeviceProps:()=>vA,stats:()=>RA});F();F();var UT=1,kT=1,xr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:i=Number.POSITIVE_INFINITY,rate:s=1,repeat:o=1}=e,n=UT++,a={time:0,delay:r,duration:i,rate:s,repeat:o};return this._setChannelTime(a,this.time),this.channels.set(n,a),n}removeChannel(e){this.channels.delete(e);for(let[r,i]of this.animations)i.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let s of r)this._setChannelTime(s,this.time);let i=this.animations.values();for(let s of i){let{animation:o,channel:n}=s;o.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=kT++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let i=r-e.delay,s=e.duration*e.repeat;i>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};F();function Zd(t){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function Kd(t){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}Wi();var VT=0,zT="Animation Loop",Dl=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...Dl.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Oe({id:`animation-loop-${VT++}`}),this.sharedStats=Xt.stats.get(zT),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport}),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),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Zd(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Kd(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let r=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:r,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&r>0?e/r:1;return{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let r=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=r-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let r=this.sharedStats.get(e.name,e.type);r.sampleSize=e.sampleSize,r.time=e.time,r.count=e.count,r.samples=e.samples,r.lastTiming=e.lastTiming,r.lastSampleTime=e.lastSampleTime,r.lastSampleCount=e.lastSampleCount,r._count=e._count,r._time=e._time,r._samples=e._samples,r._startTime=e._startTime,r._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},ci=Dl;P(ci,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});F();function ss(t,e){if(!t){let r=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,ss),r}}var Fl={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function Qd(t){let e={};for(let[r,i]of Object.entries(t))e[r]=WT(i);return e}function WT(t){let e=qd(t);if(e!=="object")return{value:t,...Fl[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...Fl[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=qd(t.value),{...t,...Fl[e],type:e}):{type:"object",value:null};throw new Error("props")}function qd(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var Gd=`#ifdef MODULE_LOGDEPTH
|
|
18
|
+
<code><pre>${o}</pre></code>`,n&&(a.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${n}</pre></code>`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}},Gt=Il;P(Gt,"defaultProps",{...D.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var Nl,nt,Gd=E(()=>{ae();vl();De();Nl=class extends D{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,Nl.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(s=>s.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:r,depthStencilAttachment:i})}resize(e){let r=!e;if(e){let[i,s]=Array.isArray(e)?e:[e.width,e.height];r=r||s!==this.height||i!==this.width,this.width=i,this.height=s}r&&(x.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,i)=>{if(typeof r=="string"){let s=this.createColorTexture(r,i);return this.attachResource(s),s.view}return r instanceof B?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof B?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){if(this.colorAttachments.forEach((i,s)=>{let o=i.texture.clone({width:e,height:r});this.destroyAttachedResource(i),this.colorAttachments[s]=o.view,this.attachResource(o.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}},nt=Nl;P(nt,"defaultProps",{...D.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var Dl,Re,Bl=E(()=>{ae();Dl=class extends D{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,r){super(e,r,Dl.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}},Re=Dl;P(Re,"defaultProps",{...D.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0})});var ns,Qd=E(()=>{ae();ns=class extends D{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,r){super(e,r,{...D.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Fl,si,Jd=E(()=>{ae();Fl=class extends D{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,Fl.defaultProps),this.shaderLayout=r.shaderLayout}},si=Fl;P(si,"defaultProps",{...D.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var Ll,oi,ep=E(()=>{Jd();Bl();De();ti();Ll=class{static getDefaultPipelineFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new Ll(e),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let r={...Re.defaultProps,...e},i=this._renderPipelineCache,s=this._hashRenderPipeline(r),o=i[s]?.resource;if(o)i[s].useCount++,this.device.props.debugFactories&&x.log(3,`${this}: ${i[s].resource} reused, count=${i[s].useCount}, (id=${e.id})`)();else{let n=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;o=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:st("unnamed-cached"),_sharedRenderPipeline:n}),o.hash=s,i[s]={resource:o,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: ${o} created, count=${i[s].useCount}`)()}return o}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let r={...si.defaultProps,...e},i=this._computePipelineCache,s=this._hashComputePipeline(r),o=i[s]?.resource;return o?(i[s].useCount++,this.device.props.debugFactories&&x.log(3,`${this}: ${i[s].resource} reused, count=${i[s].useCount}, (id=${e.id})`)()):(o=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),o.hash=s,i[s]={resource:o,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: ${o} created, count=${i[s].useCount}`)()),o}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let r=this._getCache(e),i=e.hash;r[i].useCount--,r[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&x.log(3,`${this}: ${e} released and destroyed`)()):r[i].useCount<0?(x.error(`${this}: ${e} released, useCount < 0, resetting`)(),r[i].useCount=0):this.device.props.debugFactories&&x.log(3,`${this}: ${e} released, count=${r[i].useCount}`)()}createSharedRenderPipeline(e){let r=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[r];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[r]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[r];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(e){let r=this._getCache(e);return this.device.props._destroyPipelines?(delete r[e.hash],e.destroy(),e instanceof Re&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let r;if(e instanceof si&&(r=this._computePipelineCache),e instanceof Re&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return r}_hashComputePipeline(e){let{type:r}=this.device,i=this._getHash(e.shader.source),s=this._getHash(JSON.stringify(e.shaderLayout));return`${r}/C/${i}SL${s}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,s=this._getWebGLVaryingHash(e),o=this._getHash(JSON.stringify(e.shaderLayout)),n=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":let c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${r}/${i}V${s}T${e.topology}P${c}SL${o}BL${n}`;case"webgpu":default:let l=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),h=this._getWebGPUAttachmentHash(e);return`${a}/R/${r}/${i}V${s}T${e.topology}EP${l}P${f}SL${o}BL${n}A${h}`}}_hashSharedRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,s=this._getWebGLVaryingHash(e);return`webgl/S/${r}/${i}V${s}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:r=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:r,bufferMode:i}))}_getWebGPUAttachmentHash(e){let r=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:i}))}},oi=Ll;P(oi,"defaultProps",{...Re.defaultProps})});var Ul,ni,tp=E(()=>{Ol();De();Ul=class{static getDefaultShaderFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new Ul(e),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let r=this._hashShader(e),i=this._cache[r];if(i)i.useCount++,this.device.props.debugFactories&&x.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={resource:s,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: Created new shader ${s.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let r=this._hashShader(e),i=this._cache[r];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],i.resource.destroy(),this.device.props.debugFactories&&x.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&x.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},ni=Ul;P(ni,"defaultProps",{...Gt.defaultProps})});function rp(t,e,r){let i=t.bindings.find(s=>s.name===e||`${s.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!r?.ignoreWarnings&&x.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function as(t,e){if(!e)return{};if(xT(e))return Object.fromEntries(Object.entries(e).map(([s,o])=>[Number(s),{...o}]));let r={};for(let[i,s]of Object.entries(e)){let n=rp(t,i)?.group??0;r[n]||={},r[n][i]=s}return r}function pn(t){let e={};for(let r of Object.values(t))Object.assign(e,r);return e}function xT(t){let e=Object.keys(t);return e.length>0&&e.every(r=>/^\d+$/.test(r))}var ip=E(()=>{De()});var Sr,Mt,sp=E(()=>{ae();Sr=class extends D{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=Sr.normalizeProps(e,r),super(e,r,Sr.defaultProps)}static normalizeProps(e,r){return r}},Mt=Sr;P(Mt,"defaultClearColor",[0,0,0,1]),P(Mt,"defaultClearDepth",1),P(Mt,"defaultClearStencil",0),P(Mt,"defaultProps",{...D.defaultProps,framebuffer:null,parameters:void 0,clearColor:Sr.defaultClearColor,clearColors:void 0,clearDepth:Sr.defaultClearDepth,clearStencil:Sr.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var kl,ai,op=E(()=>{ae();kl=class extends D{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,r){super(e,r,kl.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let r=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),s=0n;for(let o=0;o<r;o+=2)s+=i[o+1]-i[o];this._gpuTimeMs=Number(s)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let r=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||r.timestampQuerySet!==void 0||r.beginTimestampIndex!==void 0||r.endTimestampIndex!==void 0)return r;let i=this._timeProfilingSlotCount;return i+1>=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}},ai=kl;P(ai,"defaultProps",{...D.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0})});var Vl,ci,np=E(()=>{ae();Vl=class extends D{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,Vl.defaultProps)}},ci=Vl;P(ci,"defaultProps",{...D.defaultProps})});function li(t){let e=gn(t),r=wT[e];if(!r)throw new Error(`Unsupported variable shader type: ${t}`);return r}function ap(t){let e=cp(t),r=ET[e];if(!r)throw new Error(`Unsupported attribute shader type: ${t}`);let[i,s]=r,o=i==="i32"||i==="u32",n=i!=="u32",a=ST[i]*s;return{primitiveType:i,components:s,byteLength:a,integer:o,signed:n}}function AT(t,e){return e===1?t:`vec${e}<${t}>`}function cp(t){return RT[t]||t}function gn(t){return PT[t]||t}var zl,Wl,ST,ET,wT,RT,PT,mn=E(()=>{zl=class{getVariableShaderTypeInfo(e){return li(e)}getAttributeShaderTypeInfo(e){return ap(e)}makeShaderAttributeType(e,r){return AT(e,r)}resolveAttributeShaderTypeAlias(e){return cp(e)}resolveVariableShaderTypeAlias(e){return gn(e)}};Wl=new zl,ST={f32:4,f16:2,i32:4,u32:4},ET={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},wT={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},RT={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},PT={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"}});function _n(t,e){let r={};for(let i of t.attributes){let s=vT(t,e,i.name);s&&(r[i.name]=s)}return r}function lp(t,e,r=16){let i=_n(t,e),s=new Array(r).fill(null);for(let o of Object.values(i))s[o.location]=o;return s}function vT(t,e,r){let i=MT(t,r),s=CT(e,r);if(!i)return null;let o=Wl.getAttributeShaderTypeInfo(i.type),n=Pt.getCompatibleVertexFormat(o),a=s?.vertexFormat||n,c=Pt.getVertexFormatInfo(a);return{attributeName:s?.attributeName||i.name,bufferName:s?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:o.primitiveType,shaderComponents:o.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:o.integer,stepMode:s?.stepMode||i.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function MT(t,e){let r=t.attributes.find(i=>i.name===e);return r||x.warn(`shader layout attribute "${e}" not present in shader`),r||null}function CT(t,e){IT(t);let r=OT(t,e);return r||(r=NT(t,e),r)?r:(x.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function IT(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&x.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function OT(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function NT(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let o of r.attributes||[]){let n=Pt.getVertexFormatInfo(o.format);i+=n.byteLength}let s=r.attributes?.find(o=>o.attribute===e);if(s)return{attributeName:s.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:i}}return null}var jl=E(()=>{De();mn();sn()});var Hl,fi,fp=E(()=>{jl();ae();Hl=class extends D{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,Hl.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=lp(r.shaderLayout,r.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"),this)()}},fi=Hl;P(fi,"defaultProps",{...D.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var $l,hi,hp=E(()=>{ae();$l=class extends D{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,$l.defaultProps)}},hi=$l;P(hi,"defaultProps",{...D.defaultProps,layout:void 0,buffers:{}})});var Xl,ui,up=E(()=>{ae();Xl=class extends D{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,Xl.defaultProps)}},ui=Xl;P(ui,"defaultProps",{...D.defaultProps,type:void 0,count:void 0})});var Yl,di,dp=E(()=>{ae();Yl=class extends D{get[Symbol.toStringTag](){return"Fence"}constructor(e,r={}){super(e,r,Yl.defaultProps)}},di=Yl;P(di,"defaultProps",{...D.defaultProps})});function at(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function cs(t){let[,,,,e]=DT[t];return e}var DT,Kl=E(()=>{DT={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]}});function gp(t,e={}){let r={...t},i=e.layout??"std140",s={},o=0;for(let[n,a]of Object.entries(r))o=Zl(s,n,a,o,i);return o=at(o,Qt(r,i)),{layout:i,byteLength:o*4,uniformTypes:r,fields:s}}function ls(t,e){let r=gn(t),i=li(r),s=/^mat(\d)x(\d)<.+>$/.exec(r);if(s){let n=Number(s[1]),a=Number(s[2]),c=pp(a,r,i.type,e),l=FT(c.size,c.alignment,e);return{alignment:c.alignment,size:n*l,components:n*a,columns:n,rows:a,columnStride:l,shaderType:r,type:i.type}}let o=/^vec(\d)<.+>$/.exec(r);return o?pp(Number(o[1]),r,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:i.type}}function ql(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)}function Zl(t,e,r,i,s){if(typeof r=="string"){let o=ls(r,s),n=at(i,o.alignment);return t[e]={offset:n,...o},n+o.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${e}`);let o=r[0],n=r[1],a=_p(o,s),c=at(i,Qt(r,s));for(let l=0;l<n;l++)Zl(t,`${e}[${l}]`,o,c+l*a,s);return c+a*n}if(ql(r)){let o=Qt(r,s),n=at(i,o);for(let[a,c]of Object.entries(r))n=Zl(t,`${e}.${a}`,c,n,s);return at(n,o)}throw new Error(`Unsupported CompositeShaderType for ${e}`)}function mp(t,e){if(typeof t=="string")return ls(t,e).size;if(Array.isArray(t)){let i=t[0],s=t[1];if(Array.isArray(i))throw new Error("Nested arrays are not supported");return _p(i,e)*s}let r=0;for(let i of Object.values(t)){let s=i;r=at(r,Qt(s,e)),r+=mp(s,e)}return at(r,Qt(t,e))}function Qt(t,e){if(typeof t=="string")return ls(t,e).alignment;if(Array.isArray(t)){let i=t[0],s=Qt(i,e);return yp(e)?Math.max(s,4):s}let r=1;for(let i of Object.values(t)){let s=Qt(i,e);r=Math.max(r,s)}return LT(e)?Math.max(r,4):r}function pp(t,e,r,i){return{alignment:t===2?2:4,size:t===3?3:t,components:t,columns:1,rows:t,columnStride:t===3?3:t,shaderType:e,type:r}}function _p(t,e){let r=mp(t,e),i=Qt(t,e);return BT(r,i,e)}function BT(t,e,r){return at(t,yp(r)?4:e)}function FT(t,e,r){return r==="std140"?4:at(t,e)}function yp(t){return t==="std140"||t==="wgsl-uniform"}function LT(t){return t==="std140"||t==="wgsl-uniform"}var Gl=E(()=>{Kl();mn()});function Ql(t){return(!yn||yn.byteLength<t)&&(yn=new ArrayBuffer(t)),yn}function Jl(t,e){let r=Ql(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}var yn,ef=E(()=>{});function UT(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function pi(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":UT(t)}var tf=E(()=>{});function kT(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function VT(t,e,r){return Array.prototype.slice.call(t,e,r)}var bn,bp=E(()=>{ef();tf();De();Gl();bn=class{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){let r=this.layout.fields[e];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(e){let r={};for(let[i,s]of Object.entries(e)){let o=this.layout.uniformTypes[i];o?this._flattenCompositeValue(r,i,o,s):this.layout.fields[i]&&(r[i]=s)}return r}getData(e){let r=Ql(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},s=this.getFlatUniformValues(e);for(let[o,n]of Object.entries(s))this._writeLeafValue(i,o,n);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(e,r,i,s){if(s!==void 0){if(typeof i=="string"||this.layout.fields[r]){e[r]=s;return}if(Array.isArray(i)){let o=i[0],n=i[1];if(Array.isArray(o))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof o=="string"&&pi(s)){this._flattenPackedArray(e,r,o,n,s);return}if(!Array.isArray(s)){x.warn(`Unsupported uniform array value for ${r}:`,s)();return}for(let a=0;a<Math.min(s.length,n);a++){let c=s[a];c!==void 0&&this._flattenCompositeValue(e,`${r}[${a}]`,o,c)}return}if(ql(i)&&kT(s)){for(let[o,n]of Object.entries(s)){if(n===void 0)continue;let a=`${r}.${o}`;this._flattenCompositeValue(e,a,i[o],n)}return}x.warn(`Unsupported uniform value for ${r}:`,s)()}}_flattenPackedArray(e,r,i,s,o){let n=o,c=ls(i,this.layout.layout).components;for(let l=0;l<s;l++){let f=l*c;if(f>=n.length)break;c===1?e[`${r}[${l}]`]=Number(n[f]):e[`${r}[${l}]`]=VT(o,f,f+c)}}_writeLeafValue(e,r,i){let s=this.layout.fields[r];if(!s){x.warn(`Uniform ${r} not found in layout`)();return}let{type:o,components:n,columns:a,rows:c,offset:l,columnStride:f}=s,h=e[o];if(n===1){h[l]=Number(i);return}let u=i;if(a===1){for(let p=0;p<n;p++)h[l+p]=Number(u[p]??0);return}let d=0;for(let p=0;p<a;p++){let g=l+p*f;for(let m=0;m<c;m++)h[g+m]=Number(u[d++]??0)}}}});function Tp(t,e,r=16){if(t===e)return!0;let i=t,s=e;if(!pi(i)||!pi(s)||i.length!==s.length)return!1;let o=Math.min(r,zT);if(i.length>o)return!1;for(let n=0;n<i.length;++n)if(s[n]!==i[n])return!1;return!0}function xp(t){return pi(t)?t.slice():t}var zT,Ap=E(()=>{tf();zT=128});var Tn,Sp=E(()=>{Ap();Tn=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let r=e?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let s of i.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){Tp(this.uniforms[e],r)||(this.uniforms[e]=xp(r),this.modifiedUniforms[e]=!0,this.modified=!0)}}});function jT(t){return t.type==="webgpu"?"wgsl-uniform":"std140"}var WT,fs,Ep=E(()=>{tn();De();Gl();Sp();bp();WT=1024,fs=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,r){this.device=e;for(let[i,s]of Object.entries(r)){let o=i,n=gp(s.uniformTypes??{},{layout:s.layout??jT(e)}),a=new bn(n);this.shaderBlockLayouts.set(o,n),this.shaderBlockWriters.set(o,a);let c=new Tn({name:i});c.setUniforms(a.getFlatUniformValues(s.defaultUniforms||{})),this.uniformBlocks.set(o,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e)){let s=r,n=this.shaderBlockWriters.get(s)?.getFlatUniformValues(i||{});this.uniformBlocks.get(s)?.setUniforms(n||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let r=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(r,WT)}getUniformBufferData(e){let r=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(r)||new Uint8Array(0)}createUniformBuffer(e,r){r&&this.setUniforms(r);let i=this.getUniformBufferByteLength(e),s=this.device.createBuffer({usage:I.UNIFORM|I.COPY_DST,byteLength:i}),o=this.getUniformBufferData(e);return s.write(o),s}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let r=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:I.UNIFORM|I.COPY_DST,byteLength:r});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&x.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),s=!1;if(i&&r?.needsRedraw){s||=r.needsRedraw;let o=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(o);let n=this.uniformBlocks.get(e)?.getAllUniforms();x.log(4,`Writing to uniform buffer ${String(e)}`,o,n)()}return s}}});var L=E(()=>{Ud();kd();Sl();$d();Xd();tn();vl();Yd();Ol();Pl();Gd();Bl();Qd();ep();tp();sp();op();np();fp();hp();up();dp();Ep();rn();Kl();mn();sn();cn();Tl();De();ip();wl();ef();jl()});var _r,ly=E(()=>{(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(_r||(_r={}))});var fy=E(()=>{ly()});function hy(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(r,i){if(r==="webgl"||r==="experimental-webgl"){let s=this.originalGetContext("webgl2",i);return s instanceof HTMLElement&&cP(s),s}return this.originalGetContext(r,i)}}function cP(t){t.getExtension("EXT_color_buffer_float");let e={...sP,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:oP(t),OES_vertex_array_object:nP(t),ANGLE_instanced_arrays:aP(t)},r=t.getExtension;t.getExtension=function(s){let o=r.call(t,s);return o||(s in e?e[s]:null)};let i=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(i.apply(t)||[])?.concat(Object.keys(e))}}var sP,oP,nP,aP,uy=E(()=>{sP={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},oP=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),nP=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),aP=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}})});async function za(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((s,o)=>{i.onload=s,i.onerror=n=>o(new Error(`Unable to load script '${t}': ${n}`)),r.appendChild(i)})}var Tu=E(()=>{});function jr(t){let e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},t.luma=e,e}var Wa=E(()=>{});async function py(t){if(!globalThis.SPECTOR)try{await za(t.debugSpectorJSUrl||ja.debugSpectorJSUrl)}catch(e){x.warn(String(e))}}function gy(t){if(t={...ja,...t},!t.debugSpectorJS)return null;if(!Ie&&globalThis.SPECTOR&&!globalThis.luma?.spector){x.probe(lP,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;Ie=new e,globalThis.luma&&(globalThis.luma.spector=Ie)}if(!Ie)return null;if(dy||(dy=!0,Ie.spyCanvases(),Ie?.onCaptureStarted.add(e=>x.info("Spector capture started:",e)()),Ie?.onCapture.add(e=>{x.info("Spector capture complete:",e)(),Ie?.getResultUI(),Ie?.resultView.display(),Ie?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=jr(e),i=r.device;Ie?.startCapture(t.gl,500),r.device=i,new Promise(s=>setTimeout(s,2e3)).then(s=>{x.info("Spector capture stopped after 2 seconds")(),Ie?.stopCapture()})}return Ie}var lP,Ie,dy,ja,xu=E(()=>{L();Tu();Wa();lP=1,Ie=null,dy=!1,ja={debugSpectorJS:x.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function _y(t){return t.luma=t.luma||{},t.luma}async function yy(){he()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await za(fP))}function by(t,e={}){return e.debugWebGL||e.traceWebGL?uP(t,e):hP(t)}function hP(t){let e=_y(t);return e.realContext?e.realContext:t}function uP(t,e){if(!globalThis.WebGLDebugUtils)return x.warn("webgl-debug not loaded")(),t;let r=_y(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({..._r,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,dP.bind(null,e),pP.bind(null,e));for(let n in _r)!(n in i)&&typeof _r[n]=="number"&&(i[n]=_r[n]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(s,i);let o=Object.create(s);return r.realContext=t,r.debugContext=o,o.luma=r,o.debug=!0,o}function my(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function dP(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(e),o=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),n=`${s} in gl.${r}(${o})`;x.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",n)();debugger;throw new Error(n)}function pP(t,e,r){let i="";t.traceWebGL&&x.level>=1&&(i=my(e,r),x.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)());for(let s of r)if(s===void 0){i=i||my(e,r);debugger}}var fP,Au=E(()=>{L();fy();Xt();Tu();fP="https://unpkg.com/webgl-debug@2.0.1/index.js"});function Su(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Q(t,e,r){return e[t]!==void 0?e[t]:r[t]}var bo,ie,Ty,Oe,xy,yo,Ay,Sy,Eu,bt,wu,Ey,Ru=E(()=>{bo={[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},ie=(t,e,r)=>e?t.enable(r):t.disable(r),Ty=(t,e,r)=>t.hint(r,e),Oe=(t,e,r)=>t.pixelStorei(r,e),xy=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},yo=(t,e,r)=>{let s={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(s,e)};Ay={[3042]:ie,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:ie,[2885]:(t,e)=>t.cullFace(e),[2929]:ie,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:ie,[35723]:Ty,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:xy,[36010]:xy,[34964]:yo,[36662]:yo,[36663]:yo,[35053]:yo,[35055]:yo,[2886]:(t,e)=>t.frontFace(e),[33170]:Ty,[2849]:(t,e)=>t.lineWidth(e),[32823]:ie,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:ie,[32926]:ie,[32928]:ie,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:ie,[3088]:(t,e)=>t.scissor(...e),[2960]:ie,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.stencilMaskSeparate(1029,e),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(t,e)=>t.viewport(...e),[34383]:ie,[10754]:ie,[12288]:ie,[12289]:ie,[12290]:ie,[12291]:ie,[12292]:ie,[12293]:ie,[12294]:ie,[12295]:ie,[3333]:Oe,[3317]:Oe,[37440]:Oe,[37441]:Oe,[37443]:Oe,[3330]:Oe,[3332]:Oe,[3331]:Oe,[3314]:Oe,[32878]:Oe,[3316]:Oe,[3315]:Oe,[32877]:Oe,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Su(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=Su(e)&&e.length===3?[...e,...e]:e;let[r,i,s,o,n,a]=e;t.stencilFuncSeparate(1028,r,i,s),t.stencilFuncSeparate(1029,o,n,a)},stencilOp:(t,e)=>{e=Su(e)&&e.length===3?[...e,...e]:e;let[r,i,s,o,n,a]=e;t.stencilOpSeparate(1028,r,i,s),t.stencilOpSeparate(1029,o,n,a)},viewport:(t,e)=>t.viewport(...e)};Sy={blendEquation:(t,e,r)=>t.blendEquationSeparate(Q(32777,e,r),Q(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(Q(32969,e,r),Q(32968,e,r),Q(32971,e,r),Q(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(Q(32824,e,r),Q(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(Q(32938,e,r),Q(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,Q(2962,e,r),Q(2967,e,r),Q(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,Q(34816,e,r),Q(36003,e,r),Q(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,Q(2964,e,r),Q(2965,e,r),Q(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,Q(34817,e,r),Q(34818,e,r),Q(34819,e,r))},Eu={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,s)=>t({[32773]:new Float32Array([e,r,i,s])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,i,s)=>t({[32969]:e,[32968]:r,[32971]:i,[32970]:s}),clearColor:(t,e,r,i,s)=>t({[3106]:new Float32Array([e,r,i,s])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,i,s)=>t({[3107]:[e,r,i,s]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,i,s)=>t({[3088]:new Int32Array([e,r,i,s])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({[2962]:e,[2967]:r,[2963]:i,[34816]:e,[36003]:r,[36004]:i}),stencilFuncSeparate:(t,e,r,i,s)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:s}),stencilOp:(t,e,r,i)=>t({[2964]:e,[2965]:r,[2966]:i,[34817]:e,[34818]:r,[34819]:i}),stencilOpSeparate:(t,e,r,i,s)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:s}),viewport:(t,e,r,i,s)=>t({[2978]:[e,r,i,s]})},bt=(t,e)=>t.isEnabled(e),wu={[3042]:bt,[2884]:bt,[2929]:bt,[3024]:bt,[32823]:bt,[32926]:bt,[32928]:bt,[3089]:bt,[2960]:bt,[35977]:bt},Ey=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 Qe(t,e){if(gP(e))return;let r={};for(let s in e){let o=Number(s),n=Ay[s];n&&(typeof n=="string"?r[n]=!0:n(t,e[s],o))}let i=t.lumaState?.cache;if(i)for(let s in r){let o=Sy[s];o(t,e,i)}}function Ha(t,e=bo){if(typeof e=="number"){let s=e,o=wu[s];return o?o(t,s):t.getParameter(s)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let s of r){let o=wu[s];i[s]=o?o(t,Number(s)):t.getParameter(Number(s))}return i}function wy(t){Qe(t,bo)}function gP(t){for(let e in t)return!1;return!0}var zi=E(()=>{Ru()});function Py(t,e){if(t===e)return!0;if(Ry(t)&&Ry(e)&&t.length===e.length){for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}return!1}function Ry(t){return Array.isArray(t)||ArrayBuffer.isView(t)}var vy=E(()=>{});function My(t,e){let r=t[e].bind(t);t[e]=function(s){if(s===void 0||Ey.has(s))return r(s);let o=Je.get(t);return s in o.cache||(o.cache[s]=r(s)),o.enable?o.cache[s]:r(s)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function mP(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...o){let n=Je.get(t),{valueChanged:a,oldValue:c}=r(n._updateCache,...o);return a&&i(...o),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function _P(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let s=Je.get(t);s.program!==i&&(e(i),s.program=i)}}var Je,Pu=E(()=>{zi();vy();Ru();Je=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,r){this.gl=e,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];Qe(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r?.copyState?Ha(e):Object.assign({},bo),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,_P(e);for(let i in Eu){let s=Eu[i];mP(e,i,s)}My(e,"getParameter"),My(e,"isEnabled")}_updateCache(e){let r=!1,i,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let o in e){let n=e[o],a=this.cache[o];Py(n,a)||(r=!0,i=a,s&&!(o in s)&&(s[o]=a),this.cache[o]=n)}return{valueChanged:r,oldValue:i}}}});function Cy(t,e,r){let i="",s=c=>{let l=c.statusMessage;l&&(i||=l)};t.addEventListener("webglcontextcreationerror",s,!1);let o=r.failIfMajorPerformanceCaveat!==!0,n={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=t.getContext("webgl2",n),!a&&n.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&o&&(n.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",n),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=jr(a);l.softwareRenderer=c;let{onContextLost:f,onContextRestored:h}=e;return t.addEventListener("webglcontextlost",u=>f(u),!1),t.addEventListener("webglcontextrestored",u=>h(u),!1),a}finally{t.removeEventListener("webglcontextcreationerror",s,!1)}}var Iy=E(()=>{Wa()});function et(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}var To=E(()=>{});function Oy(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);et(t,"WEBGL_debug_renderer_info",e);let s=e.WEBGL_debug_renderer_info,o=t.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),n=t.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=o||r,c=n||i,l=t.getParameter(7938),f=Ny(a,c),h=yP(a,c),u=bP(a,c);return{type:"webgl",gpu:f,gpuType:u,gpuBackend:h,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Ny(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function yP(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function bP(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(Ny(t,e)){case"apple":return TP(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function TP(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}var Dy=E(()=>{To()});function $a(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}var vu=E(()=>{});function Ly(t){return t in Ya}function Nu(t,e,r){return Uy(t,e,r,new Set)}function Uy(t,e,r,i){let s=Ya[e];if(!s||i.has(e))return!1;i.add(e);let o=(s.features||[]).every(n=>Uy(t,n,r,i));return i.delete(e),o?(s.extensions||[]).every(n=>Boolean(et(t,n,r))):!1}function ky(t,e,r){let i=e.create,s=Ka[e.format];s?.gl===void 0&&(i=!1),s?.x&&(i=i&&Boolean(et(t,s.x,r))),e.format==="stencil8"&&(i=!1);let o=s?.r===!1?!1:s?.r===void 0||Nu(t,s.r,r),n=i&&e.render&&o&&vP(t,e.format,r);return{format:e.format,create:i&&e.create,render:n,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function vP(t,e,r){let i=Ka[e],s=i?.gl;if(s===void 0||i?.x&&!et(t,i.x,r))return!1;let o=t.getParameter(32873),n=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;let l=Number(0),f=Number(t.getError());for(;f!==l;)f=t.getError();let h=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,s,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),h=Number(t.checkFramebufferStatus(36160))===Number(36053)&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,n),t.deleteFramebuffer(c),t.bindTexture(3553,o),t.deleteTexture(a)}return h}function Za(t){let e=Ka[t],r=CP(t),i=pe.getInfo(t);return i.compressed&&(e.dataFormat=r),{internalFormat:r,format:e?.dataFormat||MP(i.channels,i.integer,i.normalized,r),type:i.dataType?$a(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function Vy(t){switch(pe.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function MP(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function CP(t){let r=Ka[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var xo,Ao,Wi,ji,xP,AP,SP,EP,wP,RP,By,Fy,Mu,Cu,Iu,Ou,Xa,PP,Ya,Ka,Hi=E(()=>{L();To();vu();xo="WEBGL_compressed_texture_s3tc",Ao="WEBGL_compressed_texture_s3tc_srgb",Wi="EXT_texture_compression_rgtc",ji="EXT_texture_compression_bptc",xP="WEBGL_compressed_texture_etc",AP="WEBGL_compressed_texture_astc",SP="WEBGL_compressed_texture_etc1",EP="WEBGL_compressed_texture_pvrtc",wP="WEBGL_compressed_texture_atc",RP="EXT_texture_norm16",By="EXT_render_snorm",Fy="EXT_color_buffer_float",Mu="snorm8-renderable-webgl",Cu="norm16-renderable-webgl",Iu="snorm16-renderable-webgl",Ou="float16-renderable-webgl",Xa="float32-renderable-webgl",PP="rgb9e5ufloat-renderable-webgl",Ya={"float32-renderable-webgl":{extensions:[Fy]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[By]},"norm16-webgl":{extensions:[RP]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[By]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[xo,Ao,Wi,ji]},"texture-compression-bc5-webgl":{extensions:[Wi]},"texture-compression-bc7-webgl":{extensions:[ji]},"texture-compression-etc2":{extensions:[xP]},"texture-compression-astc":{extensions:[AP]},"texture-compression-etc1-webgl":{extensions:[SP]},"texture-compression-pvrtc-webgl":{extensions:[EP]},"texture-compression-atc-webgl":{extensions:[wP]}};Ka={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:Mu},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:Mu},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:Ou},r16unorm:{gl:33322,rb:!0,r:Cu},r16snorm:{gl:36760,r:Iu},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:Mu},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:Ou},rg16unorm:{gl:33324,r:Cu},rg16snorm:{gl:36761,r:Iu},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Xa},rgb9e5ufloat:{gl:35901,r:PP},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Xa},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:Ou},rgba16unorm:{gl:32859,rb:!0,r:Cu},rgba16snorm:{gl:36763,r:Iu},"rgb32float-webgl":{gl:34837,x:Fy,r:Xa,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Xa},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:xo},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Ao},"bc1-rgba-unorm":{gl:33777,x:xo},"bc1-rgba-unorm-srgb":{gl:35916,x:Ao},"bc2-rgba-unorm":{gl:33778,x:xo},"bc2-rgba-unorm-srgb":{gl:35918,x:Ao},"bc3-rgba-unorm":{gl:33779,x:xo},"bc3-rgba-unorm-srgb":{gl:35919,x:Ao},"bc4-r-unorm":{gl:36283,x:Wi},"bc4-r-snorm":{gl:36284,x:Wi},"bc5-rg-unorm":{gl:36285,x:Wi},"bc5-rg-snorm":{gl:36286,x:Wi},"bc6h-rgb-ufloat":{gl:36495,x:ji},"bc6h-rgb-float":{gl:36494,x:ji},"bc7-rgba-unorm":{gl:36492,x:ji},"bc7-rgba-unorm-srgb":{gl:36493,x:ji},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var zy,qa,Wy=E(()=>{L();To();Hi();zy={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"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 rs{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,et(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Ly(e)&&Nu(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(zy),...Object.keys(Ya)]}getWebGLFeature(e){let r=zy[e];return Boolean(typeof r=="string"?et(this.gl,r,this.extensions):r)}}});var Ga,jy=E(()=>{L();Ga=class extends ts{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 maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function IP(t){return t<34069?t+34069:t}function OP(t){switch(t){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${t}`}}var Tt,Qa=E(()=>{L();Hi();Tt=class extends nt{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let i=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),i||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r<this.colorAttachments.length;++r){let i=this.colorAttachments[r];if(i){let s=36064+r;this._attachTextureView(s,i)}}if(this.depthStencilAttachment){let r=Vy(this.depthStencilAttachment.props.format);this._attachTextureView(r,this.depthStencilAttachment)}if(this.device.props.debug){let r=this.gl.checkFramebufferStatus(36160);if(r!==36053)throw new Error(`Framebuffer ${OP(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:i}=this.device,{texture:s}=r,o=r.props.baseMipLevel,n=r.props.baseArrayLayer;switch(i.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:i.framebufferTextureLayer(36160,e,s.handle,o,n);break;case 34067:let a=IP(n);i.framebufferTexture2D(36160,e,a,s.handle,o);break;case 3553:i.framebufferTexture2D(36160,e,3553,s.handle,o);break;default:throw new Error("Illegal texture type")}i.bindTexture(s.glTarget,null)}resizeAttachments(e,r){if(this.handle===null){this.width=e,this.height=r;return}super.resizeAttachments(e,r)}}});var Ja,Hy=E(()=>{L();Qa();Ja=class extends ii{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new Tt(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var ec,$y=E(()=>{L();ec=class extends os{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,r={}){super(r),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let o=this.canvas.getContext("2d");if(!o)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=o,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[r,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(r!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(e)}}});function Xy(t="id"){Du[t]=Du[t]||1;let e=Du[t]++;return`${t}-${e}`}var Du,Yy=E(()=>{Du={}});function NP(t){return t&I.INDEX?34963:t&I.VERTEX?34962:t&I.UNIFORM?35345:34962}function DP(t){return t&I.INDEX||t&I.VERTEX?35044:t&I.UNIFORM?35048:35044}var tt,tc=E(()=>{L();tt=class extends I{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=NP(this.props.usage),this.glUsage=DP(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)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,r=0,i=e.byteLength+r){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,i,this.glUsage),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,r=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),s=0,o=void 0,n=36663;this.gl.bindBuffer(n,this.handle),s!==0||o!==void 0?this.gl.bufferSubData(n,r,i,s,o):this.gl.bufferSubData(n,r,i),this.gl.bindBuffer(n,null),this._setDebugData(e,r,e.byteLength)}async mapAndWriteAsync(e,r=0,i=this.byteLength-r){let s=new ArrayBuffer(i);await e(s,"copied"),this.write(s,r)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}async mapAndReadAsync(e,r=0,i){let s=await this.readAsync(r,i);return await e(s.buffer,"copied")}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,s,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}}});function Ky(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let s=i.trim(),o=i.split(":"),n=o[0]?.trim();if(o.length===2){let[d,p]=o;if(!d||!p){r.push({message:s,type:rc(n||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:rc(d),lineNum:0,linePos:0});continue}let[a,c,l,...f]=o;if(!a||!c||!l){r.push({message:o.slice(1).join(":").trim()||s,type:rc(n||"info"),lineNum:0,linePos:0});continue}let h=parseInt(l,10);isNaN(h)&&(h=0);let u=parseInt(c,10);isNaN(u)&&(u=0),r.push({message:f.join(":").trim(),type:rc(a),lineNum:h,linePos:u})}return r}function rc(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var Zy=E(()=>{});var ic,qy=E(()=>{L();Zy();ic=class extends Gt{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});let i=this._compile(this.source);i&&typeof i.catch=="function"&&i.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?Ky(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es
|
|
19
|
+
${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(this.handle),!this.device.props.debug){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}return x.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{x.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function Qy(t,e,r,i){if(UP(e))return i(t);let s=t;s.pushState();try{return BP(t,e),Qe(s.gl,r),i(t)}finally{s.popState()}}function BP(t,e){let r=t,{gl:i}=r;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Hr("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let o=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,n=Hr("provokingVertex",e.provokingVertex,{first:36429,last:36430});o?.provokingVertexWEBGL(n)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let o=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,n=Hr("polygonMode",e.polygonMode,{fill:6914,line:6913});o?.polygonModeWEBGL(1028,n),o?.polygonModeWEBGL(1029,n)}e.polygonOffsetLine&&i.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(LP("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(oc("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let s=e.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&x.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let s=e.stencilReadMask||4294967295,o=oc("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,o,0,s),i.stencilFuncSeparate(1029,o,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let s=Bu("stencilPassOperation",e.stencilPassOperation),o=Bu("stencilFailOperation",e.stencilFailOperation),n=Bu("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,o,n,s),i.stencilOpSeparate(1029,o,n,s)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let s=Gy("blendColorOperation",e.blendColorOperation||"add"),o=Gy("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(s,o);let n=sc("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=sc("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=sc("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=sc("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(n,a,c,l)}}function oc(t,e){return Hr(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Bu(t,e){return Hr(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Gy(t,e){return Hr(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function sc(t,e,r="color"){return Hr(t,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function FP(t,e){return`Illegal parameter ${e} for ${t}`}function Hr(t,e,r){if(!(e in r))throw new Error(FP(t,e));return r[e]}function LP(t,e){return e}function UP(t){let e=!0;for(let r in t){e=!1;break}return e}var Fu=E(()=>{L();zi()});function nc(t){let e={};return t.addressModeU&&(e[10242]=Lu(t.addressModeU)),t.addressModeV&&(e[10243]=Lu(t.addressModeV)),t.addressModeW&&(e[32882]=Lu(t.addressModeW)),t.magFilter&&(e[10240]=Uu(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=kP(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=oc("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Lu(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Uu(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function kP(t,e="none"){if(!e)return Uu(t);switch(e){case"none":return Uu(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}var ku=E(()=>{Fu()});var ac,Jy=E(()=>{L();ku();ac=class extends Be{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=nc(r),this.handle=r.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,i]of Object.entries(e)){let s=Number(r);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,i);break;default:this.device.gl.samplerParameteri(this.handle,s,i);break}}}}});function xt(t,e,r){if(VP(e))return r(t);let{nocatch:i=!0}=e,s=Je.get(t);s.push(),Qe(t,e);let o;if(i)o=r(t),s.pop();else try{o=r(t)}finally{s.pop()}return o}function VP(t){for(let e in t)return!1;return!0}var cc=E(()=>{zi();Pu()});var At,Vu=E(()=>{L();At=class extends qt{device;gl;handle;texture;constructor(e,r){super(e,{...B.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function lc(t){return zP[t]}var zP,zu=E(()=>{zP={[5124]:"sint32",[5125]:"uint32",[5122]:"sint16",[5123]:"uint16",[5120]:"sint8",[5121]:"uint8",[5126]:"float32",[5131]:"float16",[33635]:"uint16",[32819]:"uint16",[32820]:"uint16",[33640]:"uint32",[35899]:"uint32",[35902]:"uint32",[34042]:"uint32",[36269]:"uint32"}});function WP(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function jP(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function HP(t){switch(t){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(t)}function fc(t,e,r){return e==="cube"?34069+r:t}var St,hc=E(()=>{L();Hi();ku();cc();Vu();zu();St=class extends B{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,r){super(e,r,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=Za(this.props.format);this.glTarget=HP(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);let{dimension:s,width:o,height:n,depth:a,mipLevels:c,glTarget:l,glInternalFormat:f}=this;if(!this.compressed)switch(s){case"2d":case"cube":this.gl.texStorage2D(l,c,f,o,n);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,f,o,n,a);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new At(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new At(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let r=nc(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(e){let r=this._normalizeCopyExternalImageOptions(e);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:s}=this,{image:o,depth:n,mipLevel:a,x:c,y:l,z:f,width:h,height:u}=r,d=fc(this.glTarget,this.dimension,f),p=r.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),xt(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,h,u,i,s,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,f,h,u,n,i,s,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),s=e.byteOffset??0,o=this.computeMemoryLayout(i);if(r.byteLength<s+o.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${s+o.byteLength})`);let n=r;this.gl.bindBuffer(35051,n.handle);try{this._readColorTextureLayers(i,o,a=>{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,s+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,r={}){let i=this._normalizeTextureWriteOptions(r),{width:s,height:o,depthOrArrayLayers:n,mipLevel:a,byteOffset:c,x:l,y:f,z:h}=i,{glFormat:u,glType:d,compressed:p}=this,g=fc(this.glTarget,this.dimension,h);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),_=m?i.bytesPerRow/m:void 0,b={[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),xt(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,f,s,o,u,d,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,f,h,s,o,n,u,d,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,r={}){let i=this._normalizeTextureWriteOptions(r),s=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:o,height:n,depthOrArrayLayers:a,mipLevel:c,x:l,y:f,z:h,byteOffset:u}=i,{glFormat:d,glType:p,compressed:g}=this,m=fc(this.glTarget,this.dimension,h),_;if(!g){let{bytesPerPixel:w}=this.device.getTextureFormatInfo(this.format);w&&(_=i.bytesPerRow/w)}let b=this.compressed?{}:{[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage},y=jP(s,u),T=g?WP(s,u):s,S=this._getMipLevelSize(c),A=l===0&&f===0&&h===0&&o===S.width&&n===S.height&&a===S.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),xt(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":g?A?this.gl.compressedTexImage2D(m,c,d,o,n,0,T):this.gl.compressedTexSubImage2D(m,c,l,f,o,n,d,T):this.gl.texSubImage2D(m,c,l,f,o,n,d,p,s,y);break;case"2d-array":case"3d":g?A?this.gl.compressedTexImage3D(m,c,d,o,n,a,0,T):this.gl.compressedTexSubImage3D(m,c,l,f,h,o,n,a,d,T):this.gl.texSubImage3D(m,c,l,f,h,o,n,a,d,p,s,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let r=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(r),s=lc(this.glType),o=cs(s),n=new o(i.byteLength/o.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,i,a=>{let c=new o(n.buffer,n.byteOffset+a,i.bytesPerImage/o.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),n.buffer}_readColorTextureLayers(e,r,i){let s=this._getFramebuffer(),o=r.bytesPerRow/r.bytesPerPixel,n={[3333]:this.byteAlignment,...o!==e.width?{[3330]:o}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,s.handle);try{this.gl.readBuffer(36064),xt(this.gl,n,()=>{for(let l=0;l<e.depthOrArrayLayers;l++)this._attachReadSubresource(s,e.mipLevel,e.z+l),i(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,r,i){let s=`${r}:${i}`;if(this._framebufferAttachmentKey!==s){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,fc(this.glTarget,this.dimension,i),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,i);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let o=Number(this.gl.checkFramebufferStatus(36160));if(o!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${o})`)}this._framebufferAttachmentKey=s}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(x.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!e?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(i){x.warn(`Error generating mipmap for ${this}: ${i.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){x.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,i]of Object.entries(e)){let s=Number(r),o=i;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,null),e}}});function eb(t,e,r,i){let s=t,o=i;o===!0&&(o=1),o===!1&&(o=0);let n=typeof o=="number"?[o]:o;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,i);case 5126:return t.uniform1fv(e,n);case 35664:return t.uniform2fv(e,n);case 35665:return t.uniform3fv(e,n);case 35666:return t.uniform4fv(e,n);case 5124:return t.uniform1iv(e,n);case 35667:return t.uniform2iv(e,n);case 35668:return t.uniform3iv(e,n);case 35669:return t.uniform4iv(e,n);case 35670:return t.uniform1iv(e,n);case 35671:return t.uniform2iv(e,n);case 35672:return t.uniform3iv(e,n);case 35673:return t.uniform4iv(e,n);case 5125:return s.uniform1uiv(e,n,1);case 36294:return s.uniform2uiv(e,n,2);case 36295:return s.uniform3uiv(e,n,3);case 36296:return s.uniform4uiv(e,n,4);case 35674:return t.uniformMatrix2fv(e,!1,n);case 35675:return t.uniformMatrix3fv(e,!1,n);case 35676:return t.uniformMatrix4fv(e,!1,n);case 35685:return s.uniformMatrix2x3fv(e,!1,n);case 35686:return s.uniformMatrix2x4fv(e,!1,n);case 35687:return s.uniformMatrix3x2fv(e,!1,n);case 35688:return s.uniformMatrix3x4fv(e,!1,n);case 35689:return s.uniformMatrix4x2fv(e,!1,n);case 35690:return s.uniformMatrix4x3fv(e,!1,n)}throw new Error("Illegal uniform")}var tb=E(()=>{});function rb(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(t)}}function ib(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(t)}}var Wu=E(()=>{});function $P(t,e){let r={...t,attributes:t.attributes.map(i=>({...i})),bindings:t.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let s=r.attributes.find(o=>o.name===i.name);s?(s.type=i.type||s.type,s.stepMode=i.stepMode||s.stepMode):x.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let s=ob(r,i.name);if(!s){x.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(s,i)}return r}function ob(t,e){return t.bindings.find(r=>r.name===e||r.name===`${e}Uniforms`||`${r.name}Uniforms`===e)}function sb(t,e){return t[e]||t[`${e}Uniforms`]||t[e.replace(/Uniforms$/,"")]}var uc,nb=E(()=>{L();Fu();tb();tc();Qa();hc();Vu();Wu();uc=class extends Re{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,r){super(e,r),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=i.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?$P(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,r){let i=pn(as(this.shaderLayout,e));for(let[s,o]of Object.entries(i)){let n=ob(this.shaderLayout,s);if(!n){let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||x.warn(`No binding "${s}" in render pipeline "${this.id}", expected one of ${a}`,o)();continue}switch(o||x.warn(`Unsetting binding "${s}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(o instanceof tt)&&!(o.buffer instanceof tt))throw new Error("buffer value");break;case"texture":if(!(o instanceof At||o instanceof St||o instanceof Tt))throw new Error(`${this} Bad texture binding for ${s}`);break;case"sampler":x.warn(`Ignoring sampler ${s}`)();break;default:throw new Error(n.type)}this.bindings[s]=o}}draw(e){this._syncLinkStatus();let r=e.bindGroups?pn(e.bindGroups):e.bindings||this.bindings,{renderPass:i,parameters:s=this.props.parameters,topology:o=this.props.topology,vertexArray:n,vertexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:f=0,transformFeedback:h,uniforms:u=this.uniforms}=e,d=rb(o),p=Boolean(n.indexBuffer),g=n.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return x.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(r))return x.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),n.bindBeforeRender(i),h&&h.begin(this.props.topology),this._applyBindings(r,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(u);let m=i;return Qy(this.device,s,m.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(d,a||0,g,f,c||0):p?this.device.gl.drawElements(d,a||0,g,f):l?this.device.gl.drawArraysInstanced(d,f,a||0,c||0):this.device.gl.drawArrays(d,f,a||0),h&&h.end()}),n.unbindAfterRender(i),!0}_areTexturesRenderable(e){let r=!0;for(let i of this.shaderLayout.bindings)sb(e,i.name)||(x.warn(`Binding ${i.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(e,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let s=0,o=0;for(let n of this.shaderLayout.bindings){let a=sb(e,n.name);if(!a)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":let{name:c}=n,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,o),a instanceof tt)i.bindBufferBase(35345,o,a.handle);else{let h=a;i.bindBufferRange(35345,o,h.buffer.handle,h.offset||0,h.size||h.buffer.byteLength-(h.offset||0))}o+=1;break;case"texture":if(!(a instanceof At||a instanceof St||a instanceof Tt))throw new Error("texture");let f;if(a instanceof At)f=a.texture;else if(a instanceof St)f=a;else if(a instanceof Tt&&a.colorAttachments[0]instanceof At)x.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+s),i.bindTexture(f.glTarget,f.handle),s+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let r of this.shaderLayout.uniforms||[]){let{name:i,location:s,type:o,textureUnit:n}=r,a=e[i]??n;a!==void 0&&eb(this.device.gl,s,o,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function ab(t){return YP[t]}function dc(t){return XP[t]}function pc(t){return Boolean(lb[t])}function cb(t){return lb[t]}var XP,lb,YP,gc=E(()=>{XP={[5126]:"f32",[35664]:"vec2<f32>",[35665]:"vec3<f32>",[35666]:"vec4<f32>",[5124]:"i32",[35667]:"vec2<i32>",[35668]:"vec3<i32>",[35669]:"vec4<i32>",[5125]:"u32",[36294]:"vec2<u32>",[36295]:"vec3<u32>",[36296]:"vec4<u32>",[35670]:"f32",[35671]:"vec2<f32>",[35672]:"vec3<f32>",[35673]:"vec4<f32>",[35674]:"mat2x2<f32>",[35685]:"mat2x3<f32>",[35686]:"mat2x4<f32>",[35687]:"mat3x2<f32>",[35675]:"mat3x3<f32>",[35688]:"mat3x4<f32>",[35689]:"mat4x2<f32>",[35690]:"mat4x3<f32>",[35676]:"mat4x4<f32>"},lb={[35678]:{viewDimension:"2d",sampleType:"float"},[35680]:{viewDimension:"cube",sampleType:"float"},[35679]:{viewDimension:"3d",sampleType:"float"},[35682]:{viewDimension:"3d",sampleType:"depth"},[36289]:{viewDimension:"2d-array",sampleType:"float"},[36292]:{viewDimension:"2d-array",sampleType:"depth"},[36293]:{viewDimension:"cube",sampleType:"float"},[36298]:{viewDimension:"2d",sampleType:"sint"},[36299]:{viewDimension:"3d",sampleType:"sint"},[36300]:{viewDimension:"cube",sampleType:"sint"},[36303]:{viewDimension:"2d-array",sampleType:"uint"},[36306]:{viewDimension:"2d",sampleType:"uint"},[36307]:{viewDimension:"3d",sampleType:"uint"},[36308]:{viewDimension:"cube",sampleType:"uint"},[36311]:{viewDimension:"2d-array",sampleType:"uint"}},YP={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function fb(t,e){let r={attributes:[],bindings:[]};r.attributes=KP(t,e);let i=GP(t,e);for(let a of i){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let s=qP(t,e),o=0;for(let a of s)if(pc(a.type)){let{viewDimension:c,sampleType:l}=cb(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:o,viewDimension:c,sampleType:l}),a.textureUnit=o,o+=1}s.length&&(r.uniforms=s);let n=ZP(t,e);return n?.length&&(r.varyings=n),r}function KP(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let s=0;s<i;s++){let o=t.getActiveAttrib(e,s);if(!o)throw new Error("activeInfo");let{name:n,type:a}=o,c=t.getAttribLocation(e,n);if(c>=0){let l=dc(a),f=/instance/i.test(n)?"instance":"vertex";r.push({name:n,location:c,stepMode:f,type:l})}}return r.sort((s,o)=>s.location-o.location),r}function ZP(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let s=0;s<i;s++){let o=t.getTransformFeedbackVarying(e,s);if(!o)throw new Error("activeInfo");let{name:n,type:a,size:c}=o,l=dc(a),{type:f,components:h}=li(l);r.push({location:s,name:n,type:f,size:c*h})}return r.sort((s,o)=>s.location-o.location),r}function qP(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let s=0;s<i;s++){let o=t.getActiveUniform(e,s);if(!o)throw new Error("activeInfo");let{name:n,size:a,type:c}=o,{name:l,isArray:f}=QP(n),h=t.getUniformLocation(e,l),u={location:h,name:l,size:a,type:c,isArray:f};if(r.push(u),u.size>1)for(let d=0;d<u.size;d++){let p=`${l}[${d}]`;h=t.getUniformLocation(e,p);let g={...u,name:p,location:h};r.push(g)}}return r}function GP(t,e){let r=(o,n)=>t.getActiveUniformBlockParameter(e,o,n),i=[],s=t.getProgramParameter(e,35382);for(let o=0;o<s;o++){let n={name:t.getActiveUniformBlockName(e,o)||"",location:r(o,35391),byteLength:r(o,35392),vertex:r(o,35396),fragment:r(o,35398),uniformCount:r(o,35394),uniforms:[]},a=r(o,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),h=t.getActiveUniforms(e,a,35388);for(let p=0;p<n.uniformCount;++p){let g=a[p];if(g!==void 0){let m=t.getActiveUniform(e,g);if(!m)throw new Error("activeInfo");let _=dc(c[p]);n.uniforms.push({name:m.name,format:_,type:c[p],arrayLength:l[p],byteOffset:f[p],byteStride:h[p]})}}let u=new Set(n.uniforms.map(p=>p.name.split(".")[0]).filter(p=>Boolean(p))),d=n.name.replace(/Uniforms$/,"");if(u.size===1&&!u.has(n.name)&&!u.has(d)){let[p]=u;x.warn(`Uniform block "${n.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${n.name}") and alias ("${d}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}i.push(n)}return i.sort((o,n)=>o.location-n.location),i}function QP(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:Ar(r?.[1],`Failed to parse GLSL uniform name ${t}`),length:r?.[2]?1:0,isArray:Boolean(r?.[2])}}var hb=E(()=>{L();gc()});var ub,mc,db=E(()=>{L();hb();gc();ub=4,mc=class extends ns{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(e,r){super(e,r),this.device=e,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders(),x.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=fb(this.device.gl,this.handle),x.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),x.time(ub,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),x.timeEnd(ub,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}x.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),x.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(e){switch(e){case"success":return;default:let r=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=e.getProgramParameter(this.handle,35718);for(let s=0;s<i;s++){let o=e.getActiveUniform(this.handle,s);if(o&&pc(o.type)){let n=o.name.endsWith("[0]"),a=n?o.name.slice(0,-3):o.name,c=e.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,o,n,r))}}}_assignSamplerUniform(e,r,i,s){let{gl:o}=this.device;if(i&&r.size>1){let n=Int32Array.from({length:r.size},(a,c)=>s+c);return o.uniform1iv(e,n),s+r.size}return o.uniform1i(e,s),s+1}async _waitForLinkComplete(){let e=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function JP(t,e){let r=e.sourceBuffer,i=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function ev(t,e){throw new Error("copyBufferToTexture is not supported in WebGL")}function tv(t,e){let{sourceTexture:r,mipLevel:i=0,aspect:s="all",width:o=e.sourceTexture.width,height:n=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:h,rowsPerImage:u}=e;if(r instanceof B){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:o,height:n,depthOrArrayLayers:a,mipLevel:i,aspect:s,byteOffset:f},l);return}if(s!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||h||u)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=pb(r),g;try{let m=l,_=o||d.width,b=n||d.height,y=Ar(d.colorAttachments[0]),T=Za(y.texture.props.format),S=T.format,A=T.type;t.gl.bindBuffer(35051,m.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],_,b,S,A,f)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function rv(t,e){let{sourceTexture:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:o=[0,0,0],destinationTexture:n}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:f}=pb(r),[h=0,u=0]=s,[d,p,g]=o,m=t.gl.bindFramebuffer(36160,l.handle),_,b;if(n instanceof St)_=n,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),b=_.glTarget;else throw new Error("invalid destination");switch(b){case 3553:case 34067:t.gl.copyTexSubImage2D(b,i,d,p,h,u,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(b,i,d,p,g,h,u,a,c);break;default:}_&&_._unbind(),t.gl.bindFramebuffer(36160,m),f&&l.destroy()}function pb(t){if(t instanceof B){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var _c,gb=E(()=>{L();Hi();hc();_c=class extends ci{device;handle=null;commands=[];constructor(e,r={}){super(e,r),this.device=e}_executeCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":JP(this.device,r.options);break;case"copy-buffer-to-texture":ev(this.device,r.options);break;case"copy-texture-to-buffer":tv(this.device,r.options);break;case"copy-texture-to-texture":rv(this.device,r.options);break;default:throw new Error(r.name)}}}});var iv,yc,mb=E(()=>{L();cc();zi();iv=[1,2,4,8],yc=class extends Mt{device;handle=null;glParameters={};constructor(e,r){super(e,r),this.device=e;let i=this.props.framebuffer,s=!i||i.handle===null;s&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let o;if(!r?.parameters?.viewport)if(s){let[n,a]=e.getDefaultCanvasContext().getDrawingBufferSize();o=[0,0,n,a]}else{let{width:n,height:a}=i;o=[0,0,n,a]}if(this.device.pushState(),this.setParameters({viewport:o,...this.props.parameters}),s)this.device.gl.drawBuffers([1029]);else{let n=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(n)}this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference!==void 0&&(r[2967]=e.stencilReference,r[36003]=e.stencilReference),"colorMask"in e&&(r.colorMask=iv.map(i=>Boolean(i&e.colorMask))),this.glParameters=r,Qe(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((i,s)=>{i&&this.clearColorBuffer(s,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,e.clearStencil=this.props.clearStencil),r!==0&&xt(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){xt(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var So,_b=E(()=>{L();gb();mb();So=class extends ai{device;handle=null;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new _c(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new yc(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,r){e.writeTimestamp(r)}}});function yb(t){let{target:e,source:r,start:i=0,count:s=1}=t,o=r.length,n=s*o,a=0;for(let c=i;a<o;a++)e[c++]=r[a]??0;for(;a<n;)a<n-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+n-a),a=n);return t.target}var bb=E(()=>{});function sv(t){return Array.isArray(t)?new Float32Array(t):t}function ov(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var $i,Tb=E(()=>{L();Xt();vu();bb();$i=class extends fi{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return rl()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:o,stride:n,offset:a,normalized:c,integer:l,divisor:f}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,s,o,n,a):this.device.gl.vertexAttribPointer(e,s,o,c,n,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,f||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let i=$a(r.bufferDataType);return{size:r.bufferComponents,type:i,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let s=$i.isConstantAttributeZeroSupported(this.device)||e!==0;(r||s)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let i=sv(r),s=i.byteLength*e,o=i.length*e;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let n=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),n||=!ov(i,this.bufferValue),n){let a=Jl(r.constructor,o);yb({target:a,source:i,start:0,count:o}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function xb(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var bc,Ab=E(()=>{L();Tc();Wu();bc=class extends hi{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(ib(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,i]of Object.entries(e))this.setBuffer(r,i)})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:s,byteLength:o,byteOffset:n}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=s,x.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:s,byteLength:o,byteOffset:n},this.bindOnUse||this._bindBuffer(i,s,n,o)}getBuffer(e){if(xb(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return this.buffers[r]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof tt)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:s}}_getVaryingIndex(e){if(xb(e))return Number(e);for(let r of this.layout.varyings||[])if(e===r.name)return r.location;return-1}_bindBuffers(){for(let[e,r]of Object.entries(this.buffers)){let{buffer:i,byteLength:s,byteOffset:o}=this._getBufferRange(r);this._bindBuffer(Number(e),i,o,s)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,s){let o=r&&r.handle;!o||s===void 0?this.gl.bindBufferBase(35982,e,o):this.gl.bindBufferRange(35982,e,o,i,s)}}});var xc,Sb=E(()=>{L();xc=class extends ui{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){if(super(e,r),this.device=e,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let r of e.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((r,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let r=e?.firstQuery||0,i=e?.queryCount||this.props.count-r;if(this._validateRange(r,i),this.props.type==="timestamp"){let s=new Array(i).fill(0n),o=Math.floor(r/2),n=Math.floor((r+i-1)/2);for(let a=o;a<=n;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,f=l+1;l>=r&&l<r+i&&(s[l-r]=0n),f>=r&&f<r+i&&(s[f-r]=c)}return s}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||r>=this.props.count||r<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||r!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(e),i=this._timestampPairs[r];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let s=this.device.gl.createQuery();if(!s)throw new Error("WebGL query not supported");let o={handle:s,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,s),i.activeQuery=o;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,r){if(e<0||r<0||e+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let r=this._timestampPairs[e];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=Boolean(this.device.gl.getParameter(36795));return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let r=this._timestampPairs[e];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=r.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((r,i)=>{e.resolve=r,e.reject=i;let s=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,r(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(s);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):r(e.result||0n)};s()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let r=e.resolve;e.promise=null,e.resolve=null,e.reject=null,r(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var Ac,Eb=E(()=>{L();Ac=class extends di{device;gl;handle;signaled;_signaled=!1;constructor(e,r={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(s=>{let o=()=>{let n=this.gl.clientWaitSync(this.handle,0,0);n===this.gl.ALREADY_SIGNALED||n===this.gl.CONDITION_SATISFIED?(this._signaled=!0,s()):setTimeout(o,1)};o()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function ju(t){switch(t){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function wb(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var Rb=E(()=>{});function Pb(t,e){let{sourceX:r=0,sourceY:i=0,sourceAttachment:s=0}=e||{},{target:o=null,sourceWidth:n,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{},{framebuffer:h,deleteFramebuffer:u}=Mb(t),{gl:d,handle:p}=h;n||=h.width,a||=h.height;let g=h.colorAttachments[s]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${s}`);c=g?.depth||1,l||=g?.glFormat||6408,f||=g?.glType||5121,o=av(o,f,l,n,a,c);let m=de.getDataType(o);f=f||ab(m);let _=d.bindFramebuffer(36160,p);return d.readBuffer(36064+s),d.readPixels(r,i,n,a,l,f,o),d.readBuffer(36064),d.bindFramebuffer(36160,_||null),u&&h.destroy(),o}function vb(t,e){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:o=6408,targetByteOffset:n=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:f,deleteFramebuffer:h}=Mb(t);a=a||f.width,c=c||f.height;let u=f;l=l||5121;let d=r;if(!d){let g=ju(o),m=wb(l),_=n+a*c*g*m;d=u.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[i,s],destinationBuffer:d,byteOffset:n}),p.destroy(),h&&f.destroy(),d}function Mb(t){return t instanceof nt?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:nv(t),deleteFramebuffer:!0}}function nv(t,e){let{device:r,width:i,height:s,id:o}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${o}`,width:i,height:s,colorAttachments:[t]})}function av(t,e,r,i,s,o){if(t)return t;e||=5121;let n=lc(e),a=de.getTypedArrayConstructor(n),c=ju(r);return new a(i*s*c)}var Cb=E(()=>{L();gc();Rb();zu()});var Hu={};Rt(Hu,{WebGLDevice:()=>rt});function cv(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:}}function lv(t,e,r){t.gl.vertexAttribI4iv(e,r)}function fv(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function hv(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var rt,Sc=E(()=>{L();Pu();Iy();Wa();Dy();Wy();jy();Hy();$y();xu();Au();Hi();Yy();tc();qy();Jy();hc();Qa();nb();db();_b();Tb();Ab();Sb();Eb();Cb();zi();cc();To();rt=class extends xe{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||Xy("webgl-device")});let r=xe._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=r.canvas?.gl??null,s=rt.getDeviceFromContext(i);if(s)throw new Error(`WebGL context already attached to device ${s.id}`);this.canvasContext=new Ja(this,r),this.lost=new Promise(f=>{this._resolveContextLost=f});let o={...e.webgl};r.alphaMode==="premultiplied"&&(o.premultipliedAlpha=!0),e.powerPreference!==void 0&&(o.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(o.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||Cy(this.canvasContext.canvas,{onContextLost:f=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:f=>console.log("WebGL context restored")},o);if(!a)throw new Error("WebGL context creation failed");if(s=rt.getDeviceFromContext(a),s){if(e._reuseDevices)return x.log(1,`Not creating a new Device, instead returning a reference to Device ${s.id} already attached to WebGL context`,s)(),this.canvasContext.destroy(),s._reused=!0,s;throw new Error(`WebGL context already attached to device ${s.id}`)}this.handle=a,this.gl=a,this.spectorJS=gy({...this.props,gl:this.handle});let c=jr(this.handle);c.device=this,this.extensions=c.extensions||(c.extensions={}),this.info=Oy(this.gl,this.extensions),this.limits=new Ga(this.gl),this.features=new qa(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Je(this.gl,{log:(...f)=>x.log(1,...f)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=by(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),x.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(x.level=Math.max(x.level,1)),this.commandEncoder=new So(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=jr(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new ec(this,e||{})}createBuffer(e){let r=this._normalizeBufferProps(e);return new tt(this,r)}createTexture(e){return new St(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ac(this,e)}createShader(e){return new ic(this,e)}createFramebuffer(e){return new Tt(this,e)}createVertexArray(e){return new $i(this,e)}createTransformFeedback(e){return new bc(this,e)}createQuerySet(e){return new xc(this,e)}createFence(){return new Ac(this)}createRenderPipeline(e){return new uc(this,e)}_createSharedRenderPipelineWebGL(e){return new mc(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new So(this,e)}submit(e){let r=null;e||({submittedCommandEncoder:r,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,r=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:r}}readPixelsToArrayWebGL(e,r){return Pb(e,r)}readPixelsToBufferWebGL(e,r){return vb(e,r)}setParametersWebGL(e){Qe(this.gl,e)}getParametersWebGL(e){return Ha(this.gl,e)}withParametersWebGL(e,r){return xt(this.gl,e,r)}resetWebGL(){x.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),wy(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return ky(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Je.get(this.gl).push()}popState(){Je.get(this.gl).pop()}getGLKey(e,r){let i=Number(e);for(let s in this.gl)if(this.gl[s]===i)return`GL.${s}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[s,o])=>(i[`${s}:${this.getGLKey(s,r)}`]=`${o}:${this.getGLKey(o,r)}`,i),{})}setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let s=this._constants[e];switch(s&&hv(s,r)&&x.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:cv(this,e,r);break;case Int32Array:lv(this,e,r);break;case Uint32Array:fv(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return et(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,r,i){e.luma=r;let s={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=s}}});function uv(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&typeof t.createVertexArray=="function")}var Eo,$u,wo,Ib=E(()=>{L();uy();xu();Au();Eo=1,$u=class extends is{type="webgl";constructor(){super(),xe.defaultProps={...xe.defaultProps,...ja}}enforceWebGL2(e){hy(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&x.warn("WebGL1 is not supported",e)(),!1)}async attach(e,r={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(Sc(),Hu));if(e instanceof i)return e;let s=i.getDeviceFromContext(e);if(s)return s;if(!uv(e))throw new Error("Invalid WebGL2RenderingContext");let o=r.createCanvasContext===!0?{}:r.createCanvasContext;return new i({...r,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...o}})}async create(e={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(Sc(),Hu)),i=[];(e.debugWebGL||e.debug)&&i.push(yy()),e.debugSpectorJS&&i.push(py(e));let s=await Promise.allSettled(i);for(let o of s)o.status==="rejected"&&x.error(`Failed to initialize debug libraries ${o.reason}`)();try{let o=new r(e);x.groupCollapsed(Eo,`WebGLDevice ${o.id} created`)();let n=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return x.probe(Eo,n)(),x.table(Eo,o.info)(),o}finally{x.groupEnd(Eo)(),x.info(Eo,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};wo=new $u});var Tc=E(()=>{Ib();Sc();tc()});var x2={};Rt(x2,{AmbientLight:()=>Ni,Attribute:()=>$t,AttributeManager:()=>$r,COORDINATE_SYSTEM:()=>k,CompositeLayer:()=>s0,Controller:()=>Te,Deck:()=>Ec,DeckGL:()=>Xo,DeckRenderer:()=>Wr,DirectionalLight:()=>Ft,FirstPersonController:()=>Kr,FirstPersonView:()=>n0,FirstPersonViewport:()=>jc,FlyToInterpolator:()=>Ho,Layer:()=>Fc,LayerExtension:()=>d0,LayerManager:()=>Vr,LightingEffect:()=>ur,LinearInterpolator:()=>ce,MapController:()=>Ht,MapView:()=>Fa,OPERATION:()=>E_,OrbitController:()=>Zr,OrbitView:()=>a0,OrbitViewport:()=>kc,OrthographicController:()=>qr,OrthographicView:()=>l0,OrthographicViewport:()=>zc,PointLight:()=>Li,PostProcessEffect:()=>oo,TRANSITION_EVENTS:()=>lo,TerrainController:()=>Wo,Tesselator:()=>$o,TransitionInterpolator:()=>zt,UNIT:()=>lr,VERSION:()=>sa,View:()=>be,Viewport:()=>Ee,WebMercatorViewport:()=>dr,Widget:()=>mr,_CameraLight:()=>ro,_Component:()=>Ki,_ComponentState:()=>Xr,_GlobeController:()=>Gr,_GlobeView:()=>u0,_GlobeViewport:()=>ki,_LayersPass:()=>Ye,_PickLayersPass:()=>Lt,_SunLight:()=>io,_applyStyles:()=>mo,_compareProps:()=>Nc,_count:()=>Dc,_deepEqual:()=>Z,_fillArray:()=>Ma,_flatten:()=>gr,_memoize:()=>Ue,_mergeShaders:()=>Fo,_registerLoggers:()=>ia,_removeStyles:()=>Va,assert:()=>Y,color:()=>Xh,createIterable:()=>Xi,fp64LowPart:()=>hu,getShaderAssembler:()=>Sa,gouraudMaterial:()=>ys,log:()=>F,phongMaterial:()=>bs,picking:()=>lu,project:()=>fr,project32:()=>iu,shadow:()=>Oi});var fh={};Rt(fh,{Buffer:()=>I,BufferTransform:()=>je,CubeGeometry:()=>Ps,Device:()=>xe,Framebuffer:()=>nt,Geometry:()=>He,GroupNode:()=>rr,Model:()=>ve,ModelNode:()=>Rs,ScenegraphNode:()=>lt,SphereGeometry:()=>ws,Texture:()=>B,TextureTransform:()=>Ss,attachDevice:()=>lE,createDevice:()=>fE,enforceWebGL2:()=>hE,getSupportedAdapters:()=>aE,setDefaultDeviceProps:()=>cE,stats:()=>nE});L();L();var HT=1,$T=1,Er=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:i=Number.POSITIVE_INFINITY,rate:s=1,repeat:o=1}=e,n=HT++,a={time:0,delay:r,duration:i,rate:s,repeat:o};return this._setChannelTime(a,this.time),this.channels.set(n,a),n}removeChannel(e){this.channels.delete(e);for(let[r,i]of this.animations)i.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let s of r)this._setChannelTime(s,this.time);let i=this.animations.values();for(let s of i){let{animation:o,channel:n}=s;o.setTime(this.getTime(n))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=$T++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let i=r-e.delay,s=e.duration*e.repeat;i>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};L();function wp(t){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function Rp(t){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}qi();var XT=0,YT="Animation Loop",rf=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...rf.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Ne({id:`animation-loop-${XT++}`}),this.sharedStats=Zt.stats.get(YT),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport}),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),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=wp(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Rp(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let r=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:r,useDevicePixels:i,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&r>0?e/r:1;return{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let r=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=r-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let r=this.sharedStats.get(e.name,e.type);r.sampleSize=e.sampleSize,r.time=e.time,r.count=e.count,r.samples=e.samples,r.lastTiming=e.lastTiming,r.lastSampleTime=e.lastSampleTime,r.lastSampleCount=e.lastSampleCount,r._count=e._count,r._time=e._time,r._samples=e._samples,r._startTime=e._startTime,r._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},gi=rf;P(gi,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});L();function wr(t,e){if(!t){let r=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,wr),r}}var sf={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function vp(t){let e={};for(let[r,i]of Object.entries(t))e[r]=KT(i);return e}function KT(t){let e=Pp(t);if(e!=="object")return{value:t,...sf[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...sf[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=Pp(t.value),{...t,...sf[e],type:e}):{type:"object",value:null};throw new Error("props")}function Pp(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var Mp=`#ifdef MODULE_LOGDEPTH
|
|
20
20
|
logdepth_adjustPosition(gl_Position);
|
|
21
21
|
#endif
|
|
22
|
-
`,
|
|
22
|
+
`,Cp=`#ifdef MODULE_MATERIAL
|
|
23
23
|
fragColor = material_filterColor(fragColor);
|
|
24
24
|
#endif
|
|
25
25
|
|
|
@@ -39,9 +39,12 @@ ${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(thi
|
|
|
39
39
|
#ifdef MODULE_LOGDEPTH
|
|
40
40
|
logdepth_setFragDepth();
|
|
41
41
|
#endif
|
|
42
|
-
`;var
|
|
42
|
+
`;var ZT={vertex:Mp,fragment:Cp},Ip=/void\s+main\s*\([^)]*\)\s*\{\n?/,Op=/}\n?[^{}]*$/,of=[],hs="__LUMA_INJECT_DECLARATIONS__";function Np(t){let e={vertex:{},fragment:{}};for(let r in t){let i=t[r],s=qT(r);typeof i=="string"&&(i={order:0,injection:i}),e[s][r]=i}return e}function qT(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function us(t,e,r,i=!1){let s=e==="vertex";for(let o in r){let n=r[o];n.sort((c,l)=>c.order-l.order),of.length=n.length;for(let c=0,l=n.length;c<l;++c)of[c]=n[c].injection;let a=`${of.join(`
|
|
43
43
|
`)}
|
|
44
|
-
`;switch(o){case"vs:#decl":s&&(t=t.replace(
|
|
44
|
+
`;switch(o){case"vs:#decl":s&&(t=t.replace(hs,a));break;case"vs:#main-start":s&&(t=t.replace(Ip,c=>c+a));break;case"vs:#main-end":s&&(t=t.replace(Op,c=>a+c));break;case"fs:#decl":s||(t=t.replace(hs,a));break;case"fs:#main-start":s||(t=t.replace(Ip,c=>c+a));break;case"fs:#main-end":s||(t=t.replace(Op,c=>a+c));break;default:t=t.replace(o,c=>c+a)}}return t=t.replace(hs,""),i&&(t=t.replace(/\}\s*$/,o=>o+ZT[e])),t}function Rr(t){t.map(e=>xn(e))}function xn(t){if(t.instance)return;Rr(t.dependencies||[]);let{propTypes:e={},deprecations:r=[],inject:i={}}=t,s={normalizedInjections:Np(i),parsedDeprecations:GT(r)};e&&(s.propValidators=vp(e)),t.instance=s;let o={};e&&(o=Object.entries(e).reduce((n,[a,c])=>{let l=c?.value;return l&&(n[a]=l),n},{})),t.defaultUniforms={...t.defaultUniforms,...o}}function nf(t,e,r){t.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?r.deprecated(i.old,i.new)():r.removed(i.old,i.new)())})}function GT(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function mi(t){Rr(t);let e={},r={};Dp({modules:t,level:0,moduleMap:e,moduleDepth:r});let i=Object.keys(r).sort((s,o)=>r[o]-r[s]).map(s=>e[s]);return Rr(i),i}function Dp(t){let{modules:e,level:r,moduleMap:i,moduleDepth:s}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let o of e)i[o.name]=o,(s[o.name]===void 0||s[o.name]<r)&&(s[o.name]=r);for(let o of e)o.dependencies&&Dp({modules:o.dependencies,level:r+1,moduleMap:i,moduleDepth:s})}var QT=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,JT=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Bp(t){return`${t.name}Uniforms`}function ex(t,e){let r=e==="wgsl"?t.source:e==="vertex"?t.vs:t.fs;if(!r)return null;let i=Bp(t);return rx(r,e==="wgsl"?"wgsl":"glsl",i)}function tx(t,e){let r=Object.keys(t.uniformTypes||{});if(!r.length)return null;let i=ex(t,e);return i?{moduleName:t.name,uniformBlockName:Bp(t),stage:e,expectedUniformNames:r,actualUniformNames:i,matches:ox(r,i)}:null}function Fp(t,e,r={}){let i=tx(t,e);if(!i||i.matches)return i;let s=nx(i);return r.log?.error?.(s,i)(),r.throwOnError!==!1&&wr(!1,s),i}function Lp(t){let e=[],r=ax(t);for(let i of r.matchAll(JT)){let s=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:s,hasLayoutQualifier:Boolean(s),isStd140:Boolean(s&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(s))})}return e}function Up(t,e,r,i){let s=Lp(t).filter(n=>!n.isStd140),o=new Set;for(let n of s){if(o.has(n.blockName))continue;o.add(n.blockName);let a=i?.label?`${i.label} `:"",c=n.hasLayoutQualifier?`declares ${cx(n.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${n.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(l,n)()}return s}function rx(t,e,r){let i=e==="wgsl"?ix(t,r):sx(t,r);if(!i)return null;let s=[];for(let o of i.split(`
|
|
45
|
+
`)){let n=o.replace(/\/\/.*$/,"").trim();if(!n||n.startsWith("#"))continue;let a=e==="wgsl"?n.match(/^([A-Za-z0-9_]+)\s*:/):n.match(QT);a&&s.push(a[1])}return s}function ix(t,e){let r=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(t);if(!r)return null;let i=t.indexOf("{",r.index);if(i<0)return null;let s=0;for(let o=i;o<t.length;o++){let n=t[o];if(n==="{"){s++;continue}if(n==="}"&&(s--,s===0))return t.slice(i+1,o)}return null}function sx(t,e){return Lp(t).find(i=>i.blockName===e)?.body||null}function ox(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function nx(t){return`${t.moduleName}: ${t.stage} shader uniform block ${t.uniformBlockName} does not match module.uniformTypes.
|
|
46
|
+
Expected: ${t.expectedUniformNames.join(", ")}
|
|
47
|
+
Actual: ${t.actualUniformNames.join(", ")}`}function ax(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function cx(t){return t.replace(/\s+/g," ").trim()}function kp(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
45
48
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
46
49
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
47
50
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -65,46 +68,49 @@ ${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(thi
|
|
|
65
68
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
66
69
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
67
70
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
68
|
-
`}}function
|
|
69
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
71
|
+
`}}function zp(t,e){if(Number(t.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return t=Vp(t,lx),t;case"fragment":return t=Vp(t,fx),t;default:throw new Error(e)}}var Wp=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
72
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],lx=[...Wp,[af("attribute"),"in $1"],[af("varying"),"out $1"]],fx=[...Wp,[af("varying"),"in $1"]];function Vp(t,e){for(let[r,i]of e)t=t.replace(r,i);return t}function af(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function cf(t,e){let r="";for(let i in t){let s=t[i];if(r+=`void ${s.signature} {
|
|
70
73
|
`,s.header&&(r+=` ${s.header}`),e[i]){let o=e[i];o.sort((n,a)=>n.order-a.order);for(let n of o)r+=` ${n.injection}
|
|
71
74
|
`}s.footer&&(r+=` ${s.footer}`),r+=`}
|
|
72
|
-
`}return r}function
|
|
75
|
+
`}return r}function lf(t){let e={vertex:{},fragment:{}};for(let r of t){let i,s;typeof r!="string"?(i=r,s=i.hook):(i={},s=r),s=s.trim();let[o,n]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(i,{signature:n});switch(o){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(o)}}return e}function jp(t,e){return{name:hx(t,e),language:"glsl",version:ux(t)}}function hx(t,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return i?i[1]:e}function ux(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Hp=[/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*var(?:<([^>]+)>)?\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^;]+);/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*var(?:<([^>]+)>)?\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^;]+);/g];function An(t,e=[]){let r=new Map;for(let s of e)r.set($p(s.name,s.group,s.location),s.moduleName);let i=[];for(let s of Hp){s.lastIndex=0;let o;for(;o=s.exec(t);){let n=s===Hp[0],a=Number(o[n?1:2]),c=Number(o[n?2:1]),l=o[3]?.trim(),f=o[4],h=o[5].trim(),u=r.get($p(f,c,a));i.push(dx({name:f,group:c,binding:a,owner:u?"module":"application",moduleName:u,accessDeclaration:l,resourceType:h}))}}return i.sort((s,o)=>s.group!==o.group?s.group-o.group:s.binding!==o.binding?s.binding-o.binding:s.name.localeCompare(o.name))}function dx(t){let e={name:t.name,group:t.group,binding:t.binding,owner:t.owner,kind:"unknown",moduleName:t.moduleName,resourceType:t.resourceType};if(t.accessDeclaration){let r=t.accessDeclaration.split(",").map(i=>i.trim());if(r[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let i=r[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return t.resourceType==="sampler"||t.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:t.resourceType==="sampler_comparison"?"comparison":"filtering"}:t.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:gx(t.resourceType),viewDimension:Xp(t.resourceType)}:t.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:Xp(t.resourceType),sampleType:px(t.resourceType),multisampled:t.resourceType.startsWith("texture_multisampled_")}:e}function $p(t,e,r){return`${e}:${r}:${t}`}function Xp(t){if(t.includes("cube_array"))return"cube-array";if(t.includes("2d_array"))return"2d-array";if(t.includes("cube"))return"cube";if(t.includes("3d"))return"3d";if(t.includes("2d"))return"2d";if(t.includes("1d"))return"1d"}function px(t){if(t.startsWith("texture_depth_"))return"depth";if(t.includes("<i32>"))return"sint";if(t.includes("<u32>"))return"uint";if(t.includes("<f32>"))return"float"}function gx(t){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(t)?.[1]}var Qp=`
|
|
73
76
|
|
|
74
|
-
${
|
|
75
|
-
`,
|
|
76
|
-
`;function
|
|
77
|
+
${hs}
|
|
78
|
+
`,Sn=[/@binding\(\s*(auto|\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(auto|\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g],Yp=[/@binding\(\s*(\d+)\s*\)\s*@group\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g,/@group\(\s*(\d+)\s*\)\s*@binding\(\s*(\d+)\s*\)\s*(var(?:<[^>]+>)?\s+([A-Za-z_][A-Za-z0-9_]*))/g],ds=100,mx=`precision highp float;
|
|
79
|
+
`;function Jp(t){let e=mi(t.modules||[]),{source:r,bindingAssignments:i}=_x(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e});return{source:r,getUniforms:tg(e),bindingAssignments:i,bindingTable:An(r,i)}}function eg(t){let{vs:e,fs:r}=t,i=mi(t.modules||[]);return{vs:Kp(t.platformInfo,{...t,source:e,stage:"vertex",modules:i}),fs:Kp(t.platformInfo,{...t,source:r,stage:"fragment",modules:i}),getUniforms:tg(i)}}function _x(t,e){let{source:r,stage:i,modules:s,hookFunctions:o=[],inject:n={},log:a}=e;wr(typeof r=="string","shader source must be a string");let c=r,l="",f=lf(o),h={},u={},d={};for(let b in n){let y=typeof n[b]=="string"?{injection:n[b],order:0}:n[b],T=/^(v|f)s:(#)?([\w-]+)$/.exec(b);if(T){let S=T[2],A=T[3];S?A==="decl"?u[b]=[y]:d[b]=[y]:h[b]=[y]}else d[b]=[y]}let p=s,g=bx(c),m=Ax(p,e._bindingRegistry,g),_=[];for(let b of p){a&&nf(b,c,a);let y=Tx(rg(b,"wgsl",a),b,{usedBindingsByGroup:g,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:m});_.push(...y.bindingAssignments);let T=y.source;l+=T;let S=b.injections?.[i]||{};for(let A in S){let w=/^(v|f)s:#([\w-]+)$/.exec(A);if(w){let R=w[2]==="decl"?u:d;R[A]=R[A]||[],R[A].push(S[A])}else h[A]=h[A]||[],h[A].push(S[A])}}return l+=Qp,l=us(l,i,u),l+=cf(f[i],h),l+=Px(_),l+=c,l=us(l,i,d),Rx(l),{source:l,bindingAssignments:_}}function Kp(t,e){let{source:r,stage:i,language:s="glsl",modules:o,defines:n={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:f}=e;wr(typeof r=="string","shader source must be a string");let h=s==="glsl"?jp(r).version:-1,u=t.shaderLanguageVersion,d=h===100?"#version 100":"#version 300 es",g=r.split(`
|
|
77
80
|
`).slice(1).join(`
|
|
78
81
|
`),m={};o.forEach(A=>{Object.assign(m,A.defines)}),Object.assign(m,n);let _="";switch(s){case"wgsl":break;case"glsl":_=l?`${d}
|
|
79
82
|
|
|
80
83
|
// ----- PROLOGUE -------------------------
|
|
81
84
|
${`#define SHADER_TYPE_${i.toUpperCase()}`}
|
|
82
85
|
|
|
83
|
-
${
|
|
84
|
-
${i==="fragment"?
|
|
86
|
+
${kp(t)}
|
|
87
|
+
${i==="fragment"?mx:""}
|
|
85
88
|
|
|
86
89
|
// ----- APPLICATION DEFINES -------------------------
|
|
87
90
|
|
|
88
|
-
${
|
|
91
|
+
${yx(m)}
|
|
89
92
|
|
|
90
93
|
`:`${d}
|
|
91
|
-
`;break}let
|
|
92
|
-
`)}return e}function
|
|
93
|
-
|
|
94
|
-
`;return e!=="wgsl"&&(
|
|
95
|
-
`),
|
|
96
|
-
`,
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
`;break}let b=lf(a),y={},T={},S={};for(let A in c){let w=typeof c[A]=="string"?{injection:c[A],order:0}:c[A],v=/^(v|f)s:(#)?([\w-]+)$/.exec(A);if(v){let R=v[2],M=v[3];R?M==="decl"?T[A]=[w]:S[A]=[w]:y[A]=[w]}else S[A]=[w]}for(let A of o){f&&nf(A,g,f);let w=rg(A,i,f);_+=w;let v=A.instance?.normalizedInjections[i]||{};for(let R in v){let M=/^(v|f)s:#([\w-]+)$/.exec(R);if(M){let C=M[2]==="decl"?T:S;C[R]=C[R]||[],C[R].push(v[R])}else y[R]=y[R]||[],y[R].push(v[R])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=Qp,_=us(_,i,T),_+=cf(b[i],y),_+=g,_=us(_,i,S),s==="glsl"&&h!==u&&(_=zp(_,i)),s==="glsl"&&Up(_,i,f),_.trim()}function tg(t){return function(r){let i={};for(let s of t){let o=s.getUniforms?.(r,i);Object.assign(i,o)}return i}}function yx(t={}){let e="";for(let r in t){let i=t[r];(i||Number.isFinite(i))&&(e+=`#define ${r.toUpperCase()} ${t[r]}
|
|
95
|
+
`)}return e}function rg(t,e,r){let i;switch(e){case"vertex":i=t.vs||"";break;case"fragment":i=t.fs||"";break;case"wgsl":i=t.source||"";break;default:wr(!1)}if(!t.name)throw new Error("Shader module must have a name");Fp(t,e,{log:r});let s=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),o=`// ----- MODULE ${t.name} ---------------
|
|
96
|
+
|
|
97
|
+
`;return e!=="wgsl"&&(o+=`#define MODULE_${s}
|
|
98
|
+
`),o+=`${i}
|
|
99
|
+
`,o}function bx(t){let e=new Map;for(let r of Yp){r.lastIndex=0;let i;for(;i=r.exec(t);){let s=r===Yp[0],o=Number(i[s?1:2]),n=Number(i[s?2:1]),a=i[4];wx(n,o,a),En(e,n,o,`application binding "${a}"`)}}return e}function Tx(t,e,r){let i=[],s={sawSupportedBindingDeclaration:!1,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=Zp(t,Sn[0],{isBindingFirst:!0,module:e,context:r,bindingAssignments:i,relocationState:s});if(o=Zp(o,Sn[1],{isBindingFirst:!1,module:e,context:r,bindingAssignments:i,relocationState:s}),t.includes("@binding(auto)")&&!s.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use "@group(N) @binding(auto) var ..." or "@binding(auto) @group(N) var ..." on a single line.`);return{source:o,bindingAssignments:i}}function Zp(t,e,r){return t.replace(e,(...i)=>xx(i,r))}function xx(t,e){let{isBindingFirst:r,module:i,context:s,bindingAssignments:o,relocationState:n}=e;n.sawSupportedBindingDeclaration=!0;let a=t[0],c=t[r?1:2],l=t[r?2:1],f=t[4],h=Number(l);if(c==="auto"){let d=ig(h,i.name,f),p=s.bindingRegistry?.get(d),g=p!==void 0?p:n.nextHintedBindingLocation===null?Gp(h,s.usedBindingsByGroup):Gp(h,s.usedBindingsByGroup,n.nextHintedBindingLocation);return qp(i.name,h,g,f),p!==void 0&&Sx(s.reservedBindingKeysByGroup,h,g,d)?(o.push({moduleName:i.name,name:f,group:h,location:g}),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${g})`)):(En(s.usedBindingsByGroup,h,g,`module "${i.name}" binding "${f}"`),s.bindingRegistry?.set(d,g),o.push({moduleName:i.name,name:f,group:h,location:g}),n.nextHintedBindingLocation!==null&&p===void 0&&(n.nextHintedBindingLocation=g+1),a.replace(/@binding\(\s*auto\s*\)/,`@binding(${g})`))}let u=Number(c);return qp(i.name,h,u,f),En(s.usedBindingsByGroup,h,u,`module "${i.name}" binding "${f}"`),o.push({moduleName:i.name,name:f,group:h,location:u}),a}function Ax(t,e,r){let i=new Map;if(!e)return i;for(let s of t)for(let o of Ex(s)){let n=ig(o.group,s.name,o.name),a=e.get(n);if(a!==void 0){let c=i.get(o.group)||new Map,l=c.get(a);if(l&&l!==n)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${n}": group ${o.group}, binding ${a}.`);En(r,o.group,a,`registered module binding "${n}"`),c.set(a,n),i.set(o.group,c)}}return i}function Sx(t,e,r,i){let s=t.get(e);if(!s)return!1;let o=s.get(r);if(!o)return!1;if(o!==i)throw new Error(`Registered module binding "${i}" collided with "${o}": group ${e}, binding ${r}.`);return!0}function Ex(t){let e=[],r=t.source||"";for(let i of Sn){i.lastIndex=0;let s;for(;s=i.exec(r);){let o=i===Sn[0];e.push({name:s[4],group:Number(s[o?2:1])})}}return e}function wx(t,e,r){if(t===0&&e>=ds)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${ds}.`)}function qp(t,e,r,i){if(e===0&&r<ds)throw new Error(`Module "${t}" binding "${i}" in group 0 uses reserved application binding ${r}. Module-owned explicit group-0 bindings must be ${ds} or higher.`)}function En(t,e,r,i){let s=t.get(e)||new Set;if(s.has(r))throw new Error(`Duplicate WGSL binding assignment for ${i}: group ${e}, binding ${r}.`);s.add(r),t.set(e,s)}function Gp(t,e,r){let i=e.get(t)||new Set,s=r??(t===0?ds:i.size>0?Math.max(...i)+1:0);for(;i.has(s);)s++;return s}function Rx(t){if(/@binding\(\s*auto\s*\)/.test(t))throw new Error("Unresolved @binding(auto) remained in assembled WGSL source.")}function Px(t){if(t.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
|
|
100
|
+
`;for(let r of t)e+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location})
|
|
101
|
+
`;return e+=`
|
|
102
|
+
`,e}function ig(t,e,r){return`${t}:${e}:${r}`}var ff="([a-zA-Z_][a-zA-Z0-9_]*)",vx=new RegExp(`^\\s*\\#\\s*ifdef\\s*${ff}\\s*$`),Mx=new RegExp(`^\\s*\\#\\s*ifndef\\s*${ff}\\s*(?:\\/\\/.*)?$`),Cx=/^\s*\#\s*else\s*(?:\/\/.*)?$/,Ix=/^\s*\#\s*endif\s*$/,Ox=new RegExp(`^\\s*\\#\\s*ifdef\\s*${ff}\\s*(?:\\/\\/.*)?$`),Nx=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function sg(t,e){let r=t.split(`
|
|
103
|
+
`),i=[],s=[],o=!0;for(let n of r){let a=n.match(Ox)||n.match(vx),c=n.match(Mx),l=n.match(Cx),f=n.match(Nx)||n.match(Ix);if(a||c){let h=(a||c)?.[1],u=Boolean(e?.defines?.[h]),d=a?u:!u,p=o&&d;s.push({parentActive:o,branchTaken:d,active:p}),o=p}else if(l){let h=s[s.length-1];if(!h)throw new Error("Encountered #else without matching #ifdef or #ifndef");h.active=h.parentActive&&!h.branchTaken,h.branchTaken=!0,o=h.active}else f?(s.pop(),o=s.length?s[s.length-1].active:!0):o&&i.push(n)}if(s.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(`
|
|
104
|
+
`)}var _i=class{_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return _i.defaultShaderAssembler=_i.defaultShaderAssembler||new _i,_i.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let r=this._getModuleList(e.modules),i=this._hookFunctions,{source:s,getUniforms:o,bindingAssignments:n}=Jp({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:r,hookFunctions:i}),a={...r.reduce((l,f)=>(Object.assign(l,f.defines),l),{}),...e.defines},c=e.platformInfo.shaderLanguage==="wgsl"?sg(s,{defines:a}):s;return{source:c,getUniforms:o,modules:r,bindingAssignments:n,bindingTable:An(c,n)}}assembleGLSLShaderPair(e){let r=this._getModuleList(e.modules),i=this._hookFunctions;return{...eg({...e,vs:e.vs,fs:e.fs,modules:r,hookFunctions:i}),modules:r}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),i={},s=0;for(let o=0,n=this._defaultModules.length;o<n;++o){let a=this._defaultModules[o],c=a.name;r[s++]=a,i[c]=!0}for(let o=0,n=e.length;o<n;++o){let a=e[o],c=a.name;i[c]||(r[s++]=a,i[c]=!0)}return r.length=s,Rr(r),r}},Jt=_i;P(Jt,"defaultShaderAssembler");var Dx=`out vec4 transform_output;
|
|
99
105
|
void main() {
|
|
100
106
|
transform_output = vec4(0);
|
|
101
|
-
}`,
|
|
102
|
-
${
|
|
107
|
+
}`,Bx=`#version 300 es
|
|
108
|
+
${Dx}`;function ps(t){let{input:e,inputChannels:r,output:i}=t||{};if(!e)return Bx;if(!r)throw new Error("inputChannels");let s=Fx(r),o=og(e,r);return`#version 300 es
|
|
103
109
|
in ${s} ${e};
|
|
104
110
|
out vec4 ${i};
|
|
105
111
|
void main() {
|
|
106
112
|
${i} = ${o};
|
|
107
|
-
}`}function ab(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function mp(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var cb=1/Math.PI*180,lb=1/180*Math.PI,fb={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...fb}};var te=globalThis.mathgl.config;function cs(t,{precision:e=te.precision}={}){return t=hb(t),`${parseFloat(t.toPrecision(e))}`}function Pt(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function hi(t,e){return zl(t,r=>r*lb,e)}function qt(t,e){return zl(t,r=>r*cb,e)}function B(t,e,r){return zl(t,i=>Math.max(e,Math.min(r,i)))}function vt(t,e,r){return Pt(t)?t.map((i,s)=>vt(i,e[s],r)):r*e+(1-r)*t}function Re(t,e,r){let i=te.EPSILON;r&&(te.EPSILON=r);try{if(t===e)return!0;if(Pt(t)&&Pt(e)){if(t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(!Re(t[s],e[s]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=te.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{te.EPSILON=i}}function hb(t){return Math.round(t/te.EPSILON)*te.EPSILON}function ub(t){return t.clone?t.clone():new Array(t.length)}function zl(t,e,r){if(Pt(t)){let i=t;r=r||ub(i);for(let s=0;s<r.length&&s<i.length;++s){let o=typeof t=="number"?t:t[s];r[s]=e(o,s,r)}return r}return e(t)}var ui=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=e[i+r];return this.check()}toArray(e=[],r=0){for(let i=0;i<this.ELEMENTS;++i)e[r+i]=this[i];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Pt(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(te)}formatString(e){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+cs(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Re(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,i){if(i===void 0)return this.lerp(this,e,r);for(let s=0;s<this.ELEMENTS;++s){let o=e[s],n=typeof r=="number"?r:r[s];this[s]=o+i*(n-o)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e[i]),r[i]);return this.check()}add(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(te.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e),r);return this.check()}get elements(){return this}};function db(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function fe(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function _n(t,e,r=""){if(te.debug&&!db(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function Wl(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var yn=class extends ui{get x(){return this[0]}set x(e){this[0]=fe(e)}get y(){return this[1]}set y(e){this[1]=fe(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let i=0;i<this.ELEMENTS;++i){let s=this[i]-e[i];r+=s*s}return fe(r)}dot(e){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*e[i];return fe(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Wl(e>=0&&e<this.ELEMENTS,"index is out of range"),fe(this[e])}setComponent(e,r){return Wl(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var ee={};At(ee,{add:()=>yb,angle:()=>Lb,ceil:()=>Tb,clone:()=>pb,copy:()=>mb,create:()=>_p,cross:()=>Cb,dist:()=>Xb,distance:()=>xp,div:()=>$b,divide:()=>bp,dot:()=>Mb,equals:()=>zb,exactEquals:()=>Vb,floor:()=>bb,forEach:()=>Kb,fromValues:()=>gb,inverse:()=>Pb,len:()=>Wb,length:()=>Sp,lerp:()=>Ib,max:()=>Ab,min:()=>xb,mul:()=>Hb,multiply:()=>Tp,negate:()=>Rb,normalize:()=>vb,random:()=>Ob,rotate:()=>Bb,round:()=>Sb,scale:()=>Eb,scaleAndAdd:()=>wb,set:()=>_b,sqrDist:()=>Yb,sqrLen:()=>Zb,squaredDistance:()=>Ap,squaredLength:()=>Ep,str:()=>kb,sub:()=>jb,subtract:()=>yp,transformMat2:()=>Nb,transformMat2d:()=>Db,transformMat3:()=>Fb,transformMat4:()=>jl,zero:()=>Ub});var q=typeof Float32Array<"u"?Float32Array:Array,it=Math.random;function De(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var xI=Math.PI/180;function _p(){let t=new q(2);return q!=Float32Array&&(t[0]=0,t[1]=0),t}function pb(t){let e=new q(2);return e[0]=t[0],e[1]=t[1],e}function gb(t,e){let r=new q(2);return r[0]=t,r[1]=e,r}function mb(t,e){return t[0]=e[0],t[1]=e[1],t}function _b(t,e,r){return t[0]=e,t[1]=r,t}function yb(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function yp(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Tp(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function bp(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Tb(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function bb(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function xb(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Ab(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function Sb(t,e){return t[0]=De(e[0]),t[1]=De(e[1]),t}function Eb(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function wb(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function xp(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function Ap(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function Sp(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function Ep(t){let e=t[0],r=t[1];return e*e+r*r}function Rb(t,e){return t[0]=-e[0],t[1]=-e[1],t}function Pb(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function vb(t,e){let r=e[0],i=e[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t}function Mb(t,e){return t[0]*e[0]+t[1]*e[1]}function Cb(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function Ib(t,e,r,i){let s=e[0],o=e[1];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t}function Ob(t,e){e=e===void 0?1:e;let r=it()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function Nb(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t}function Db(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s+r[4],t[1]=r[1]*i+r[3]*s+r[5],t}function Fb(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[3]*s+r[6],t[1]=r[1]*i+r[4]*s+r[7],t}function jl(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[4]*s+r[12],t[1]=r[1]*i+r[5]*s+r[13],t}function Bb(t,e,r,i){let s=e[0]-r[0],o=e[1]-r[1],n=Math.sin(i),a=Math.cos(i);return t[0]=s*a-o*n+r[0],t[1]=s*n+o*a+r[1],t}function Lb(t,e){let r=t[0],i=t[1],s=e[0],o=e[1],n=Math.sqrt((r*r+i*i)*(s*s+o*o)),a=n&&(r*s+i*o)/n;return Math.acos(Math.min(Math.max(a,-1),1))}function Ub(t){return t[0]=0,t[1]=0,t}function kb(t){return`vec2(${t[0]}, ${t[1]})`}function Vb(t,e){return t[0]===e[0]&&t[1]===e[1]}function zb(t,e){let r=t[0],i=t[1],s=e[0],o=e[1];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))}var Wb=Sp,jb=yp,Hb=Tp,$b=bp,Xb=xp,Yb=Ap,Zb=Ep,Kb=function(){let t=_p();return function(e,r,i,s,o,n){let a,c;for(r||(r=2),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],o(t,t,n),e[a]=t[0],e[a+1]=t[1];return e}}();function wp(t,e,r){let i=e[0],s=e[1],o=r[3]*i+r[7]*s||1;return t[0]=(r[0]*i+r[4]*s)/o,t[1]=(r[1]*i+r[5]*s)/o,t}function bn(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[3]*i+r[7]*s+r[11]*o||1;return t[0]=(r[0]*i+r[4]*s+r[8]*o)/n,t[1]=(r[1]*i+r[5]*s+r[9]*o)/n,t[2]=(r[2]*i+r[6]*s+r[10]*o)/n,t}function Rp(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t[2]=e[2],t}var pe={};At(pe,{add:()=>ex,angle:()=>Ql,bezier:()=>px,ceil:()=>tx,clone:()=>qb,copy:()=>Gb,create:()=>Pp,cross:()=>$l,dist:()=>Sx,distance:()=>Ip,div:()=>Ax,divide:()=>Cp,dot:()=>Hl,equals:()=>Tx,exactEquals:()=>yx,floor:()=>rx,forEach:()=>Px,fromValues:()=>Qb,hermite:()=>dx,inverse:()=>lx,len:()=>wx,length:()=>xn,lerp:()=>hx,max:()=>sx,min:()=>ix,mul:()=>xx,multiply:()=>Mp,negate:()=>cx,normalize:()=>fx,random:()=>gx,rotateX:()=>Zl,rotateY:()=>Kl,rotateZ:()=>ql,round:()=>ox,scale:()=>nx,scaleAndAdd:()=>ax,set:()=>Jb,slerp:()=>ux,sqrDist:()=>Ex,sqrLen:()=>Rx,squaredDistance:()=>Op,squaredLength:()=>Np,str:()=>_x,sub:()=>bx,subtract:()=>vp,transformMat3:()=>Xl,transformMat4:()=>ls,transformQuat:()=>Yl,zero:()=>mx});function Pp(){let t=new q(3);return q!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function qb(t){let e=new q(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function xn(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function Qb(t,e,r){let i=new q(3);return i[0]=t,i[1]=e,i[2]=r,i}function Gb(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Jb(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function ex(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function vp(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Mp(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Cp(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function tx(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function rx(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function ix(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function sx(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function ox(t,e){return t[0]=De(e[0]),t[1]=De(e[1]),t[2]=De(e[2]),t}function nx(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function ax(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function Ip(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(r*r+i*i+s*s)}function Op(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return r*r+i*i+s*s}function Np(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function cx(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function lx(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function fx(t,e){let r=e[0],i=e[1],s=e[2],o=r*r+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function Hl(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function $l(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[0],a=r[1],c=r[2];return t[0]=s*c-o*a,t[1]=o*n-i*c,t[2]=i*a-s*n,t}function hx(t,e,r,i){let s=e[0],o=e[1],n=e[2];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t[2]=n+i*(r[2]-n),t}function ux(t,e,r,i){let s=Math.acos(Math.min(Math.max(Hl(e,r),-1),1)),o=Math.sin(s),n=Math.sin((1-i)*s)/o,a=Math.sin(i*s)/o;return t[0]=n*e[0]+a*r[0],t[1]=n*e[1]+a*r[1],t[2]=n*e[2]+a*r[2],t}function dx(t,e,r,i,s,o){let n=o*o,a=n*(2*o-3)+1,c=n*(o-2)+o,l=n*(o-1),f=n*(3-2*o);return t[0]=e[0]*a+r[0]*c+i[0]*l+s[0]*f,t[1]=e[1]*a+r[1]*c+i[1]*l+s[1]*f,t[2]=e[2]*a+r[2]*c+i[2]*l+s[2]*f,t}function px(t,e,r,i,s,o){let n=1-o,a=n*n,c=o*o,l=a*n,f=3*o*a,h=3*c*n,u=c*o;return t[0]=e[0]*l+r[0]*f+i[0]*h+s[0]*u,t[1]=e[1]*l+r[1]*f+i[1]*h+s[1]*u,t[2]=e[2]*l+r[2]*f+i[2]*h+s[2]*u,t}function gx(t,e){e=e===void 0?1:e;let r=it()*2*Math.PI,i=it()*2-1,s=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*s,t[1]=Math.sin(r)*s,t[2]=i*e,t}function ls(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[3]*i+r[7]*s+r[11]*o+r[15];return n=n||1,t[0]=(r[0]*i+r[4]*s+r[8]*o+r[12])/n,t[1]=(r[1]*i+r[5]*s+r[9]*o+r[13])/n,t[2]=(r[2]*i+r[6]*s+r[10]*o+r[14])/n,t}function Xl(t,e,r){let i=e[0],s=e[1],o=e[2];return t[0]=i*r[0]+s*r[3]+o*r[6],t[1]=i*r[1]+s*r[4]+o*r[7],t[2]=i*r[2]+s*r[5]+o*r[8],t}function Yl(t,e,r){let i=r[0],s=r[1],o=r[2],n=r[3],a=e[0],c=e[1],l=e[2],f=s*l-o*c,h=o*a-i*l,u=i*c-s*a,d=s*u-o*h,p=o*f-i*u,g=i*h-s*f,m=n*2;return f*=m,h*=m,u*=m,d*=2,p*=2,g*=2,t[0]=a+f+d,t[1]=c+h+p,t[2]=l+u+g,t}function Zl(t,e,r,i){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0],o[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),o[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Kl(t,e,r,i){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),o[1]=s[1],o[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function ql(t,e,r,i){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),o[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),o[2]=s[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Ql(t,e){let r=t[0],i=t[1],s=t[2],o=e[0],n=e[1],a=e[2],c=Math.sqrt((r*r+i*i+s*s)*(o*o+n*n+a*a)),l=c&&Hl(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function mx(t){return t[0]=0,t[1]=0,t[2]=0,t}function _x(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function yx(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Tx(t,e){let r=t[0],i=t[1],s=t[2],o=e[0],n=e[1],a=e[2];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var bx=vp,xx=Mp,Ax=Cp,Sx=Ip,Ex=Op,wx=xn,Rx=Np,Px=function(){let t=Pp();return function(e,r,i,s,o,n){let a,c;for(r||(r=3),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var Gl=[0,0,0],An,H=class extends yn{static get ZERO(){return An||(An=new H(0,0,0),Object.freeze(An)),An}constructor(e=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&Pt(e)?this.copy(e):(te.debug&&(fe(e),fe(r),fe(i)),this[0]=e,this[1]=r,this[2]=i)}set(e,r,i){return this[0]=e,this[1]=r,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return te.debug&&(fe(e.x),fe(e.y),fe(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=fe(e)}angle(e){return Ql(this,e)}cross(e){return $l(this,this,e),this.check()}rotateX({radians:e,origin:r=Gl}){return Zl(this,this,r,e),this.check()}rotateY({radians:e,origin:r=Gl}){return Kl(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=Gl}){return ql(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return ls(this,this,e),this.check()}transformAsVector(e){return bn(this,this,e),this.check()}transformByMatrix3(e){return Xl(this,this,e),this.check()}transformByMatrix2(e){return Rp(this,this,e),this.check()}transformByQuaternion(e){return Yl(this,this,e),this.check()}};var Sn=class extends ui{toString(){let e="[";if(te.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)e+=` ${this[i*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,i){return this[r*this.RANK+e]=fe(i),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let i=e*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[i+s];return r}setColumn(e,r){let i=e*this.RANK;for(let s=0;s<this.RANK;++s)this[i+s]=r[s];return this}};var re={};At(re,{add:()=>Gx,adjoint:()=>Nx,clone:()=>Mx,copy:()=>Cx,create:()=>vx,decompose:()=>jx,determinant:()=>tf,equals:()=>r1,exactEquals:()=>t1,frob:()=>Qx,fromQuat:()=>lf,fromQuat2:()=>Vx,fromRotation:()=>Bx,fromRotationTranslation:()=>Fp,fromRotationTranslationScale:()=>Hx,fromRotationTranslationScaleOrigin:()=>$x,fromScaling:()=>Fx,fromTranslation:()=>Dx,fromValues:()=>Ix,fromXRotation:()=>Lx,fromYRotation:()=>Ux,fromZRotation:()=>kx,frustum:()=>ff,getRotation:()=>Wx,getScaling:()=>Bp,getTranslation:()=>zx,identity:()=>Dp,invert:()=>ef,lookAt:()=>df,mul:()=>i1,multiply:()=>fs,multiplyScalar:()=>Jx,multiplyScalarAndAdd:()=>e1,ortho:()=>uf,orthoNO:()=>Up,orthoZO:()=>Zx,perspective:()=>hf,perspectiveFromFieldOfView:()=>Yx,perspectiveNO:()=>Lp,perspectiveZO:()=>Xx,rotate:()=>of,rotateX:()=>nf,rotateY:()=>af,rotateZ:()=>cf,scale:()=>sf,set:()=>Ox,str:()=>qx,sub:()=>s1,subtract:()=>kp,targetTo:()=>Kx,translate:()=>rf,transpose:()=>Jl});function vx(){let t=new q(16);return q!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function Mx(t){let e=new q(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Cx(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ix(t,e,r,i,s,o,n,a,c,l,f,h,u,d,p,g){let m=new q(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=i,m[4]=s,m[5]=o,m[6]=n,m[7]=a,m[8]=c,m[9]=l,m[10]=f,m[11]=h,m[12]=u,m[13]=d,m[14]=p,m[15]=g,m}function Ox(t,e,r,i,s,o,n,a,c,l,f,h,u,d,p,g,m){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t[4]=o,t[5]=n,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=h,t[11]=u,t[12]=d,t[13]=p,t[14]=g,t[15]=m,t}function Dp(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Jl(t,e){if(t===e){let r=e[1],i=e[2],s=e[3],o=e[6],n=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=o,t[11]=e[14],t[12]=s,t[13]=n,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function ef(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],T=r*a-i*n,y=r*c-s*n,x=r*l-o*n,S=i*c-s*a,A=i*l-o*a,w=s*l-o*c,v=f*g-h*p,R=f*m-u*p,M=f*_-d*p,I=h*m-u*g,C=h*_-d*g,W=u*_-d*m,V=T*W-y*C+x*I+S*M-A*R+w*v;return V?(V=1/V,t[0]=(a*W-c*C+l*I)*V,t[1]=(s*C-i*W-o*I)*V,t[2]=(g*w-m*A+_*S)*V,t[3]=(u*A-h*w-d*S)*V,t[4]=(c*M-n*W-l*R)*V,t[5]=(r*W-s*M+o*R)*V,t[6]=(m*x-p*w-_*y)*V,t[7]=(f*w-u*x+d*y)*V,t[8]=(n*C-a*M+l*v)*V,t[9]=(i*M-r*C-o*v)*V,t[10]=(p*A-g*x+_*T)*V,t[11]=(h*x-f*A-d*T)*V,t[12]=(a*R-n*I-c*v)*V,t[13]=(r*I-i*R+s*v)*V,t[14]=(g*y-p*S-m*T)*V,t[15]=(f*S-h*y+u*T)*V,t):null}function Nx(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],T=r*a-i*n,y=r*c-s*n,x=r*l-o*n,S=i*c-s*a,A=i*l-o*a,w=s*l-o*c,v=f*g-h*p,R=f*m-u*p,M=f*_-d*p,I=h*m-u*g,C=h*_-d*g,W=u*_-d*m;return t[0]=a*W-c*C+l*I,t[1]=s*C-i*W-o*I,t[2]=g*w-m*A+_*S,t[3]=u*A-h*w-d*S,t[4]=c*M-n*W-l*R,t[5]=r*W-s*M+o*R,t[6]=m*x-p*w-_*y,t[7]=f*w-u*x+d*y,t[8]=n*C-a*M+l*v,t[9]=i*M-r*C-o*v,t[10]=p*A-g*x+_*T,t[11]=h*x-f*A-d*T,t[12]=a*R-n*I-c*v,t[13]=r*I-i*R+s*v,t[14]=g*y-p*S-m*T,t[15]=f*S-h*y+u*T,t}function tf(t){let e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],n=t[5],a=t[6],c=t[7],l=t[8],f=t[9],h=t[10],u=t[11],d=t[12],p=t[13],g=t[14],m=t[15],_=e*n-r*o,T=e*a-i*o,y=r*a-i*n,x=l*p-f*d,S=l*g-h*d,A=f*g-h*p,w=e*A-r*S+i*x,v=o*A-n*S+a*x,R=l*y-f*T+h*_,M=d*y-p*T+g*_;return c*w-s*v+m*R-u*M}function fs(t,e,r){let i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],m=e[13],_=e[14],T=e[15],y=r[0],x=r[1],S=r[2],A=r[3];return t[0]=y*i+x*a+S*h+A*g,t[1]=y*s+x*c+S*u+A*m,t[2]=y*o+x*l+S*d+A*_,t[3]=y*n+x*f+S*p+A*T,y=r[4],x=r[5],S=r[6],A=r[7],t[4]=y*i+x*a+S*h+A*g,t[5]=y*s+x*c+S*u+A*m,t[6]=y*o+x*l+S*d+A*_,t[7]=y*n+x*f+S*p+A*T,y=r[8],x=r[9],S=r[10],A=r[11],t[8]=y*i+x*a+S*h+A*g,t[9]=y*s+x*c+S*u+A*m,t[10]=y*o+x*l+S*d+A*_,t[11]=y*n+x*f+S*p+A*T,y=r[12],x=r[13],S=r[14],A=r[15],t[12]=y*i+x*a+S*h+A*g,t[13]=y*s+x*c+S*u+A*m,t[14]=y*o+x*l+S*d+A*_,t[15]=y*n+x*f+S*p+A*T,t}function rf(t,e,r){let i=r[0],s=r[1],o=r[2],n,a,c,l,f,h,u,d,p,g,m,_;return e===t?(t[12]=e[0]*i+e[4]*s+e[8]*o+e[12],t[13]=e[1]*i+e[5]*s+e[9]*o+e[13],t[14]=e[2]*i+e[6]*s+e[10]*o+e[14],t[15]=e[3]*i+e[7]*s+e[11]*o+e[15]):(n=e[0],a=e[1],c=e[2],l=e[3],f=e[4],h=e[5],u=e[6],d=e[7],p=e[8],g=e[9],m=e[10],_=e[11],t[0]=n,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=h,t[6]=u,t[7]=d,t[8]=p,t[9]=g,t[10]=m,t[11]=_,t[12]=n*i+f*s+p*o+e[12],t[13]=a*i+h*s+g*o+e[13],t[14]=c*i+u*s+m*o+e[14],t[15]=l*i+d*s+_*o+e[15]),t}function sf(t,e,r){let i=r[0],s=r[1],o=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function of(t,e,r,i){let s=i[0],o=i[1],n=i[2],a=Math.sqrt(s*s+o*o+n*n),c,l,f,h,u,d,p,g,m,_,T,y,x,S,A,w,v,R,M,I,C,W,V,J;return a<1e-6?null:(a=1/a,s*=a,o*=a,n*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,h=e[0],u=e[1],d=e[2],p=e[3],g=e[4],m=e[5],_=e[6],T=e[7],y=e[8],x=e[9],S=e[10],A=e[11],w=s*s*f+c,v=o*s*f+n*l,R=n*s*f-o*l,M=s*o*f-n*l,I=o*o*f+c,C=n*o*f+s*l,W=s*n*f+o*l,V=o*n*f-s*l,J=n*n*f+c,t[0]=h*w+g*v+y*R,t[1]=u*w+m*v+x*R,t[2]=d*w+_*v+S*R,t[3]=p*w+T*v+A*R,t[4]=h*M+g*I+y*C,t[5]=u*M+m*I+x*C,t[6]=d*M+_*I+S*C,t[7]=p*M+T*I+A*C,t[8]=h*W+g*V+y*J,t[9]=u*W+m*V+x*J,t[10]=d*W+_*V+S*J,t[11]=p*W+T*V+A*J,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function nf(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=e[4],n=e[5],a=e[6],c=e[7],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*s+l*i,t[5]=n*s+f*i,t[6]=a*s+h*i,t[7]=c*s+u*i,t[8]=l*s-o*i,t[9]=f*s-n*i,t[10]=h*s-a*i,t[11]=u*s-c*i,t}function af(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=e[0],n=e[1],a=e[2],c=e[3],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s-l*i,t[1]=n*s-f*i,t[2]=a*s-h*i,t[3]=c*s-u*i,t[8]=o*i+l*s,t[9]=n*i+f*s,t[10]=a*i+h*s,t[11]=c*i+u*s,t}function cf(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=e[0],n=e[1],a=e[2],c=e[3],l=e[4],f=e[5],h=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s+l*i,t[1]=n*s+f*i,t[2]=a*s+h*i,t[3]=c*s+u*i,t[4]=l*s-o*i,t[5]=f*s-n*i,t[6]=h*s-a*i,t[7]=u*s-c*i,t}function Dx(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function Fx(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Bx(t,e,r){let i=r[0],s=r[1],o=r[2],n=Math.sqrt(i*i+s*s+o*o),a,c,l;return n<1e-6?null:(n=1/n,i*=n,s*=n,o*=n,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=i*i*l+a,t[1]=s*i*l+o*c,t[2]=o*i*l-s*c,t[3]=0,t[4]=i*s*l-o*c,t[5]=s*s*l+a,t[6]=o*s*l+i*c,t[7]=0,t[8]=i*o*l+s*c,t[9]=s*o*l-i*c,t[10]=o*o*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function Lx(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ux(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function kx(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Fp(t,e,r){let i=e[0],s=e[1],o=e[2],n=e[3],a=i+i,c=s+s,l=o+o,f=i*a,h=i*c,u=i*l,d=s*c,p=s*l,g=o*l,m=n*a,_=n*c,T=n*l;return t[0]=1-(d+g),t[1]=h+T,t[2]=u-_,t[3]=0,t[4]=h-T,t[5]=1-(f+g),t[6]=p+m,t[7]=0,t[8]=u+_,t[9]=p-m,t[10]=1-(f+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function Vx(t,e){let r=new q(3),i=-e[0],s=-e[1],o=-e[2],n=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=i*i+s*s+o*o+n*n;return h>0?(r[0]=(a*n+f*i+c*o-l*s)*2/h,r[1]=(c*n+f*s+l*i-a*o)*2/h,r[2]=(l*n+f*o+a*s-c*i)*2/h):(r[0]=(a*n+f*i+c*o-l*s)*2,r[1]=(c*n+f*s+l*i-a*o)*2,r[2]=(l*n+f*o+a*s-c*i)*2),Fp(t,e,r),t}function zx(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Bp(t,e){let r=e[0],i=e[1],s=e[2],o=e[4],n=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+i*i+s*s),t[1]=Math.sqrt(o*o+n*n+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function Wx(t,e){let r=new q(3);Bp(r,e);let i=1/r[0],s=1/r[1],o=1/r[2],n=e[0]*i,a=e[1]*s,c=e[2]*o,l=e[4]*i,f=e[5]*s,h=e[6]*o,u=e[8]*i,d=e[9]*s,p=e[10]*o,g=n+f+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,t[3]=.25*m,t[0]=(h-d)/m,t[1]=(u-c)/m,t[2]=(a-l)/m):n>f&&n>p?(m=Math.sqrt(1+n-f-p)*2,t[3]=(h-d)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(u+c)/m):f>p?(m=Math.sqrt(1+f-n-p)*2,t[3]=(u-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(h+d)/m):(m=Math.sqrt(1+p-n-f)*2,t[3]=(a-l)/m,t[0]=(u+c)/m,t[1]=(h+d)/m,t[2]=.25*m),t}function jx(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let s=i[0],o=i[1],n=i[2],a=i[4],c=i[5],l=i[6],f=i[8],h=i[9],u=i[10];r[0]=Math.sqrt(s*s+o*o+n*n),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+h*h+u*u);let d=1/r[0],p=1/r[1],g=1/r[2],m=s*d,_=o*p,T=n*g,y=a*d,x=c*p,S=l*g,A=f*d,w=h*p,v=u*g,R=m+x+v,M=0;return R>0?(M=Math.sqrt(R+1)*2,t[3]=.25*M,t[0]=(S-w)/M,t[1]=(A-T)/M,t[2]=(_-y)/M):m>x&&m>v?(M=Math.sqrt(1+m-x-v)*2,t[3]=(S-w)/M,t[0]=.25*M,t[1]=(_+y)/M,t[2]=(A+T)/M):x>v?(M=Math.sqrt(1+x-m-v)*2,t[3]=(A-T)/M,t[0]=(_+y)/M,t[1]=.25*M,t[2]=(S+w)/M):(M=Math.sqrt(1+v-m-x)*2,t[3]=(_-y)/M,t[0]=(A+T)/M,t[1]=(S+w)/M,t[2]=.25*M),t}function Hx(t,e,r,i){let s=e[0],o=e[1],n=e[2],a=e[3],c=s+s,l=o+o,f=n+n,h=s*c,u=s*l,d=s*f,p=o*l,g=o*f,m=n*f,_=a*c,T=a*l,y=a*f,x=i[0],S=i[1],A=i[2];return t[0]=(1-(p+m))*x,t[1]=(u+y)*x,t[2]=(d-T)*x,t[3]=0,t[4]=(u-y)*S,t[5]=(1-(h+m))*S,t[6]=(g+_)*S,t[7]=0,t[8]=(d+T)*A,t[9]=(g-_)*A,t[10]=(1-(h+p))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function $x(t,e,r,i,s){let o=e[0],n=e[1],a=e[2],c=e[3],l=o+o,f=n+n,h=a+a,u=o*l,d=o*f,p=o*h,g=n*f,m=n*h,_=a*h,T=c*l,y=c*f,x=c*h,S=i[0],A=i[1],w=i[2],v=s[0],R=s[1],M=s[2],I=(1-(g+_))*S,C=(d+x)*S,W=(p-y)*S,V=(d-x)*A,J=(1-(u+_))*A,bt=(m+T)*A,xt=(p+y)*w,Nu=(m-T)*w,Du=(1-(u+g))*w;return t[0]=I,t[1]=C,t[2]=W,t[3]=0,t[4]=V,t[5]=J,t[6]=bt,t[7]=0,t[8]=xt,t[9]=Nu,t[10]=Du,t[11]=0,t[12]=r[0]+v-(I*v+V*R+xt*M),t[13]=r[1]+R-(C*v+J*R+Nu*M),t[14]=r[2]+M-(W*v+bt*R+Du*M),t[15]=1,t}function lf(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=r+r,a=i+i,c=s+s,l=r*n,f=i*n,h=i*a,u=s*n,d=s*a,p=s*c,g=o*n,m=o*a,_=o*c;return t[0]=1-h-p,t[1]=f+_,t[2]=u-m,t[3]=0,t[4]=f-_,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=u+m,t[9]=d-g,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ff(t,e,r,i,s,o,n){let a=1/(r-e),c=1/(s-i),l=1/(o-n);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(s+i)*c,t[10]=(n+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=n*o*2*l,t[15]=0,t}function Lp(t,e,r,i,s){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let n=1/(i-s);t[10]=(s+i)*n,t[14]=2*s*i*n}else t[10]=-1,t[14]=-2*i;return t}var hf=Lp;function Xx(t,e,r,i,s){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let n=1/(i-s);t[10]=s*n,t[14]=s*i*n}else t[10]=-1,t[14]=-i;return t}function Yx(t,e,r,i){let s=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),n=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(n+a),l=2/(s+o);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((n-a)*c*.5),t[9]=(s-o)*l*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function Up(t,e,r,i,s,o,n){let a=1/(e-r),c=1/(i-s),l=1/(o-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=(n+o)*l,t[15]=1,t}var uf=Up;function Zx(t,e,r,i,s,o,n){let a=1/(e-r),c=1/(i-s),l=1/(o-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=o*l,t[15]=1,t}function df(t,e,r,i){let s,o,n,a,c,l,f,h,u,d,p=e[0],g=e[1],m=e[2],_=i[0],T=i[1],y=i[2],x=r[0],S=r[1],A=r[2];return Math.abs(p-x)<1e-6&&Math.abs(g-S)<1e-6&&Math.abs(m-A)<1e-6?Dp(t):(h=p-x,u=g-S,d=m-A,s=1/Math.sqrt(h*h+u*u+d*d),h*=s,u*=s,d*=s,o=T*d-y*u,n=y*h-_*d,a=_*u-T*h,s=Math.sqrt(o*o+n*n+a*a),s?(s=1/s,o*=s,n*=s,a*=s):(o=0,n=0,a=0),c=u*a-d*n,l=d*o-h*a,f=h*n-u*o,s=Math.sqrt(c*c+l*l+f*f),s?(s=1/s,c*=s,l*=s,f*=s):(c=0,l=0,f=0),t[0]=o,t[1]=c,t[2]=h,t[3]=0,t[4]=n,t[5]=l,t[6]=u,t[7]=0,t[8]=a,t[9]=f,t[10]=d,t[11]=0,t[12]=-(o*p+n*g+a*m),t[13]=-(c*p+l*g+f*m),t[14]=-(h*p+u*g+d*m),t[15]=1,t)}function Kx(t,e,r,i){let s=e[0],o=e[1],n=e[2],a=i[0],c=i[1],l=i[2],f=s-r[0],h=o-r[1],u=n-r[2],d=f*f+h*h+u*u;d>0&&(d=1/Math.sqrt(d),f*=d,h*=d,u*=d);let p=c*u-l*h,g=l*f-a*u,m=a*h-c*f;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=h*m-u*g,t[5]=u*p-f*m,t[6]=f*g-h*p,t[7]=0,t[8]=f,t[9]=h,t[10]=u,t[11]=0,t[12]=s,t[13]=o,t[14]=n,t[15]=1,t}function qx(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function Qx(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function Gx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function kp(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function Jx(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function e1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function t1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function r1(t,e){let r=t[0],i=t[1],s=t[2],o=t[3],n=t[4],a=t[5],c=t[6],l=t[7],f=t[8],h=t[9],u=t[10],d=t[11],p=t[12],g=t[13],m=t[14],_=t[15],T=e[0],y=e[1],x=e[2],S=e[3],A=e[4],w=e[5],v=e[6],R=e[7],M=e[8],I=e[9],C=e[10],W=e[11],V=e[12],J=e[13],bt=e[14],xt=e[15];return Math.abs(r-T)<=1e-6*Math.max(1,Math.abs(r),Math.abs(T))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(s-x)<=1e-6*Math.max(1,Math.abs(s),Math.abs(x))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(n-A)<=1e-6*Math.max(1,Math.abs(n),Math.abs(A))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-v)<=1e-6*Math.max(1,Math.abs(c),Math.abs(v))&&Math.abs(l-R)<=1e-6*Math.max(1,Math.abs(l),Math.abs(R))&&Math.abs(f-M)<=1e-6*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(h-I)<=1e-6*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(d-W)<=1e-6*Math.max(1,Math.abs(d),Math.abs(W))&&Math.abs(p-V)<=1e-6*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(g-J)<=1e-6*Math.max(1,Math.abs(g),Math.abs(J))&&Math.abs(m-bt)<=1e-6*Math.max(1,Math.abs(m),Math.abs(bt))&&Math.abs(_-xt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(xt))}var i1=fs,s1=kp;var xe={};At(xe,{add:()=>l1,ceil:()=>f1,clone:()=>o1,copy:()=>a1,create:()=>Vp,cross:()=>x1,dist:()=>O1,distance:()=>Hp,div:()=>I1,divide:()=>jp,dot:()=>b1,equals:()=>v1,exactEquals:()=>P1,floor:()=>h1,forEach:()=>B1,fromValues:()=>n1,inverse:()=>y1,len:()=>D1,length:()=>Xp,lerp:()=>A1,max:()=>d1,min:()=>u1,mul:()=>C1,multiply:()=>Wp,negate:()=>_1,normalize:()=>T1,random:()=>S1,round:()=>p1,scale:()=>g1,scaleAndAdd:()=>m1,set:()=>c1,sqrDist:()=>N1,sqrLen:()=>F1,squaredDistance:()=>$p,squaredLength:()=>Yp,str:()=>R1,sub:()=>M1,subtract:()=>zp,transformMat4:()=>pf,transformQuat:()=>E1,zero:()=>w1});function Vp(){let t=new q(4);return q!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function o1(t){let e=new q(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function n1(t,e,r,i){let s=new q(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=i,s}function a1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function c1(t,e,r,i,s){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t}function l1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function zp(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function Wp(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function jp(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function f1(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function h1(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function u1(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function d1(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function p1(t,e){return t[0]=De(e[0]),t[1]=De(e[1]),t[2]=De(e[2]),t[3]=De(e[3]),t}function g1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function m1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function Hp(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],o=e[3]-t[3];return Math.sqrt(r*r+i*i+s*s+o*o)}function $p(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],o=e[3]-t[3];return r*r+i*i+s*s+o*o}function Xp(t){let e=t[0],r=t[1],i=t[2],s=t[3];return Math.sqrt(e*e+r*r+i*i+s*s)}function Yp(t){let e=t[0],r=t[1],i=t[2],s=t[3];return e*e+r*r+i*i+s*s}function _1(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function y1(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function T1(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=r*r+i*i+s*s+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=r*n,t[1]=i*n,t[2]=s*n,t[3]=o*n,t}function b1(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function x1(t,e,r,i){let s=r[0]*i[1]-r[1]*i[0],o=r[0]*i[2]-r[2]*i[0],n=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],f=e[0],h=e[1],u=e[2],d=e[3];return t[0]=h*l-u*c+d*a,t[1]=-(f*l)+u*n-d*o,t[2]=f*c-h*n+d*s,t[3]=-(f*a)+h*o-u*s,t}function A1(t,e,r,i){let s=e[0],o=e[1],n=e[2],a=e[3];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t[2]=n+i*(r[2]-n),t[3]=a+i*(r[3]-a),t}function S1(t,e){e=e===void 0?1:e;let r,i,s,o,n,a;do r=it()*2-1,i=it()*2-1,n=r*r+i*i;while(n>=1);do s=it()*2-1,o=it()*2-1,a=s*s+o*o;while(a>=1);let c=Math.sqrt((1-n)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*s*c,t[3]=e*o*c,t}function pf(t,e,r){let i=e[0],s=e[1],o=e[2],n=e[3];return t[0]=r[0]*i+r[4]*s+r[8]*o+r[12]*n,t[1]=r[1]*i+r[5]*s+r[9]*o+r[13]*n,t[2]=r[2]*i+r[6]*s+r[10]*o+r[14]*n,t[3]=r[3]*i+r[7]*s+r[11]*o+r[15]*n,t}function E1(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[0],a=r[1],c=r[2],l=r[3],f=l*i+a*o-c*s,h=l*s+c*i-n*o,u=l*o+n*s-a*i,d=-n*i-a*s-c*o;return t[0]=f*l+d*-n+h*-c-u*-a,t[1]=h*l+d*-a+u*-n-f*-c,t[2]=u*l+d*-c+f*-a-h*-n,t[3]=e[3],t}function w1(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function R1(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function P1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function v1(t,e){let r=t[0],i=t[1],s=t[2],o=t[3],n=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(o-l)<=1e-6*Math.max(1,Math.abs(o),Math.abs(l))}var M1=zp,C1=Wp,I1=jp,O1=Hp,N1=$p,D1=Xp,F1=Yp,B1=function(){let t=Vp();return function(e,r,i,s,o,n){let a,c;for(r||(r=4),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var _f;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(_f||(_f={}));var L1=45*Math.PI/180,U1=1,gf=.1,mf=500,k1=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends Sn{static get IDENTITY(){return z1()}static get ZERO(){return V1()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return _f}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,i,s,o,n,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=r,this[2]=i,this[3]=s,this[4]=o,this[5]=n,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=h,this[11]=u,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(e,r,i,s,o,n,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=o,this[2]=l,this[3]=d,this[4]=r,this[5]=n,this[6]=f,this[7]=p,this[8]=i,this[9]=a,this[10]=h,this[11]=g,this[12]=s,this[13]=c,this[14]=u,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(k1)}fromObject(e){return this.check()}fromQuaternion(e){return lf(this,e),this.check()}frustum(e){let{left:r,right:i,bottom:s,top:o,near:n=gf,far:a=mf}=e;return a===1/0?W1(this,r,i,s,o,n):ff(this,r,i,s,o,n,a),this.check()}lookAt(e){let{eye:r,center:i=[0,0,0],up:s=[0,1,0]}=e;return df(this,r,i,s),this.check()}ortho(e){let{left:r,right:i,bottom:s,top:o,near:n=gf,far:a=mf}=e;return uf(this,r,i,s,o,n,a),this.check()}orthographic(e){let{fovy:r=L1,aspect:i=U1,focalDistance:s=1,near:o=gf,far:n=mf}=e;Zp(r);let a=r/2,c=s*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:n})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:i=1,near:s=.1,far:o=500}=e;return Zp(r),hf(this,r,i,s,o),this.check()}determinant(){return tf(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),s=1/i[0],o=1/i[1],n=1/i[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*n,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*o,e[6]=this[6]*n,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*o,e[10]=this[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),s=1/i[0],o=1/i[1],n=1/i[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*n,e[3]=this[4]*s,e[4]=this[5]*o,e[5]=this[6]*n,e[6]=this[8]*s,e[7]=this[9]*o,e[8]=this[10]*n,e}transpose(){return Jl(this,this),this.check()}invert(){return ef(this,this),this.check()}multiplyLeft(e){return fs(this,e,this),this.check()}multiplyRight(e){return fs(this,this,e),this.check()}rotateX(e){return nf(this,this,e),this.check()}rotateY(e){return af(this,this,e),this.check()}rotateZ(e){return cf(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return of(this,this,e,r),this.check()}scale(e){return sf(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return rf(this,this,e),this.check()}transform(e,r){return e.length===4?(r=pf(r||[-0,-0,-0,-0],e,this),_n(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:i}=e,s;switch(i){case 2:s=jl(r||[-0,-0],e,this);break;case 3:s=ls(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return _n(s,e.length),s}transformAsVector(e,r){let i;switch(e.length){case 2:i=wp(r||[-0,-0],e,this);break;case 3:i=bn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return _n(i,e.length),i}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,i){return this.identity().translate([e,r,i])}},En,wn;function V1(){return En||(En=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(En)),En}function z1(){return wn||(wn=new z,Object.freeze(wn)),wn}function Zp(t){if(t>Math.PI*2)throw Error("expected radians")}function W1(t,e,r,i,s,o){let n=2*o/(r-e),a=2*o/(s-i),c=(r+e)/(r-e),l=(s+i)/(s-i),f=-1,h=-1,u=-2*o;return t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=h,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}var Kp=1e-6,j1=6371e3,Ve=class{constructor({phi:e=0,theta:r=0,radius:i=1,bearing:s,pitch:o,altitude:n,radiusScale:a=j1}={}){this.phi=e,this.theta=r,this.radius=i||n||1,this.radiusScale=a||1,s!==void 0&&(this.bearing=s),o!==void 0&&(this.pitch=o),this.check()}toString(){return this.formatString(te)}formatString({printTypes:e=!1}){let r=cs;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Re(this.radius,e.radius)&&Re(this.theta,e.theta)&&Re(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-qt(this.phi)}set bearing(e){this.phi=Math.PI-hi(e)}get pitch(){return qt(this.theta)}set pitch(e){this.theta=hi(e)}get longitude(){return qt(this.phi)}get latitude(){return qt(this.theta)}get lng(){return qt(this.phi)}get lat(){return qt(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,i){return this.radius=e,this.phi=r,this.theta=i,this.check()}clone(){return new Ve().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,i]){return this.radius=1+i/this.radiusScale,this.phi=hi(r),this.theta=hi(e),this.check()}fromVector3(e){return this.radius=xn(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(B(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new H(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(Kp,Math.min(Math.PI-Kp,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}};function yf(t,e=[],r=0){let i=Math.fround(t),s=t-i;return e[r]=i,e[r+1]=s,e}function qp(t){return t-Math.fround(t)}function Qp(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let s=r*4+i;yf(t[i*4+r],e,s*2)}return e}var H1=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
113
|
+
}`}function Fx(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function og(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var Lx=1/Math.PI*180,Ux=1/180*Math.PI,kx={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...kx}};var te=globalThis.mathgl.config;function gs(t,{precision:e=te.precision}={}){return t=Vx(t),`${parseFloat(t.toPrecision(e))}`}function Ct(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function yi(t,e){return hf(t,r=>r*Ux,e)}function er(t,e){return hf(t,r=>r*Lx,e)}function U(t,e,r){return hf(t,i=>Math.max(e,Math.min(r,i)))}function It(t,e,r){return Ct(t)?t.map((i,s)=>It(i,e[s],r)):r*e+(1-r)*t}function Pe(t,e,r){let i=te.EPSILON;r&&(te.EPSILON=r);try{if(t===e)return!0;if(Ct(t)&&Ct(e)){if(t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(!Pe(t[s],e[s]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=te.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{te.EPSILON=i}}function Vx(t){return Math.round(t/te.EPSILON)*te.EPSILON}function zx(t){return t.clone?t.clone():new Array(t.length)}function hf(t,e,r){if(Ct(t)){let i=t;r=r||zx(i);for(let s=0;s<r.length&&s<i.length;++s){let o=typeof t=="number"?t:t[s];r[s]=e(o,s,r)}return r}return e(t)}var bi=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=e[i+r];return this.check()}toArray(e=[],r=0){for(let i=0;i<this.ELEMENTS;++i)e[r+i]=this[i];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ct(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(te)}formatString(e){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+gs(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Pe(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,i){if(i===void 0)return this.lerp(this,e,r);for(let s=0;s<this.ELEMENTS;++s){let o=e[s],n=typeof r=="number"?r:r[s];this[s]=o+i*(n-o)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e[i]),r[i]);return this.check()}add(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(te.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e),r);return this.check()}get elements(){return this}};function Wx(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function fe(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function wn(t,e,r=""){if(te.debug&&!Wx(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function uf(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Rn=class extends bi{get x(){return this[0]}set x(e){this[0]=fe(e)}get y(){return this[1]}set y(e){this[1]=fe(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let i=0;i<this.ELEMENTS;++i){let s=this[i]-e[i];r+=s*s}return fe(r)}dot(e){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*e[i];return fe(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return uf(e>=0&&e<this.ELEMENTS,"index is out of range"),fe(this[e])}setComponent(e,r){return uf(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var ee={};Rt(ee,{add:()=>Yx,angle:()=>u1,ceil:()=>Kx,clone:()=>jx,copy:()=>$x,create:()=>ng,cross:()=>o1,dist:()=>x1,distance:()=>fg,div:()=>T1,divide:()=>lg,dot:()=>s1,equals:()=>m1,exactEquals:()=>g1,floor:()=>Zx,forEach:()=>E1,fromValues:()=>Hx,inverse:()=>r1,len:()=>_1,length:()=>ug,lerp:()=>n1,max:()=>Gx,min:()=>qx,mul:()=>b1,multiply:()=>cg,negate:()=>t1,normalize:()=>i1,random:()=>a1,rotate:()=>h1,round:()=>Qx,scale:()=>Jx,scaleAndAdd:()=>e1,set:()=>Xx,sqrDist:()=>A1,sqrLen:()=>S1,squaredDistance:()=>hg,squaredLength:()=>dg,str:()=>p1,sub:()=>y1,subtract:()=>ag,transformMat2:()=>c1,transformMat2d:()=>l1,transformMat3:()=>f1,transformMat4:()=>df,zero:()=>d1});var q=typeof Float32Array<"u"?Float32Array:Array,ct=Math.random;function Fe(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var ON=Math.PI/180;function ng(){let t=new q(2);return q!=Float32Array&&(t[0]=0,t[1]=0),t}function jx(t){let e=new q(2);return e[0]=t[0],e[1]=t[1],e}function Hx(t,e){let r=new q(2);return r[0]=t,r[1]=e,r}function $x(t,e){return t[0]=e[0],t[1]=e[1],t}function Xx(t,e,r){return t[0]=e,t[1]=r,t}function Yx(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function ag(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function cg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function lg(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function Kx(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function Zx(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function qx(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function Gx(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function Qx(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t}function Jx(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function e1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function fg(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function hg(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function ug(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function dg(t){let e=t[0],r=t[1];return e*e+r*r}function t1(t,e){return t[0]=-e[0],t[1]=-e[1],t}function r1(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function i1(t,e){let r=e[0],i=e[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t}function s1(t,e){return t[0]*e[0]+t[1]*e[1]}function o1(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function n1(t,e,r,i){let s=e[0],o=e[1];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t}function a1(t,e){e=e===void 0?1:e;let r=ct()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function c1(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t}function l1(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s+r[4],t[1]=r[1]*i+r[3]*s+r[5],t}function f1(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[3]*s+r[6],t[1]=r[1]*i+r[4]*s+r[7],t}function df(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[4]*s+r[12],t[1]=r[1]*i+r[5]*s+r[13],t}function h1(t,e,r,i){let s=e[0]-r[0],o=e[1]-r[1],n=Math.sin(i),a=Math.cos(i);return t[0]=s*a-o*n+r[0],t[1]=s*n+o*a+r[1],t}function u1(t,e){let r=t[0],i=t[1],s=e[0],o=e[1],n=Math.sqrt((r*r+i*i)*(s*s+o*o)),a=n&&(r*s+i*o)/n;return Math.acos(Math.min(Math.max(a,-1),1))}function d1(t){return t[0]=0,t[1]=0,t}function p1(t){return`vec2(${t[0]}, ${t[1]})`}function g1(t,e){return t[0]===e[0]&&t[1]===e[1]}function m1(t,e){let r=t[0],i=t[1],s=e[0],o=e[1];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))}var _1=ug,y1=ag,b1=cg,T1=lg,x1=fg,A1=hg,S1=dg,E1=function(){let t=ng();return function(e,r,i,s,o,n){let a,c;for(r||(r=2),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],o(t,t,n),e[a]=t[0],e[a+1]=t[1];return e}}();function pg(t,e,r){let i=e[0],s=e[1],o=r[3]*i+r[7]*s||1;return t[0]=(r[0]*i+r[4]*s)/o,t[1]=(r[1]*i+r[5]*s)/o,t}function vn(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[3]*i+r[7]*s+r[11]*o||1;return t[0]=(r[0]*i+r[4]*s+r[8]*o)/n,t[1]=(r[1]*i+r[5]*s+r[9]*o)/n,t[2]=(r[2]*i+r[6]*s+r[10]*o)/n,t}function gg(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t[2]=e[2],t}var ge={};Rt(ge,{add:()=>M1,angle:()=>xf,bezier:()=>j1,ceil:()=>C1,clone:()=>w1,copy:()=>P1,create:()=>mg,cross:()=>gf,dist:()=>Q1,distance:()=>Tg,div:()=>G1,divide:()=>bg,dot:()=>pf,equals:()=>K1,exactEquals:()=>Y1,floor:()=>I1,forEach:()=>rA,fromValues:()=>R1,hermite:()=>W1,inverse:()=>U1,len:()=>eA,length:()=>Mn,lerp:()=>V1,max:()=>N1,min:()=>O1,mul:()=>q1,multiply:()=>yg,negate:()=>L1,normalize:()=>k1,random:()=>H1,rotateX:()=>yf,rotateY:()=>bf,rotateZ:()=>Tf,round:()=>D1,scale:()=>B1,scaleAndAdd:()=>F1,set:()=>v1,slerp:()=>z1,sqrDist:()=>J1,sqrLen:()=>tA,squaredDistance:()=>xg,squaredLength:()=>Ag,str:()=>X1,sub:()=>Z1,subtract:()=>_g,transformMat3:()=>mf,transformMat4:()=>ms,transformQuat:()=>_f,zero:()=>$1});function mg(){let t=new q(3);return q!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function w1(t){let e=new q(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Mn(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function R1(t,e,r){let i=new q(3);return i[0]=t,i[1]=e,i[2]=r,i}function P1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function v1(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function M1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function _g(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function yg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function bg(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function C1(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function I1(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function O1(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function N1(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function D1(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t[2]=Fe(e[2]),t}function B1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function F1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function Tg(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(r*r+i*i+s*s)}function xg(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return r*r+i*i+s*s}function Ag(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function L1(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function U1(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function k1(t,e){let r=e[0],i=e[1],s=e[2],o=r*r+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function pf(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function gf(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[0],a=r[1],c=r[2];return t[0]=s*c-o*a,t[1]=o*n-i*c,t[2]=i*a-s*n,t}function V1(t,e,r,i){let s=e[0],o=e[1],n=e[2];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t[2]=n+i*(r[2]-n),t}function z1(t,e,r,i){let s=Math.acos(Math.min(Math.max(pf(e,r),-1),1)),o=Math.sin(s),n=Math.sin((1-i)*s)/o,a=Math.sin(i*s)/o;return t[0]=n*e[0]+a*r[0],t[1]=n*e[1]+a*r[1],t[2]=n*e[2]+a*r[2],t}function W1(t,e,r,i,s,o){let n=o*o,a=n*(2*o-3)+1,c=n*(o-2)+o,l=n*(o-1),f=n*(3-2*o);return t[0]=e[0]*a+r[0]*c+i[0]*l+s[0]*f,t[1]=e[1]*a+r[1]*c+i[1]*l+s[1]*f,t[2]=e[2]*a+r[2]*c+i[2]*l+s[2]*f,t}function j1(t,e,r,i,s,o){let n=1-o,a=n*n,c=o*o,l=a*n,f=3*o*a,h=3*c*n,u=c*o;return t[0]=e[0]*l+r[0]*f+i[0]*h+s[0]*u,t[1]=e[1]*l+r[1]*f+i[1]*h+s[1]*u,t[2]=e[2]*l+r[2]*f+i[2]*h+s[2]*u,t}function H1(t,e){e=e===void 0?1:e;let r=ct()*2*Math.PI,i=ct()*2-1,s=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*s,t[1]=Math.sin(r)*s,t[2]=i*e,t}function ms(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[3]*i+r[7]*s+r[11]*o+r[15];return n=n||1,t[0]=(r[0]*i+r[4]*s+r[8]*o+r[12])/n,t[1]=(r[1]*i+r[5]*s+r[9]*o+r[13])/n,t[2]=(r[2]*i+r[6]*s+r[10]*o+r[14])/n,t}function mf(t,e,r){let i=e[0],s=e[1],o=e[2];return t[0]=i*r[0]+s*r[3]+o*r[6],t[1]=i*r[1]+s*r[4]+o*r[7],t[2]=i*r[2]+s*r[5]+o*r[8],t}function _f(t,e,r){let i=r[0],s=r[1],o=r[2],n=r[3],a=e[0],c=e[1],l=e[2],f=s*l-o*c,h=o*a-i*l,u=i*c-s*a,d=s*u-o*h,p=o*f-i*u,g=i*h-s*f,m=n*2;return f*=m,h*=m,u*=m,d*=2,p*=2,g*=2,t[0]=a+f+d,t[1]=c+h+p,t[2]=l+u+g,t}function yf(t,e,r,i){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0],o[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),o[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function bf(t,e,r,i){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),o[1]=s[1],o[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Tf(t,e,r,i){let s=[],o=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],o[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),o[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),o[2]=s[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function xf(t,e){let r=t[0],i=t[1],s=t[2],o=e[0],n=e[1],a=e[2],c=Math.sqrt((r*r+i*i+s*s)*(o*o+n*n+a*a)),l=c&&pf(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function $1(t){return t[0]=0,t[1]=0,t[2]=0,t}function X1(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function Y1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function K1(t,e){let r=t[0],i=t[1],s=t[2],o=e[0],n=e[1],a=e[2];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var Z1=_g,q1=yg,G1=bg,Q1=Tg,J1=xg,eA=Mn,tA=Ag,rA=function(){let t=mg();return function(e,r,i,s,o,n){let a,c;for(r||(r=3),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var Af=[0,0,0],Cn,H=class extends Rn{static get ZERO(){return Cn||(Cn=new H(0,0,0),Object.freeze(Cn)),Cn}constructor(e=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&Ct(e)?this.copy(e):(te.debug&&(fe(e),fe(r),fe(i)),this[0]=e,this[1]=r,this[2]=i)}set(e,r,i){return this[0]=e,this[1]=r,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return te.debug&&(fe(e.x),fe(e.y),fe(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=fe(e)}angle(e){return xf(this,e)}cross(e){return gf(this,this,e),this.check()}rotateX({radians:e,origin:r=Af}){return yf(this,this,r,e),this.check()}rotateY({radians:e,origin:r=Af}){return bf(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=Af}){return Tf(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return ms(this,this,e),this.check()}transformAsVector(e){return vn(this,this,e),this.check()}transformByMatrix3(e){return mf(this,this,e),this.check()}transformByMatrix2(e){return gg(this,this,e),this.check()}transformByQuaternion(e){return _f(this,this,e),this.check()}};var In=class extends bi{toString(){let e="[";if(te.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)e+=` ${this[i*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,i){return this[r*this.RANK+e]=fe(i),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let i=e*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[i+s];return r}setColumn(e,r){let i=e*this.RANK;for(let s=0;s<this.RANK;++s)this[i+s]=r[s];return this}};var re={};Rt(re,{add:()=>PA,adjoint:()=>cA,clone:()=>sA,copy:()=>oA,create:()=>iA,decompose:()=>yA,determinant:()=>wf,equals:()=>IA,exactEquals:()=>CA,frob:()=>RA,fromQuat:()=>Of,fromQuat2:()=>gA,fromRotation:()=>hA,fromRotationTranslation:()=>Eg,fromRotationTranslationScale:()=>bA,fromRotationTranslationScaleOrigin:()=>TA,fromScaling:()=>fA,fromTranslation:()=>lA,fromValues:()=>nA,fromXRotation:()=>uA,fromYRotation:()=>dA,fromZRotation:()=>pA,frustum:()=>Nf,getRotation:()=>_A,getScaling:()=>wg,getTranslation:()=>mA,identity:()=>Sg,invert:()=>Ef,lookAt:()=>Ff,mul:()=>OA,multiply:()=>_s,multiplyScalar:()=>vA,multiplyScalarAndAdd:()=>MA,ortho:()=>Bf,orthoNO:()=>Pg,orthoZO:()=>SA,perspective:()=>Df,perspectiveFromFieldOfView:()=>AA,perspectiveNO:()=>Rg,perspectiveZO:()=>xA,rotate:()=>vf,rotateX:()=>Mf,rotateY:()=>Cf,rotateZ:()=>If,scale:()=>Pf,set:()=>aA,str:()=>wA,sub:()=>NA,subtract:()=>vg,targetTo:()=>EA,translate:()=>Rf,transpose:()=>Sf});function iA(){let t=new q(16);return q!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function sA(t){let e=new q(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function oA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function nA(t,e,r,i,s,o,n,a,c,l,f,h,u,d,p,g){let m=new q(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=i,m[4]=s,m[5]=o,m[6]=n,m[7]=a,m[8]=c,m[9]=l,m[10]=f,m[11]=h,m[12]=u,m[13]=d,m[14]=p,m[15]=g,m}function aA(t,e,r,i,s,o,n,a,c,l,f,h,u,d,p,g,m){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t[4]=o,t[5]=n,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=h,t[11]=u,t[12]=d,t[13]=p,t[14]=g,t[15]=m,t}function Sg(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Sf(t,e){if(t===e){let r=e[1],i=e[2],s=e[3],o=e[6],n=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=o,t[11]=e[14],t[12]=s,t[13]=n,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ef(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],b=r*a-i*n,y=r*c-s*n,T=r*l-o*n,S=i*c-s*a,A=i*l-o*a,w=s*l-o*c,v=f*g-h*p,R=f*m-u*p,M=f*_-d*p,O=h*m-u*g,C=h*_-d*g,W=u*_-d*m,V=b*W-y*C+T*O+S*M-A*R+w*v;return V?(V=1/V,t[0]=(a*W-c*C+l*O)*V,t[1]=(s*C-i*W-o*O)*V,t[2]=(g*w-m*A+_*S)*V,t[3]=(u*A-h*w-d*S)*V,t[4]=(c*M-n*W-l*R)*V,t[5]=(r*W-s*M+o*R)*V,t[6]=(m*T-p*w-_*y)*V,t[7]=(f*w-u*T+d*y)*V,t[8]=(n*C-a*M+l*v)*V,t[9]=(i*M-r*C-o*v)*V,t[10]=(p*A-g*T+_*b)*V,t[11]=(h*T-f*A-d*b)*V,t[12]=(a*R-n*O-c*v)*V,t[13]=(r*O-i*R+s*v)*V,t[14]=(g*y-p*S-m*b)*V,t[15]=(f*S-h*y+u*b)*V,t):null}function cA(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],b=r*a-i*n,y=r*c-s*n,T=r*l-o*n,S=i*c-s*a,A=i*l-o*a,w=s*l-o*c,v=f*g-h*p,R=f*m-u*p,M=f*_-d*p,O=h*m-u*g,C=h*_-d*g,W=u*_-d*m;return t[0]=a*W-c*C+l*O,t[1]=s*C-i*W-o*O,t[2]=g*w-m*A+_*S,t[3]=u*A-h*w-d*S,t[4]=c*M-n*W-l*R,t[5]=r*W-s*M+o*R,t[6]=m*T-p*w-_*y,t[7]=f*w-u*T+d*y,t[8]=n*C-a*M+l*v,t[9]=i*M-r*C-o*v,t[10]=p*A-g*T+_*b,t[11]=h*T-f*A-d*b,t[12]=a*R-n*O-c*v,t[13]=r*O-i*R+s*v,t[14]=g*y-p*S-m*b,t[15]=f*S-h*y+u*b,t}function wf(t){let e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],n=t[5],a=t[6],c=t[7],l=t[8],f=t[9],h=t[10],u=t[11],d=t[12],p=t[13],g=t[14],m=t[15],_=e*n-r*o,b=e*a-i*o,y=r*a-i*n,T=l*p-f*d,S=l*g-h*d,A=f*g-h*p,w=e*A-r*S+i*T,v=o*A-n*S+a*T,R=l*y-f*b+h*_,M=d*y-p*b+g*_;return c*w-s*v+m*R-u*M}function _s(t,e,r){let i=e[0],s=e[1],o=e[2],n=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],m=e[13],_=e[14],b=e[15],y=r[0],T=r[1],S=r[2],A=r[3];return t[0]=y*i+T*a+S*h+A*g,t[1]=y*s+T*c+S*u+A*m,t[2]=y*o+T*l+S*d+A*_,t[3]=y*n+T*f+S*p+A*b,y=r[4],T=r[5],S=r[6],A=r[7],t[4]=y*i+T*a+S*h+A*g,t[5]=y*s+T*c+S*u+A*m,t[6]=y*o+T*l+S*d+A*_,t[7]=y*n+T*f+S*p+A*b,y=r[8],T=r[9],S=r[10],A=r[11],t[8]=y*i+T*a+S*h+A*g,t[9]=y*s+T*c+S*u+A*m,t[10]=y*o+T*l+S*d+A*_,t[11]=y*n+T*f+S*p+A*b,y=r[12],T=r[13],S=r[14],A=r[15],t[12]=y*i+T*a+S*h+A*g,t[13]=y*s+T*c+S*u+A*m,t[14]=y*o+T*l+S*d+A*_,t[15]=y*n+T*f+S*p+A*b,t}function Rf(t,e,r){let i=r[0],s=r[1],o=r[2],n,a,c,l,f,h,u,d,p,g,m,_;return e===t?(t[12]=e[0]*i+e[4]*s+e[8]*o+e[12],t[13]=e[1]*i+e[5]*s+e[9]*o+e[13],t[14]=e[2]*i+e[6]*s+e[10]*o+e[14],t[15]=e[3]*i+e[7]*s+e[11]*o+e[15]):(n=e[0],a=e[1],c=e[2],l=e[3],f=e[4],h=e[5],u=e[6],d=e[7],p=e[8],g=e[9],m=e[10],_=e[11],t[0]=n,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=h,t[6]=u,t[7]=d,t[8]=p,t[9]=g,t[10]=m,t[11]=_,t[12]=n*i+f*s+p*o+e[12],t[13]=a*i+h*s+g*o+e[13],t[14]=c*i+u*s+m*o+e[14],t[15]=l*i+d*s+_*o+e[15]),t}function Pf(t,e,r){let i=r[0],s=r[1],o=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function vf(t,e,r,i){let s=i[0],o=i[1],n=i[2],a=Math.sqrt(s*s+o*o+n*n),c,l,f,h,u,d,p,g,m,_,b,y,T,S,A,w,v,R,M,O,C,W,V,J;return a<1e-6?null:(a=1/a,s*=a,o*=a,n*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,h=e[0],u=e[1],d=e[2],p=e[3],g=e[4],m=e[5],_=e[6],b=e[7],y=e[8],T=e[9],S=e[10],A=e[11],w=s*s*f+c,v=o*s*f+n*l,R=n*s*f-o*l,M=s*o*f-n*l,O=o*o*f+c,C=n*o*f+s*l,W=s*n*f+o*l,V=o*n*f-s*l,J=n*n*f+c,t[0]=h*w+g*v+y*R,t[1]=u*w+m*v+T*R,t[2]=d*w+_*v+S*R,t[3]=p*w+b*v+A*R,t[4]=h*M+g*O+y*C,t[5]=u*M+m*O+T*C,t[6]=d*M+_*O+S*C,t[7]=p*M+b*O+A*C,t[8]=h*W+g*V+y*J,t[9]=u*W+m*V+T*J,t[10]=d*W+_*V+S*J,t[11]=p*W+b*V+A*J,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Mf(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=e[4],n=e[5],a=e[6],c=e[7],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*s+l*i,t[5]=n*s+f*i,t[6]=a*s+h*i,t[7]=c*s+u*i,t[8]=l*s-o*i,t[9]=f*s-n*i,t[10]=h*s-a*i,t[11]=u*s-c*i,t}function Cf(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=e[0],n=e[1],a=e[2],c=e[3],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s-l*i,t[1]=n*s-f*i,t[2]=a*s-h*i,t[3]=c*s-u*i,t[8]=o*i+l*s,t[9]=n*i+f*s,t[10]=a*i+h*s,t[11]=c*i+u*s,t}function If(t,e,r){let i=Math.sin(r),s=Math.cos(r),o=e[0],n=e[1],a=e[2],c=e[3],l=e[4],f=e[5],h=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s+l*i,t[1]=n*s+f*i,t[2]=a*s+h*i,t[3]=c*s+u*i,t[4]=l*s-o*i,t[5]=f*s-n*i,t[6]=h*s-a*i,t[7]=u*s-c*i,t}function lA(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function fA(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function hA(t,e,r){let i=r[0],s=r[1],o=r[2],n=Math.sqrt(i*i+s*s+o*o),a,c,l;return n<1e-6?null:(n=1/n,i*=n,s*=n,o*=n,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=i*i*l+a,t[1]=s*i*l+o*c,t[2]=o*i*l-s*c,t[3]=0,t[4]=i*s*l-o*c,t[5]=s*s*l+a,t[6]=o*s*l+i*c,t[7]=0,t[8]=i*o*l+s*c,t[9]=s*o*l-i*c,t[10]=o*o*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function uA(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function dA(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function pA(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Eg(t,e,r){let i=e[0],s=e[1],o=e[2],n=e[3],a=i+i,c=s+s,l=o+o,f=i*a,h=i*c,u=i*l,d=s*c,p=s*l,g=o*l,m=n*a,_=n*c,b=n*l;return t[0]=1-(d+g),t[1]=h+b,t[2]=u-_,t[3]=0,t[4]=h-b,t[5]=1-(f+g),t[6]=p+m,t[7]=0,t[8]=u+_,t[9]=p-m,t[10]=1-(f+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function gA(t,e){let r=new q(3),i=-e[0],s=-e[1],o=-e[2],n=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=i*i+s*s+o*o+n*n;return h>0?(r[0]=(a*n+f*i+c*o-l*s)*2/h,r[1]=(c*n+f*s+l*i-a*o)*2/h,r[2]=(l*n+f*o+a*s-c*i)*2/h):(r[0]=(a*n+f*i+c*o-l*s)*2,r[1]=(c*n+f*s+l*i-a*o)*2,r[2]=(l*n+f*o+a*s-c*i)*2),Eg(t,e,r),t}function mA(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function wg(t,e){let r=e[0],i=e[1],s=e[2],o=e[4],n=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+i*i+s*s),t[1]=Math.sqrt(o*o+n*n+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function _A(t,e){let r=new q(3);wg(r,e);let i=1/r[0],s=1/r[1],o=1/r[2],n=e[0]*i,a=e[1]*s,c=e[2]*o,l=e[4]*i,f=e[5]*s,h=e[6]*o,u=e[8]*i,d=e[9]*s,p=e[10]*o,g=n+f+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,t[3]=.25*m,t[0]=(h-d)/m,t[1]=(u-c)/m,t[2]=(a-l)/m):n>f&&n>p?(m=Math.sqrt(1+n-f-p)*2,t[3]=(h-d)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(u+c)/m):f>p?(m=Math.sqrt(1+f-n-p)*2,t[3]=(u-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(h+d)/m):(m=Math.sqrt(1+p-n-f)*2,t[3]=(a-l)/m,t[0]=(u+c)/m,t[1]=(h+d)/m,t[2]=.25*m),t}function yA(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let s=i[0],o=i[1],n=i[2],a=i[4],c=i[5],l=i[6],f=i[8],h=i[9],u=i[10];r[0]=Math.sqrt(s*s+o*o+n*n),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+h*h+u*u);let d=1/r[0],p=1/r[1],g=1/r[2],m=s*d,_=o*p,b=n*g,y=a*d,T=c*p,S=l*g,A=f*d,w=h*p,v=u*g,R=m+T+v,M=0;return R>0?(M=Math.sqrt(R+1)*2,t[3]=.25*M,t[0]=(S-w)/M,t[1]=(A-b)/M,t[2]=(_-y)/M):m>T&&m>v?(M=Math.sqrt(1+m-T-v)*2,t[3]=(S-w)/M,t[0]=.25*M,t[1]=(_+y)/M,t[2]=(A+b)/M):T>v?(M=Math.sqrt(1+T-m-v)*2,t[3]=(A-b)/M,t[0]=(_+y)/M,t[1]=.25*M,t[2]=(S+w)/M):(M=Math.sqrt(1+v-m-T)*2,t[3]=(_-y)/M,t[0]=(A+b)/M,t[1]=(S+w)/M,t[2]=.25*M),t}function bA(t,e,r,i){let s=e[0],o=e[1],n=e[2],a=e[3],c=s+s,l=o+o,f=n+n,h=s*c,u=s*l,d=s*f,p=o*l,g=o*f,m=n*f,_=a*c,b=a*l,y=a*f,T=i[0],S=i[1],A=i[2];return t[0]=(1-(p+m))*T,t[1]=(u+y)*T,t[2]=(d-b)*T,t[3]=0,t[4]=(u-y)*S,t[5]=(1-(h+m))*S,t[6]=(g+_)*S,t[7]=0,t[8]=(d+b)*A,t[9]=(g-_)*A,t[10]=(1-(h+p))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function TA(t,e,r,i,s){let o=e[0],n=e[1],a=e[2],c=e[3],l=o+o,f=n+n,h=a+a,u=o*l,d=o*f,p=o*h,g=n*f,m=n*h,_=a*h,b=c*l,y=c*f,T=c*h,S=i[0],A=i[1],w=i[2],v=s[0],R=s[1],M=s[2],O=(1-(g+_))*S,C=(d+T)*S,W=(p-y)*S,V=(d-T)*A,J=(1-(u+_))*A,Et=(m+b)*A,wt=(p+y)*w,od=(m-b)*w,nd=(1-(u+g))*w;return t[0]=O,t[1]=C,t[2]=W,t[3]=0,t[4]=V,t[5]=J,t[6]=Et,t[7]=0,t[8]=wt,t[9]=od,t[10]=nd,t[11]=0,t[12]=r[0]+v-(O*v+V*R+wt*M),t[13]=r[1]+R-(C*v+J*R+od*M),t[14]=r[2]+M-(W*v+Et*R+nd*M),t[15]=1,t}function Of(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=r+r,a=i+i,c=s+s,l=r*n,f=i*n,h=i*a,u=s*n,d=s*a,p=s*c,g=o*n,m=o*a,_=o*c;return t[0]=1-h-p,t[1]=f+_,t[2]=u-m,t[3]=0,t[4]=f-_,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=u+m,t[9]=d-g,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Nf(t,e,r,i,s,o,n){let a=1/(r-e),c=1/(s-i),l=1/(o-n);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(s+i)*c,t[10]=(n+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=n*o*2*l,t[15]=0,t}function Rg(t,e,r,i,s){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let n=1/(i-s);t[10]=(s+i)*n,t[14]=2*s*i*n}else t[10]=-1,t[14]=-2*i;return t}var Df=Rg;function xA(t,e,r,i,s){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let n=1/(i-s);t[10]=s*n,t[14]=s*i*n}else t[10]=-1,t[14]=-i;return t}function AA(t,e,r,i){let s=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),n=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(n+a),l=2/(s+o);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((n-a)*c*.5),t[9]=(s-o)*l*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function Pg(t,e,r,i,s,o,n){let a=1/(e-r),c=1/(i-s),l=1/(o-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=(n+o)*l,t[15]=1,t}var Bf=Pg;function SA(t,e,r,i,s,o,n){let a=1/(e-r),c=1/(i-s),l=1/(o-n);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=o*l,t[15]=1,t}function Ff(t,e,r,i){let s,o,n,a,c,l,f,h,u,d,p=e[0],g=e[1],m=e[2],_=i[0],b=i[1],y=i[2],T=r[0],S=r[1],A=r[2];return Math.abs(p-T)<1e-6&&Math.abs(g-S)<1e-6&&Math.abs(m-A)<1e-6?Sg(t):(h=p-T,u=g-S,d=m-A,s=1/Math.sqrt(h*h+u*u+d*d),h*=s,u*=s,d*=s,o=b*d-y*u,n=y*h-_*d,a=_*u-b*h,s=Math.sqrt(o*o+n*n+a*a),s?(s=1/s,o*=s,n*=s,a*=s):(o=0,n=0,a=0),c=u*a-d*n,l=d*o-h*a,f=h*n-u*o,s=Math.sqrt(c*c+l*l+f*f),s?(s=1/s,c*=s,l*=s,f*=s):(c=0,l=0,f=0),t[0]=o,t[1]=c,t[2]=h,t[3]=0,t[4]=n,t[5]=l,t[6]=u,t[7]=0,t[8]=a,t[9]=f,t[10]=d,t[11]=0,t[12]=-(o*p+n*g+a*m),t[13]=-(c*p+l*g+f*m),t[14]=-(h*p+u*g+d*m),t[15]=1,t)}function EA(t,e,r,i){let s=e[0],o=e[1],n=e[2],a=i[0],c=i[1],l=i[2],f=s-r[0],h=o-r[1],u=n-r[2],d=f*f+h*h+u*u;d>0&&(d=1/Math.sqrt(d),f*=d,h*=d,u*=d);let p=c*u-l*h,g=l*f-a*u,m=a*h-c*f;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=h*m-u*g,t[5]=u*p-f*m,t[6]=f*g-h*p,t[7]=0,t[8]=f,t[9]=h,t[10]=u,t[11]=0,t[12]=s,t[13]=o,t[14]=n,t[15]=1,t}function wA(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function RA(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function PA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function vg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function vA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function MA(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function CA(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function IA(t,e){let r=t[0],i=t[1],s=t[2],o=t[3],n=t[4],a=t[5],c=t[6],l=t[7],f=t[8],h=t[9],u=t[10],d=t[11],p=t[12],g=t[13],m=t[14],_=t[15],b=e[0],y=e[1],T=e[2],S=e[3],A=e[4],w=e[5],v=e[6],R=e[7],M=e[8],O=e[9],C=e[10],W=e[11],V=e[12],J=e[13],Et=e[14],wt=e[15];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(s-T)<=1e-6*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(n-A)<=1e-6*Math.max(1,Math.abs(n),Math.abs(A))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-v)<=1e-6*Math.max(1,Math.abs(c),Math.abs(v))&&Math.abs(l-R)<=1e-6*Math.max(1,Math.abs(l),Math.abs(R))&&Math.abs(f-M)<=1e-6*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(h-O)<=1e-6*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(d-W)<=1e-6*Math.max(1,Math.abs(d),Math.abs(W))&&Math.abs(p-V)<=1e-6*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(g-J)<=1e-6*Math.max(1,Math.abs(g),Math.abs(J))&&Math.abs(m-Et)<=1e-6*Math.max(1,Math.abs(m),Math.abs(Et))&&Math.abs(_-wt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(wt))}var OA=_s,NA=vg;var Ae={};Rt(Ae,{add:()=>UA,ceil:()=>kA,clone:()=>DA,copy:()=>FA,create:()=>Mg,cross:()=>qA,dist:()=>aS,distance:()=>Ng,div:()=>nS,divide:()=>Og,dot:()=>ZA,equals:()=>iS,exactEquals:()=>rS,floor:()=>VA,forEach:()=>hS,fromValues:()=>BA,inverse:()=>YA,len:()=>lS,length:()=>Bg,lerp:()=>GA,max:()=>WA,min:()=>zA,mul:()=>oS,multiply:()=>Ig,negate:()=>XA,normalize:()=>KA,random:()=>QA,round:()=>jA,scale:()=>HA,scaleAndAdd:()=>$A,set:()=>LA,sqrDist:()=>cS,sqrLen:()=>fS,squaredDistance:()=>Dg,squaredLength:()=>Fg,str:()=>tS,sub:()=>sS,subtract:()=>Cg,transformMat4:()=>Lf,transformQuat:()=>JA,zero:()=>eS});function Mg(){let t=new q(4);return q!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function DA(t){let e=new q(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function BA(t,e,r,i){let s=new q(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=i,s}function FA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function LA(t,e,r,i,s){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t}function UA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Cg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function Ig(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function Og(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function kA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function VA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function zA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function WA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function jA(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t[2]=Fe(e[2]),t[3]=Fe(e[3]),t}function HA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function $A(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function Ng(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],o=e[3]-t[3];return Math.sqrt(r*r+i*i+s*s+o*o)}function Dg(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],o=e[3]-t[3];return r*r+i*i+s*s+o*o}function Bg(t){let e=t[0],r=t[1],i=t[2],s=t[3];return Math.sqrt(e*e+r*r+i*i+s*s)}function Fg(t){let e=t[0],r=t[1],i=t[2],s=t[3];return e*e+r*r+i*i+s*s}function XA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function YA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function KA(t,e){let r=e[0],i=e[1],s=e[2],o=e[3],n=r*r+i*i+s*s+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=r*n,t[1]=i*n,t[2]=s*n,t[3]=o*n,t}function ZA(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function qA(t,e,r,i){let s=r[0]*i[1]-r[1]*i[0],o=r[0]*i[2]-r[2]*i[0],n=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],f=e[0],h=e[1],u=e[2],d=e[3];return t[0]=h*l-u*c+d*a,t[1]=-(f*l)+u*n-d*o,t[2]=f*c-h*n+d*s,t[3]=-(f*a)+h*o-u*s,t}function GA(t,e,r,i){let s=e[0],o=e[1],n=e[2],a=e[3];return t[0]=s+i*(r[0]-s),t[1]=o+i*(r[1]-o),t[2]=n+i*(r[2]-n),t[3]=a+i*(r[3]-a),t}function QA(t,e){e=e===void 0?1:e;let r,i,s,o,n,a;do r=ct()*2-1,i=ct()*2-1,n=r*r+i*i;while(n>=1);do s=ct()*2-1,o=ct()*2-1,a=s*s+o*o;while(a>=1);let c=Math.sqrt((1-n)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*s*c,t[3]=e*o*c,t}function Lf(t,e,r){let i=e[0],s=e[1],o=e[2],n=e[3];return t[0]=r[0]*i+r[4]*s+r[8]*o+r[12]*n,t[1]=r[1]*i+r[5]*s+r[9]*o+r[13]*n,t[2]=r[2]*i+r[6]*s+r[10]*o+r[14]*n,t[3]=r[3]*i+r[7]*s+r[11]*o+r[15]*n,t}function JA(t,e,r){let i=e[0],s=e[1],o=e[2],n=r[0],a=r[1],c=r[2],l=r[3],f=l*i+a*o-c*s,h=l*s+c*i-n*o,u=l*o+n*s-a*i,d=-n*i-a*s-c*o;return t[0]=f*l+d*-n+h*-c-u*-a,t[1]=h*l+d*-a+u*-n-f*-c,t[2]=u*l+d*-c+f*-a-h*-n,t[3]=e[3],t}function eS(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function tS(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function rS(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function iS(t,e){let r=t[0],i=t[1],s=t[2],o=t[3],n=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(o-l)<=1e-6*Math.max(1,Math.abs(o),Math.abs(l))}var sS=Cg,oS=Ig,nS=Og,aS=Ng,cS=Dg,lS=Bg,fS=Fg,hS=function(){let t=Mg();return function(e,r,i,s,o,n){let a,c;for(r||(r=4),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],o(t,t,n),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var Vf;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Vf||(Vf={}));var uS=45*Math.PI/180,dS=1,Uf=.1,kf=500,pS=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends In{static get IDENTITY(){return mS()}static get ZERO(){return gS()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Vf}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,i,s,o,n,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=r,this[2]=i,this[3]=s,this[4]=o,this[5]=n,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=h,this[11]=u,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(e,r,i,s,o,n,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=o,this[2]=l,this[3]=d,this[4]=r,this[5]=n,this[6]=f,this[7]=p,this[8]=i,this[9]=a,this[10]=h,this[11]=g,this[12]=s,this[13]=c,this[14]=u,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(pS)}fromObject(e){return this.check()}fromQuaternion(e){return Of(this,e),this.check()}frustum(e){let{left:r,right:i,bottom:s,top:o,near:n=Uf,far:a=kf}=e;return a===1/0?_S(this,r,i,s,o,n):Nf(this,r,i,s,o,n,a),this.check()}lookAt(e){let{eye:r,center:i=[0,0,0],up:s=[0,1,0]}=e;return Ff(this,r,i,s),this.check()}ortho(e){let{left:r,right:i,bottom:s,top:o,near:n=Uf,far:a=kf}=e;return Bf(this,r,i,s,o,n,a),this.check()}orthographic(e){let{fovy:r=uS,aspect:i=dS,focalDistance:s=1,near:o=Uf,far:n=kf}=e;Lg(r);let a=r/2,c=s*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:n})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:i=1,near:s=.1,far:o=500}=e;return Lg(r),Df(this,r,i,s,o),this.check()}determinant(){return wf(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),s=1/i[0],o=1/i[1],n=1/i[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*n,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*o,e[6]=this[6]*n,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*o,e[10]=this[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),s=1/i[0],o=1/i[1],n=1/i[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*n,e[3]=this[4]*s,e[4]=this[5]*o,e[5]=this[6]*n,e[6]=this[8]*s,e[7]=this[9]*o,e[8]=this[10]*n,e}transpose(){return Sf(this,this),this.check()}invert(){return Ef(this,this),this.check()}multiplyLeft(e){return _s(this,e,this),this.check()}multiplyRight(e){return _s(this,this,e),this.check()}rotateX(e){return Mf(this,this,e),this.check()}rotateY(e){return Cf(this,this,e),this.check()}rotateZ(e){return If(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return vf(this,this,e,r),this.check()}scale(e){return Pf(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Rf(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Lf(r||[-0,-0,-0,-0],e,this),wn(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:i}=e,s;switch(i){case 2:s=df(r||[-0,-0],e,this);break;case 3:s=ms(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return wn(s,e.length),s}transformAsVector(e,r){let i;switch(e.length){case 2:i=pg(r||[-0,-0],e,this);break;case 3:i=vn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return wn(i,e.length),i}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,i){return this.identity().translate([e,r,i])}},On,Nn;function gS(){return On||(On=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(On)),On}function mS(){return Nn||(Nn=new z,Object.freeze(Nn)),Nn}function Lg(t){if(t>Math.PI*2)throw Error("expected radians")}function _S(t,e,r,i,s,o){let n=2*o/(r-e),a=2*o/(s-i),c=(r+e)/(r-e),l=(s+i)/(s-i),f=-1,h=-1,u=-2*o;return t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=h,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}var Ug=1e-6,yS=6371e3,We=class{constructor({phi:e=0,theta:r=0,radius:i=1,bearing:s,pitch:o,altitude:n,radiusScale:a=yS}={}){this.phi=e,this.theta=r,this.radius=i||n||1,this.radiusScale=a||1,s!==void 0&&(this.bearing=s),o!==void 0&&(this.pitch=o),this.check()}toString(){return this.formatString(te)}formatString({printTypes:e=!1}){let r=gs;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Pe(this.radius,e.radius)&&Pe(this.theta,e.theta)&&Pe(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-er(this.phi)}set bearing(e){this.phi=Math.PI-yi(e)}get pitch(){return er(this.theta)}set pitch(e){this.theta=yi(e)}get longitude(){return er(this.phi)}get latitude(){return er(this.theta)}get lng(){return er(this.phi)}get lat(){return er(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,i){return this.radius=e,this.phi=r,this.theta=i,this.check()}clone(){return new We().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,i]){return this.radius=1+i/this.radiusScale,this.phi=yi(r),this.theta=yi(e),this.check()}fromVector3(e){return this.radius=Mn(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(U(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new H(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(Ug,Math.min(Math.PI-Ug,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}};function zf(t,e=[],r=0){let i=Math.fround(t),s=t-i;return e[r]=i,e[r+1]=s,e}function kg(t){return t-Math.fround(t)}function Vg(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let s=r*4+i;zf(t[i*4+r],e,s*2)}return e}var bS=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
108
114
|
|
|
109
115
|
// All these functions are for substituting tan() function from Intel GPU only
|
|
110
116
|
const float TWO_PI = 6.2831854820251465;
|
|
@@ -254,9 +260,10 @@ float tan_fp32(float a) {
|
|
|
254
260
|
return tan(a);
|
|
255
261
|
#endif
|
|
256
262
|
}
|
|
257
|
-
`,
|
|
258
|
-
uniform fp64arithmeticUniforms {
|
|
263
|
+
`,Wf={name:"fp32",vs:bS};var jf=`
|
|
264
|
+
layout(std140) uniform fp64arithmeticUniforms {
|
|
259
265
|
uniform float ONE;
|
|
266
|
+
uniform float SPLIT;
|
|
260
267
|
} fp64;
|
|
261
268
|
|
|
262
269
|
/*
|
|
@@ -266,6 +273,12 @@ The purpose of this workaround is to prevent shader compilers from
|
|
|
266
273
|
optimizing away necessary arithmetic operations by swapping their sequences
|
|
267
274
|
or transform the equation to some 'equivalent' form.
|
|
268
275
|
|
|
276
|
+
These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
|
|
277
|
+
folds constants or reassociates the arithmetic, the high/low split can stop
|
|
278
|
+
tracking the rounding error correctly. That failure mode tends to look fine in
|
|
279
|
+
simple coordinate setup, but then breaks down inside iterative arithmetic such
|
|
280
|
+
as fp64 Mandelbrot loops.
|
|
281
|
+
|
|
269
282
|
The method is to multiply an artifical variable, ONE, which will be known to
|
|
270
283
|
the compiler to be 1 only at runtime. The whole expression is then represented
|
|
271
284
|
as a polynomial with respective to ONE. In the coefficients of all terms, only one a
|
|
@@ -274,17 +287,23 @@ and one b should appear
|
|
|
274
287
|
err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
|
|
275
288
|
*/
|
|
276
289
|
|
|
277
|
-
|
|
278
|
-
vec2 split(float a) {
|
|
279
|
-
const float SPLIT = 4097.0;
|
|
280
|
-
float t = a * SPLIT;
|
|
290
|
+
float prevent_fp64_optimization(float value) {
|
|
281
291
|
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
282
|
-
|
|
283
|
-
float a_lo = a * fp64.ONE - a_hi;
|
|
292
|
+
return value + fp64.ONE * 0.0;
|
|
284
293
|
#else
|
|
285
|
-
|
|
286
|
-
float a_lo = a - a_hi;
|
|
294
|
+
return value;
|
|
287
295
|
#endif
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Divide float number to high and low floats to extend fraction bits
|
|
299
|
+
vec2 split(float a) {
|
|
300
|
+
// Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
|
|
301
|
+
// split into a constant expression and reassociate the recovery steps.
|
|
302
|
+
float split = prevent_fp64_optimization(fp64.SPLIT);
|
|
303
|
+
float t = prevent_fp64_optimization(a * split);
|
|
304
|
+
float temp = t - a;
|
|
305
|
+
float a_hi = t - temp;
|
|
306
|
+
float a_lo = a - a_hi;
|
|
288
307
|
return vec2(a_hi, a_lo);
|
|
289
308
|
}
|
|
290
309
|
|
|
@@ -348,8 +367,26 @@ vec2 twoProd(float a, float b) {
|
|
|
348
367
|
float prod = a * b;
|
|
349
368
|
vec2 a_fp64 = split(a);
|
|
350
369
|
vec2 b_fp64 = split(b);
|
|
351
|
-
|
|
352
|
-
|
|
370
|
+
// twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
|
|
371
|
+
// on the split terms and cross terms staying in the original evaluation
|
|
372
|
+
// order. If the compiler folds or reassociates them, the low part tends to
|
|
373
|
+
// collapse to zero or NaN on some drivers.
|
|
374
|
+
float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
|
|
375
|
+
float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
|
|
376
|
+
float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
|
|
377
|
+
float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
|
|
378
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
379
|
+
float err1 = (highProduct - prod) * fp64.ONE;
|
|
380
|
+
float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
|
|
381
|
+
float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
382
|
+
float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
383
|
+
#else
|
|
384
|
+
float err1 = highProduct - prod;
|
|
385
|
+
float err2 = crossProduct1;
|
|
386
|
+
float err3 = crossProduct2;
|
|
387
|
+
float err4 = lowProduct;
|
|
388
|
+
#endif
|
|
389
|
+
float err = ((err1 + err2) + err3) + err4;
|
|
353
390
|
return vec2(prod, err);
|
|
354
391
|
}
|
|
355
392
|
|
|
@@ -422,7 +459,213 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
422
459
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
423
460
|
#endif
|
|
424
461
|
}
|
|
425
|
-
`;var
|
|
462
|
+
`;var zg=`struct Fp64ArithmeticUniforms {
|
|
463
|
+
ONE: f32,
|
|
464
|
+
SPLIT: f32,
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms;
|
|
468
|
+
|
|
469
|
+
fn fp64_nan(seed: f32) -> f32 {
|
|
470
|
+
let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0);
|
|
471
|
+
return bitcast<f32>(nanBits);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
fn fp64_runtime_zero() -> f32 {
|
|
475
|
+
return fp64arithmetic.ONE * 0.0;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
fn prevent_fp64_optimization(value: f32) -> f32 {
|
|
479
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
480
|
+
return value + fp64_runtime_zero();
|
|
481
|
+
#else
|
|
482
|
+
return value;
|
|
483
|
+
#endif
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
fn split(a: f32) -> vec2f {
|
|
487
|
+
let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero());
|
|
488
|
+
let t = prevent_fp64_optimization(a * splitValue);
|
|
489
|
+
let temp = prevent_fp64_optimization(t - a);
|
|
490
|
+
let aHi = prevent_fp64_optimization(t - temp);
|
|
491
|
+
let aLo = prevent_fp64_optimization(a - aHi);
|
|
492
|
+
return vec2f(aHi, aLo);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
fn split2(a: vec2f) -> vec2f {
|
|
496
|
+
var b = split(a.x);
|
|
497
|
+
b.y = b.y + a.y;
|
|
498
|
+
return b;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
fn quickTwoSum(a: f32, b: f32) -> vec2f {
|
|
502
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
503
|
+
let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE);
|
|
504
|
+
let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE);
|
|
505
|
+
#else
|
|
506
|
+
let sum = prevent_fp64_optimization(a + b);
|
|
507
|
+
let err = prevent_fp64_optimization(b - (sum - a));
|
|
508
|
+
#endif
|
|
509
|
+
return vec2f(sum, err);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
fn twoSum(a: f32, b: f32) -> vec2f {
|
|
513
|
+
let s = prevent_fp64_optimization(a + b);
|
|
514
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
515
|
+
let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
|
|
516
|
+
let err =
|
|
517
|
+
prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
|
|
518
|
+
fp64arithmetic.ONE *
|
|
519
|
+
fp64arithmetic.ONE *
|
|
520
|
+
fp64arithmetic.ONE) +
|
|
521
|
+
prevent_fp64_optimization(b - v);
|
|
522
|
+
#else
|
|
523
|
+
let v = prevent_fp64_optimization(s - a);
|
|
524
|
+
let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v);
|
|
525
|
+
#endif
|
|
526
|
+
return vec2f(s, err);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
fn twoSub(a: f32, b: f32) -> vec2f {
|
|
530
|
+
let s = prevent_fp64_optimization(a - b);
|
|
531
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
532
|
+
let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE);
|
|
533
|
+
let err =
|
|
534
|
+
prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) *
|
|
535
|
+
fp64arithmetic.ONE *
|
|
536
|
+
fp64arithmetic.ONE *
|
|
537
|
+
fp64arithmetic.ONE) -
|
|
538
|
+
prevent_fp64_optimization(b + v);
|
|
539
|
+
#else
|
|
540
|
+
let v = prevent_fp64_optimization(s - a);
|
|
541
|
+
let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v);
|
|
542
|
+
#endif
|
|
543
|
+
return vec2f(s, err);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
fn twoSqr(a: f32) -> vec2f {
|
|
547
|
+
let prod = prevent_fp64_optimization(a * a);
|
|
548
|
+
let aFp64 = split(a);
|
|
549
|
+
let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x);
|
|
550
|
+
let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y);
|
|
551
|
+
let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y);
|
|
552
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
553
|
+
let err =
|
|
554
|
+
(prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE +
|
|
555
|
+
crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) +
|
|
556
|
+
lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
|
|
557
|
+
#else
|
|
558
|
+
let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct);
|
|
559
|
+
#endif
|
|
560
|
+
return vec2f(prod, err);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
fn twoProd(a: f32, b: f32) -> vec2f {
|
|
564
|
+
let prod = prevent_fp64_optimization(a * b);
|
|
565
|
+
let aFp64 = split(a);
|
|
566
|
+
let bFp64 = split(b);
|
|
567
|
+
let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x);
|
|
568
|
+
let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y);
|
|
569
|
+
let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x);
|
|
570
|
+
let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y);
|
|
571
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
572
|
+
let err1 = (highProduct - prod) * fp64arithmetic.ONE;
|
|
573
|
+
let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE;
|
|
574
|
+
let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE;
|
|
575
|
+
let err4 =
|
|
576
|
+
lowProduct *
|
|
577
|
+
fp64arithmetic.ONE *
|
|
578
|
+
fp64arithmetic.ONE *
|
|
579
|
+
fp64arithmetic.ONE *
|
|
580
|
+
fp64arithmetic.ONE;
|
|
581
|
+
#else
|
|
582
|
+
let err1 = highProduct - prod;
|
|
583
|
+
let err2 = crossProduct1;
|
|
584
|
+
let err3 = crossProduct2;
|
|
585
|
+
let err4 = lowProduct;
|
|
586
|
+
#endif
|
|
587
|
+
let err12InputA = prevent_fp64_optimization(err1);
|
|
588
|
+
let err12InputB = prevent_fp64_optimization(err2);
|
|
589
|
+
let err12 = prevent_fp64_optimization(err12InputA + err12InputB);
|
|
590
|
+
let err123InputA = prevent_fp64_optimization(err12);
|
|
591
|
+
let err123InputB = prevent_fp64_optimization(err3);
|
|
592
|
+
let err123 = prevent_fp64_optimization(err123InputA + err123InputB);
|
|
593
|
+
let err1234InputA = prevent_fp64_optimization(err123);
|
|
594
|
+
let err1234InputB = prevent_fp64_optimization(err4);
|
|
595
|
+
let err = prevent_fp64_optimization(err1234InputA + err1234InputB);
|
|
596
|
+
return vec2f(prod, err);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
fn sum_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
600
|
+
var s = twoSum(a.x, b.x);
|
|
601
|
+
let t = twoSum(a.y, b.y);
|
|
602
|
+
s.y = prevent_fp64_optimization(s.y + t.x);
|
|
603
|
+
s = quickTwoSum(s.x, s.y);
|
|
604
|
+
s.y = prevent_fp64_optimization(s.y + t.y);
|
|
605
|
+
s = quickTwoSum(s.x, s.y);
|
|
606
|
+
return s;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
fn sub_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
610
|
+
var s = twoSub(a.x, b.x);
|
|
611
|
+
let t = twoSub(a.y, b.y);
|
|
612
|
+
s.y = prevent_fp64_optimization(s.y + t.x);
|
|
613
|
+
s = quickTwoSum(s.x, s.y);
|
|
614
|
+
s.y = prevent_fp64_optimization(s.y + t.y);
|
|
615
|
+
s = quickTwoSum(s.x, s.y);
|
|
616
|
+
return s;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
fn mul_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
620
|
+
var prod = twoProd(a.x, b.x);
|
|
621
|
+
let crossProduct1 = prevent_fp64_optimization(a.x * b.y);
|
|
622
|
+
prod.y = prevent_fp64_optimization(prod.y + crossProduct1);
|
|
623
|
+
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
|
|
624
|
+
prod = split2(prod);
|
|
625
|
+
#endif
|
|
626
|
+
prod = quickTwoSum(prod.x, prod.y);
|
|
627
|
+
let crossProduct2 = prevent_fp64_optimization(a.y * b.x);
|
|
628
|
+
prod.y = prevent_fp64_optimization(prod.y + crossProduct2);
|
|
629
|
+
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
|
|
630
|
+
prod = split2(prod);
|
|
631
|
+
#endif
|
|
632
|
+
prod = quickTwoSum(prod.x, prod.y);
|
|
633
|
+
return prod;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
fn div_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
637
|
+
let xn = prevent_fp64_optimization(1.0 / b.x);
|
|
638
|
+
let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero()));
|
|
639
|
+
let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x);
|
|
640
|
+
let prod = twoProd(xn, diff);
|
|
641
|
+
return sum_fp64(yn, prod);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
645
|
+
if (a.x == 0.0 && a.y == 0.0) {
|
|
646
|
+
return vec2f(0.0, 0.0);
|
|
647
|
+
}
|
|
648
|
+
if (a.x < 0.0) {
|
|
649
|
+
let nanValue = fp64_nan(a.x);
|
|
650
|
+
return vec2f(nanValue, nanValue);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
let x = prevent_fp64_optimization(1.0 / sqrt(a.x));
|
|
654
|
+
let yn = prevent_fp64_optimization(a.x * x);
|
|
655
|
+
#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
656
|
+
let ynSqr = twoSqr(yn) * fp64arithmetic.ONE;
|
|
657
|
+
#else
|
|
658
|
+
let ynSqr = twoSqr(yn);
|
|
659
|
+
#endif
|
|
660
|
+
let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x);
|
|
661
|
+
let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff);
|
|
662
|
+
#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND
|
|
663
|
+
return sum_fp64(split(yn), prod);
|
|
664
|
+
#else
|
|
665
|
+
return sum_fp64(vec2f(yn, 0.0), prod);
|
|
666
|
+
#endif
|
|
667
|
+
}
|
|
668
|
+
`;var TS={ONE:1,SPLIT:4097},Hf={name:"fp64arithmetic",source:zg,fs:jf,vs:jf,defaultUniforms:TS,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:zf,fp64LowPart:kg,fp64ifyMatrix4:Vg};var xS=[0,1,1,1],AS=`layout(std140) uniform pickingUniforms {
|
|
426
669
|
float isActive;
|
|
427
670
|
float isAttribute;
|
|
428
671
|
float isHighlightActive;
|
|
@@ -493,7 +736,7 @@ void picking_setPickingAttribute(vec3 value) {
|
|
|
493
736
|
picking_vRGBcolor_Avalid.rgb = value;
|
|
494
737
|
}
|
|
495
738
|
}
|
|
496
|
-
`,
|
|
739
|
+
`,SS=`layout(std140) uniform pickingUniforms {
|
|
497
740
|
float isActive;
|
|
498
741
|
float isAttribute;
|
|
499
742
|
float isHighlightActive;
|
|
@@ -549,7 +792,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
549
792
|
vec4 highlightColor = picking_filterHighlightColor(color);
|
|
550
793
|
return picking_filterPickingColor(highlightColor);
|
|
551
794
|
}
|
|
552
|
-
`,
|
|
795
|
+
`,Dn={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:xS},vs:AS,fs:SS,getUniforms:ES};function ES(t={},e){let r={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let i=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=i}if(t.highlightColor){let i=Array.from(t.highlightColor,s=>s/255);Number.isFinite(i[3])||(i[3]=1),r.highlightColor=i}return t.isActive!==void 0&&(r.isActive=Boolean(t.isActive),r.isAttribute=Boolean(t.isAttribute)),t.useFloatColors!==void 0&&(r.useFloatColors=Boolean(t.useFloatColors)),r}L();var $f=`precision highp int;
|
|
553
796
|
|
|
554
797
|
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
555
798
|
struct AmbientLight {
|
|
@@ -562,77 +805,51 @@ struct PointLight {
|
|
|
562
805
|
vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
|
|
563
806
|
};
|
|
564
807
|
|
|
808
|
+
struct SpotLight {
|
|
809
|
+
vec3 color;
|
|
810
|
+
vec3 position;
|
|
811
|
+
vec3 direction;
|
|
812
|
+
vec3 attenuation;
|
|
813
|
+
vec2 coneCos;
|
|
814
|
+
};
|
|
815
|
+
|
|
565
816
|
struct DirectionalLight {
|
|
566
817
|
vec3 color;
|
|
567
818
|
vec3 direction;
|
|
568
819
|
};
|
|
569
820
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
821
|
+
struct UniformLight {
|
|
822
|
+
vec3 color;
|
|
823
|
+
vec3 position;
|
|
824
|
+
vec3 direction;
|
|
825
|
+
vec3 attenuation;
|
|
826
|
+
vec2 coneCos;
|
|
827
|
+
};
|
|
573
828
|
|
|
829
|
+
layout(std140) uniform lightingUniforms {
|
|
830
|
+
int enabled;
|
|
574
831
|
int directionalLightCount;
|
|
575
832
|
int pointLightCount;
|
|
576
|
-
|
|
833
|
+
int spotLightCount;
|
|
577
834
|
vec3 ambientColor;
|
|
578
|
-
|
|
579
|
-
vec3 lightColor0;
|
|
580
|
-
vec3 lightPosition0;
|
|
581
|
-
vec3 lightDirection0;
|
|
582
|
-
vec3 lightAttenuation0;
|
|
583
|
-
|
|
584
|
-
vec3 lightColor1;
|
|
585
|
-
vec3 lightPosition1;
|
|
586
|
-
vec3 lightDirection1;
|
|
587
|
-
vec3 lightAttenuation1;
|
|
588
|
-
|
|
589
|
-
vec3 lightColor2;
|
|
590
|
-
vec3 lightPosition2;
|
|
591
|
-
vec3 lightDirection2;
|
|
592
|
-
vec3 lightAttenuation2;
|
|
593
|
-
|
|
594
|
-
vec3 lightColor3;
|
|
595
|
-
vec3 lightPosition3;
|
|
596
|
-
vec3 lightDirection3;
|
|
597
|
-
vec3 lightAttenuation3;
|
|
598
|
-
|
|
599
|
-
vec3 lightColor4;
|
|
600
|
-
vec3 lightPosition4;
|
|
601
|
-
vec3 lightDirection4;
|
|
602
|
-
vec3 lightAttenuation4;
|
|
835
|
+
UniformLight lights[5];
|
|
603
836
|
} lighting;
|
|
604
837
|
|
|
605
838
|
PointLight lighting_getPointLight(int index) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
case 3:
|
|
614
|
-
return PointLight(lighting.lightColor3, lighting.lightPosition3, lighting.lightAttenuation3);
|
|
615
|
-
case 4:
|
|
616
|
-
default:
|
|
617
|
-
return PointLight(lighting.lightColor4, lighting.lightPosition4, lighting.lightAttenuation4);
|
|
618
|
-
}
|
|
839
|
+
UniformLight light = lighting.lights[index];
|
|
840
|
+
return PointLight(light.color, light.position, light.attenuation);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
SpotLight lighting_getSpotLight(int index) {
|
|
844
|
+
UniformLight light = lighting.lights[lighting.pointLightCount + index];
|
|
845
|
+
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
|
|
619
846
|
}
|
|
620
847
|
|
|
621
848
|
DirectionalLight lighting_getDirectionalLight(int index) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
|
|
627
|
-
case 2:
|
|
628
|
-
return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
|
|
629
|
-
case 3:
|
|
630
|
-
return DirectionalLight(lighting.lightColor3, lighting.lightDirection3);
|
|
631
|
-
case 4:
|
|
632
|
-
default:
|
|
633
|
-
return DirectionalLight(lighting.lightColor4, lighting.lightDirection4);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
849
|
+
UniformLight light =
|
|
850
|
+
lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
|
|
851
|
+
return DirectionalLight(light.color, light.direction);
|
|
852
|
+
}
|
|
636
853
|
|
|
637
854
|
float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
638
855
|
return pointLight.attenuation.x
|
|
@@ -640,8 +857,22 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
|
|
|
640
857
|
+ pointLight.attenuation.z * distance * distance;
|
|
641
858
|
}
|
|
642
859
|
|
|
860
|
+
float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
|
|
861
|
+
vec3 light_direction = normalize(positionWorldspace - spotLight.position);
|
|
862
|
+
float coneFactor = smoothstep(
|
|
863
|
+
spotLight.coneCos.y,
|
|
864
|
+
spotLight.coneCos.x,
|
|
865
|
+
dot(normalize(spotLight.direction), light_direction)
|
|
866
|
+
);
|
|
867
|
+
float distanceAttenuation = getPointLightAttenuation(
|
|
868
|
+
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
|
|
869
|
+
distance(spotLight.position, positionWorldspace)
|
|
870
|
+
);
|
|
871
|
+
return distanceAttenuation / max(coneFactor, 0.0001);
|
|
872
|
+
}
|
|
873
|
+
|
|
643
874
|
// #endif
|
|
644
|
-
`;var
|
|
875
|
+
`;var Wg=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
645
876
|
const MAX_LIGHTS: i32 = 5;
|
|
646
877
|
|
|
647
878
|
struct AmbientLight {
|
|
@@ -654,103 +885,81 @@ struct PointLight {
|
|
|
654
885
|
attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
|
|
655
886
|
};
|
|
656
887
|
|
|
888
|
+
struct SpotLight {
|
|
889
|
+
color: vec3<f32>,
|
|
890
|
+
position: vec3<f32>,
|
|
891
|
+
direction: vec3<f32>,
|
|
892
|
+
attenuation: vec3<f32>,
|
|
893
|
+
coneCos: vec2<f32>,
|
|
894
|
+
};
|
|
895
|
+
|
|
657
896
|
struct DirectionalLight {
|
|
658
897
|
color: vec3<f32>,
|
|
659
898
|
direction: vec3<f32>,
|
|
660
899
|
};
|
|
661
900
|
|
|
901
|
+
struct UniformLight {
|
|
902
|
+
color: vec3<f32>,
|
|
903
|
+
position: vec3<f32>,
|
|
904
|
+
direction: vec3<f32>,
|
|
905
|
+
attenuation: vec3<f32>,
|
|
906
|
+
coneCos: vec2<f32>,
|
|
907
|
+
};
|
|
908
|
+
|
|
662
909
|
struct lightingUniforms {
|
|
663
910
|
enabled: i32,
|
|
664
|
-
lightType: i32,
|
|
665
|
-
|
|
666
911
|
directionalLightCount: i32,
|
|
667
912
|
pointLightCount: i32,
|
|
668
|
-
|
|
913
|
+
spotLightCount: i32,
|
|
669
914
|
ambientColor: vec3<f32>,
|
|
670
|
-
|
|
671
|
-
lightColor0: vec3<f32>,
|
|
672
|
-
lightPosition0: vec3<f32>,
|
|
673
|
-
lightDirection0: vec3<f32>,
|
|
674
|
-
lightAttenuation0: vec3<f32>,
|
|
675
|
-
|
|
676
|
-
lightColor1: vec3<f32>,
|
|
677
|
-
lightPosition1: vec3<f32>,
|
|
678
|
-
lightDirection1: vec3<f32>,
|
|
679
|
-
lightAttenuation1: vec3<f32>,
|
|
680
|
-
|
|
681
|
-
lightColor2: vec3<f32>,
|
|
682
|
-
lightPosition2: vec3<f32>,
|
|
683
|
-
lightDirection2: vec3<f32>,
|
|
684
|
-
lightAttenuation2: vec3<f32>,
|
|
685
|
-
|
|
686
|
-
lightColor3: vec3<f32>,
|
|
687
|
-
lightPosition3: vec3<f32>,
|
|
688
|
-
lightDirection3: vec3<f32>,
|
|
689
|
-
lightAttenuation3: vec3<f32>,
|
|
690
|
-
|
|
691
|
-
lightColor4: vec3<f32>,
|
|
692
|
-
lightPosition4: vec3<f32>,
|
|
693
|
-
lightDirection4: vec3<f32>,
|
|
694
|
-
lightAttenuation4: vec3<f32>,
|
|
915
|
+
lights: array<UniformLight, 5>,
|
|
695
916
|
};
|
|
696
917
|
|
|
697
|
-
|
|
698
|
-
@binding(1) @group(0) var<uniform> lighting : lightingUniforms;
|
|
918
|
+
@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
|
|
699
919
|
|
|
700
920
|
fn lighting_getPointLight(index: i32) -> PointLight {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
case 2: {
|
|
709
|
-
return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
|
|
710
|
-
}
|
|
711
|
-
case 3: {
|
|
712
|
-
return PointLight(lighting.lightColor3, lighting.lightPosition3, lighting.lightAttenuation3);
|
|
713
|
-
}
|
|
714
|
-
case 4, default: {
|
|
715
|
-
return PointLight(lighting.lightColor4, lighting.lightPosition4, lighting.lightAttenuation4);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
921
|
+
let light = lighting.lights[index];
|
|
922
|
+
return PointLight(light.color, light.position, light.attenuation);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
fn lighting_getSpotLight(index: i32) -> SpotLight {
|
|
926
|
+
let light = lighting.lights[lighting.pointLightCount + index];
|
|
927
|
+
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
|
|
718
928
|
}
|
|
719
929
|
|
|
720
930
|
fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}
|
|
725
|
-
case 1: {
|
|
726
|
-
return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
|
|
727
|
-
}
|
|
728
|
-
case 2: {
|
|
729
|
-
return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
|
|
730
|
-
}
|
|
731
|
-
case 3: {
|
|
732
|
-
return DirectionalLight(lighting.lightColor3, lighting.lightDirection3);
|
|
733
|
-
}
|
|
734
|
-
case 4, default: {
|
|
735
|
-
return DirectionalLight(lighting.lightColor4, lighting.lightDirection4);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
931
|
+
let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
|
|
932
|
+
return DirectionalLight(light.color, light.direction);
|
|
933
|
+
}
|
|
739
934
|
|
|
740
935
|
fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
|
|
741
936
|
return pointLight.attenuation.x
|
|
742
937
|
+ pointLight.attenuation.y * distance
|
|
743
938
|
+ pointLight.attenuation.z * distance * distance;
|
|
744
939
|
}
|
|
745
|
-
|
|
940
|
+
|
|
941
|
+
fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
|
|
942
|
+
let lightDirection = normalize(positionWorldspace - spotLight.position);
|
|
943
|
+
let coneFactor = smoothstep(
|
|
944
|
+
spotLight.coneCos.y,
|
|
945
|
+
spotLight.coneCos.x,
|
|
946
|
+
dot(normalize(spotLight.direction), lightDirection)
|
|
947
|
+
);
|
|
948
|
+
let distanceAttenuation = getPointLightAttenuation(
|
|
949
|
+
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
|
|
950
|
+
distance(spotLight.position, positionWorldspace)
|
|
951
|
+
);
|
|
952
|
+
return distanceAttenuation / max(coneFactor, 0.0001);
|
|
953
|
+
}
|
|
954
|
+
`;var Pr=5,wS=255,RS={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},Ln={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[RS,Pr]},defaultUniforms:Fn(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:Wg,vs:$f,fs:$f,getUniforms:PS};function PS(t,e={}){if(t=t&&{...t},!t)return Fn();t.lights&&(t={...t,...MS(t.lights),lights:void 0});let{ambientLight:r,pointLights:i,spotLights:s,directionalLights:o}=t||{};if(!(r||i&&i.length>0||s&&s.length>0||o&&o.length>0))return{...Fn(),enabled:0};let a={...Fn(),...vS({ambientLight:r,pointLights:i,spotLights:s,directionalLights:o})};return t.enabled!==void 0&&(a.enabled=t.enabled?1:0),a}function vS({ambientLight:t,pointLights:e=[],spotLights:r=[],directionalLights:i=[]}){let s=jg(),o=0,n=0,a=0,c=0;for(let l of e){if(o>=Pr)break;s[o]={...s[o],color:Bn(l),position:l.position,attenuation:l.attenuation||[1,0,0]},o++,n++}for(let l of r){if(o>=Pr)break;s[o]={...s[o],color:Bn(l),position:l.position,direction:l.direction,attenuation:l.attenuation||[1,0,0],coneCos:IS(l)},o++,a++}for(let l of i){if(o>=Pr)break;s[o]={...s[o],color:Bn(l),direction:l.direction},o++,c++}return e.length+r.length+i.length>Pr&&x.warn(`MAX_LIGHTS exceeded, truncating to ${Pr}`)(),{ambientColor:Bn(t),directionalLightCount:c,pointLightCount:n,spotLightCount:a,lights:s}}function MS(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function Bn(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(i=>i*r/wS)}function Fn(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:jg()}}function jg(){return Array.from({length:Pr},()=>CS())}function CS(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function IS(t){let e=t.innerConeAngle??0,r=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(r)]}var Un=`layout(std140) uniform phongMaterialUniforms {
|
|
955
|
+
uniform bool unlit;
|
|
746
956
|
uniform float ambient;
|
|
747
957
|
uniform float diffuse;
|
|
748
958
|
uniform float shininess;
|
|
749
959
|
uniform vec3 specularColor;
|
|
750
960
|
} material;
|
|
751
|
-
`,
|
|
752
|
-
|
|
753
|
-
uniform phongMaterialUniforms {
|
|
961
|
+
`,kn=`layout(std140) uniform phongMaterialUniforms {
|
|
962
|
+
uniform bool unlit;
|
|
754
963
|
uniform float ambient;
|
|
755
964
|
uniform float diffuse;
|
|
756
965
|
uniform float shininess;
|
|
@@ -772,6 +981,10 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_d
|
|
|
772
981
|
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
|
773
982
|
vec3 lightColor = surfaceColor;
|
|
774
983
|
|
|
984
|
+
if (material.unlit) {
|
|
985
|
+
return surfaceColor;
|
|
986
|
+
}
|
|
987
|
+
|
|
775
988
|
if (lighting.enabled == 0) {
|
|
776
989
|
return lightColor;
|
|
777
990
|
}
|
|
@@ -787,22 +1000,30 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
787
1000
|
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
|
|
788
1001
|
}
|
|
789
1002
|
|
|
790
|
-
int
|
|
791
|
-
|
|
1003
|
+
for (int i = 0; i < lighting.spotLightCount; i++) {
|
|
1004
|
+
SpotLight spotLight = lighting_getSpotLight(i);
|
|
1005
|
+
vec3 light_position_worldspace = spotLight.position;
|
|
1006
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
|
1007
|
+
float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
|
|
1008
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
for (int i = 0; i < lighting.directionalLightCount; i++) {
|
|
792
1012
|
DirectionalLight directionalLight = lighting_getDirectionalLight(i);
|
|
793
1013
|
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
794
1014
|
}
|
|
795
1015
|
|
|
796
1016
|
return lightColor;
|
|
797
1017
|
}
|
|
798
|
-
`;var
|
|
1018
|
+
`;var Vn=`struct phongMaterialUniforms {
|
|
1019
|
+
unlit: u32,
|
|
799
1020
|
ambient: f32,
|
|
800
1021
|
diffuse: f32,
|
|
801
1022
|
shininess: f32,
|
|
802
1023
|
specularColor: vec3<f32>,
|
|
803
1024
|
};
|
|
804
1025
|
|
|
805
|
-
@
|
|
1026
|
+
@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms;
|
|
806
1027
|
|
|
807
1028
|
fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> {
|
|
808
1029
|
let halfway_direction: vec3<f32> = normalize(light_direction + view_direction);
|
|
@@ -819,6 +1040,10 @@ fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, v
|
|
|
819
1040
|
fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> {
|
|
820
1041
|
var lightColor: vec3<f32> = surfaceColor;
|
|
821
1042
|
|
|
1043
|
+
if (phongMaterial.unlit != 0u) {
|
|
1044
|
+
return surfaceColor;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
822
1047
|
if (lighting.enabled == 0) {
|
|
823
1048
|
return lightColor;
|
|
824
1049
|
}
|
|
@@ -843,8 +1068,21 @@ fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, p
|
|
|
843
1068
|
);
|
|
844
1069
|
}
|
|
845
1070
|
|
|
846
|
-
|
|
847
|
-
|
|
1071
|
+
for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
|
|
1072
|
+
let spotLight: SpotLight = lighting_getSpotLight(i);
|
|
1073
|
+
let light_position_worldspace: vec3<f32> = spotLight.position;
|
|
1074
|
+
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
|
1075
|
+
let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
|
|
1076
|
+
lightColor += lighting_getLightColor(
|
|
1077
|
+
surfaceColor,
|
|
1078
|
+
light_direction,
|
|
1079
|
+
view_direction,
|
|
1080
|
+
normal_worldspace,
|
|
1081
|
+
spotLight.color / light_attenuation
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
|
|
848
1086
|
let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
|
|
849
1087
|
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
850
1088
|
}
|
|
@@ -876,15 +1114,28 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
876
1114
|
);
|
|
877
1115
|
}
|
|
878
1116
|
|
|
879
|
-
|
|
880
|
-
|
|
1117
|
+
for (var i: i32 = 0; i < lighting.spotLightCount; i++) {
|
|
1118
|
+
let spotLight: SpotLight = lighting_getSpotLight(i);
|
|
1119
|
+
let light_position_worldspace: vec3<f32> = spotLight.position;
|
|
1120
|
+
let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace);
|
|
1121
|
+
let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace);
|
|
1122
|
+
lightColor += lighting_getLightColor(
|
|
1123
|
+
surfaceColor,
|
|
1124
|
+
light_direction,
|
|
1125
|
+
view_direction,
|
|
1126
|
+
normal_worldspace,
|
|
1127
|
+
spotLight.color / light_attenuation
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
for (var i: i32 = 0; i < lighting.directionalLightCount; i++) {
|
|
881
1132
|
let directionalLight: DirectionalLight = lighting_getDirectionalLight(i);
|
|
882
1133
|
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
|
883
1134
|
}
|
|
884
1135
|
}
|
|
885
1136
|
return lightColor;
|
|
886
1137
|
}
|
|
887
|
-
`;var us={props:{},name:"gouraudMaterial",vs:Mn.replace("phongMaterial","gouraudMaterial"),fs:vn.replace("phongMaterial","gouraudMaterial"),source:Cn.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Sr],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){let e={...t};return e.specularColor&&(e.specularColor=e.specularColor.map(r=>r/255)),{...us.defaultUniforms,...e}}};var ds={name:"phongMaterial",dependencies:[Sr],source:Cn,vs:vn,fs:Mn,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){let e={...t};return e.specularColor&&(e.specularColor=e.specularColor.map(r=>r/255)),{...ds.defaultUniforms,...e}}};F();var Sf={};function ie(t="id"){Sf[t]=Sf[t]||1;let e=Sf[t]++;return`${t}-${e}`}var In=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||ie("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&D.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function eg(t,e){if(e instanceof In)return e;let r=eA(t,e),{attributes:i,bufferLayout:s}=tA(t,e);return new In({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:r,attributes:i})}function eA(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:D.INDEX,data:r})}function tA(t,e){let r=[],i={};for(let[o,n]of Object.entries(e.attributes)){let a=o;switch(o){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(n){i[a]=t.createBuffer({data:n.value,id:`${o}-buffer`});let{value:c,size:l,normalized:f}=n;r.push({name:a,format:tl(c,l,f)})}}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:s}}F();var Ef=class{static getDefaultPipelineFactory(e){let r=e.getModuleData("@luma.gl/engine");return r.defaultPipelineFactory||=new Ef(e),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let r={...we.defaultProps,...e},i=this._renderPipelineCache,s=this._hashRenderPipeline(r),o=i[s]?.resource;if(o)i[s].useCount++,this.device.props.debugFactories&&b.log(3,`${this}: ${i[s].resource} reused, count=${i[s].useCount}, (id=${e.id})`)();else{let n=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;o=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:ie("unnamed-cached"),_sharedRenderPipeline:n}),o.hash=s,i[s]={resource:o,useCount:1},this.device.props.debugFactories&&b.log(3,`${this}: ${o} created, count=${i[s].useCount}`)()}return o}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let r={...br.defaultProps,...e},i=this._computePipelineCache,s=this._hashComputePipeline(r),o=i[s]?.resource;return o?(i[s].useCount++,this.device.props.debugFactories&&b.log(3,`${this}: ${i[s].resource} reused, count=${i[s].useCount}, (id=${e.id})`)()):(o=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),o.hash=s,i[s]={resource:o,useCount:1},this.device.props.debugFactories&&b.log(3,`${this}: ${o} created, count=${i[s].useCount}`)()),o}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let r=this._getCache(e),i=e.hash;r[i].useCount--,r[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&b.log(3,`${this}: ${e} released and destroyed`)()):r[i].useCount<0?(b.error(`${this}: ${e} released, useCount < 0, resetting`)(),r[i].useCount=0):this.device.props.debugFactories&&b.log(3,`${this}: ${e} released, count=${r[i].useCount}`)()}createSharedRenderPipeline(e){let r=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[r];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[r]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[r];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(e){let r=this._getCache(e);return this.device.props._destroyPipelines?(delete r[e.hash],e.destroy(),e instanceof we&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let r;if(e instanceof br&&(r=this._computePipelineCache),e instanceof we&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return r}_hashComputePipeline(e){let{type:r}=this.device,i=this._getHash(e.shader.source);return`${r}/C/${i}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,s=this._getWebGLVaryingHash(e),o=this._getHash(JSON.stringify(e.bufferLayout)),{type:n}=this.device;switch(n){case"webgl":let a=this._getHash(JSON.stringify(e.parameters));return`${n}/R/${r}/${i}V${s}T${e.topology}P${a}BL${o}`;case"webgpu":default:let c=this._getHash(JSON.stringify(e.parameters));return`${n}/R/${r}/${i}V${s}T${e.topology}P${c}BL${o}`}}_hashSharedRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,s=this._getWebGLVaryingHash(e);return`webgl/S/${r}/${i}V${s}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:r=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:r,bufferMode:i}))}},ps=Ef;P(ps,"defaultProps",{...we.defaultProps});F();var wf=class{static getDefaultShaderFactory(e){let r=e.getModuleData("@luma.gl/engine");return r.defaultShaderFactory||=new wf(e),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let r=this._hashShader(e),i=this._cache[r];if(i)i.useCount++,this.device.props.debugFactories&&b.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={resource:s,useCount:1},this.device.props.debugFactories&&b.log(3,`${this}: Created new shader ${s.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let r=this._hashShader(e),i=this._cache[r];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],i.resource.destroy(),this.device.props.debugFactories&&b.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&b.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},gs=wf;P(gs,"defaultProps",{...Zt.defaultProps});function tg(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let s of t.attributes)if(s){let o=`${s.location} ${s.name}: ${s.type}`;r[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(let s of t.varyings||[]){let o=`${s.location} ${s.name}`;r[`out ${o}`]={[i]:JSON.stringify(s)}}return r}var ne=null,Rf=null;function rg(t,{id:e,minimap:r,opaque:i,top:s="0",left:o="0",rgbaScale:n=1}){ne||(ne=document.createElement("canvas"),ne.id=e,ne.title=e,ne.style.zIndex="100",ne.style.position="absolute",ne.style.top=s,ne.style.left=o,ne.style.border="blue 5px solid",ne.style.transform="scaleY(-1)",document.body.appendChild(ne),Rf=ne.getContext("2d")),(ne.width!==t.width||ne.height!==t.height)&&(ne.width=t.width/2,ne.height=t.height/2,ne.style.width="400px",ne.style.height="400px");let a=t.device.readPixelsToArrayWebGL(t),c=Rf?.createImageData(t.width,t.height);if(c){for(let f=0;f<a.length;f+=4)c.data[0+f+0]=a[f+0]*n,c.data[0+f+1]=a[f+1]*n,c.data[0+f+2]=a[f+2]*n,c.data[0+f+3]=i?255:a[f+3]*n;Rf?.putImageData(c,0,0)}}function On(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!On(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(let o of i)if(!e.hasOwnProperty(o)||!On(t[o],e[o],r-1))return!1;return!0}return!1}F();var di=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(r=>r.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(r=>r.attribute):[e.name]}mergeBufferLayouts(e,r){let i=[...e];for(let s of r){let o=i.findIndex(n=>n.name===s.name);o<0?i.push(s):i[o]=s}return i}getBufferIndex(e){let r=this.bufferLayouts.findIndex(i=>i.name===e);return r===-1&&b.warn(`BufferLayout: Missing buffer for "${e}".`)(),r}};function ig(t,e){let r=1/0;for(let i of t){let s=e[i];s!==void 0&&(r=Math.min(r,s))}return r}function sg(t,e){let r=Object.fromEntries(t.attributes.map(s=>[s.name,s.location])),i=e.slice();return i.sort((s,o)=>{let n=s.attributes?s.attributes.map(f=>f.attribute):[s.name],a=o.attributes?o.attributes.map(f=>f.attribute):[o.name],c=ig(n,r),l=ig(a,r);return c-l}),i}F();function og(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function ng(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function Pf(t){return og(t)||ng(t)}function rA(t){return Pf(t)||typeof t=="number"||typeof t=="boolean"}function ag(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let i=t[r];rA(i)?e.uniforms[r]=i:e.bindings[r]=i}),e}var Nn=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let i=li(Object.values(e).filter(s=>s.dependencies));for(let s of i)e[s.name]=s;b.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[s,o]of Object.entries(e))this._addModule(o),o.name&&s!==o.name&&!this.options.disableWarnings&&b.warn(`Module name: ${s} vs ${o.name}`)()}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,s=e[i]||{},o=this.modules[i];if(!o){this.options.disableWarnings||b.warn(`Module ${r} not found`)();continue}let n=this.moduleUniforms[i],a=this.moduleBindings[i],c=o.getUniforms?.(s,n)||s,{uniforms:l,bindings:f}=ag(c);this.moduleUniforms[i]={...n,...l},this.moduleBindings[i]={...a,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[s,o]of Object.entries(i))e[`${r}.${s}`]={type:this.modules[r].uniformTypes?.[s],value:String(o)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=e.defaultUniforms||{},this.moduleBindings[r]={}}};F();F();var vf={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function ms(t){return t?Array.isArray(t)?t[0]??null:t:null}function cg(t){let{dimension:e,data:r}=t;if(!r)return null;switch(e){case"1d":{let i=ms(r);if(!i)return null;let{width:s}=_s(i);return{width:s,height:1}}case"2d":{let i=ms(r);return i?_s(i):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;let i=ms(r[0]);return i?_s(i):null}case"cube":{let i=Object.keys(r)[0]??null;if(!i)return null;let s=r[i],o=ms(s);return o?_s(o):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;let i=r[0],s=Object.keys(i)[0]??null;if(!s)return null;let o=ms(i[s]);return o?_s(o):null}default:return null}}function _s(t){if(ei(t))return Ki(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function iA(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function Mf(t){let{textureFormat:e,format:r}=t;if(e&&r&&e!==r)throw new Error(`Conflicting texture formats "${e}" and "${r}" provided for the same mip level`);return e??r}function lg(t){let e=vf[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function sA(t,e){return 6*t+lg(e)}function Cf(t){throw new Error("setTexture1DData not supported in WebGL.")}function oA(t){return Array.isArray(t)?t:[t]}function Er(t,e){let r=oA(e),i=t,s=[];for(let o=0;o<r.length;o++){let n=r[o];if(ei(n))s.push({type:"external-image",image:n,z:i,mipLevel:o});else if(iA(n))s.push({type:"texture-data",data:n,textureFormat:Mf(n),z:i,mipLevel:o});else throw new Error("Unsupported 2D mip-level payload")}return s}function If(t){let e=[];for(let r=0;r<t.length;r++)e.push(...Er(r,t[r]));return e}function Of(t){let e=[];for(let r=0;r<t.length;r++)e.push(...Er(r,t[r]));return e}function Nf(t){let e=[];for(let[r,i]of Object.entries(t)){let s=lg(r);e.push(...Er(s,i))}return e}function Df(t){let e=[];return t.forEach((r,i)=>{for(let[s,o]of Object.entries(r)){let n=sA(i,s);e.push(...Er(n,o))}}),e}var Ff=class{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){return`DynamicTexture:"${this.id}":${this.texture.width}x${this.texture.height}px:(${this.isReady?"ready":"loading..."})`}constructor(e,r){this.device=e;let i=ie("dynamic-texture"),s=r;this.props={...Ff.defaultProps,id:i,...r,data:null},this.id=this.props.id,this.ready=new Promise((o,n)=>{this.resolveReady=o,this.rejectReady=n}),this.initAsync(s)}async initAsync(e){try{let r=await this._loadAllData(e);this._checkNotDestroyed();let i=r.data?nA(r):[],s="format"in e&&e.format!==void 0,o="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let g=cg(r);return g||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=aA(this.device,i,a,{format:s?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!o&&(f.usage=U.SAMPLE|U.COPY_DST);let h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&h){let g=this.props.dimension==="3d"?U.SAMPLE|U.STORAGE|U.COPY_DST|U.COPY_SRC:U.SAMPLE|U.RENDER|U.COPY_DST|U.COPY_SRC;f.usage|=g}let u=this.device.getMipLevelCount(f.width,f.height),d=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),p={...f,mipLevels:d};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&b.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),b.info(0,`${this} created`)()}catch(r){let i=r instanceof Error?r:new Error(String(r));throw this.rejectReady(i),i}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):b.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let r=e instanceof Ne?e:this.device.createSampler(e);this.texture.setSampler(r),this._sampler=r}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let r=this.texture;return this._texture=r.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),b.info(`${this} resized`),!0}getCubeFaceIndex(e){let r=vf[e];if(r===void 0)throw new Error(`Invalid cube face: ${e}`);return r}getCubeArrayFaceIndex(e,r){return 6*e+this.getCubeFaceIndex(r)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let r=Cf(e);this._setTextureSubresources(r)}setTexture2DData(e,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let i=Er(r,e);this._setTextureSubresources(i)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let r=If(e);this._setTextureSubresources(r)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let r=Of(e);this._setTextureSubresources(r)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let r=Nf(e);this._setTextureSubresources(r)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let r=Df(e);this._setTextureSubresources(r)}_setTextureSubresources(e){for(let r of e){let{z:i,mipLevel:s}=r;switch(r.type){case"external-image":let{image:o,flipY:n}=r;this.texture.copyExternalImage({image:o,z:i,mipLevel:s,flipY:n});break;case"texture-data":let{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${s} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:i,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:s});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){let r=await ug(e.data);return{dimension:e.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&b.warn(`${this} already destroyed`)}_checkReady(){this.isReady||b.warn(`${this} Cannot perform this operation before ready`)}},wr=Ff;P(wr,"defaultProps",{...U.defaultProps,dimension:"2d",data:null,mipmaps:!1});function nA(t){if(!t.data)return[];switch(t.dimension){case"1d":return Cf(t.data);case"2d":return Er(0,t.data);case"3d":return If(t.data);case"2d-array":return Of(t.data);case"cube":return Nf(t.data);case"cube-array":return Df(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function aA(t,e,r,i){if(e.length===0)return{subresources:e,mipLevels:1,format:i.format,hasExplicitMipChain:!1};let s=new Map;for(let f of e){let h=s.get(f.z)??[];h.push(f),s.set(f.z,h)}let o=e.some(f=>f.mipLevel>0),n=i.format,a=Number.POSITIVE_INFINITY,c=[];for(let[f,h]of s){let u=[...h].sort((T,y)=>T.mipLevel-y.mipLevel),d=u[0];if(!d||d.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);let p=hg(t,d);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);let g=fg(d);if(g){if(n&&n!==g)throw new Error(`DynamicTexture: slice ${f} base level format "${g}" does not match texture format "${n}"`);n=g}let m=n&&t.isTextureFormatCompressed(n)?cA(t,p.width,p.height,n):t.getMipLevelCount(p.width,p.height),_=0;for(let T=0;T<u.length;T++){let y=u[T];if(!y||y.mipLevel!==T||T>=m)break;let x=hg(t,y),S=Math.max(1,p.width>>T),A=Math.max(1,p.height>>T);if(x.width!==S||x.height!==A)break;let w=fg(y);if(w&&(n||(n=w),w!==n))break;_++,c.push(y)}a=Math.min(a,_)}let l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:n,hasExplicitMipChain:o}}function fg(t){if(t.type==="texture-data")return t.textureFormat??Mf(t.data)}function hg(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function cA(t,e,r,i){let{blockWidth:s=1,blockHeight:o=1}=t.getTextureFormatInfo(i),n=1;for(let a=1;;a++){let c=Math.max(1,e>>a),l=Math.max(1,r>>a);if(c<s||l<o)break;n++}return n}async function ug(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(ug));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e)),i=Object.keys(e),s={};for(let o=0;o<i.length;o++)s[i[o]]=r[o];return s}return t}var Rr=2,lA=1e4,Bf=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...Bf.defaultProps,...r},r=this.props,this.id=r.id||ie("model"),this.device=e,Object.assign(this.userData,r.userData);let i=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),s=r.shaderInputs||new Nn(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);let o=hA(e),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:o,...this.props,modules:n});this.source=c,this._getModuleUniforms=l,this.props.shaderLayout||=e.getShaderLayout(this.source)}else{let{vs:c,fs:l,getUniforms:f}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:o,...this.props,modules:n});this.vs=c,this.fs=l,this._getModuleUniforms=f}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||ps.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||gs.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),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.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return b.info(Rr,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let s=this._getBindings(),{indexBuffer:o}=this.vertexArray,n=o?o.byteLength/(o.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:n,transformFeedback:this.transformFeedback||void 0,bindings:s,uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&eg(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let i=new di(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let r=new di(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){On(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new is(this.shaderInputs.modules);for(let[r,i]of Object.entries(this.shaderInputs.modules))if(fA(i)){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.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,r){let i=r?.disableWarnings??this.props.disableWarnings;e.indices&&b.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=sg(this.pipeline.shaderLayout,this.bufferLayout);let s=new di(this.bufferLayout);for(let[o,n]of Object.entries(e)){let a=s.getBufferLayout(o);if(!a){i||b.warn(`Model(${this.id}): Missing layout for buffer "${o}".`)();continue}let c=s.getAttributeNamesForBuffer(a),l=!1;for(let f of c){let h=this._attributeInfos[f];if(h){let u=this.device.type==="webgpu"?s.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(u,n),l=!0}}!l&&!i&&b.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${o}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,s]of Object.entries(e)){let o=this._attributeInfos[i];o?this.vertexArray.setConstantWebGL(o.location,s):(r?.disableWarnings??this.props.disableWarnings)||b.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof wr&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,i]of Object.entries(this.bindings))i instanceof wr?i.isReady&&(e[r]=i.texture):e[r]=i;return e}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof Yt?e=Math.max(e,r.texture.updateTimestamp):r instanceof D||r instanceof U?e=Math.max(e,r.updateTimestamp):r instanceof wr?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Ne||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(s=>s.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(b.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),s=null;this.source?s=i:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:i,fs:s}),this._attributeInfos=hn(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&r!==e&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=b.level>3?0:lA;b.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,b.group(Rr,`>>> DRAWING MODEL ${this.id}`,{collapsed:b.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=tg(this.pipeline.shaderLayout,this.id);b.table(Rr,e)();let r=this.shaderInputs.getDebugTable();b.table(Rr,r)();let i=this._getAttributeDebugTable();b.table(Rr,this._attributeInfos)(),b.table(Rr,i)(),b.groupEnd(Rr)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let i=e.props.framebuffer;i&&rg(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos)){let s=this.vertexArray.attributes[i.location];e[i.location]={name:r,type:i.shaderType,values:s?this._getBufferOrConstantValues(s,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=Et(r);return(e instanceof D?new i(e.debugData):e).toString()}},Pe=Bf;P(Pe,"defaultProps",{...we.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Kt.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function fA(t){return Boolean(t.uniformTypes&&!uA(t.uniformTypes))}function hA(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function uA(t){for(let e in t)return!1;return!0}F();var Dn=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=Dn.defaultProps){if(!Dn.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Pe(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||as(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof D)return r.readAsync();let{buffer:i,byteOffset:s=0,byteLength:o=i.byteLength}=r;return i.readAsync(s,o)}},ze=Dn;P(ze,"defaultProps",{...Pe.defaultProps,outputs:void 0,feedbackBuffers:void 0});var dA="transform_output",ys=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Pe(this.device,{id:r.id||ie("texture-transform-model"),fs:r.fs||as({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:dA}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.end(),this.device.submit()}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:i,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),s){e.targetTexture=s;let{width:o,height:n}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:o,height:n,colorAttachments:[s]}),e.framebuffer.resize({width:o,height:n})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var We=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:s=null}=e;this.id=e.id||ie("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[o,n]of Object.entries(r)){let a=ArrayBuffer.isView(n)?{value:n}:n;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(o)}: must be typed array or object with value as typed array`);if((o==="POSITION"||o==="positions")&&!a.size&&(a.size=3),o==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[o]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let s of Object.values(e)){let{value:o,size:n,constant:a}=s;!a&&o&&n!==void 0&&n>=1&&(i=Math.min(i,o.length/n))}return i}};var pA=`struct VertexInputs {
|
|
1138
|
+
`;var ys={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:kn.replace("phongMaterial","gouraudMaterial"),fs:Un.replace("phongMaterial","gouraudMaterial"),source:Vn.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Ln],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){let e={...t};return e.specularColor&&(e.specularColor=e.specularColor.map(r=>r/255)),{...ys.defaultUniforms,...e}}};var bs={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[Ln],source:Vn,vs:Un,fs:kn,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(t){let e={...t};return e.specularColor&&(e.specularColor=e.specularColor.map(r=>r/255)),{...bs.defaultUniforms,...e}}};L();var Xf={};function oe(t="id"){Xf[t]=Xf[t]||1;let e=Xf[t]++;return`${t}-${e}`}var zn=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||oe("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&I.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function Hg(t,e){if(e instanceof zn)return e;let r=OS(t,e),{attributes:i,bufferLayout:s}=NS(t,e);return new zn({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:r,attributes:i})}function OS(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:I.INDEX,data:r})}function NS(t,e){let r=[],i={};for(let[o,n]of Object.entries(e.attributes)){let a=o;switch(o){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(n){i[a]=t.createBuffer({data:n.value,id:`${o}-buffer`});let{value:c,size:l,normalized:f}=n;if(l===void 0)throw new Error(`Attribute ${o} is missing a size`);r.push({name:a,format:Pt.getVertexFormatFromAttribute(c,l,f)})}}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:s}}function $g(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let s of t.attributes)if(s){let o=`${s.location} ${s.name}: ${s.type}`;r[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(let s of t.varyings||[]){let o=`${s.location} ${s.name}`;r[`out ${o}`]={[i]:JSON.stringify(s)}}return r}var ne=null,Yf=null;function Xg(t,{id:e,minimap:r,opaque:i,top:s="0",left:o="0",rgbaScale:n=1}){ne||(ne=document.createElement("canvas"),ne.id=e,ne.title=e,ne.style.zIndex="100",ne.style.position="absolute",ne.style.top=s,ne.style.left=o,ne.style.border="blue 5px solid",ne.style.transform="scaleY(-1)",document.body.appendChild(ne),Yf=ne.getContext("2d")),(ne.width!==t.width||ne.height!==t.height)&&(ne.width=t.width/2,ne.height=t.height/2,ne.style.width="400px",ne.style.height="400px");let a=t.device.readPixelsToArrayWebGL(t),c=Yf?.createImageData(t.width,t.height);if(c){for(let f=0;f<a.length;f+=4)c.data[0+f+0]=a[f+0]*n,c.data[0+f+1]=a[f+1]*n,c.data[0+f+2]=a[f+2]*n,c.data[0+f+3]=i?255:a[f+3]*n;Yf?.putImageData(c,0,0)}}function Wn(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Wn(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(let o of i)if(!e.hasOwnProperty(o)||!Wn(t[o],e[o],r-1))return!1;return!0}return!1}L();var Ti=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(r=>r.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(r=>r.attribute):[e.name]}mergeBufferLayouts(e,r){let i=[...e];for(let s of r){let o=i.findIndex(n=>n.name===s.name);o<0?i.push(s):i[o]=s}return i}getBufferIndex(e){let r=this.bufferLayouts.findIndex(i=>i.name===e);return r===-1&&x.warn(`BufferLayout: Missing buffer for "${e}".`)(),r}};function Yg(t,e){let r=1/0;for(let i of t){let s=e[i];s!==void 0&&(r=Math.min(r,s))}return r}function Kg(t,e){let r=Object.fromEntries(t.attributes.map(s=>[s.name,s.location])),i=e.slice();return i.sort((s,o)=>{let n=s.attributes?s.attributes.map(f=>f.attribute):[s.name],a=o.attributes?o.attributes.map(f=>f.attribute):[o.name],c=Yg(n,r),l=Yg(a,r);return c-l}),i}function Kf(t,e){if(!t||!e.some(i=>i.bindingLayout?.length))return t;let r={...t,bindings:t.bindings.map(i=>({...i}))};"attributes"in(t||{})&&(r.attributes=t?.attributes||[]);for(let i of e)for(let s of i.bindingLayout||[])for(let o of DS(s.name)){let n=r.bindings.find(a=>a.name===o);n?.group===0&&(n.group=s.group)}return r}function Zg(t){return Boolean(t.uniformTypes&&!BS(t.uniformTypes))}function DS(t){let e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function BS(t){for(let e in t)return!1;return!0}L();function qg(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Gg(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function Zf(t){return qg(t)||Gg(t)}function FS(t){return Zf(t)||typeof t=="number"||typeof t=="boolean"}function Qg(t,e={}){let r={bindings:{},uniforms:{}};return Object.keys(t).forEach(i=>{let s=t[i];Object.prototype.hasOwnProperty.call(e,i)||FS(s)?r.uniforms[i]=s:r.bindings[i]=s}),r}var jn=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let i=mi(Object.values(e).filter(LS));for(let s of i)e[s.name]=s;x.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[s,o]of Object.entries(e))o&&(this._addModule(o),o.name&&s!==o.name&&!this.options.disableWarnings&&x.warn(`Module name: ${s} vs ${o.name}`)())}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,s=e[i]||{},o=this.modules[i];if(!o){this.options.disableWarnings||x.warn(`Module ${r} not found`)();continue}let n=this.moduleUniforms[i],a=this.moduleBindings[i],c=o.getUniforms?.(s,n)||s,{uniforms:l,bindings:f}=Qg(c,o.uniformTypes);this.moduleUniforms[i]=Jg(n,l,o.uniformTypes),this.moduleBindings[i]={...a,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[s,o]of Object.entries(i))e[`${r}.${s}`]={type:this.modules[r].uniformTypes?.[s],value:String(o)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=Jg({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[r]={}}};function Jg(t={},e={},r={}){let i={...t};for(let[s,o]of Object.entries(e))o!==void 0&&(i[s]=qf(t[s],o,r[s]));return i}function qf(t,e,r){if(!r||typeof r=="string")return Ts(e);if(Array.isArray(r)){if(Gf(e)||!Array.isArray(e))return Ts(e);let n=Array.isArray(t)&&!Gf(t)?[...t]:[],a=n.slice();for(let c=0;c<e.length;c++){let l=e[c];l!==void 0&&(a[c]=qf(n[c],l,r[0]))}return a}if(!Qf(e))return Ts(e);let i=r,s=Qf(t)?t:{},o={...s};for(let[n,a]of Object.entries(e))a!==void 0&&(o[n]=qf(s[n],a,i[n]));return o}function Ts(t){return ArrayBuffer.isView(t)?Array.prototype.slice.call(t):Array.isArray(t)?Gf(t)?t.slice():t.map(r=>r===void 0?void 0:Ts(r)):Qf(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,r===void 0?void 0:Ts(r)])):t}function Gf(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(t.length===0||typeof t[0]=="number")}function Qf(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function LS(t){return Boolean(t?.dependencies)}L();L();var Jf={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function xs(t){return t?Array.isArray(t)?t[0]??null:t:null}function em(t){let{dimension:e,data:r}=t;if(!r)return null;switch(e){case"1d":{let i=xs(r);if(!i)return null;let{width:s}=As(i);return{width:s,height:1}}case"2d":{let i=xs(r);return i?As(i):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;let i=xs(r[0]);return i?As(i):null}case"cube":{let i=Object.keys(r)[0]??null;if(!i)return null;let s=r[i],o=xs(s);return o?As(o):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;let i=r[0],s=Object.keys(i)[0]??null;if(!s)return null;let o=xs(i[s]);return o?As(o):null}default:return null}}function As(t){if(ri(t))return es(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function US(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function kS(t){return ArrayBuffer.isView(t)}function eh(t){let{textureFormat:e,format:r}=t;if(e&&r&&e!==r)throw new Error(`Conflicting texture formats "${e}" and "${r}" provided for the same mip level`);return e??r}function tm(t){let e=Jf[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function VS(t,e){return 6*t+tm(e)}function th(t){throw new Error("setTexture1DData not supported in WebGL.")}function zS(t){return Array.isArray(t)?t:[t]}function vr(t,e,r,i){let s=zS(e),o=t,n=[];for(let a=0;a<s.length;a++){let c=s[a];if(ri(c))n.push({type:"external-image",image:c,z:o,mipLevel:a});else if(US(c))n.push({type:"texture-data",data:c,textureFormat:eh(c),z:o,mipLevel:a});else if(kS(c)&&r)n.push({type:"texture-data",data:{data:c,width:Math.max(1,r.width>>a),height:Math.max(1,r.height>>a),...i?{format:i}:{}},textureFormat:i,z:o,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return n}function rh(t){let e=[];for(let r=0;r<t.length;r++)e.push(...vr(r,t[r]));return e}function ih(t){let e=[];for(let r=0;r<t.length;r++)e.push(...vr(r,t[r]));return e}function sh(t){let e=[];for(let[r,i]of Object.entries(t)){let s=tm(r);e.push(...vr(s,i))}return e}function oh(t){let e=[];return t.forEach((r,i)=>{for(let[s,o]of Object.entries(r)){let n=VS(i,s);e.push(...vr(n,o))}}),e}var ah=class{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){return`DynamicTexture:"${this.id}":${this.texture.width}x${this.texture.height}px:(${this.isReady?"ready":"loading..."})`}constructor(e,r){this.device=e;let i=oe("dynamic-texture"),s=r;this.props={...ah.defaultProps,id:i,...r,data:null},this.id=this.props.id,this.ready=new Promise((o,n)=>{this.resolveReady=o,this.rejectReady=n}),this.initAsync(s)}async initAsync(e){try{let r=await this._loadAllData(e);this._checkNotDestroyed();let i=r.data?WS({...r,width:e.width,height:e.height,format:e.format}):[],s="format"in e&&e.format!==void 0,o="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let g=em(r);return g||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=jS(this.device,i,a,{format:s?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!o&&(f.usage=B.SAMPLE|B.COPY_DST);let h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&h){let g=this.props.dimension==="3d"?B.SAMPLE|B.STORAGE|B.COPY_DST|B.COPY_SRC:B.SAMPLE|B.RENDER|B.COPY_DST|B.COPY_SRC;f.usage|=g}let u=this.device.getMipLevelCount(f.width,f.height),d=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),p={...f,mipLevels:d};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&x.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),x.info(0,`${this} created`)()}catch(r){let i=r instanceof Error?r:new Error(String(r));this.rejectReady(i)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):x.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let r=e instanceof Be?e:this.device.createSampler(e);this.texture.setSampler(r),this._sampler=r}async readBuffer(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,i=e.height??this.texture.height,s=e.depthOrArrayLayers??this.texture.depth,o=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:s}),n=this.device.createBuffer({byteLength:o.byteLength,usage:I.COPY_DST|I.MAP_READ});this.texture.readBuffer({...e,width:r,height:i,depthOrArrayLayers:s},n);let a=this.device.createFence();return await a.signaled,a.destroy(),n}async readAsync(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,i=e.height??this.texture.height,s=e.depthOrArrayLayers??this.texture.depth,o=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:s}),n=await this.readBuffer(e),a=await n.readAsync(0,o.byteLength);return n.destroy(),a.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let r=this.texture;return this._texture=r.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),x.info(`${this} resized`),!0}getCubeFaceIndex(e){let r=Jf[e];if(r===void 0)throw new Error(`Invalid cube face: ${e}`);return r}getCubeArrayFaceIndex(e,r){return 6*e+this.getCubeFaceIndex(r)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let r=th(e);this._setTextureSubresources(r)}setTexture2DData(e,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let i=vr(r,e);this._setTextureSubresources(i)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let r=rh(e);this._setTextureSubresources(r)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let r=ih(e);this._setTextureSubresources(r)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let r=sh(e);this._setTextureSubresources(r)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let r=oh(e);this._setTextureSubresources(r)}_setTextureSubresources(e){for(let r of e){let{z:i,mipLevel:s}=r;switch(r.type){case"external-image":let{image:o,flipY:n}=r;this.texture.copyExternalImage({image:o,z:i,mipLevel:s,flipY:n});break;case"texture-data":let{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${s} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:i,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:s});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){let r=await nh(e.data);return{dimension:e.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&x.warn(`${this} already destroyed`)}_checkReady(){this.isReady||x.warn(`${this} Cannot perform this operation before ready`)}},tr=ah;P(tr,"defaultProps",{...B.defaultProps,dimension:"2d",data:null,mipmaps:!1});function WS(t){if(!t.data)return[];let e=t.width&&t.height?{width:t.width,height:t.height}:void 0,r="format"in t?t.format:void 0;switch(t.dimension){case"1d":return th(t.data);case"2d":return vr(0,t.data,e,r);case"3d":return rh(t.data);case"2d-array":return ih(t.data);case"cube":return sh(t.data);case"cube-array":return oh(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function jS(t,e,r,i){if(e.length===0)return{subresources:e,mipLevels:1,format:i.format,hasExplicitMipChain:!1};let s=new Map;for(let f of e){let h=s.get(f.z)??[];h.push(f),s.set(f.z,h)}let o=e.some(f=>f.mipLevel>0),n=i.format,a=Number.POSITIVE_INFINITY,c=[];for(let[f,h]of s){let u=[...h].sort((b,y)=>b.mipLevel-y.mipLevel),d=u[0];if(!d||d.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);let p=im(t,d);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);let g=rm(d);if(g){if(n&&n!==g)throw new Error(`DynamicTexture: slice ${f} base level format "${g}" does not match texture format "${n}"`);n=g}let m=n&&t.isTextureFormatCompressed(n)?HS(t,p.width,p.height,n):t.getMipLevelCount(p.width,p.height),_=0;for(let b=0;b<u.length;b++){let y=u[b];if(!y||y.mipLevel!==b||b>=m)break;let T=im(t,y),S=Math.max(1,p.width>>b),A=Math.max(1,p.height>>b);if(T.width!==S||T.height!==A)break;let w=rm(y);if(w&&(n||(n=w),w!==n))break;_++,c.push(y)}a=Math.min(a,_)}let l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:n,hasExplicitMipChain:o}}function rm(t){if(t.type==="texture-data")return t.textureFormat??eh(t.data)}function im(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function HS(t,e,r,i){let{blockWidth:s=1,blockHeight:o=1}=t.getTextureFormatInfo(i),n=1;for(let a=1;;a++){let c=Math.max(1,e>>a),l=Math.max(1,r>>a);if(c<s||l<o)break;n++}return n}async function nh(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(nh));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e).map(nh)),i=Object.keys(e),s={};for(let o=0;o<i.length;o++)s[i[o]]=r[o];return s}return t}var Mr=2,$S=1e4,ch=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...ch.defaultProps,...r},r=this.props,this.id=r.id||oe("model"),this.device=e,Object.assign(this.userData,r.userData),this.material=r.material||null;let i=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),s=r.shaderInputs||new jn(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);let o=XS(e),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=Kf(this.props.shaderLayout,n)||null,this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l,bindingTable:f}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:o,...this.props,modules:n});this.source=c,this._getModuleUniforms=l,this._bindingTable=f;let h=e.getShaderLayout?.(this.source);this.props.shaderLayout=Kf(this.props.shaderLayout||h||null,n)||null}else{let{vs:c,fs:l,getUniforms:f}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:o,...this.props,modules:n});this.vs=c,this.fs=l,this._getModuleUniforms=f,this._bindingTable=[]}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||oi.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||ni.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),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.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return x.info(Mr,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let s=this._getBindings(),o=this._getBindGroups(),{indexBuffer:n}=this.vertexArray,a=n?n.byteLength/(n.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:a,transformFeedback:this.transformFeedback||void 0,bindings:s,bindGroups:o,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&Hg(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let i=new Ti(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let r=new Ti(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Wn(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new fs(this.device,this.shaderInputs.modules);for(let[r,i]of Object.entries(this.shaderInputs.modules))if(Zg(i)&&!this.material?.ownsModule(r)){let s=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=s}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,r){let i=r?.disableWarnings??this.props.disableWarnings;e.indices&&x.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=Kg(this.pipeline.shaderLayout,this.bufferLayout);let s=new Ti(this.bufferLayout);for(let[o,n]of Object.entries(e)){let a=s.getBufferLayout(o);if(!a){i||x.warn(`Model(${this.id}): Missing layout for buffer "${o}".`)();continue}let c=s.getAttributeNamesForBuffer(a),l=!1;for(let f of c){let h=this._attributeInfos[f];if(h){let u=this.device.type==="webgpu"?s.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(u,n),l=!0}}!l&&!i&&x.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${o}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,s]of Object.entries(e)){let o=this._attributeInfos[i];o?this.vertexArray.setConstantWebGL(o.location,s):(r?.disableWarnings??this.props.disableWarnings)||x.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof tr&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof tr&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,i]of Object.entries(this.bindings))i instanceof tr?i.isReady&&(e[r]=i.texture):e[r]=i;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},r=e.bindings.length?as(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return r;for(let[i,s]of Object.entries(this.material.getBindingsByGroup())){let o=Number(i);r[o]={...r[o]||{},...s}}return r}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof qt?e=Math.max(e,r.texture.updateTimestamp):r instanceof I||r instanceof B?e=Math.max(e,r.updateTimestamp):r instanceof tr?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Be||(e=Math.max(e,r.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(s=>s.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(x.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),s=null;this.source?s=i:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:i,fs:s}),this._attributeInfos=_n(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&r!==e&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=x.level>3?0:$S;x.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,x.group(Mr,`>>> DRAWING MODEL ${this.id}`,{collapsed:x.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=$g(this.pipeline.shaderLayout,this.id);x.table(Mr,e)();let r=this.shaderInputs.getDebugTable();x.table(Mr,r)();let i=this._getAttributeDebugTable();x.table(Mr,this._attributeInfos)(),x.table(Mr,i)(),x.groupEnd(Mr)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let i=e.props.framebuffer;i&&Xg(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos)){let s=this.vertexArray.attributes[i.location];e[i.location]={name:r,type:i.shaderType,values:s?this._getBufferOrConstantValues(s,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=de.getTypedArrayConstructor(r);return(e instanceof I?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let r={};for(let[i,s]of Object.entries(e))this.material.ownsBinding(i)||(r[i]=s);return r}},ve=ch;P(ve,"defaultProps",{...Re.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Jt.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function XS(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}L();var Hn=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=Hn.defaultProps){if(!Hn.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new ve(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||ps(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof I)return r.readAsync();let{buffer:i,byteOffset:s=0,byteLength:o=i.byteLength}=r;return i.readAsync(s,o)}},je=Hn;P(je,"defaultProps",{...ve.defaultProps,outputs:void 0,feedbackBuffers:void 0});var YS="transform_output",Ss=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new ve(this.device,{id:r.id||oe("texture-transform-model"),fs:r.fs||ps({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:YS}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.end(),this.device.submit()}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:i,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),s){e.targetTexture=s;let{width:o,height:n}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:o,height:n,colorAttachments:[s]}),e.framebuffer.resize({width:o,height:n})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var He=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:s=null}=e;this.id=e.id||oe("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[o,n]of Object.entries(r)){let a=ArrayBuffer.isView(n)?{value:n}:n;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(o)}: must be typed array or object with value as typed array`);if((o==="POSITION"||o==="positions")&&!a.size&&(a.size=3),o==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[o]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let s of Object.values(e)){let{value:o,size:n,constant:a}=s;!a&&o&&n!==void 0&&n>=1&&(i=Math.min(i,o.length/n))}return i}};var KS=`struct VertexInputs {
|
|
888
1139
|
@location(0) clipSpacePositions: vec2<f32>,
|
|
889
1140
|
@location(1) texCoords: vec2<f32>,
|
|
890
1141
|
@location(2) coordinates: vec2<f32>
|
|
@@ -906,7 +1157,7 @@ fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
|
|
|
906
1157
|
outputs.uv = inputs.texCoords;
|
|
907
1158
|
return outputs;
|
|
908
1159
|
}
|
|
909
|
-
`,
|
|
1160
|
+
`,ZS=`#version 300 es
|
|
910
1161
|
in vec2 clipSpacePositions;
|
|
911
1162
|
in vec2 texCoords;
|
|
912
1163
|
in vec2 coordinates;
|
|
@@ -921,31 +1172,28 @@ void main(void) {
|
|
|
921
1172
|
coordinate = coordinates;
|
|
922
1173
|
uv = texCoords;
|
|
923
1174
|
}
|
|
924
|
-
`,
|
|
925
|
-
${r.source}`}),super(e,{id:r.id||ie("clip-space"),...r,vs:gA,vertexCount:4,geometry:new We({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(dg)},texCoords:{size:2,value:new Float32Array(i)},coordinates:{size:2,value:new Float32Array(i)}}})})}};function Lf(t,e){if(!t)throw new Error(e)}var st=class{id;matrix=new z;display=!0;position=new H;rotation=new H;scale=new H(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||ie(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return Lf(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return Lf(e.length===3||e.length===4,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return Lf(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:i,scale:s,update:o=!0}=e;return r&&this.setPosition(r),i&&this.setRotation(i),s&&this.setScale(s),o&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),this.rotation.length===4){let e=new z().fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:r,scale:i}={}){return e&&this.setPosition(e),r&&this.setRotation(r),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(e,r){r=r||this.matrix;let i=new z(e).multiplyRight(r),s=i.invert(),o=s.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:i,worldInverseMatrix:s,worldInverseTransposeMatrix:o}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};F();var Qt=class extends st{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;b.assert(r.every(i=>i instanceof st),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:i})=>{let s=r.getBounds();if(!s)return;let[o,n]=s,a=new H(o).add(n).divide([2,2,2]);i.transformAsPoint(a,a);let c=new H(n).subtract(o).divide([2,2,2]);i.transformAsVector(c,c);for(let l=0;l<8;l++){let f=new H(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let h=0;h<3;h++)e[0][h]=Math.min(e[0][h],f[h]),e[1][h]=Math.max(e[1][h],f[h])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,i=r.indexOf(e);return i>-1&&r.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new z}={}){let i=new z(r).multiplyRight(this.matrix);for(let s of this.children)s instanceof Qt?s.traverse(e,{worldMatrix:i}):e(s,{worldMatrix:i})}preorderTraversal(e,{worldMatrix:r=new z}={}){let i=new z(r).multiplyRight(this.matrix);e(this,{worldMatrix:i});for(let s of this.children)s instanceof Qt?s.preorderTraversal(e,{worldMatrix:i}):e(s,{worldMatrix:i})}};var bs=class extends st{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var xs=class extends We{constructor(e={}){let{id:r=ie("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:mA},attributes:{...SA,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...EA,...e.attributes}})}},mA=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]),_A=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]),yA=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]),TA=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]),bA=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]),xA=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]),AA=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]),SA={POSITION:{size:3,value:_A},NORMAL:{size:3,value:yA},TEXCOORD_0:{size:2,value:TA}},EA={POSITION:{size:3,value:bA},TEXCOORD_0:{size:2,value:xA},COLOR_0:{size:3,value:AA}};var As=class extends We{constructor(e={}){let{id:r=ie("sphere-geometry")}=e,{indices:i,attributes:s}=wA(e);super({...e,id:r,topology:"triangle-list",indices:i,attributes:{...s,...e.attributes}})}};function wA(t){let{nlat:e=10,nlong:r=10}=t,o=Math.PI-0,n=0,c=2*Math.PI-n,l=(e+1)*(r+1),f=(_,T,y,x,S)=>t.radius||1,h=new Float32Array(l*3),u=new Float32Array(l*3),d=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,g=new p(e*r*6);for(let _=0;_<=e;_++)for(let T=0;T<=r;T++){let y=T/r,x=_/e,S=T+_*(r+1),A=S*2,w=S*3,v=c*y,R=o*x,M=Math.sin(v),I=Math.cos(v),C=Math.sin(R),W=Math.cos(R),V=I*C,J=W,bt=M*C,xt=f(V,J,bt,y,x);h[w+0]=xt*V,h[w+1]=xt*J,h[w+2]=xt*bt,u[w+0]=V,u[w+1]=J,u[w+2]=bt,d[A+0]=y,d[A+1]=1-x}let m=r+1;for(let _=0;_<r;_++)for(let T=0;T<e;T++){let y=(_*e+T)*6;g[y+0]=T*m+_,g[y+1]=T*m+_+1,g[y+2]=(T+1)*m+_,g[y+3]=(T+1)*m+_,g[y+4]=T*m+_+1,g[y+5]=(T+1)*m+_+1}return{indices:{size:1,value:g},attributes:{POSITION:{size:3,value:h},NORMAL:{size:3,value:u},TEXCOORD_0:{size:2,value:d}}}}var{stats:RA,getSupportedAdapters:PA,setDefaultDeviceProps:vA,attachDevice:MA,createDevice:CA,enforceWebGL2:IA}=Xt;var uh={};At(uh,{fetchFile:()=>yi,load:()=>rr,parse:()=>tr,registerLoaders:()=>Os});function Gt(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var ot={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},OA=ot.self||ot.window||ot.global||{},NA=ot.window||ot.self||ot.global||{},DA=ot.global||ot.self||ot.window||{},FA=ot.document||{};var Pr=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var pg=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),BA=pg&&parseFloat(pg[1])||0;ji();var kf="4.4.0-alpha.18",LA=kf[0]>="0"&&kf[0]<="9"?`v${kf}`:"";function UA(){let t=new ue({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=LA,globalThis.probe||={},globalThis.probe.loaders=t,t}var Vf=UA();var kA=t=>typeof t=="boolean",nt=t=>typeof t=="function",at=t=>t!==null&&typeof t=="object",Fn=t=>at(t)&&t.constructor==={}.constructor;var zf=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,pi=t=>at(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var Wf=t=>Boolean(t)&&nt(t[Symbol.iterator]),jf=t=>Boolean(t)&&nt(t[Symbol.asyncIterator]);var ve=t=>typeof Response<"u"&&t instanceof Response||at(t)&&nt(t.arrayBuffer)&&nt(t.text)&&nt(t.json);var Me=t=>typeof Blob<"u"&&t instanceof Blob;var gg=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||at(t)&&nt(t.tee)&&nt(t.cancel)&&nt(t.getReader);var mg=t=>at(t)&&nt(t.read)&&nt(t.pipe)&&kA(t.readable),Ss=t=>gg(t)||mg(t);function Hf(t,e){return _g(t||{},e)}function _g(t,e,r=0){if(r>3)return e;let i={...t};for(let[s,o]of Object.entries(e))o&&typeof o=="object"&&!Array.isArray(o)?i[s]=_g(i[s]||{},e[s],r+1):i[s]=e[s];return i}var yg="beta";function VA(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.0-alpha.18"),globalThis._loadersgl_.version}var Tg=VA();function ge(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var ct={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},kD=ct.self||ct.window||ct.global||{},VD=ct.window||ct.self||ct.global||{},zD=ct.global||ct.self||ct.window||{},WD=ct.document||{};var Fe=typeof process!="object"||String(process)!=="[object process]"||process.browser;var xg=typeof window<"u"&&typeof window.orientation<"u",bg=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),jD=bg&&parseFloat(bg[1])||0;var Es=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){ge(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){ge(this.isRunning),this.isRunning=!1,this._reject(e)}};var gi=class{terminate(){}};var $f=new Map;function Ag(t){ge(t.source&&!t.url||!t.source&&t.url);let e=$f.get(t.source||t.url);return e||(t.url&&(e=zA(t.url),$f.set(t.url,e)),t.source&&(e=Sg(t.source),$f.set(t.source,e))),ge(e),e}function zA(t){if(!t.startsWith("http"))return t;let e=WA(t);return Sg(e)}function Sg(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function WA(t){return`try {
|
|
1175
|
+
`,sm=[-1,-1,1,-1,-1,1,1,1],Es=class extends ve{constructor(e,r){let i=sm.map(s=>s===-1?0:s);r.source&&(r={...r,source:`${KS}
|
|
1176
|
+
${r.source}`}),super(e,{id:r.id||oe("clip-space"),...r,vs:ZS,vertexCount:4,geometry:new He({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(sm)},texCoords:{size:2,value:new Float32Array(i)},coordinates:{size:2,value:new Float32Array(i)}}})})}};var ws=class extends He{constructor(e={}){let{id:r=oe("sphere-geometry")}=e,{indices:i,attributes:s}=qS(e);super({...e,id:r,topology:"triangle-list",indices:i,attributes:{...s,...e.attributes}})}};function qS(t){let{nlat:e=10,nlong:r=10}=t,o=Math.PI-0,n=0,c=2*Math.PI-n,l=(e+1)*(r+1),f=(_,b,y,T,S)=>t.radius||1,h=new Float32Array(l*3),u=new Float32Array(l*3),d=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,g=new p(e*r*6);for(let _=0;_<=e;_++)for(let b=0;b<=r;b++){let y=b/r,T=_/e,S=b+_*(r+1),A=S*2,w=S*3,v=c*y,R=o*T,M=Math.sin(v),O=Math.cos(v),C=Math.sin(R),W=Math.cos(R),V=O*C,J=W,Et=M*C,wt=f(V,J,Et,y,T);h[w+0]=wt*V,h[w+1]=wt*J,h[w+2]=wt*Et,u[w+0]=V,u[w+1]=J,u[w+2]=Et,d[A+0]=y,d[A+1]=1-T}let m=r+1;for(let _=0;_<r;_++)for(let b=0;b<e;b++){let y=(_*e+b)*6;g[y+0]=b*m+_,g[y+1]=b*m+_+1,g[y+2]=(b+1)*m+_,g[y+3]=(b+1)*m+_,g[y+4]=b*m+_+1,g[y+5]=(b+1)*m+_+1}return{indices:{size:1,value:g},attributes:{POSITION:{size:3,value:h},NORMAL:{size:3,value:u},TEXCOORD_0:{size:2,value:d}}}}function lh(t,e){if(!t)throw new Error(e)}var lt=class{id;matrix=new z;display=!0;position=new H;rotation=new H;scale=new H(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||oe(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return lh(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return lh(e.length===3||e.length===4,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return lh(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:i,scale:s,update:o=!0}=e;return r&&this.setPosition(r),i&&this.setRotation(i),s&&this.setScale(s),o&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),this.rotation.length===4){let e=new z().fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:r,scale:i}={}){return e&&this.setPosition(e),r&&this.setRotation(r),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(e,r){r=r||this.matrix;let i=new z(e).multiplyRight(r),s=i.invert(),o=s.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:i,worldInverseMatrix:s,worldInverseTransposeMatrix:o}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};L();var rr=class extends lt{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;x.assert(r.every(i=>i instanceof lt),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:i})=>{let s=r.getBounds();if(!s)return;let[o,n]=s,a=new H(o).add(n).divide([2,2,2]);i.transformAsPoint(a,a);let c=new H(n).subtract(o).divide([2,2,2]);i.transformAsVector(c,c);for(let l=0;l<8;l++){let f=new H(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let h=0;h<3;h++)e[0][h]=Math.min(e[0][h],f[h]),e[1][h]=Math.max(e[1][h],f[h])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,i=r.indexOf(e);return i>-1&&r.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new z}={}){let i=new z(r).multiplyRight(this.matrix);for(let s of this.children)s instanceof rr?s.traverse(e,{worldMatrix:i}):e(s,{worldMatrix:i})}preorderTraversal(e,{worldMatrix:r=new z}={}){let i=new z(r).multiplyRight(this.matrix);e(this,{worldMatrix:i});for(let s of this.children)s instanceof rr?s.preorderTraversal(e,{worldMatrix:i}):e(s,{worldMatrix:i})}};var Rs=class extends lt{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var Ps=class extends He{constructor(e={}){let{id:r=oe("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:GS},attributes:{...sE,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...oE,...e.attributes}})}},GS=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]),QS=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]),JS=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]),eE=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]),rE=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]),iE=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:QS},NORMAL:{size:3,value:JS},TEXCOORD_0:{size:2,value:eE}},oE={POSITION:{size:3,value:tE},TEXCOORD_0:{size:2,value:rE},COLOR_0:{size:3,value:iE}};var{stats:nE,getSupportedAdapters:aE,setDefaultDeviceProps:cE,attachDevice:lE,createDevice:fE,enforceWebGL2:hE}=Zt;var Uh={};Rt(Uh,{fetchFile:()=>wi,load:()=>ar,parse:()=>nr,registerLoaders:()=>Ls});function ir(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var ft={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},uE=ft.self||ft.window||ft.global||{},dE=ft.window||ft.self||ft.global||{},pE=ft.global||ft.self||ft.window||{},gE=ft.document||{};var Cr=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var om=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),mE=om&&parseFloat(om[1])||0;Gi();var hh="4.4.0-alpha.18",_E=hh[0]>="0"&&hh[0]<="9"?`v${hh}`:"";function yE(){let t=new ue({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=_E,globalThis.probe||={},globalThis.probe.loaders=t,t}var uh=yE();var bE=t=>typeof t=="boolean",ht=t=>typeof t=="function",ut=t=>t!==null&&typeof t=="object",$n=t=>ut(t)&&t.constructor==={}.constructor;var dh=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,xi=t=>ut(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var ph=t=>Boolean(t)&&ht(t[Symbol.iterator]),gh=t=>Boolean(t)&&ht(t[Symbol.asyncIterator]);var Me=t=>typeof Response<"u"&&t instanceof Response||ut(t)&&ht(t.arrayBuffer)&&ht(t.text)&&ht(t.json);var Ce=t=>typeof Blob<"u"&&t instanceof Blob;var nm=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||ut(t)&&ht(t.tee)&&ht(t.cancel)&&ht(t.getReader);var am=t=>ut(t)&&ht(t.read)&&ht(t.pipe)&&bE(t.readable),vs=t=>nm(t)||am(t);function mh(t,e){return cm(t||{},e)}function cm(t,e,r=0){if(r>3)return e;let i={...t};for(let[s,o]of Object.entries(e))o&&typeof o=="object"&&!Array.isArray(o)?i[s]=cm(i[s]||{},e[s],r+1):i[s]=e[s];return i}var lm="beta";function TE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.0-alpha.18"),globalThis._loadersgl_.version}var fm=TE();function me(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var dt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},$F=dt.self||dt.window||dt.global||{},XF=dt.window||dt.self||dt.global||{},YF=dt.global||dt.self||dt.window||{},KF=dt.document||{};var Le=typeof process!="object"||String(process)!=="[object process]"||process.browser;var um=typeof window<"u"&&typeof window.orientation<"u",hm=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),ZF=hm&&parseFloat(hm[1])||0;var Ms=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){me(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){me(this.isRunning),this.isRunning=!1,this._reject(e)}};var Ai=class{terminate(){}};var _h=new Map;function dm(t){me(t.source&&!t.url||!t.source&&t.url);let e=_h.get(t.source||t.url);return e||(t.url&&(e=xE(t.url),_h.set(t.url,e)),t.source&&(e=pm(t.source),_h.set(t.source,e))),me(e),e}function xE(t){if(!t.startsWith("http"))return t;let e=AE(t);return pm(e)}function pm(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function AE(t){return`try {
|
|
926
1177
|
importScripts('${t}');
|
|
927
1178
|
} catch (error) {
|
|
928
1179
|
console.error(error);
|
|
929
1180
|
throw error;
|
|
930
|
-
}`}function Xf(t,e=!0,r){let i=r||new Set;if(t){if(Eg(t))i.add(t);else if(Eg(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let s in t)Xf(t[s],e,i)}}return r===void 0?Array.from(i):[]}function Eg(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Yf=()=>{},Jt=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Fe||typeof gi<"u"&&!Fe}constructor(e){let{name:r,source:i,url:s}=e;ge(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=Yf,this.onError=o=>console.log(o),this.worker=Fe?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Yf,this.onError=Yf,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||Xf(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=Ag({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,s=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new gi(i,{eval:!1,type:s})}else if(this.source)e=new gi(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var ws=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Jt.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(s,o,n)=>s.done(n),i=(s,o)=>s.error(o)){let s=new Promise(o=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:o}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new Es(r.name,e);e.onMessage=s=>r.onMessage(i,s.type,s.payload),e.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Fe||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Jt({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return xg?this.maxMobileConcurrency:this.maxConcurrency}};var jA={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},vr=class{props;workerPools=new Map;static isSupported(){return Jt.isSupported()}static getWorkerFarm(e={}){return vr._workerFarm=vr._workerFarm||new vr({}),vr._workerFarm.setProps(e),vr._workerFarm}constructor(e){this.props={...jA},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:s}=e,o=this.workerPools.get(r);return o||(o=new ws({name:r,source:i,url:s}),o.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,o)),o}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},er=vr;P(er,"_workerFarm");function Zf(t,e={}){let r=e[t.id]||{},i=Fe?`${t.id}-worker.js`:`${t.id}-worker-node.js`,s=r.workerUrl;if(!s&&t.id==="compression"&&(s=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Fe?s=`modules/${t.module}/dist/${i}`:s=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!s){let n=t.version;n==="latest"&&(n=yg);let a=n?`@${n}`:"";s=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${i}`}return ge(s),s}function Kf(t,e=Tg){ge(t,"no worker provided");let r=t.version;return!(!e||!r)}function qf(t,e){if(!er.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Fe&&!r)return!1;let i=e?.worker??e?.core?.worker;return Boolean(t.worker&&i)}async function Qf(t,e,r,i,s){let o=t.id,n=Zf(t,r),c=er.getWorkerFarm(r?.core).getWorkerPool({name:o,url:n});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",HA.bind(null,s));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function HA(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:s,input:o,options:n}=i;try{let a=await t(o,n);e.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Gf(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let i=new Uint8Array(t),s=new Uint8Array(e);for(let o=0;o<i.length;++o)if(i[o]!==s[o])return!1;return!0}function Jf(...t){return wg(t)}function wg(t){let e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,n)=>o+n.byteLength,0),i=new Uint8Array(r),s=0;for(let o of e)i.set(o,s),s+=o.byteLength;return i.buffer}async function eh(t){let e=[];for await(let r of t)e.push($A(r));return Jf(...e)}function $A(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:i}=t;return Rg(e,r,i)}return Rg(t)}function Rg(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}var XA="",Pg={};function th(t){for(let e in Pg)if(t.startsWith(e)){let r=Pg[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${XA}${t}`),t}function Ln(t){return t&&typeof t=="object"&&t.isBuffer}function mi(t){if(Ln(t))return t;if(t instanceof ArrayBuffer)return t;if(zf(t))return Bn(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Rs(t){if(t instanceof ArrayBuffer)return t;if(zf(t))return Bn(t);let{buffer:e,byteOffset:r,byteLength:i}=t;return e instanceof ArrayBuffer&&r===0&&i===e.byteLength?e:Bn(e,r,i)}function Bn(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}function rh(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Mr={};At(Mr,{dirname:()=>ZA,filename:()=>YA,join:()=>KA,resolve:()=>qA});function vg(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function YA(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function ZA(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function KA(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function qA(...t){let e=[];for(let o=0;o<t.length;o++)e[o]=t[o];let r="",i=!1,s;for(let o=e.length-1;o>=-1&&!i;o--){let n;o>=0?n=e[o]:(s===void 0&&(s=vg()),n=s),n.length!==0&&(r=`${n}/${r}`,i=n.charCodeAt(0)===Ps)}return r=QA(r,!i),i?`/${r}`:r.length>0?r:"."}var Ps=47,ih=46;function QA(t,e){let r="",i=-1,s=0,o,n=!1;for(let a=0;a<=t.length;++a){if(a<t.length)o=t.charCodeAt(a);else{if(o===Ps)break;o=Ps}if(o===Ps){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(r.length<2||!n||r.charCodeAt(r.length-1)!==ih||r.charCodeAt(r.length-2)!==ih){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Ps;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,s=0,n=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,s=0,n=!1;continue}}e&&(r.length>0?r+="/..":r="..",n=!0)}else{let c=t.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,n=!1}i=a,s=0}else o===ih&&s!==-1?++s:s=-1}return r}var Un=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var eS=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,tS=/^([-\w.]+\/[-\w.+]+)/;function sh(t,e){return t.toLowerCase()===e.toLowerCase()}function Mg(t){let e=tS.exec(t);return e?e[1]:t}function oh(t){let e=eS.exec(t);return e?e[1]:""}var Cg=/\?.*/;function Ig(t){let e=t.match(Cg);return e&&e[0]}function _i(t){return t.replace(Cg,"")}function Og(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Cr(t){return ve(t)?t.url:Me(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function vs(t){if(ve(t)){let e=t.headers.get("content-type")||"",r=_i(t.url);return Mg(e)||oh(r)}return Me(t)?t.type||"":typeof t=="string"?oh(t):""}function Ng(t){return ve(t)?t.headers["content-length"]||-1:Me(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function kn(t){if(ve(t))return t;let e={},r=Ng(t);r>=0&&(e["content-length"]=String(r));let i=Cr(t),s=vs(t);s&&(e["content-type"]=s);let o=await iS(t);o&&(e["x-first-bytes"]=o),typeof t=="string"&&(t=new TextEncoder().encode(t));let n=new Response(t,{headers:e});return Object.defineProperty(n,"url",{value:i}),n}async function Dg(t){if(!t.ok)throw await rS(t)}async function rS(t){let e=Og(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let s=t.headers.get("Content-Type");i.reason=!t.bodyUsed&&s?.includes("application/json")?await t.json():await t.text()}catch{}return new Un(r,i)}async function iS(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let s=new FileReader;s.onload=o=>i(o?.target?.result),s.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${sS(r)}`}return null}function sS(t){let e="",r=new Uint8Array(t);for(let i=0;i<r.byteLength;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function oS(t){return!nS(t)&&!aS(t)}function nS(t){return t.startsWith("http:")||t.startsWith("https:")}function aS(t){return t.startsWith("data:")}async function yi(t,e){if(typeof t=="string"){let r=th(t);return oS(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await kn(t)}ji();var Ms=new ue({id:"loaders.gl"}),Vn=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},zn=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Wn={core:{baseUri:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new zn,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Pr,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Fg={baseUri:"core.baseUri",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var nh=["baseUri","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function ah(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function ch(){let t=ah();return t.globalOptions=t.globalOptions||{...Wn,core:{...Wn.core}},Ir(t.globalOptions)}function Ug(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],cS(t,r),Ir(fS(e,t,i))}function Ir(t){let e=uS(t);kg(e);for(let r of nh)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function cS(t,e){Bg(t,null,Wn,Fg,e);for(let r of e){let i=t&&t[r.id]||{},s=r.options&&r.options[r.id]||{},o=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Bg(i,r.id,s,o,e)}}function Bg(t,e,r,i,s){let o=e||"Top level",n=e?`${e}.`:"";for(let a in t){let c=!e&&at(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in i)Ms.level>0&&Ms.warn(`${o} loader option '${n}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&Ms.level>0){let h=lS(a,s);Ms.warn(`${o} loader option '${n}${a}' not recognized. ${h}`)()}}}}function lS(t,e){let r=t.toLowerCase(),i="";for(let s of e)for(let o in s.options){if(t===o)return`Did you mean '${s.id}.${o}'?`;let n=o.toLowerCase();(r.startsWith(n)||n.startsWith(r))&&(i=i||`Did you mean '${s.id}.${o}'?`)}return i}function fS(t,e,r){let i=t.options||{},s={...i};i.core&&(s.core={...i.core}),kg(s),s.core?.log===null&&(s.core={...s.core,log:new Vn}),Lg(s,Ir(ch()));let o=Ir(e);return Lg(s,o),hS(s,r),dS(s),s}function Lg(t,e){for(let r in e)if(r in e){let i=e[r];Fn(i)&&Fn(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function hS(t,e){if(!e)return;let r=t.baseUri!==void 0,i=t.core?.baseUri!==void 0;!r&&!i&&(t.core||={},t.core.baseUri=e)}function uS(t){let e={...t};return t.core&&(e.core={...t.core}),e}function kg(t){for(let r of nh)if(t[r]!==void 0){let s=t.core=t.core||{};s[r]===void 0&&(s[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function dS(t){let e=t.core;if(e)for(let r of nh)e[r]!==void 0&&(t[r]=e[r])}function Cs(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function Is(t){Gt(t,"null loader"),Gt(Cs(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var Vg=()=>{let t=ah();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function Os(t){let e=Vg();t=Array.isArray(t)?t:[t];for(let r of t){let i=Is(r);e.find(s=>i===s)||e.unshift(i)}}function zg(){return Vg()}var pS=/\.([^.]+)$/;async function Hg(t,e=[],r,i){if(!$g(t))return null;let s=Ir(r||{});s.core||={};let o=Wg(t,e,{...s,core:{...s.core,nothrow:!0}},i);if(o)return o;if(Me(t)&&(t=await t.slice(0,10).arrayBuffer(),o=Wg(t,e,s,i)),!o&&!s.core.nothrow)throw new Error(Xg(t));return o}function Wg(t,e=[],r,i){if(!$g(t))return null;let s=Ir(r||{});if(s.core||={},e&&!Array.isArray(e))return Is(e);let o=[];e&&(o=o.concat(e)),s.core.ignoreRegisteredLoaders||o.push(...zg()),mS(o);let n=gS(t,o,s,i);if(!n&&!s.core.nothrow)throw new Error(Xg(t));return n}function gS(t,e,r,i){let s=Cr(t),o=vs(t),n=_i(s)||i?.url,a=null,c="";return r?.core?.mimeType&&(a=lh(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||_S(e,n),c=c||(a?`matched url ${n}`:""),a=a||lh(e,o),c=c||(a?`matched MIME type ${o}`:""),a=a||TS(e,t),c=c||(a?`matched initial data ${Yg(t)}`:""),r?.core?.fallbackMimeType&&(a=a||lh(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${o}`:"")),c&&Vf.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function $g(t){return!(t instanceof Response&&t.status===204)}function Xg(t){let e=Cr(t),r=vs(t),i="No valid loader found (";i+=e?`${Mr.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let s=t?Yg(t):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function mS(t){for(let e of t)Is(e)}function _S(t,e){let r=e&&pS.exec(e),i=r&&r[1];return i?yS(t,i):null}function yS(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function lh(t,e){for(let r of t)if(r.mimeTypes?.some(i=>sh(e,i))||sh(e,`application/x.${r.id}`))return r;return null}function TS(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(bS(e,r))return r}else if(ArrayBuffer.isView(e)){if(jg(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&jg(e,0,r))return r;return null}function bS(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function jg(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(s=>xS(t,e,r,s))}function xS(t,e,r,i){if(pi(i))return Gf(i,t,i.byteLength);switch(typeof i){case"function":return i(Rs(t));case"string":let s=fh(t,e,i.length);return i===s;default:return!1}}function Yg(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?fh(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?fh(t,0,e):""}function fh(t,e,r){if(t.byteLength<e+r)return"";let i=new DataView(t),s="";for(let o=0;o<r;o++)s+=String.fromCharCode(i.getUint8(e+o));return s}var AS=256*1024;function*Zg(t,e){let r=e?.chunkSize||AS,i=0,s=new TextEncoder;for(;i<t.length;){let o=Math.min(t.length-i,r),n=t.slice(i,i+o);i+=o,yield Rs(s.encode(n))}}function*Kg(t,e={}){let{chunkSize:r=262144}=e,i=0;for(;i<t.byteLength;){let s=Math.min(t.byteLength-i,r),o=new ArrayBuffer(s),n=new Uint8Array(t,i,s);new Uint8Array(o).set(n),i+=s,yield o}}async function*qg(t,e){let r=e?.chunkSize||1048576,i=0;for(;i<t.size;){let s=i+r,o=await t.slice(i,s).arrayBuffer();i=s,yield o}}function hh(t,e){return Pr?SS(t,e):ES(t,e)}async function*SS(t,e){let r=t.getReader(),i;try{for(;;){let s=i||r.read();e?._streamReadAhead&&(i=r.read());let{done:o,value:n}=await s;if(o)return;yield mi(n)}}catch{r.releaseLock()}}async function*ES(t,e){for await(let r of t)yield mi(r)}function Qg(t,e){if(typeof t=="string")return Zg(t,e);if(t instanceof ArrayBuffer)return Kg(t,e);if(Me(t))return qg(t,e);if(Ss(t))return hh(t,e);if(ve(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return hh(r,e)}throw new Error("makeIterator")}var Gg="Cannot convert supplied data type";function wS(t,e,r){if(e.text&&typeof t=="string")return t;if(Ln(t)&&(t=t.buffer),pi(t)){let i=rh(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(i):mi(i)}throw new Error(Gg)}async function Jg(t,e,r){if(typeof t=="string"||pi(t))return wS(t,e,r);if(Me(t)&&(t=await kn(t)),ve(t))return await Dg(t),e.binary?await t.arrayBuffer():await t.text();if(Ss(t)&&(t=Qg(t,r)),Wf(t)||jf(t))return eh(t);throw new Error(Gg)}function jn(t,e){let r=ch(),i=t||r,s=i.fetch??i.core?.fetch;return typeof s=="function"?s:at(s)?o=>yi(o,s):e?.fetch?e?.fetch:yi}function em(t,e,r){if(r)return r;let i={fetch:jn(e,t),...t};if(i.url){let s=_i(i.url);i.baseUrl=s,i.queryString=Ig(i.url),i.filename=Mr.filename(s),i.baseUrl=Mr.dirname(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function tm(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function tr(t,e,r,i){e&&!Array.isArray(e)&&!Cs(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let s=Cr(t),n=tm(e,i),a=await Hg(t,n,r);if(!a)return null;let c=Ug(r,a,n,s);return i=em({url:s,_parse:tr,loaders:n},c,i||null),await RS(a,t,c,i)}async function RS(t,e,r,i){if(Kf(t),r=Hf(t.options,r),ve(e)){let{ok:o,redirected:n,status:a,statusText:c,type:l,url:f}=e,h=Object.fromEntries(e.headers.entries());i.response={headers:h,ok:o,redirected:n,status:a,statusText:c,type:l,url:f}}e=await Jg(e,t,r);let s=t;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,r,i);if(qf(t,r))return await Qf(t,e,r,i,tr);if(s.parseText&&typeof e=="string")return await s.parseText(e,r,i);if(s.parse)return await s.parse(e,r,i);throw ge(!s.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function rr(t,e,r,i){let s,o;!Array.isArray(e)&&!Cs(e)?(s=[],o=e,i=void 0):(s=e,o=r);let n=jn(o),a=t;return typeof t=="string"&&(a=await n(t)),Me(t)&&(a=await n(t)),Array.isArray(s)?await tr(a,s,o):await tr(a,s,o)}var rm="4.4.0-alpha.18";var PS=globalThis.loaders?.parseImageNode,dh=typeof Image<"u",ph=typeof ImageBitmap<"u",vS=Boolean(PS),gh=Pr?!0:vS;function im(t){switch(t){case"auto":return ph||dh||gh;case"imagebitmap":return ph;case"image":return dh;case"data":return gh;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function sm(){if(ph)return"imagebitmap";if(dh)return"image";if(gh)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function MS(t){let e=CS(t);if(!e)throw new Error("Not an image");return e}function om(t){switch(MS(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function CS(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var IS=/^data:image\/svg\+xml/,OS=/\.svg((\?|#).*)?$/;function Hn(t){return t&&(IS.test(t)||OS.test(t))}function nm(t,e){if(Hn(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return mh(t,e)}function mh(t,e){if(Hn(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function $n(t,e,r){let i=nm(t,r),s=self.URL||self.webkitURL,o=typeof i!="string"&&s.createObjectURL(i);try{return await NS(o||i,e)}finally{o&&s.revokeObjectURL(o)}}async function NS(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,s)=>{try{r.onload=()=>i(r),r.onerror=o=>{let n=o instanceof Error?o.message:"error";s(new Error(n))}}catch(o){s(o)}})}var am=!0;async function cm(t,e,r){let i;Hn(r)?i=await $n(t,e,r):i=mh(t,r);let s=e&&e.imagebitmap;return await DS(i,s)}async function DS(t,e=null){if((FS(e)||!am)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),am=!1}return await createImageBitmap(t)}function FS(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function lm(t){return!kS(t,"ftyp",4)||!(t[8]&96)?null:BS(t)}function BS(t){switch(LS(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function LS(t,e,r){return String.fromCharCode(...t.slice(e,r))}function US(t){return[...t].map(e=>e.charCodeAt(0))}function kS(t,e,r=0){let i=US(e);for(let s=0;s<i.length;++s)if(i[s]!==t[s+r])return!1;return!0}var lt=!1,Ns=!0;function Xn(t){let e=Ds(t);return zS(e)||HS(e)||WS(e)||jS(e)||VS(e)}function VS(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=lm(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function zS(t){let e=Ds(t);return e.byteLength>=24&&e.getUint32(0,lt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,lt),height:e.getUint32(20,lt)}:null}function WS(t){let e=Ds(t);return e.byteLength>=10&&e.getUint32(0,lt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Ns),height:e.getUint16(8,Ns)}:null}function jS(t){let e=Ds(t);return e.byteLength>=14&&e.getUint16(0,lt)===16973&&e.getUint32(2,Ns)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Ns),height:e.getUint32(22,Ns)}:null}function HS(t){let e=Ds(t);if(!(e.byteLength>=3&&e.getUint16(0,lt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:s}=$S(),o=2;for(;o+9<e.byteLength;){let n=e.getUint16(o,lt);if(s.has(n))return{mimeType:"image/jpeg",height:e.getUint16(o+5,lt),width:e.getUint16(o+7,lt)};if(!i.has(n))return null;o+=2,o+=e.getUint16(o,lt)}return null}function $S(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Ds(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function fm(t,e){let{mimeType:r}=Xn(t)||{},i=globalThis.loaders?.parseImageNode;return Gt(i),await i(t,r)}async function hm(t,e,r){e=e||{};let s=(e.image||{}).type||"auto",{url:o}=r||{},n=XS(s),a;switch(n){case"imagebitmap":a=await cm(t,e,o);break;case"image":a=await $n(t,e,o);break;case"data":a=await fm(t,e);break;default:Gt(!1)}return s==="data"&&(a=om(a)),a}function XS(t){switch(t){case"auto":case"data":return sm();default:return im(t),t}}var YS=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],ZS=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],KS={image:{type:"auto",decode:!0}},_h={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:rm,mimeTypes:ZS,extensions:YS,parse:hm,tests:[t=>Boolean(Xn(new DataView(t)))],options:KS};ji();var qS=new ue({id:"deck"}),L=qS;var yh={};function Yn(t){yh=t}function Q(t,e,r,i){L.level>0&&yh[t]&&yh[t].call(null,e,r,i)}function QS(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var um={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:QS,parseTextSync:JSON.parse};function GS(){let t="9.3.0-alpha.2",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(L.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:L,_registerLoggers:Yn},Os([um,[_h,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var Zn=GS();var dm=`uniform layerUniforms {
|
|
931
|
-
uniform float opacity;
|
|
932
|
-
} layer;
|
|
933
|
-
`,Th={name:"layer",vs:dm,fs:dm,getUniforms:t=>({opacity:Math.pow(t.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var JS=`
|
|
934
|
-
|
|
935
|
-
struct ColorUniforms {
|
|
1181
|
+
}`}function yh(t,e=!0,r){let i=r||new Set;if(t){if(gm(t))i.add(t);else if(gm(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let s in t)yh(t[s],e,i)}}return r===void 0?Array.from(i):[]}function gm(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var bh=()=>{},sr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Le||typeof Ai<"u"&&!Le}constructor(e){let{name:r,source:i,url:s}=e;me(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=bh,this.onError=o=>console.log(o),this.worker=Le?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=bh,this.onError=bh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||yh(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=dm({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,s=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Ai(i,{eval:!1,type:s})}else if(this.source)e=new Ai(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var Cs=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return sr.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(s,o,n)=>s.done(n),i=(s,o)=>s.error(o)){let s=new Promise(o=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:o}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new Ms(r.name,e);e.onMessage=s=>r.onMessage(i,s.type,s.payload),e.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Le||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new sr({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return um?this.maxMobileConcurrency:this.maxConcurrency}};var SE={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Ir=class{props;workerPools=new Map;static isSupported(){return sr.isSupported()}static getWorkerFarm(e={}){return Ir._workerFarm=Ir._workerFarm||new Ir({}),Ir._workerFarm.setProps(e),Ir._workerFarm}constructor(e){this.props={...SE},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:s}=e,o=this.workerPools.get(r);return o||(o=new Cs({name:r,source:i,url:s}),o.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,o)),o}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},or=Ir;P(or,"_workerFarm");function Th(t,e={}){let r=e[t.id]||{},i=Le?`${t.id}-worker.js`:`${t.id}-worker-node.js`,s=r.workerUrl;if(!s&&t.id==="compression"&&(s=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Le?s=`modules/${t.module}/dist/${i}`:s=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!s){let n=t.version;n==="latest"&&(n=lm);let a=n?`@${n}`:"";s=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${i}`}return me(s),s}function xh(t,e=fm){me(t,"no worker provided");let r=t.version;return!(!e||!r)}function Ah(t,e){if(!or.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Le&&!r)return!1;let i=e?.worker??e?.core?.worker;return Boolean(t.worker&&i)}async function Sh(t,e,r,i,s){let o=t.id,n=Th(t,r),c=or.getWorkerFarm(r?.core).getWorkerPool({name:o,url:n});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",EE.bind(null,s));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function EE(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:s,input:o,options:n}=i;try{let a=await t(o,n);e.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Eh(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let i=new Uint8Array(t),s=new Uint8Array(e);for(let o=0;o<i.length;++o)if(i[o]!==s[o])return!1;return!0}function wh(...t){return mm(t)}function mm(t){let e=t.map(o=>o instanceof ArrayBuffer?new Uint8Array(o):o),r=e.reduce((o,n)=>o+n.byteLength,0),i=new Uint8Array(r),s=0;for(let o of e)i.set(o,s),s+=o.byteLength;return i.buffer}async function Rh(t){let e=[];for await(let r of t)e.push(wE(r));return wh(...e)}function wE(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:i}=t;return _m(e,r,i)}return _m(t)}function _m(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}var RE="",ym={};function Ph(t){for(let e in ym)if(t.startsWith(e)){let r=ym[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${RE}${t}`),t}function Yn(t){return t&&typeof t=="object"&&t.isBuffer}function Si(t){if(Yn(t))return t;if(t instanceof ArrayBuffer)return t;if(dh(t))return Xn(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Is(t){if(t instanceof ArrayBuffer)return t;if(dh(t))return Xn(t);let{buffer:e,byteOffset:r,byteLength:i}=t;return e instanceof ArrayBuffer&&r===0&&i===e.byteLength?e:Xn(e,r,i)}function Xn(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),s=new Uint8Array(i.length);return s.set(i),s.buffer}function vh(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Or={};Rt(Or,{dirname:()=>vE,filename:()=>PE,join:()=>ME,resolve:()=>CE});function bm(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function PE(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function vE(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function ME(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function CE(...t){let e=[];for(let o=0;o<t.length;o++)e[o]=t[o];let r="",i=!1,s;for(let o=e.length-1;o>=-1&&!i;o--){let n;o>=0?n=e[o]:(s===void 0&&(s=bm()),n=s),n.length!==0&&(r=`${n}/${r}`,i=n.charCodeAt(0)===Os)}return r=IE(r,!i),i?`/${r}`:r.length>0?r:"."}var Os=47,Mh=46;function IE(t,e){let r="",i=-1,s=0,o,n=!1;for(let a=0;a<=t.length;++a){if(a<t.length)o=t.charCodeAt(a);else{if(o===Os)break;o=Os}if(o===Os){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(r.length<2||!n||r.charCodeAt(r.length-1)!==Mh||r.charCodeAt(r.length-2)!==Mh){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Os;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,s=0,n=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,s=0,n=!1;continue}}e&&(r.length>0?r+="/..":r="..",n=!0)}else{let c=t.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,n=!1}i=a,s=0}else o===Mh&&s!==-1?++s:s=-1}return r}var Kn=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var DE=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,BE=/^([-\w.]+\/[-\w.+]+)/;function Ch(t,e){return t.toLowerCase()===e.toLowerCase()}function Tm(t){let e=BE.exec(t);return e?e[1]:t}function Ih(t){let e=DE.exec(t);return e?e[1]:""}var xm=/\?.*/;function Am(t){let e=t.match(xm);return e&&e[0]}function Ei(t){return t.replace(xm,"")}function Sm(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Nr(t){return Me(t)?t.url:Ce(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Ns(t){if(Me(t)){let e=t.headers.get("content-type")||"",r=Ei(t.url);return Tm(e)||Ih(r)}return Ce(t)?t.type||"":typeof t=="string"?Ih(t):""}function Em(t){return Me(t)?t.headers["content-length"]||-1:Ce(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Zn(t){if(Me(t))return t;let e={},r=Em(t);r>=0&&(e["content-length"]=String(r));let i=Nr(t),s=Ns(t);s&&(e["content-type"]=s);let o=await LE(t);o&&(e["x-first-bytes"]=o),typeof t=="string"&&(t=new TextEncoder().encode(t));let n=new Response(t,{headers:e});return Object.defineProperty(n,"url",{value:i}),n}async function wm(t){if(!t.ok)throw await FE(t)}async function FE(t){let e=Sm(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let s=t.headers.get("Content-Type");i.reason=!t.bodyUsed&&s?.includes("application/json")?await t.json():await t.text()}catch{}return new Kn(r,i)}async function LE(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let s=new FileReader;s.onload=o=>i(o?.target?.result),s.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${UE(r)}`}return null}function UE(t){let e="",r=new Uint8Array(t);for(let i=0;i<r.byteLength;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function kE(t){return!VE(t)&&!zE(t)}function VE(t){return t.startsWith("http:")||t.startsWith("https:")}function zE(t){return t.startsWith("data:")}async function wi(t,e){if(typeof t=="string"){let r=Ph(t);return kE(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await Zn(t)}Gi();var Ds=new ue({id:"loaders.gl"}),qn=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Gn=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Qn={core:{baseUri:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new Gn,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Cr,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Rm={baseUri:"core.baseUri",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var Oh=["baseUri","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Nh(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function Dh(){let t=Nh();return t.globalOptions=t.globalOptions||{...Qn,core:{...Qn.core}},Dr(t.globalOptions)}function Mm(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],WE(t,r),Dr(HE(e,t,i))}function Dr(t){let e=XE(t);Cm(e);for(let r of Oh)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function WE(t,e){Pm(t,null,Qn,Rm,e);for(let r of e){let i=t&&t[r.id]||{},s=r.options&&r.options[r.id]||{},o=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Pm(i,r.id,s,o,e)}}function Pm(t,e,r,i,s){let o=e||"Top level",n=e?`${e}.`:"";for(let a in t){let c=!e&&ut(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in i)Ds.level>0&&Ds.warn(`${o} loader option '${n}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&Ds.level>0){let h=jE(a,s);Ds.warn(`${o} loader option '${n}${a}' not recognized. ${h}`)()}}}}function jE(t,e){let r=t.toLowerCase(),i="";for(let s of e)for(let o in s.options){if(t===o)return`Did you mean '${s.id}.${o}'?`;let n=o.toLowerCase();(r.startsWith(n)||n.startsWith(r))&&(i=i||`Did you mean '${s.id}.${o}'?`)}return i}function HE(t,e,r){let i=t.options||{},s={...i};i.core&&(s.core={...i.core}),Cm(s),s.core?.log===null&&(s.core={...s.core,log:new qn}),vm(s,Dr(Dh()));let o=Dr(e);return vm(s,o),$E(s,r),YE(s),s}function vm(t,e){for(let r in e)if(r in e){let i=e[r];$n(i)&&$n(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function $E(t,e){if(!e)return;let r=t.baseUri!==void 0,i=t.core?.baseUri!==void 0;!r&&!i&&(t.core||={},t.core.baseUri=e)}function XE(t){let e={...t};return t.core&&(e.core={...t.core}),e}function Cm(t){for(let r of Oh)if(t[r]!==void 0){let s=t.core=t.core||{};s[r]===void 0&&(s[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function YE(t){let e=t.core;if(e)for(let r of Oh)e[r]!==void 0&&(t[r]=e[r])}function Bs(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function Fs(t){ir(t,"null loader"),ir(Bs(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var Im=()=>{let t=Nh();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function Ls(t){let e=Im();t=Array.isArray(t)?t:[t];for(let r of t){let i=Fs(r);e.find(s=>i===s)||e.unshift(i)}}function Om(){return Im()}var KE=/\.([^.]+)$/;async function Bm(t,e=[],r,i){if(!Fm(t))return null;let s=Dr(r||{});s.core||={};let o=Nm(t,e,{...s,core:{...s.core,nothrow:!0}},i);if(o)return o;if(Ce(t)&&(t=await t.slice(0,10).arrayBuffer(),o=Nm(t,e,s,i)),!o&&!s.core.nothrow)throw new Error(Lm(t));return o}function Nm(t,e=[],r,i){if(!Fm(t))return null;let s=Dr(r||{});if(s.core||={},e&&!Array.isArray(e))return Fs(e);let o=[];e&&(o=o.concat(e)),s.core.ignoreRegisteredLoaders||o.push(...Om()),qE(o);let n=ZE(t,o,s,i);if(!n&&!s.core.nothrow)throw new Error(Lm(t));return n}function ZE(t,e,r,i){let s=Nr(t),o=Ns(t),n=Ei(s)||i?.url,a=null,c="";return r?.core?.mimeType&&(a=Bh(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||GE(e,n),c=c||(a?`matched url ${n}`:""),a=a||Bh(e,o),c=c||(a?`matched MIME type ${o}`:""),a=a||JE(e,t),c=c||(a?`matched initial data ${Um(t)}`:""),r?.core?.fallbackMimeType&&(a=a||Bh(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${o}`:"")),c&&uh.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function Fm(t){return!(t instanceof Response&&t.status===204)}function Lm(t){let e=Nr(t),r=Ns(t),i="No valid loader found (";i+=e?`${Or.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let s=t?Um(t):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function qE(t){for(let e of t)Fs(e)}function GE(t,e){let r=e&&KE.exec(e),i=r&&r[1];return i?QE(t,i):null}function QE(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function Bh(t,e){for(let r of t)if(r.mimeTypes?.some(i=>Ch(e,i))||Ch(e,`application/x.${r.id}`))return r;return null}function JE(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(ew(e,r))return r}else if(ArrayBuffer.isView(e)){if(Dm(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&Dm(e,0,r))return r;return null}function ew(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function Dm(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(s=>tw(t,e,r,s))}function tw(t,e,r,i){if(xi(i))return Eh(i,t,i.byteLength);switch(typeof i){case"function":return i(Is(t));case"string":let s=Fh(t,e,i.length);return i===s;default:return!1}}function Um(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Fh(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Fh(t,0,e):""}function Fh(t,e,r){if(t.byteLength<e+r)return"";let i=new DataView(t),s="";for(let o=0;o<r;o++)s+=String.fromCharCode(i.getUint8(e+o));return s}var rw=256*1024;function*km(t,e){let r=e?.chunkSize||rw,i=0,s=new TextEncoder;for(;i<t.length;){let o=Math.min(t.length-i,r),n=t.slice(i,i+o);i+=o,yield Is(s.encode(n))}}function*Vm(t,e={}){let{chunkSize:r=262144}=e,i=0;for(;i<t.byteLength;){let s=Math.min(t.byteLength-i,r),o=new ArrayBuffer(s),n=new Uint8Array(t,i,s);new Uint8Array(o).set(n),i+=s,yield o}}async function*zm(t,e){let r=e?.chunkSize||1048576,i=0;for(;i<t.size;){let s=i+r,o=await t.slice(i,s).arrayBuffer();i=s,yield o}}function Lh(t,e){return Cr?iw(t,e):sw(t,e)}async function*iw(t,e){let r=t.getReader(),i;try{for(;;){let s=i||r.read();e?._streamReadAhead&&(i=r.read());let{done:o,value:n}=await s;if(o)return;yield Si(n)}}catch{r.releaseLock()}}async function*sw(t,e){for await(let r of t)yield Si(r)}function Wm(t,e){if(typeof t=="string")return km(t,e);if(t instanceof ArrayBuffer)return Vm(t,e);if(Ce(t))return zm(t,e);if(vs(t))return Lh(t,e);if(Me(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return Lh(r,e)}throw new Error("makeIterator")}var jm="Cannot convert supplied data type";function ow(t,e,r){if(e.text&&typeof t=="string")return t;if(Yn(t)&&(t=t.buffer),xi(t)){let i=vh(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(i):Si(i)}throw new Error(jm)}async function Hm(t,e,r){if(typeof t=="string"||xi(t))return ow(t,e,r);if(Ce(t)&&(t=await Zn(t)),Me(t))return await wm(t),e.binary?await t.arrayBuffer():await t.text();if(vs(t)&&(t=Wm(t,r)),ph(t)||gh(t))return Rh(t);throw new Error(jm)}function Jn(t,e){let r=Dh(),i=t||r,s=i.fetch??i.core?.fetch;return typeof s=="function"?s:ut(s)?o=>wi(o,s):e?.fetch?e?.fetch:wi}function $m(t,e,r){if(r)return r;let i={fetch:Jn(e,t),...t};if(i.url){let s=Ei(i.url);i.baseUrl=s,i.queryString=Am(i.url),i.filename=Or.filename(s),i.baseUrl=Or.dirname(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function Xm(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function nr(t,e,r,i){e&&!Array.isArray(e)&&!Bs(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let s=Nr(t),n=Xm(e,i),a=await Bm(t,n,r);if(!a)return null;let c=Mm(r,a,n,s);return i=$m({url:s,_parse:nr,loaders:n},c,i||null),await nw(a,t,c,i)}async function nw(t,e,r,i){if(xh(t),r=mh(t.options,r),Me(e)){let{ok:o,redirected:n,status:a,statusText:c,type:l,url:f}=e,h=Object.fromEntries(e.headers.entries());i.response={headers:h,ok:o,redirected:n,status:a,statusText:c,type:l,url:f}}e=await Hm(e,t,r);let s=t;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,r,i);if(Ah(t,r))return await Sh(t,e,r,i,nr);if(s.parseText&&typeof e=="string")return await s.parseText(e,r,i);if(s.parse)return await s.parse(e,r,i);throw me(!s.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function ar(t,e,r,i){let s,o;!Array.isArray(e)&&!Bs(e)?(s=[],o=e,i=void 0):(s=e,o=r);let n=Jn(o),a=t;return typeof t=="string"&&(a=await n(t)),Ce(t)&&(a=await n(t)),Array.isArray(s)?await nr(a,s,o):await nr(a,s,o)}var Ym="4.4.0-alpha.18";var aw=globalThis.loaders?.parseImageNode,kh=typeof Image<"u",Vh=typeof ImageBitmap<"u",cw=Boolean(aw),zh=Cr?!0:cw;function Km(t){switch(t){case"auto":return Vh||kh||zh;case"imagebitmap":return Vh;case"image":return kh;case"data":return zh;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function Zm(){if(Vh)return"imagebitmap";if(kh)return"image";if(zh)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function lw(t){let e=fw(t);if(!e)throw new Error("Not an image");return e}function qm(t){switch(lw(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function fw(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var hw=/^data:image\/svg\+xml/,uw=/\.svg((\?|#).*)?$/;function ea(t){return t&&(hw.test(t)||uw.test(t))}function Gm(t,e){if(ea(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return Wh(t,e)}function Wh(t,e){if(ea(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function ta(t,e,r){let i=Gm(t,r),s=self.URL||self.webkitURL,o=typeof i!="string"&&s.createObjectURL(i);try{return await dw(o||i,e)}finally{o&&s.revokeObjectURL(o)}}async function dw(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,s)=>{try{r.onload=()=>i(r),r.onerror=o=>{let n=o instanceof Error?o.message:"error";s(new Error(n))}}catch(o){s(o)}})}var Qm=!0;async function Jm(t,e,r){let i;ea(r)?i=await ta(t,e,r):i=Wh(t,r);let s=e&&e.imagebitmap;return await pw(i,s)}async function pw(t,e=null){if((gw(e)||!Qm)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Qm=!1}return await createImageBitmap(t)}function gw(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function e_(t){return!bw(t,"ftyp",4)||!(t[8]&96)?null:mw(t)}function mw(t){switch(_w(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function _w(t,e,r){return String.fromCharCode(...t.slice(e,r))}function yw(t){return[...t].map(e=>e.charCodeAt(0))}function bw(t,e,r=0){let i=yw(e);for(let s=0;s<i.length;++s)if(i[s]!==t[s+r])return!1;return!0}var pt=!1,Us=!0;function ra(t){let e=ks(t);return xw(e)||Ew(e)||Aw(e)||Sw(e)||Tw(e)}function Tw(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=e_(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function xw(t){let e=ks(t);return e.byteLength>=24&&e.getUint32(0,pt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,pt),height:e.getUint32(20,pt)}:null}function Aw(t){let e=ks(t);return e.byteLength>=10&&e.getUint32(0,pt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Us),height:e.getUint16(8,Us)}:null}function Sw(t){let e=ks(t);return e.byteLength>=14&&e.getUint16(0,pt)===16973&&e.getUint32(2,Us)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Us),height:e.getUint32(22,Us)}:null}function Ew(t){let e=ks(t);if(!(e.byteLength>=3&&e.getUint16(0,pt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:s}=ww(),o=2;for(;o+9<e.byteLength;){let n=e.getUint16(o,pt);if(s.has(n))return{mimeType:"image/jpeg",height:e.getUint16(o+5,pt),width:e.getUint16(o+7,pt)};if(!i.has(n))return null;o+=2,o+=e.getUint16(o,pt)}return null}function ww(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ks(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function t_(t,e){let{mimeType:r}=ra(t)||{},i=globalThis.loaders?.parseImageNode;return ir(i),await i(t,r)}async function r_(t,e,r){e=e||{};let s=(e.image||{}).type||"auto",{url:o}=r||{},n=Rw(s),a;switch(n){case"imagebitmap":a=await Jm(t,e,o);break;case"image":a=await ta(t,e,o);break;case"data":a=await t_(t,e);break;default:ir(!1)}return s==="data"&&(a=qm(a)),a}function Rw(t){switch(t){case"auto":case"data":return Zm();default:return Km(t),t}}var Pw=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],vw=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],Mw={image:{type:"auto",decode:!0}},jh={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Ym,mimeTypes:vw,extensions:Pw,parse:r_,tests:[t=>Boolean(ra(new DataView(t)))],options:Mw};Gi();var Cw=new ue({id:"deck"}),F=Cw;var Hh={};function ia(t){Hh=t}function G(t,e,r,i){F.level>0&&Hh[t]&&Hh[t].call(null,e,r,i)}function Iw(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var i_={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:Iw,parseTextSync:JSON.parse};function Ow(){let t="9.3.0-alpha.5",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(F.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:F,_registerLoggers:ia},Ls([i_,[jh,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var sa=Ow();var Nw=`struct LayerUniforms {
|
|
936
1182
|
opacity: f32,
|
|
937
1183
|
};
|
|
938
1184
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1185
|
+
@group(0) @binding(auto)
|
|
1186
|
+
var<uniform> layer: LayerUniforms;
|
|
1187
|
+
`,s_=`layout(std140) uniform layerUniforms {
|
|
1188
|
+
uniform float opacity;
|
|
1189
|
+
} layer;
|
|
1190
|
+
`,$h={name:"layer",source:Nw,vs:s_,fs:s_,getUniforms:t=>({opacity:Math.pow(t.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var Dw=`
|
|
943
1191
|
|
|
944
1192
|
@must_use
|
|
945
1193
|
fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
|
|
946
1194
|
return vec4(fragColor.rgb * fragColor.a, fragColor.a);
|
|
947
1195
|
};
|
|
948
|
-
`,
|
|
1196
|
+
`,Xh={name:"color",dependencies:[],source:Dw,getUniforms:t=>({})};var Bw=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
|
|
949
1197
|
|
|
950
1198
|
struct VertexGeometry {
|
|
951
1199
|
position: vec4<f32>,
|
|
@@ -974,7 +1222,7 @@ var<private> fragmentGeometry: FragmentGeometry;
|
|
|
974
1222
|
fn smoothedge(edge: f32, x: f32) -> f32 {
|
|
975
1223
|
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
976
1224
|
}
|
|
977
|
-
`,
|
|
1225
|
+
`,o_="#define SMOOTH_EDGE_RADIUS 0.5",Fw=`${o_}
|
|
978
1226
|
|
|
979
1227
|
struct VertexGeometry {
|
|
980
1228
|
vec4 position;
|
|
@@ -991,7 +1239,7 @@ struct VertexGeometry {
|
|
|
991
1239
|
vec2(0.0),
|
|
992
1240
|
vec3(0.0)
|
|
993
1241
|
);
|
|
994
|
-
`,
|
|
1242
|
+
`,Lw=`${o_}
|
|
995
1243
|
|
|
996
1244
|
struct FragmentGeometry {
|
|
997
1245
|
vec2 uv;
|
|
@@ -1000,9 +1248,9 @@ struct FragmentGeometry {
|
|
|
1000
1248
|
float smoothedge(float edge, float x) {
|
|
1001
1249
|
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
1002
1250
|
}
|
|
1003
|
-
`,Kn={name:"geometry",source:eE,vs:tE,fs:rE};var $;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})($||($={}));var Z;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(Z||(Z={}));var O;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})(O||(O={}));var gm="compute",xh="auto",Fs="manipulation",Or="none",Bs="pan-x",Ls="pan-y";function Ah(t){if(t.includes(Or))return Or;let e=t.includes(Bs),r=t.includes(Ls);return e&&r?Or:e||r?e?Bs:Ls:t.includes(Fs)?Fs:xh}var Us=class{constructor(e,r){this.actions="",this.manager=e,this.set(r)}set(e){e===gm&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let r of this.manager.recognizers)r.options.enable&&(e=e.concat(r.getTouchAction()));return Ah(e.join(" "))}};function Ti(t){return t.trim().split(/\s+/g)}function qn(t,e,r){if(t)for(let i of Ti(e))t.addEventListener(i,r,!1)}function Qn(t,e,r){if(t)for(let i of Ti(e))t.removeEventListener(i,r,!1)}function Sh(t){return(t.ownerDocument||t).defaultView}function Eh(t,e){let r=t;for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function Gn(t){let e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let r=0,i=0,s=0;for(;s<e;)r+=t[s].clientX,i+=t[s].clientY,s++;return{x:Math.round(r/e),y:Math.round(i/e)}}function wh(t){let e=[],r=0;for(;r<t.pointers.length;)e[r]={clientX:Math.round(t.pointers[r].clientX),clientY:Math.round(t.pointers[r].clientY)},r++;return{timeStamp:Date.now(),pointers:e,center:Gn(e),deltaX:t.deltaX,deltaY:t.deltaY}}function Jn(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.sqrt(r*r+i*i)}function Rh(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(r*r+i*i)}function mm(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.atan2(i,r)*180/Math.PI}function Ph(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.atan2(i,r)*180/Math.PI}function ea(t,e){return t===e?Z.None:Math.abs(t)>=Math.abs(e)?t<0?Z.Left:Z.Right:e<0?Z.Up:Z.Down}function _m(t,e){let r=e.center,i=t.offsetDelta,s=t.prevDelta,o=t.prevInput;return(e.eventType===$.Start||o?.eventType===$.End)&&(s=t.prevDelta={x:o?.deltaX||0,y:o?.deltaY||0},i=t.offsetDelta={x:r.x,y:r.y}),{deltaX:s.x+(r.x-i.x),deltaY:s.y+(r.y-i.y)}}function ta(t,e,r){return{x:e/t||0,y:r/t||0}}function ym(t,e){return Rh(e[0],e[1])/Rh(t[0],t[1])}function Tm(t,e){return Ph(e[1],e[0])-Ph(t[1],t[0])}function bm(t,e){let r=t.lastInterval||e,i=e.timeStamp-r.timeStamp,s,o,n,a;if(e.eventType!==$.Cancel&&(i>25||r.velocity===void 0)){let c=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,f=ta(i,c,l);o=f.x,n=f.y,s=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=ea(c,l),t.lastInterval=e}else s=r.velocity,o=r.velocityX,n=r.velocityY,a=r.direction;e.velocity=s,e.velocityX=o,e.velocityY=n,e.direction=a}function xm(t,e){let{session:r}=t,{pointers:i}=e,{length:s}=i;r.firstInput||(r.firstInput=wh(e)),s>1&&!r.firstMultiple?r.firstMultiple=wh(e):s===1&&(r.firstMultiple=!1);let{firstInput:o,firstMultiple:n}=r,a=n?n.center:o.center,c=e.center=Gn(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=mm(a,c),e.distance=Jn(a,c);let{deltaX:l,deltaY:f}=_m(r,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=ea(e.deltaX,e.deltaY);let h=ta(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,e.scale=n?ym(n.pointers,i):1,e.rotation=n?Tm(n.pointers,i):0,e.maxPointers=r.prevInput?e.pointers.length>r.prevInput.maxPointers?e.pointers.length:r.prevInput.maxPointers:e.pointers.length;let u=t.element;return Eh(e.srcEvent.target,u)&&(u=e.srcEvent.target),e.target=u,bm(r,e),e}function Am(t,e,r){let i=r.pointers.length,s=r.changedPointers.length,o=e&$.Start&&i-s===0,n=e&($.End|$.Cancel)&&i-s===0;r.isFirst=Boolean(o),r.isFinal=Boolean(n),o&&(t.session={}),r.eventType=e;let a=xm(t,r);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}var ks=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,r){Am(this.manager,e,r)}init(){qn(this.element,this.evEl,this.domHandler),qn(this.target,this.evTarget,this.domHandler),qn(Sh(this.element),this.evWin,this.domHandler)}destroy(){Qn(this.element,this.evEl,this.domHandler),Qn(this.target,this.evTarget,this.domHandler),Qn(Sh(this.element),this.evWin,this.domHandler)}};var sE={pointerdown:$.Start,pointermove:$.Move,pointerup:$.End,pointercancel:$.Cancel,pointerout:$.Cancel},oE="pointerdown",nE="pointermove pointerup pointercancel",Vs=class extends ks{constructor(e){super(e),this.evEl=oE,this.evWin=nE,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:r}=this,i=!1,s=sE[e.type],o=e.pointerType,n=o==="touch",a=r.findIndex(c=>c.pointerId===e.pointerId);s&$.Start&&(e.buttons||n)?a<0&&(r.push(e),a=r.length-1):s&($.End|$.Cancel)&&(i=!0),!(a<0)&&(r[a]=e,this.callback(s,{pointers:r,changedPointers:[e],eventType:s,pointerType:o,srcEvent:e}),i&&r.splice(a,1))}};var aE=["","webkit","Moz","MS","ms","o"];function Sm(t,e){let r=e[0].toUpperCase()+e.slice(1);for(let i of aE){let s=i?i+r:e;if(s in t)return s}}var cE=1,Em=2,wm={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},zs=class{constructor(e,r){this.options={...wm,...r,cssProps:{...wm.cssProps,...r.cssProps},inputTarget:r.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new Vs(this),this.touchAction=new Us(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?Em:cE}recognize(e){let{session:r}=this;if(r.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:s}=this,{curRecognizer:o}=r;(!o||o&&o.state&O.Recognized)&&(o=r.curRecognizer=null);let n=0;for(;n<s.length;)i=s[n],r.stopped!==Em&&(!o||i===o||i.canRecognizeWith(o))?i.recognize(e):i.reset(),!o&&i.state&(O.Began|O.Changed|O.Ended)&&(o=r.curRecognizer=i),n++}get(e){let{recognizers:r}=this;for(let i=0;i<r.length;i++)if(r[i].options.event===e)return r[i];return null}add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this}let r=this.get(e.options.event);return r&&this.remove(r),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let i of e)this.remove(i);return this}let r=typeof e=="string"?this.get(e):e;if(r){let{recognizers:i}=this,s=i.indexOf(r);s!==-1&&(i.splice(s,1),this.touchAction.update())}return this}on(e,r){if(!e||!r)return;let{handlers:i}=this;for(let s of Ti(e))i[s]=i[s]||[],i[s].push(r)}off(e,r){if(!e)return;let{handlers:i}=this;for(let s of Ti(e))r?i[s]&&i[s].splice(i[s].indexOf(r),1):delete i[s]}emit(e,r){let i=this.handlers[e]&&this.handlers[e].slice();if(!i||!i.length)return;let s=r;s.type=e,s.preventDefault=function(){r.srcEvent.preventDefault()};let o=0;for(;o<i.length;)i[o](s),o++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:r}=this;if(r){for(let[i,s]of Object.entries(this.options.cssProps)){let o=Sm(r.style,i);e?(this.oldCssProps[o]=r.style[o],r.style[o]=s):r.style[o]=this.oldCssProps[o]||""}e||(this.oldCssProps={})}}};var lE=1;function Rm(){return lE++}function vh(t){return t&O.Cancelled?"cancel":t&O.Ended?"end":t&O.Changed?"move":t&O.Began?"start":""}var Mt=class{constructor(e){this.options=e,this.id=Rm(),this.state=O.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let s of e)this.recognizeWith(s);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{simultaneous:i}=this;return i[r.id]||(i[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let i of e)this.dropRecognizeWith(i);return this}let r;return typeof e=="string"?r=this.manager.get(e):r=e,r&&delete this.simultaneous[r.id],this}requireFailure(e){if(Array.isArray(e)){for(let s of e)this.requireFailure(s);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{requireFail:i}=this;return i.indexOf(r)===-1&&(i.push(r),r.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let i of e)this.dropRequireFailure(i);return this}let r;if(typeof e=="string"?r=this.manager.get(e):r=e,r){let i=this.requireFail.indexOf(r);i>-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;let{state:r}=this;r<O.Ended&&this.manager.emit(this.options.event+vh(r),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),r>=O.Ended&&this.manager.emit(this.options.event+vh(r),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=O.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(O.Failed|O.Possible)))return!1;e++}return!0}recognize(e){let r={...e};if(!this.options.enable){this.reset(),this.state=O.Failed;return}this.state&(O.Recognized|O.Cancelled|O.Failed)&&(this.state=O.Possible),this.state=this.process(r),this.state&(O.Began|O.Changed|O.Ended|O.Cancelled)&&this.tryEmit(r)}getEventNames(){return[this.options.event]}reset(){}};var Ct=class extends Mt{attrTest(e){let r=this.options.pointers;return r===0||e.pointers.length===r}process(e){let{state:r}=this,{eventType:i}=e,s=r&(O.Began|O.Changed),o=this.attrTest(e);return s&&(i&$.Cancel||!o)?r|O.Cancelled:s||o?i&$.End?r|O.Ended:r&O.Began?r|O.Changed:O.Began:O.Failed}};var Nr=class extends Mt{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[Fs]}process(e){let{options:r}=this,i=e.pointers.length===r.pointers,s=e.distance<r.threshold,o=e.deltaTime<r.time;if(this.reset(),e.eventType&$.Start&&this.count===0)return this.failTimeout();if(s&&o&&i){if(e.eventType!==$.End)return this.failTimeout();let n=this.pTime?e.timeStamp-this.pTime<r.interval:!0,a=!this.pCenter||Jn(this.pCenter,e.center)<r.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!n?this.count=1:this.count+=1,this._input=e,this.count%r.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=O.Recognized,this.tryEmit(this._input)},r.interval),O.Began):O.Recognized}return O.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=O.Failed},this.options.interval),O.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===O.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var fE=["","start","move","end","cancel","up","down","left","right"],ir=class extends Ct{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Z.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,r=[];return e&Z.Horizontal&&r.push(Ls),e&Z.Vertical&&r.push(Bs),r}getEventNames(){return fE.map(e=>this.options.event+e)}directionTest(e){let{options:r}=this,i=!0,{distance:s}=e,{direction:o}=e,n=e.deltaX,a=e.deltaY;return o&r.direction||(r.direction&Z.Horizontal?(o=n===0?Z.None:n<0?Z.Left:Z.Right,i=n!==this.pX,s=Math.abs(e.deltaX)):(o=a===0?Z.None:a<0?Z.Up:Z.Down,i=a!==this.pY,s=Math.abs(e.deltaY))),e.direction=o,i&&s>r.threshold&&Boolean(o&r.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&O.Began)||!(this.state&O.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let r=Z[e.direction].toLowerCase();r&&(e.additionalEvent=this.options.event+r),super.emit(e)}};var hE=["","start","move","end","cancel","in","out"],bi=class extends Ct{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[Or]}getEventNames(){return hE.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&O.Began))}emit(e){if(e.scale!==1){let r=e.scale<1?"in":"out";e.additionalEvent=this.options.event+r}super.emit(e)}};var ft=class{constructor(e,r,i){this.element=e,this.callback=r,this.options=i}};var Pm=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",I6=typeof window<"u"?window:global;var gE=Pm.indexOf("firefox")!==-1,vm=4.000244140625,mE=40,_E=.25,ra=class extends ft{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=s=>{if(!this.options.enable)return;let o=s.deltaY;globalThis.WheelEvent&&(gE&&s.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(o/=globalThis.devicePixelRatio),s.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(o*=mE)),o!==0&&o%vm===0&&(o=Math.floor(o/vm)),s.shiftKey&&o&&(o=o*_E),this.callback({type:"wheel",center:{x:s.clientX,y:s.clientY},delta:-o,srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,r){e==="wheel"&&(this.options.enable=r)}};var Mm=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],ia=class extends ft{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=o=>{this.handleOverEvent(o),this.handleOutEvent(o),this.handleEnterEvent(o),this.handleLeaveEvent(o),this.handleMoveEvent(o)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,Mm.forEach(o=>e.addEventListener(o,this.handleEvent))}destroy(){Mm.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){switch(e){case"pointermove":this.enableMoveEvent=r;break;case"pointerover":this.enableOverEvent=r;break;case"pointerout":this.enableOutEvent=r;break;case"pointerenter":this.enableEnterEvent=r;break;case"pointerleave":this.enableLeaveEvent=r;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var Cm=["keydown","keyup"],sa=class extends ft{constructor(e,r,i){super(e,r,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",Cm.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){Cm.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e==="keydown"&&(this.enableDownEvent=r),e==="keyup"&&(this.enableUpEvent=r)}};var oa=class extends ft{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e==="contextmenu"&&(this.options.enable=r)}};var yE={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},TE=0,bE=1,xE=2,AE=1,SE=2,EE=4;function Im(t){let e=yE[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,s=!1,o=!1,n=!1;return e===2?(s=Boolean(r&AE),o=Boolean(r&EE),n=Boolean(r&SE)):(s=i===TE,o=i===bE,n=i===xE),{leftButton:s,middleButton:o,rightButton:n}}function Om(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),s=i.width/e.offsetWidth||1,o=i.height/e.offsetHeight||1,n={x:(r.x-i.left-e.clientLeft)/s,y:(r.y-i.top-e.clientTop)/o};return{center:r,offsetCenter:n}}var wE={srcElement:"root",priority:0},na=class{constructor(e,r){this.handleEvent=i=>{if(this.isEmpty())return;let s=this._normalizeEvent(i),o=i.srcEvent.target;for(;o&&o!==s.rootElement;){if(this._emit(s,o),s.handled)return;o=o.parentNode}this._emit(s,"root")},this.eventManager=e,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,s=!1,o=!1){let{handlers:n,handlersByElement:a}=this,c={...wE,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let f={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};s&&(f.once=!0),o&&(f.passive=!0),n.push(f),this._active=this._active||!f.passive;let h=l.length-1;for(;h>=0&&!(l[h].priority>=f.priority);)h--;l.splice(h+1,0,f)}remove(e,r){let{handlers:i,handlersByElement:s}=this;for(let o=i.length-1;o>=0;o--){let n=i[o];if(n.type===e&&n.handler===r){i.splice(o,1);let a=s.get(n.srcElement);a.splice(a.indexOf(n),1),a.length===0&&s.delete(n.srcElement)}}this._active=i.some(o=>!o.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let s=!1,o=()=>{e.handled=!0},n=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c<i.length;c++){let{type:l,handler:f,once:h}=i[c];if(f({...e,type:l,stopPropagation:o,stopImmediatePropagation:n}),h&&a.push(i[c]),s)break}for(let c=0;c<a.length;c++){let{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){let r=this.eventManager.getElement();return{...e,...Im(e),...Om(e,r),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function RE(t){if("recognizer"in t)return t;let e,r=Array.isArray(t)?[...t]:[t];if(typeof r[0]=="function"){let i=r.shift(),s=r.shift()||{};e=new i(s)}else e=r.shift();return{recognizer:e,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var Ws=class{constructor(e=null,r={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=e,!!e){this.manager=new zs(e,this.options);for(let i of this.options.recognizers){let{recognizer:s,recognizeWith:o,requireFailure:n}=RE(i);this.manager.add(s),o&&s.recognizeWith(o),n&&s.requireFailure(n)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new ra(e,this._onOtherEvent,{enable:!1}),this.moveInput=new ia(e,this._onOtherEvent,{enable:!1}),this.keyInput=new sa(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new oa(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let s=i.get(e);s&&(s.set({enable:r}),i.touchAction.update()),this.wheelInput?.enableEventType(e,r),this.moveInput?.enableEventType(e,r),this.keyInput?.enableEventType(e,r),this.contextmenuInput?.enableEventType(e,r)}_addEventHandler(e,r,i,s,o){if(typeof e!="string"){i=r;for(let[l,f]of Object.entries(e))this._addEventHandler(l,f,i,s,o);return}let{manager:n,events:a}=this;if(!n)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new na(this,l),a.set(e,c),n&&n.on(e,c.handleEvent)}c.add(e,r,i,s,o),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let[o,n]of Object.entries(e))this._removeEventHandler(o,n);return}let{events:i}=this,s=i.get(e);if(s&&(s.remove(e,r),s.isEmpty())){let{recognizerName:o}=s,n=!1;for(let a of i.values())if(a.recognizerName===o&&!a.isEmpty()){n=!0;break}n||this._toggleRecognizer(o,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(r=>r.getEventNames().includes(e))?.options.event}};var k={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(k,"IDENTITY",{get:()=>(L.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var oe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},sr={common:0,meters:1,pixels:2},js={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Mh={multipan:[ir,{threshold:10,direction:Z.Vertical,pointers:2}],pinch:[bi,{},null,["multipan"]],pan:[ir,{threshold:1},["pinch"],["multipan"]],dblclick:[Nr,{event:"dblclick",taps:2}],click:[Nr,{event:"click"},null,["dblclick"]]},Nm={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function PE(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i<r;i++)if(t[i]!==e[i])return!1;return!0}return!1}function Be(t){let e={},r;return i=>{for(let s in i)if(!PE(i[s],e[s])){r=t(i),e=i;break}return r}}var Dm=[0,0,0,0],vE=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],Fm=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],ME=[0,0,0],Bm=[0,0,0],CE=Be(OE);function Ch(t,e,r=Bm){r.length<3&&(r=[r[0],r[1],0]);let i=r,s,o=!0;switch(e===k.LNGLAT_OFFSETS||e===k.METER_OFFSETS?s=r:s=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case oe.WEB_MERCATOR:(e===k.LNGLAT||e===k.CARTESIAN)&&(s=[0,0,0],o=!1);break;case oe.WEB_MERCATOR_AUTO_OFFSET:e===k.LNGLAT?i=s:e===k.CARTESIAN&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],s=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case oe.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case oe.GLOBE:o=!1,s=null;break;default:o=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:i,offsetMode:o}}function IE(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:s}=t,{viewMatrix:o,viewProjectionMatrix:n}=t,a=Dm,c=Dm,l=t.cameraPosition,{geospatialOrigin:f,shaderCoordinateOrigin:h,offsetMode:u}=Ch(t,e,r);return u&&(c=t.projectPosition(f||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=xe.transformMat4([],c,n),o=i||o,n=re.multiply([],s,o),n=re.multiply([],n,vE)),{viewMatrix:o,viewProjectionMatrix:n,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:f}}function aa({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i=k.DEFAULT,coordinateOrigin:s=Bm,autoWrapLongitude:o=!1}){i===k.DEFAULT&&(i=t.isGeospatial?k.LNGLAT:k.CARTESIAN);let n=CE({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:s});return n.wrapLongitude=o,n.modelMatrix=r||Fm,n}function OE({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:s,viewProjectionMatrix:o,originCommon:n,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=IE(t,r,i),f=t.getDistanceScales(),h=[t.width*e,t.height*e],u=xe.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={coordinateSystem:r,projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:n.slice(0,3),center:s,pseudoMeters:Boolean(t._pseudoMeters),viewportSize:h,devicePixelRatio:e,focalDistance:u,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:ME,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:o,modelMatrix:Fm,cameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case k.METER_OFFSETS:d.commonUnitsPerWorldUnit=p.unitsPerMeter,d.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case k.LNGLAT:case k.LNGLAT_OFFSETS:t._pseudoMeters||(d.commonUnitsPerMeter=p.unitsPerMeter),d.commonUnitsPerWorldUnit=p.unitsPerDegree,d.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case k.CARTESIAN:d.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var NE=Object.keys(k).map(t=>`const COORDINATE_SYSTEM_${t}: i32 = ${k[t]};`).join(""),DE=Object.keys(oe).map(t=>`const PROJECTION_MODE_${t}: i32 = ${oe[t]};`).join(""),FE=Object.keys(sr).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${sr[t]};`).join(""),BE=`${NE}
|
|
1004
|
-
${
|
|
1005
|
-
${
|
|
1251
|
+
`,oa={name:"geometry",source:Bw,vs:Fw,fs:Lw};var $;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})($||($={}));var K;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(K||(K={}));var N;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})(N||(N={}));var n_="compute",Yh="auto",Vs="manipulation",Br="none",zs="pan-x",Ws="pan-y";function Kh(t){if(t.includes(Br))return Br;let e=t.includes(zs),r=t.includes(Ws);return e&&r?Br:e||r?e?zs:Ws:t.includes(Vs)?Vs:Yh}var js=class{constructor(e,r){this.actions="",this.manager=e,this.set(r)}set(e){e===n_&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let r of this.manager.recognizers)r.options.enable&&(e=e.concat(r.getTouchAction()));return Kh(e.join(" "))}};function Ri(t){return t.trim().split(/\s+/g)}function na(t,e,r){if(t)for(let i of Ri(e))t.addEventListener(i,r,!1)}function aa(t,e,r){if(t)for(let i of Ri(e))t.removeEventListener(i,r,!1)}function Zh(t){return(t.ownerDocument||t).defaultView}function qh(t,e){let r=t;for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function ca(t){let e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let r=0,i=0,s=0;for(;s<e;)r+=t[s].clientX,i+=t[s].clientY,s++;return{x:Math.round(r/e),y:Math.round(i/e)}}function Gh(t){let e=[],r=0;for(;r<t.pointers.length;)e[r]={clientX:Math.round(t.pointers[r].clientX),clientY:Math.round(t.pointers[r].clientY)},r++;return{timeStamp:Date.now(),pointers:e,center:ca(e),deltaX:t.deltaX,deltaY:t.deltaY}}function la(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.sqrt(r*r+i*i)}function Qh(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(r*r+i*i)}function a_(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.atan2(i,r)*180/Math.PI}function Jh(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.atan2(i,r)*180/Math.PI}function fa(t,e){return t===e?K.None:Math.abs(t)>=Math.abs(e)?t<0?K.Left:K.Right:e<0?K.Up:K.Down}function c_(t,e){let r=e.center,i=t.offsetDelta,s=t.prevDelta,o=t.prevInput;return(e.eventType===$.Start||o?.eventType===$.End)&&(s=t.prevDelta={x:o?.deltaX||0,y:o?.deltaY||0},i=t.offsetDelta={x:r.x,y:r.y}),{deltaX:s.x+(r.x-i.x),deltaY:s.y+(r.y-i.y)}}function ha(t,e,r){return{x:e/t||0,y:r/t||0}}function l_(t,e){return Qh(e[0],e[1])/Qh(t[0],t[1])}function f_(t,e){return Jh(e[1],e[0])-Jh(t[1],t[0])}function h_(t,e){let r=t.lastInterval||e,i=e.timeStamp-r.timeStamp,s,o,n,a;if(e.eventType!==$.Cancel&&(i>25||r.velocity===void 0)){let c=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,f=ha(i,c,l);o=f.x,n=f.y,s=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=fa(c,l),t.lastInterval=e}else s=r.velocity,o=r.velocityX,n=r.velocityY,a=r.direction;e.velocity=s,e.velocityX=o,e.velocityY=n,e.direction=a}function u_(t,e){let{session:r}=t,{pointers:i}=e,{length:s}=i;r.firstInput||(r.firstInput=Gh(e)),s>1&&!r.firstMultiple?r.firstMultiple=Gh(e):s===1&&(r.firstMultiple=!1);let{firstInput:o,firstMultiple:n}=r,a=n?n.center:o.center,c=e.center=ca(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=a_(a,c),e.distance=la(a,c);let{deltaX:l,deltaY:f}=c_(r,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=fa(e.deltaX,e.deltaY);let h=ha(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,e.scale=n?l_(n.pointers,i):1,e.rotation=n?f_(n.pointers,i):0,e.maxPointers=r.prevInput?e.pointers.length>r.prevInput.maxPointers?e.pointers.length:r.prevInput.maxPointers:e.pointers.length;let u=t.element;return qh(e.srcEvent.target,u)&&(u=e.srcEvent.target),e.target=u,h_(r,e),e}function d_(t,e,r){let i=r.pointers.length,s=r.changedPointers.length,o=e&$.Start&&i-s===0,n=e&($.End|$.Cancel)&&i-s===0;r.isFirst=Boolean(o),r.isFinal=Boolean(n),o&&(t.session={}),r.eventType=e;let a=u_(t,r);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}var Hs=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,r){d_(this.manager,e,r)}init(){na(this.element,this.evEl,this.domHandler),na(this.target,this.evTarget,this.domHandler),na(Zh(this.element),this.evWin,this.domHandler)}destroy(){aa(this.element,this.evEl,this.domHandler),aa(this.target,this.evTarget,this.domHandler),aa(Zh(this.element),this.evWin,this.domHandler)}};var kw={pointerdown:$.Start,pointermove:$.Move,pointerup:$.End,pointercancel:$.Cancel,pointerout:$.Cancel},Vw="pointerdown",zw="pointermove pointerup pointercancel",$s=class extends Hs{constructor(e){super(e),this.evEl=Vw,this.evWin=zw,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:r}=this,i=!1,s=kw[e.type],o=e.pointerType,n=o==="touch",a=r.findIndex(c=>c.pointerId===e.pointerId);s&$.Start&&(e.buttons||n)?a<0&&(r.push(e),a=r.length-1):s&($.End|$.Cancel)&&(i=!0),!(a<0)&&(r[a]=e,this.callback(s,{pointers:r,changedPointers:[e],eventType:s,pointerType:o,srcEvent:e}),i&&r.splice(a,1))}};var Ww=["","webkit","Moz","MS","ms","o"];function p_(t,e){let r=e[0].toUpperCase()+e.slice(1);for(let i of Ww){let s=i?i+r:e;if(s in t)return s}}var jw=1,g_=2,m_={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Xs=class{constructor(e,r){this.options={...m_,...r,cssProps:{...m_.cssProps,...r.cssProps},inputTarget:r.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new $s(this),this.touchAction=new js(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?g_:jw}recognize(e){let{session:r}=this;if(r.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:s}=this,{curRecognizer:o}=r;(!o||o&&o.state&N.Recognized)&&(o=r.curRecognizer=null);let n=0;for(;n<s.length;)i=s[n],r.stopped!==g_&&(!o||i===o||i.canRecognizeWith(o))?i.recognize(e):i.reset(),!o&&i.state&(N.Began|N.Changed|N.Ended)&&(o=r.curRecognizer=i),n++}get(e){let{recognizers:r}=this;for(let i=0;i<r.length;i++)if(r[i].options.event===e)return r[i];return null}add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this}let r=this.get(e.options.event);return r&&this.remove(r),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let i of e)this.remove(i);return this}let r=typeof e=="string"?this.get(e):e;if(r){let{recognizers:i}=this,s=i.indexOf(r);s!==-1&&(i.splice(s,1),this.touchAction.update())}return this}on(e,r){if(!e||!r)return;let{handlers:i}=this;for(let s of Ri(e))i[s]=i[s]||[],i[s].push(r)}off(e,r){if(!e)return;let{handlers:i}=this;for(let s of Ri(e))r?i[s]&&i[s].splice(i[s].indexOf(r),1):delete i[s]}emit(e,r){let i=this.handlers[e]&&this.handlers[e].slice();if(!i||!i.length)return;let s=r;s.type=e,s.preventDefault=function(){r.srcEvent.preventDefault()};let o=0;for(;o<i.length;)i[o](s),o++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:r}=this;if(r){for(let[i,s]of Object.entries(this.options.cssProps)){let o=p_(r.style,i);e?(this.oldCssProps[o]=r.style[o],r.style[o]=s):r.style[o]=this.oldCssProps[o]||""}e||(this.oldCssProps={})}}};var Hw=1;function __(){return Hw++}function eu(t){return t&N.Cancelled?"cancel":t&N.Ended?"end":t&N.Changed?"move":t&N.Began?"start":""}var Ot=class{constructor(e){this.options=e,this.id=__(),this.state=N.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let s of e)this.recognizeWith(s);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{simultaneous:i}=this;return i[r.id]||(i[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let i of e)this.dropRecognizeWith(i);return this}let r;return typeof e=="string"?r=this.manager.get(e):r=e,r&&delete this.simultaneous[r.id],this}requireFailure(e){if(Array.isArray(e)){for(let s of e)this.requireFailure(s);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{requireFail:i}=this;return i.indexOf(r)===-1&&(i.push(r),r.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let i of e)this.dropRequireFailure(i);return this}let r;if(typeof e=="string"?r=this.manager.get(e):r=e,r){let i=this.requireFail.indexOf(r);i>-1&&this.requireFail.splice(i,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;let{state:r}=this;r<N.Ended&&this.manager.emit(this.options.event+eu(r),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),r>=N.Ended&&this.manager.emit(this.options.event+eu(r),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=N.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(N.Failed|N.Possible)))return!1;e++}return!0}recognize(e){let r={...e};if(!this.options.enable){this.reset(),this.state=N.Failed;return}this.state&(N.Recognized|N.Cancelled|N.Failed)&&(this.state=N.Possible),this.state=this.process(r),this.state&(N.Began|N.Changed|N.Ended|N.Cancelled)&&this.tryEmit(r)}getEventNames(){return[this.options.event]}reset(){}};var Nt=class extends Ot{attrTest(e){let r=this.options.pointers;return r===0||e.pointers.length===r}process(e){let{state:r}=this,{eventType:i}=e,s=r&(N.Began|N.Changed),o=this.attrTest(e);return s&&(i&$.Cancel||!o)?r|N.Cancelled:s||o?i&$.End?r|N.Ended:r&N.Began?r|N.Changed:N.Began:N.Failed}};var Fr=class extends Ot{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[Vs]}process(e){let{options:r}=this,i=e.pointers.length===r.pointers,s=e.distance<r.threshold,o=e.deltaTime<r.time;if(this.reset(),e.eventType&$.Start&&this.count===0)return this.failTimeout();if(s&&o&&i){if(e.eventType!==$.End)return this.failTimeout();let n=this.pTime?e.timeStamp-this.pTime<r.interval:!0,a=!this.pCenter||la(this.pCenter,e.center)<r.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!n?this.count=1:this.count+=1,this._input=e,this.count%r.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=N.Recognized,this.tryEmit(this._input)},r.interval),N.Began):N.Recognized}return N.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=N.Failed},this.options.interval),N.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===N.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var $w=["","start","move","end","cancel","up","down","left","right"],cr=class extends Nt{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:K.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,r=[];return e&K.Horizontal&&r.push(Ws),e&K.Vertical&&r.push(zs),r}getEventNames(){return $w.map(e=>this.options.event+e)}directionTest(e){let{options:r}=this,i=!0,{distance:s}=e,{direction:o}=e,n=e.deltaX,a=e.deltaY;return o&r.direction||(r.direction&K.Horizontal?(o=n===0?K.None:n<0?K.Left:K.Right,i=n!==this.pX,s=Math.abs(e.deltaX)):(o=a===0?K.None:a<0?K.Up:K.Down,i=a!==this.pY,s=Math.abs(e.deltaY))),e.direction=o,i&&s>r.threshold&&Boolean(o&r.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&N.Began)||!(this.state&N.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let r=K[e.direction].toLowerCase();r&&(e.additionalEvent=this.options.event+r),super.emit(e)}};var Xw=["","start","move","end","cancel","in","out"],Pi=class extends Nt{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[Br]}getEventNames(){return Xw.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&N.Began))}emit(e){if(e.scale!==1){let r=e.scale<1?"in":"out";e.additionalEvent=this.options.event+r}super.emit(e)}};var gt=class{constructor(e,r,i){this.element=e,this.callback=r,this.options=i}};var y_=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",L5=typeof window<"u"?window:global;var qw=y_.indexOf("firefox")!==-1,b_=4.000244140625,Gw=40,Qw=.25,ua=class extends gt{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=s=>{if(!this.options.enable)return;let o=s.deltaY;globalThis.WheelEvent&&(qw&&s.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(o/=globalThis.devicePixelRatio),s.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(o*=Gw)),o!==0&&o%b_===0&&(o=Math.floor(o/b_)),s.shiftKey&&o&&(o=o*Qw),this.callback({type:"wheel",center:{x:s.clientX,y:s.clientY},delta:-o,srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,r){e==="wheel"&&(this.options.enable=r)}};var T_=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],da=class extends gt{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=o=>{this.handleOverEvent(o),this.handleOutEvent(o),this.handleEnterEvent(o),this.handleLeaveEvent(o),this.handleMoveEvent(o)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,T_.forEach(o=>e.addEventListener(o,this.handleEvent))}destroy(){T_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){switch(e){case"pointermove":this.enableMoveEvent=r;break;case"pointerover":this.enableOverEvent=r;break;case"pointerout":this.enableOutEvent=r;break;case"pointerenter":this.enableEnterEvent=r;break;case"pointerleave":this.enableLeaveEvent=r;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var x_=["keydown","keyup"],pa=class extends gt{constructor(e,r,i){super(e,r,{enable:!0,tabIndex:0,...i}),this.handleEvent=s=>{let o=s.target||s.srcElement;o.tagName==="INPUT"&&o.type==="text"||o.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",x_.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){x_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e==="keydown"&&(this.enableDownEvent=r),e==="keyup"&&(this.enableUpEvent=r)}};var ga=class extends gt{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e==="contextmenu"&&(this.options.enable=r)}};var Jw={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},eR=0,tR=1,rR=2,iR=1,sR=2,oR=4;function A_(t){let e=Jw[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,s=!1,o=!1,n=!1;return e===2?(s=Boolean(r&iR),o=Boolean(r&oR),n=Boolean(r&sR)):(s=i===eR,o=i===tR,n=i===rR),{leftButton:s,middleButton:o,rightButton:n}}function S_(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),s=i.width/e.offsetWidth||1,o=i.height/e.offsetHeight||1,n={x:(r.x-i.left-e.clientLeft)/s,y:(r.y-i.top-e.clientTop)/o};return{center:r,offsetCenter:n}}var nR={srcElement:"root",priority:0},ma=class{constructor(e,r){this.handleEvent=i=>{if(this.isEmpty())return;let s=this._normalizeEvent(i),o=i.srcEvent.target;for(;o&&o!==s.rootElement;){if(this._emit(s,o),s.handled)return;o=o.parentNode}this._emit(s,"root")},this.eventManager=e,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,s=!1,o=!1){let{handlers:n,handlersByElement:a}=this,c={...nR,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let f={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};s&&(f.once=!0),o&&(f.passive=!0),n.push(f),this._active=this._active||!f.passive;let h=l.length-1;for(;h>=0&&!(l[h].priority>=f.priority);)h--;l.splice(h+1,0,f)}remove(e,r){let{handlers:i,handlersByElement:s}=this;for(let o=i.length-1;o>=0;o--){let n=i[o];if(n.type===e&&n.handler===r){i.splice(o,1);let a=s.get(n.srcElement);a.splice(a.indexOf(n),1),a.length===0&&s.delete(n.srcElement)}}this._active=i.some(o=>!o.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let s=!1,o=()=>{e.handled=!0},n=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c<i.length;c++){let{type:l,handler:f,once:h}=i[c];if(f({...e,type:l,stopPropagation:o,stopImmediatePropagation:n}),h&&a.push(i[c]),s)break}for(let c=0;c<a.length;c++){let{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){let r=this.eventManager.getElement();return{...e,...A_(e),...S_(e,r),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function aR(t){if("recognizer"in t)return t;let e,r=Array.isArray(t)?[...t]:[t];if(typeof r[0]=="function"){let i=r.shift(),s=r.shift()||{};e=new i(s)}else e=r.shift();return{recognizer:e,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var Ys=class{constructor(e=null,r={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=e,!!e){this.manager=new Xs(e,this.options);for(let i of this.options.recognizers){let{recognizer:s,recognizeWith:o,requireFailure:n}=aR(i);this.manager.add(s),o&&s.recognizeWith(o),n&&s.requireFailure(n)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new ua(e,this._onOtherEvent,{enable:!1}),this.moveInput=new da(e,this._onOtherEvent,{enable:!1}),this.keyInput=new pa(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new ga(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let s=i.get(e);s&&(s.set({enable:r}),i.touchAction.update()),this.wheelInput?.enableEventType(e,r),this.moveInput?.enableEventType(e,r),this.keyInput?.enableEventType(e,r),this.contextmenuInput?.enableEventType(e,r)}_addEventHandler(e,r,i,s,o){if(typeof e!="string"){i=r;for(let[l,f]of Object.entries(e))this._addEventHandler(l,f,i,s,o);return}let{manager:n,events:a}=this;if(!n)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new ma(this,l),a.set(e,c),n&&n.on(e,c.handleEvent)}c.add(e,r,i,s,o),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let[o,n]of Object.entries(e))this._removeEventHandler(o,n);return}let{events:i}=this,s=i.get(e);if(s&&(s.remove(e,r),s.isEmpty())){let{recognizerName:o}=s,n=!1;for(let a of i.values())if(a.recognizerName===o&&!a.isEmpty()){n=!0;break}n||this._toggleRecognizer(o,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(r=>r.getEventNames().includes(e))?.options.event}};var k={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(k,"IDENTITY",{get:()=>(F.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var se={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},lr={common:0,meters:1,pixels:2},vi={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},tu={multipan:[cr,{threshold:10,direction:K.Vertical,pointers:2}],pinch:[Pi,{},null,["multipan"]],pan:[cr,{threshold:1},["pinch"],["multipan"]],dblclick:[Fr,{event:"dblclick",taps:2}],click:[Fr,{event:"click"},null,["dblclick"]]},E_={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function cR(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i<r;i++)if(t[i]!==e[i])return!1;return!0}return!1}function Ue(t){let e={},r;return i=>{for(let s in i)if(!cR(i[s],e[s])){r=t(i),e=i;break}return r}}var w_=[0,0,0,0],lR=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],R_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],fR=[0,0,0],P_=[0,0,0],hR=Ue(dR);function ru(t,e,r=P_){r.length<3&&(r=[r[0],r[1],0]);let i=r,s,o=!0;switch(e===k.LNGLAT_OFFSETS||e===k.METER_OFFSETS?s=r:s=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case se.WEB_MERCATOR:(e===k.LNGLAT||e===k.CARTESIAN)&&(s=[0,0,0],o=!1);break;case se.WEB_MERCATOR_AUTO_OFFSET:e===k.LNGLAT?i=s:e===k.CARTESIAN&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],s=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case se.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case se.GLOBE:o=!1,s=null;break;default:o=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:i,offsetMode:o}}function uR(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:s}=t,{viewMatrix:o,viewProjectionMatrix:n}=t,a=w_,c=w_,l=t.cameraPosition,{geospatialOrigin:f,shaderCoordinateOrigin:h,offsetMode:u}=ru(t,e,r);return u&&(c=t.projectPosition(f||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Ae.transformMat4([],c,n),o=i||o,n=re.multiply([],s,o),n=re.multiply([],n,lR)),{viewMatrix:o,viewProjectionMatrix:n,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:f}}function _a({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i=k.DEFAULT,coordinateOrigin:s=P_,autoWrapLongitude:o=!1}){i===k.DEFAULT&&(i=t.isGeospatial?k.LNGLAT:k.CARTESIAN);let n=hR({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:s});return n.wrapLongitude=o,n.modelMatrix=r||R_,n}function dR({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:s,viewProjectionMatrix:o,originCommon:n,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=uR(t,r,i),f=t.getDistanceScales(),h=[t.width*e,t.height*e],u=Ae.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={coordinateSystem:r,projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:n.slice(0,3),center:s,pseudoMeters:Boolean(t._pseudoMeters),viewportSize:h,devicePixelRatio:e,focalDistance:u,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:fR,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:o,modelMatrix:R_,cameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case k.METER_OFFSETS:d.commonUnitsPerWorldUnit=p.unitsPerMeter,d.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case k.LNGLAT:case k.LNGLAT_OFFSETS:t._pseudoMeters||(d.commonUnitsPerMeter=p.unitsPerMeter),d.commonUnitsPerWorldUnit=p.unitsPerDegree,d.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case k.CARTESIAN:d.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var pR=Object.keys(k).map(t=>`const COORDINATE_SYSTEM_${t}: i32 = ${k[t]};`).join(""),gR=Object.keys(se).map(t=>`const PROJECTION_MODE_${t}: i32 = ${se[t]};`).join(""),mR=Object.keys(lr).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${lr[t]};`).join(""),_R=`${pR}
|
|
1252
|
+
${gR}
|
|
1253
|
+
${mR}
|
|
1006
1254
|
|
|
1007
1255
|
const TILE_SIZE: f32 = 512.0;
|
|
1008
1256
|
const PI: f32 = 3.1415926536;
|
|
@@ -1034,14 +1282,13 @@ struct ProjectUniforms {
|
|
|
1034
1282
|
pseudoMeters: i32,
|
|
1035
1283
|
};
|
|
1036
1284
|
|
|
1037
|
-
@group(0) @binding(
|
|
1285
|
+
@group(0) @binding(auto)
|
|
1038
1286
|
var<uniform> project: ProjectUniforms;
|
|
1039
1287
|
|
|
1040
1288
|
// -----------------------------------------------------------------------------
|
|
1041
|
-
// Geometry data
|
|
1042
|
-
//
|
|
1043
|
-
//
|
|
1044
|
-
// uniform struct for demonstration.)
|
|
1289
|
+
// Geometry data shared across the project helpers.
|
|
1290
|
+
// The active layer shader is responsible for populating this private module
|
|
1291
|
+
// state before calling the project functions below.
|
|
1045
1292
|
// -----------------------------------------------------------------------------
|
|
1046
1293
|
|
|
1047
1294
|
// Structure to carry additional geometry data used by deck.gl filters.
|
|
@@ -1054,9 +1301,8 @@ struct Geometry {
|
|
|
1054
1301
|
pickingColor: vec3<f32>,
|
|
1055
1302
|
};
|
|
1056
1303
|
|
|
1057
|
-
// @group(0) @binding(1)
|
|
1058
1304
|
var<private> geometry: Geometry;
|
|
1059
|
-
`,
|
|
1305
|
+
`,v_=`${_R}
|
|
1060
1306
|
|
|
1061
1307
|
// -----------------------------------------------------------------------------
|
|
1062
1308
|
// Functions
|
|
@@ -1283,10 +1529,10 @@ fn project_pixel_size_float(pixels: f32) -> f32 {
|
|
|
1283
1529
|
fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
|
|
1284
1530
|
return pixels / project.scale;
|
|
1285
1531
|
}
|
|
1286
|
-
`;var
|
|
1287
|
-
${
|
|
1288
|
-
${
|
|
1289
|
-
uniform projectUniforms {
|
|
1532
|
+
`;var yR=Object.keys(k).map(t=>`const int COORDINATE_SYSTEM_${t} = ${k[t]};`).join(""),bR=Object.keys(se).map(t=>`const int PROJECTION_MODE_${t} = ${se[t]};`).join(""),TR=Object.keys(lr).map(t=>`const int UNIT_${t.toUpperCase()} = ${lr[t]};`).join(""),M_=`${yR}
|
|
1533
|
+
${bR}
|
|
1534
|
+
${TR}
|
|
1535
|
+
layout(std140) uniform projectUniforms {
|
|
1290
1536
|
bool wrapLongitude;
|
|
1291
1537
|
int coordinateSystem;
|
|
1292
1538
|
vec3 commonUnitsPerMeter;
|
|
@@ -1477,7 +1723,7 @@ return pixels / project.scale;
|
|
|
1477
1723
|
vec2 project_pixel_size(vec2 pixels) {
|
|
1478
1724
|
return pixels / project.scale;
|
|
1479
1725
|
}
|
|
1480
|
-
`;var
|
|
1726
|
+
`;var xR={};function AR(t=xR){return"viewport"in t?_a(t):{}}var fr={name:"project",dependencies:[Wf,oa],source:v_,vs:M_,getUniforms:AR,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}};var SR=`// Define a structure to hold both the clip-space position and the common position.
|
|
1481
1727
|
struct ProjectResult {
|
|
1482
1728
|
clipPosition: vec4<f32>,
|
|
1483
1729
|
commonPosition: vec4<f32>,
|
|
@@ -1520,7 +1766,7 @@ fn project_position_to_clipspace(
|
|
|
1520
1766
|
) -> vec4<f32> {
|
|
1521
1767
|
return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;
|
|
1522
1768
|
}
|
|
1523
|
-
`,
|
|
1769
|
+
`,ER=`vec4 project_position_to_clipspace(
|
|
1524
1770
|
vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
|
|
1525
1771
|
) {
|
|
1526
1772
|
vec3 projectedPosition = project_position(position, position64Low);
|
|
@@ -1540,8 +1786,8 @@ vec4 project_position_to_clipspace(
|
|
|
1540
1786
|
vec4 commonPosition;
|
|
1541
1787
|
return project_position_to_clipspace(position, position64Low, offset, commonPosition);
|
|
1542
1788
|
}
|
|
1543
|
-
`,
|
|
1544
|
-
uniform shadowUniforms {
|
|
1789
|
+
`,iu={name:"project32",dependencies:[fr],source:SR,vs:ER};function su(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function hr(t,e){let r=Ae.transformMat4([],e,t);return Ae.scale(r,r,1/r[3]),r}function C_(t,e,r){return r*e+(1-r)*t}function Ks(t,e,r){return t<e?e:t>r?r:t}function wR(t){return Math.log(t)*Math.LOG2E}var Zs=Math.log2||wR;function $e(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Xe=Math.PI,I_=Xe/4,ke=Xe/180,ou=180/Xe,Mi=512,ya=4003e4,_e=85.051129,O_=1.5;function qs(t){return Math.pow(2,t)}function ba(t){return Zs(t)}function Se(t){let[e,r]=t;$e(Number.isFinite(e)),$e(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*ke,s=r*ke,o=Mi*(i+Xe)/(2*Xe),n=Mi*(Xe+Math.log(Math.tan(I_+s*.5)))/(2*Xe);return[o,n]}function ye(t){let[e,r]=t,i=e/Mi*(2*Xe)-Xe,s=2*(Math.atan(Math.exp(r/Mi*(2*Xe)-Xe))-I_);return[i*ou,s*ou]}function Gs(t){let{latitude:e}=t;$e(Number.isFinite(e));let r=Math.cos(e*ke);return ba(ya*r)-9}function Qs(t){let e=Math.cos(t*ke);return Mi/ya/e}function Ci(t){let{latitude:e,longitude:r,highPrecision:i=!1}=t;$e(Number.isFinite(e)&&Number.isFinite(r));let s=Mi,o=Math.cos(e*ke),n=s/360,a=n/o,c=s/ya/o,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[n,a,c],degreesPerUnit:[1/n,1/a,1/c]};if(i){let f=ke*Math.tan(e*ke)/o,h=n*f/2,u=s/ya*f,d=u/a*c;l.unitsPerDegree2=[0,h,u],l.unitsPerMeter2=[d,0,d]}return l}function Js(t,e){let[r,i,s]=t,[o,n,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=Ci({longitude:r,latitude:i,highPrecision:!0}),f=Se(t);f[0]+=o*(c[0]+l[0]*n),f[1]+=n*(c[1]+l[1]*n);let h=ye(f),u=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[h[0],h[1],u]:h}function Ta(t){let{height:e,pitch:r,bearing:i,altitude:s,scale:o,center:n}=t,a=su();re.translate(a,a,[0,0,-s]),re.rotateX(a,a,-r*ke),re.rotateZ(a,a,i*ke);let c=o/e;return re.scale(a,a,[c,c,c]),n&&re.translate(a,a,ge.negate([],n)),a}function nu(t){let{width:e,height:r,altitude:i,pitch:s=0,offset:o,center:n,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:f=Dt(O_)}=t;i!==void 0&&(f=Dt(i));let h=f*ke,u=s*ke,d=Bt(f),p=d;n&&(p+=n[2]*a/Math.cos(u)/r);let g=h*(.5+(o?o[1]:0)/r),m=Math.sin(g)*p/Math.sin(Ks(Math.PI/2-u-g,.01,Math.PI-.01)),_=Math.sin(u)*m+p,b=p*10,y=Math.min(_*l,b);return{fov:h,aspect:e/r,focalDistance:d,near:c,far:y}}function Dt(t){return 2*Math.atan(.5/t)*ou}function Bt(t){return .5/Math.tan(.5*t*ke)}function Ii(t,e){let[r,i,s=0]=t;return $e(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(s)),hr(e,[r,i,s,1])}function Ve(t,e,r=0){let[i,s,o]=t;if($e(Number.isFinite(i)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(o))return hr(e,[i,s,o,1]);let n=hr(e,[i,s,0,1]),a=hr(e,[i,s,1,1]),c=n[2],l=a[2],f=c===l?0:((r||0)-c)/(l-c);return ee.lerp([],n,a,f)}function xa(t){let{width:e,height:r,bounds:i,minExtent:s=0,maxZoom:o=24,offset:n=[0,0]}=t,[[a,c],[l,f]]=i,h=RR(t.padding),u=Se([a,Ks(f,-_e,_e)]),d=Se([l,Ks(c,-_e,_e)]),p=[Math.max(Math.abs(d[0]-u[0]),s),Math.max(Math.abs(d[1]-u[1]),s)],g=[e-h.left-h.right-Math.abs(n[0])*2,r-h.top-h.bottom-Math.abs(n[1])*2];$e(g[0]>0&&g[1]>0);let m=g[0]/p[0],_=g[1]/p[1],b=(h.right-h.left)/2/m,y=(h.top-h.bottom)/2/_,T=[(d[0]+u[0])/2+b,(d[1]+u[1])/2+y],S=ye(T),A=Math.min(o,Zs(Math.abs(Math.min(m,_))));return $e(Number.isFinite(A)),{longitude:S[0],latitude:S[1],zoom:A}}function RR(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:($e(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var N_=Math.PI/180;function Aa(t,e=0){let{width:r,height:i,unproject:s}=t,o={targetZ:e},n=s([0,i],o),a=s([r,i],o),c,l,f=t.fovy?.5*t.fovy*N_:Math.atan(.5/t.altitude),h=(90-t.pitch)*N_;return f>h-.01?(c=D_(t,0,e),l=D_(t,r,e)):(c=s([0,0],o),l=s([r,0],o)),[n,a,l,c]}function D_(t,e,r){let{pixelUnprojectionMatrix:i}=t,s=hr(i,[e,0,1,1]),o=hr(i,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-s[2])/(o[2]-s[2]),c=ee.lerp([],s,o,a),l=ye(c);return l.push(r),l}var B_=.01,vR=["longitude","latitude","zoom"],F_={curve:1.414,speed:1.2};function au(t,e,r,i){let{startZoom:s,startCenterXY:o,uDelta:n,w0:a,u1:c,S:l,rho:f,rho2:h,r0:u}=L_(t,e,i);if(c<B_){let T={};for(let S of vR){let A=t[S],w=e[S];T[S]=C_(A,w,r)}return T}let d=r*l,p=Math.cosh(u)/Math.cosh(u+f*d),g=a*((Math.cosh(u)*Math.tanh(u+f*d)-Math.sinh(u))/h)/c,m=1/p,_=s+ba(m),b=ee.scale([],n,g);ee.add(b,b,o);let y=ye(b);return{longitude:y[0],latitude:y[1],zoom:_}}function cu(t,e,r){let i={...F_,...r},{screenSpeed:s,speed:o,maxDuration:n}=i,{S:a,rho:c}=L_(t,e,i),l=1e3*a,f;return Number.isFinite(s)?f=l/(s/c):f=l/o,Number.isFinite(n)&&f>n?0:f}function L_(t,e,r){r=Object.assign({},F_,r);let i=r.curve,s=t.zoom,o=[t.longitude,t.latitude],n=qs(s),a=e.zoom,c=[e.longitude,e.latitude],l=qs(a-s),f=Se(o),h=Se(c),u=ee.sub([],h,f),d=Math.max(t.width,t.height),p=d/l,g=ee.length(u)*n,m=Math.max(g,B_),_=i*i,b=(p*p-d*d+_*_*m*m)/(2*d*_*m),y=(p*p-d*d-_*_*m*m)/(2*p*_*m),T=Math.log(Math.sqrt(b*b+1)-b),S=Math.log(Math.sqrt(y*y+1)-y),A=(S-T)/i;return{startZoom:s,startCenterXY:f,uDelta:u,w0:d,u1:g,S:A,rho:i,rho2:_,r0:T,r1:S}}var U_=`
|
|
1790
|
+
layout(std140) uniform shadowUniforms {
|
|
1545
1791
|
bool drawShadowMap;
|
|
1546
1792
|
bool useShadowMap;
|
|
1547
1793
|
vec4 color;
|
|
@@ -1552,7 +1798,7 @@ uniform shadowUniforms {
|
|
|
1552
1798
|
vec4 projectCenter0;
|
|
1553
1799
|
vec4 projectCenter1;
|
|
1554
1800
|
} shadow;
|
|
1555
|
-
`,
|
|
1801
|
+
`,CR=`
|
|
1556
1802
|
const int max_lights = 2;
|
|
1557
1803
|
|
|
1558
1804
|
out vec3 shadow_vPosition[max_lights];
|
|
@@ -1578,10 +1824,10 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) {
|
|
|
1578
1824
|
}
|
|
1579
1825
|
return gl_Position;
|
|
1580
1826
|
}
|
|
1581
|
-
`,
|
|
1582
|
-
${
|
|
1583
|
-
${
|
|
1584
|
-
`,
|
|
1827
|
+
`,IR=`
|
|
1828
|
+
${U_}
|
|
1829
|
+
${CR}
|
|
1830
|
+
`,OR=`
|
|
1585
1831
|
const int max_lights = 2;
|
|
1586
1832
|
uniform sampler2D shadow_uShadowMap0;
|
|
1587
1833
|
uniform sampler2D shadow_uShadowMap1;
|
|
@@ -1621,14 +1867,40 @@ vec4 shadow_filterShadowColor(vec4 color) {
|
|
|
1621
1867
|
}
|
|
1622
1868
|
return color;
|
|
1623
1869
|
}
|
|
1624
|
-
`,
|
|
1625
|
-
${
|
|
1626
|
-
${
|
|
1627
|
-
`,
|
|
1870
|
+
`,NR=`
|
|
1871
|
+
${U_}
|
|
1872
|
+
${OR}
|
|
1873
|
+
`,DR=Ue(kR),BR=Ue(VR),FR=[0,0,0,1],LR=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function UR(t,e){let[r,i,s]=t,o=Ve([r,i,s],e);return Number.isFinite(s)?o:[o[0],o[1],0]}function kR({viewport:t,center:e}){return new z(t.viewProjectionMatrix).invert().transform(e)}function VR({viewport:t,shadowMatrices:e}){let r=[],i=t.pixelUnprojectionMatrix,s=t.isGeospatial?void 0:1,o=[[0,0,s],[t.width,0,s],[0,t.height,s],[t.width,t.height,s],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(n=>UR(n,i));for(let n of e){let a=n.clone().translate(new H(t.center).negate()),c=o.map(f=>a.transform(f)),l=new z().ortho({left:Math.min(...c.map(f=>f[0])),right:Math.max(...c.map(f=>f[0])),bottom:Math.min(...c.map(f=>f[1])),top:Math.max(...c.map(f=>f[1])),near:Math.min(...c.map(f=>-f[2])),far:Math.max(...c.map(f=>-f[2]))});r.push(l.multiplyRight(n))}return r}function zR(t){let{shadowEnabled:e=!0,project:r}=t;if(!e||!r||!t.shadowMatrices||!t.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let i=fr.getUniforms(r),s=DR({viewport:r.viewport,center:i.center}),o=[],n=BR({shadowMatrices:t.shadowMatrices,viewport:r.viewport}).slice();for(let c=0;c<t.shadowMatrices.length;c++){let l=n[c],f=l.clone().translate(new H(r.viewport.center).negate());i.coordinateSystem===k.LNGLAT&&i.projectionMode===se.WEB_MERCATOR?(n[c]=f,o[c]=s):(n[c]=l.clone().multiplyRight(LR),o[c]=f.transform(s))}let a={drawShadowMap:Boolean(t.drawToShadowMap),useShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,color:t.shadowColor||FR,lightId:t.shadowLightId||0,lightCount:t.shadowMatrices.length,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};for(let c=0;c<n.length;c++)a[`viewProjectionMatrix${c}`]=n[c],a[`projectCenter${c}`]=o[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=t.shadowMaps&&t.shadowMaps[c]||t.dummyShadowMap;return a}var Oi={name:"shadow",dependencies:[fr],vs:IR,fs:NR,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1628
1874
|
position = shadow_setVertexPosition(geometry.position);
|
|
1629
1875
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1630
1876
|
color = shadow_filterShadowColor(color);
|
|
1631
|
-
`},getUniforms:
|
|
1877
|
+
`},getUniforms:zR,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}};var WR=`struct pickingUniforms {
|
|
1878
|
+
isActive: f32,
|
|
1879
|
+
isAttribute: f32,
|
|
1880
|
+
isHighlightActive: f32,
|
|
1881
|
+
useFloatColors: f32,
|
|
1882
|
+
highlightedObjectColor: vec3<f32>,
|
|
1883
|
+
highlightColor: vec4<f32>,
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
@group(0) @binding(auto) var<uniform> picking: pickingUniforms;
|
|
1887
|
+
|
|
1888
|
+
fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {
|
|
1889
|
+
return select(color / 255.0, color, picking.useFloatColors > 0.5);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {
|
|
1893
|
+
return select(color / 255.0, color, picking.useFloatColors > 0.5);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
fn picking_isColorZero(color: vec3<f32>) -> bool {
|
|
1897
|
+
return dot(color, vec3<f32>(1.0)) < 0.00001;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
1901
|
+
return dot(color, vec3<f32>(1.0)) > 0.00001;
|
|
1902
|
+
}
|
|
1903
|
+
`,lu={...Dn,source:WR,defaultUniforms:{...Dn.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1632
1904
|
// for picking depth values
|
|
1633
1905
|
picking_setPickingAttribute(position.z / position.w);
|
|
1634
1906
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
@@ -1639,10 +1911,10 @@ ${QE}
|
|
|
1639
1911
|
|
|
1640
1912
|
// use picking color if rendering to picking FBO.
|
|
1641
1913
|
color = picking_filterPickingColor(color);
|
|
1642
|
-
`}}};var aw=[Kn],cw=["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)"],lw=[];function da(t){let e=Kt.getDefaultShaderAssembler();for(let i of aw)e.addDefaultModule(i);e._hookFunctions.length=0;let r=t==="glsl"?cw:lw;for(let i of r)e.addShaderHook(i);return e}var fw=[255,255,255],hw=1,uw=0,wi=class{constructor(e={}){this.type="ambient";let{color:r=fw}=e,{intensity:i=hw}=e;this.id=e.id||`ambient-${uw++}`,this.color=r,this.intensity=i}};var dw=[255,255,255],pw=1,gw=[0,0,-1],mw=0,Nt=class{constructor(e={}){this.type="directional";let{color:r=dw}=e,{intensity:i=pw}=e,{direction:s=gw}=e,{_shadow:o=!1}=e;this.id=e.id||`directional-${mw++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new H(s).normalize().toArray(),this.shadow=o}getProjectedLight(e){return this}};var Dr=class{constructor(e,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var $e=class extends Dr{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let r=this.device.canvasContext,i=e.target??r.getCurrentFramebuffer(),[s,o]=r.getDrawingBufferSize(),n=e.clearCanvas??!0,a=e.clearColor??(n?[0,0,0,0]:!1),c=n?1:!1,l=n?0:!1,f=e.colorMask??15,h={viewport:[0,0,s,o]};e.colorMask&&(h.colorMask=f),e.scissorRect&&(h.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:i,parameters:h,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,r){let{target:i,shaderModuleProps:s,viewports:o,views:n,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let f of o){let h=n&&n[f.id];a?.(f);let u=this._getDrawLayerParams(f,r),d=f.subViewports||[f];for(let p of d){let g=this._drawLayersInViewport(e,{target:i,shaderModuleProps:s,viewport:p,view:h,pass:r.pass,layers:r.layers},u);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:i,isPicking:s=!1,layerFilter:o,cullRect:n,effects:a,shaderModuleProps:c},l=!1){let f=[],h=Km(this._lastRenderIndex+1),u={layer:r[0],viewport:e,isPicking:s,renderPass:i,cullRect:n},d={};for(let p=0;p<r.length;p++){let g=r[p],m=this._shouldDrawLayer(g,u,o,d),_={shouldDrawLayer:m};m&&!l&&(_.shouldDrawLayer=!0,_.layerRenderIndex=h(g,m),_.shaderModuleProps=this._getShaderModuleProps(g,a,i,c),_.layerParameters={...g.context.deck?.props.parameters,...this.getLayerParameters(g,p,e)}),f[p]=_}return f}_drawLayersInViewport(e,{layers:r,shaderModuleProps:i,pass:s,target:o,viewport:n,view:a},c){let l=_w(this.device,{shaderModuleProps:i,target:o,viewport:n});if(a){let{clear:h,clearColor:u,clearDepth:d,clearStencil:p}=a.props;if(h){let g=[0,0,0,0],m=1,_=0;Array.isArray(u)?g=[...u.slice(0,3),u[3]||255].map(y=>y/255):u===!1&&(g=!1),d!==void 0&&(m=d),p!==void 0&&(_=p),this.device.beginRenderPass({framebuffer:o,parameters:{viewport:l,scissorRect:l},clearColor:g,clearDepth:m,clearStencil:_}).end()}}let f={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let h=0;h<r.length;h++){let u=r[h],d=c[h],{shouldDrawLayer:p}=d;if(p&&u.props.pickable&&f.pickableCount++,u.isComposite&&f.compositeCount++,u.isDrawable&&d.shouldDrawLayer){let{layerRenderIndex:g,shaderModuleProps:m,layerParameters:_}=d;f.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,g),m.project&&(m.project.viewport=n),u.context.renderPass=e;try{u._drawLayer({renderPass:e,shaderModuleProps:m,uniforms:{layerIndex:g},parameters:_})}catch(T){u.raiseError(T,`drawing ${u} to ${s}`)}}}return f}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,i){return null}getLayerParameters(e,r,i){return e.props.parameters}_shouldDrawLayer(e,r,i,s){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let n=e.parent;for(;n;){if(!n.props.visible||!n.filterSubLayer(r))return!1;r.layer=n,n=n.parent}if(i){let a=r.layer.id;if(a in s||(s[a]=i(r)),!s[a])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,i,s){let o=this.device.canvasContext.cssToDeviceRatio(),n=e.internalState?.propsInTransition||e.props,a={layer:n,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:o,modelMatrix:n.modelMatrix,coordinateSystem:n.coordinateSystem,coordinateOrigin:n.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let c of r)Zm(a,c.getShaderModuleProps?.(e,a));return Zm(a,this.getShaderModuleProps(e,r,a),s)}};function Km(t=0,e={}){let r={},i=(s,o)=>{let n=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in e)&&i(s.parent,!1),c in r){let f=r[c]=r[c]||Km(e[c],e);l=f(s,o),r[a]=f}else Number.isFinite(n)?(l=n+(e[c]||0),r[a]=null):l=t;return o&&l>=t&&(t=l+1),e[a]=l,l};return i}function _w(t,{shaderModuleProps:e,target:r,viewport:i}){let s=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,o]=t.canvasContext.getDrawingBufferSize(),n=r?r.height:o,a=i;return[a.x*s,n-(a.y+a.height)*s,a.width*s,a.height*s]}function Zm(t,...e){for(let r of e)if(r)for(let i in r)t[i]?Object.assign(t[i],r[i]):t[i]=r[i];return t}var qs=class extends $e{constructor(e,r){super(e,r);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:s})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],o=s.width*i,n=s.height*i,a=[1,1,1,1];(o!==r.width||n!==r.height)&&r.resize({width:o,height:n}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var yw={color:[255,255,255],intensity:1},qm=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],Tw=[0,0,0,200/255],ar=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=Tw,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(Ei),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:s,views:o}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let n=0;n<this.shadowPasses.length;n++)this.shadowPasses[n].render({layers:e,layerFilter:r,viewports:i,onViewportActive:s,views:o,shaderModuleProps:{shadow:{shadowLightId:n,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let i=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(n=>n.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},s={enabled:!0,lights:this._getLights(e)},o=e.props.material;return{shadow:i,lighting:s,phongMaterial:o,gouraudMaterial:o}}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Ei))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new z().lookAt({eye:new H(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let i=new qs(e);this.shadowPasses[r]=i}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:i}=this;!e&&r.length===0&&i.length===0&&(this.ambientLight=new wi(yw),this.directionalLights.push(new Nt(qm[0]),new Nt(qm[1])))}_getLights(e){let r=[];this.ambientLight&&r.push(this.ambientLight);for(let i of this.pointLights)r.push(i.getProjectedLight({layer:e}));for(let i of this.directionalLights)r.push(i.getProjectedLight({layer:e}));return r}};var Uh=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,r,{size:i=1,type:s,padding:o=0,copy:n=!1,initialize:a=!1,maxCount:c}){let l=s||e&&e.constructor||Float32Array,f=r*i+o;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let h=1/0;c&&(h=c*i+o);let u=this._allocate(l,f,a,h);return e&&n?u.set(e):a||u.fill(0,0,4),this._release(e),u}release(e){this._release(e)}_allocate(e,r,i,s){let o=Math.max(Math.ceil(r*this.opts.overAlloc),1);o>s&&(o=s);let n=this._pool,a=e.BYTES_PER_ELEMENT*o,c=n.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(n.splice(c,1)[0],0,o);return i&&l.fill(0),l}return new e(o)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:s}=i,o=r.findIndex(n=>n.byteLength>=s);o<0?r.push(i):(o>0||r.length<this.opts.poolSize)&&r.splice(o,0,i),r.length>this.opts.poolSize&&r.shift()}},Xe=new Uh;function Pi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ht(t,e){let r=t%e;return r<0?e+r:r}function Gm(t){return[t[12],t[13],t[14]]}function Jm(t){let e=t[10],r=t[14];return{near:r/(e-1),far:r/(e+1)}}function e_(t){return{left:Ri(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Ri(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Ri(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Ri(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Ri(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Ri(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var Qm=new H;function Ri(t,e,r,i){Qm.set(t,e,r);let s=Qm.len();return{distance:i/s,normal:new H(-t/s,-e/s,-r/s)}}function kh(t){return t-Math.fround(t)}var Qs;function pa(t,e){let{size:r=1,startIndex:i=0}=e,s=e.endIndex!==void 0?e.endIndex:t.length,o=(s-i)/r;Qs=Xe.allocate(Qs,o,{type:Float32Array,size:r*2});let n=i,a=0;for(;n<s;){for(let c=0;c<r;c++){let l=t[n++];Qs[a+c]=l,Qs[a+c+r]=kh(l)}a+=r*2}return Qs.subarray(0,o*r*2)}function t_(t){let e=null,r=!1;for(let i of t)i&&(e?(r||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],r=!0),e[0][0]=Math.min(e[0][0],i[0][0]),e[0][1]=Math.min(e[0][1],i[0][1]),e[1][0]=Math.max(e[1][0],i[1][0]),e[1][1]=Math.max(e[1][1],i[1][1])):e=i);return e}var bw=Math.PI/180,xw=Pi(),r_=[0,0,0],Aw={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function Sw({width:t,height:e,orthographic:r,fovyRadians:i,focalDistance:s,padding:o,near:n,far:a}){let c=t/e,l=r?new z().orthographic({fovy:i,aspect:c,focalDistance:s,near:n,far:a}):new z().perspective({fovy:i,aspect:c,near:n,far:a});if(o){let{left:f=0,right:h=0,top:u=0,bottom:d=0}=o,p=B((f+t-h)/2,0,t)-t/2,g=B((u+e-d)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=g*2/e}return l}var vi=class{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||Aw,this.focalDistance=e.focalDistance||1,this.position=e.position||r_,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:i}=e;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(r),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?oe.WEB_MERCATOR:oe.WEB_MERCATOR_AUTO_OFFSET:oe.IDENTITY}equals(e){return e instanceof vi?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Re(e.projectionMatrix,this.projectionMatrix)&&Re(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let i=this.projectPosition(e),s=Si(i,this.pixelProjectionMatrix),[o,n]=s,a=r?n:this.height-n;return e.length===2?[o,a]:[o,a,s[2]]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[s,o,n]=e,a=r?o:this.height-o,c=i&&i*this.distanceScales.unitsPerMeter[2],l=Ue([s,a,n],this.pixelUnprojectionMatrix,c),[f,h,u]=this.unprojectPosition(l);return Number.isFinite(n)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i]=this.projectFlat(e),s=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,i,s]}unprojectPosition(e){let[r,i]=this.unprojectFlat(e),s=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,i,s]}projectFlat(e){if(this.isGeospatial){let r=Ae(e);return r[1]=B(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?_e(e):e}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,0],r),s=this.unproject([this.width,0],r),o=this.unproject([0,this.height],r),n=this.unproject([this.width,this.height],r);return[Math.min(i[0],s[0],o[0],n[0]),Math.min(i[1],s[1],o[1],n[1]),Math.max(i[0],s[0],o[0],n[0]),Math.max(i[1],s[1],o[1],n[1])]}getDistanceScales(e){return e&&this.isGeospatial?Ai({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:i=1,height:s=1}){return e<this.x+this.width&&this.x<e+i&&r<this.y+this.height&&this.y<r+s}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,e_(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r,i){return null}_initProps(e){let r=e.longitude,i=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Ys({latitude:i})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Ai({latitude:i,longitude:r}));let s=Math.pow(2,this.zoom);this.scale=s;let{position:o,modelMatrix:n}=e,a=r_;if(o&&(a=n?new z(n).transformAsVector(o,[]):o),this.isGeospatial){let c=this.projectPosition([r,i,0]);this.center=new H(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:r=xw,projectionMatrix:i=null,orthographic:s=!1,fovyRadians:o,fovy:n=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new z().multiplyRight(r).translate(new H(this.center).negate()),this.projectionMatrix=i||Sw({width:this.width,height:this.height,orthographic:s,fovyRadians:o||n*bw,focalDistance:f,padding:l,near:a,far:c});let h=Pi();re.multiply(h,h,this.projectionMatrix),re.multiply(h,h,this.viewMatrix),this.viewProjectionMatrix=h,this.viewMatrixInverse=re.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=Gm(this.viewMatrixInverse);let u=Pi(),d=Pi();re.scale(u,u,[this.width/2,-this.height/2,1]),re.translate(u,u,[1,-1,0]),re.multiply(d,u,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=re.invert(Pi(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||L.warn("Pixel project matrix not invertible")()}};vi.displayName="Viewport";var Se=vi;var Fr=class extends Se{constructor(e={}){let{latitude:r=0,longitude:i=0,zoom:s=0,pitch:o=0,bearing:n=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:h=!1,projectionMatrix:u,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:_=!1}=e,{width:T,height:y,altitude:x=1.5}=e,S=Math.pow(2,s);T=T||1,y=y||1;let A,w=null;if(u)x=u[5]/2,A=It(x);else{e.fovy?(A=e.fovy,x=Ot(A)):A=It(x);let R;if(m){let{top:M=0,bottom:I=0}=m;R=[0,B((M+y-I)/2,0,y)-y/2]}w=Dh({width:T,height:y,scale:S,center:g&&[0,0,g[2]*Zs(r)],offset:R,pitch:o,fovy:A,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(w.near=l),Number.isFinite(f)&&(w.far=f)}let v=fa({height:y,pitch:o,bearing:n,scale:S,altitude:x});p&&(v=new z().translate([512*p,0,0]).multiplyLeft(v)),super({...e,width:T,height:y,viewMatrix:v,longitude:i,latitude:r,zoom:s,...w,fovy:A,focalDistance:x}),this.latitude=r,this.longitude=i,this.zoom=s,this.pitch=o,this.bearing=n,this.altitude=x,this.fovy=A,this.orthographic=h,this._subViewports=d?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),i=Math.ceil((e[2]-180)/360);for(let s=r;s<=i;s++){let o=s?new Fr({...this,worldOffset:s}):this;this._subViewports.push(o)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,i]=this.projectFlat(e),s=(e[2]||0)*Zs(e[1]);return[r,i,s]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,i]=this.unprojectFlat(e),s=(e[2]||0)/Zs(i);return[r,i,s]}addMetersToLngLat(e,r){return Ks(e,r)}panByPosition(e,r,i){let s=Ue(r,this.pixelUnprojectionMatrix),o=this.projectFlat(e),n=ee.add([],o,ee.negate([],s)),a=ee.add([],this.center,n),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,r){let i=e[2]||0,s=ee.sub([],e,this.unproject(r,{targetZ:i}));return{longitude:this.longitude+s[0],latitude:this.latitude+s[1]}}getBounds(e={}){let r=ua(this,e.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(e,r={}){let{width:i,height:s}=this,{longitude:o,latitude:n,zoom:a}=ha({width:i,height:s,bounds:e,...r});return new Fr({width:i,height:s,longitude:o,latitude:n,zoom:a})}};Fr.displayName="WebMercatorViewport";var cr=Fr;var i_=[0,0,0];function Vh(t,e,r=!1){let i=e.projectPosition(t);if(r&&e instanceof cr){let[s,o,n=0]=t,a=e.getDistanceScales([s,o]);i[2]=n*a.unitsPerMeter[2]}return i}function Ew(t){let{viewport:e,modelMatrix:r,coordinateOrigin:i}=t,{coordinateSystem:s,fromCoordinateSystem:o,fromCoordinateOrigin:n}=t;return s===k.DEFAULT&&(s=e.isGeospatial?k.LNGLAT:k.CARTESIAN),o===void 0&&(o=s),n===void 0&&(n=i),{viewport:e,coordinateSystem:s,coordinateOrigin:i,modelMatrix:r,fromCoordinateSystem:o,fromCoordinateOrigin:n}}function zh(t,{viewport:e,modelMatrix:r,coordinateSystem:i,coordinateOrigin:s,offsetMode:o}){let[n,a,c=0]=t;switch(r&&([n,a,c]=xe.transformMat4([],[n,a,c,1],r)),i){case k.LNGLAT:return Vh([n,a,c],e,o);case k.LNGLAT_OFFSETS:return Vh([n+s[0],a+s[1],c+(s[2]||0)],e,o);case k.METER_OFFSETS:return Vh(Ks(s,[n,a,c]),e,o);case k.CARTESIAN:default:return e.isGeospatial?[n+s[0],a+s[1],c+s[2]]:e.projectPosition([n,a,c])}}function ga(t,e){let{viewport:r,coordinateSystem:i,coordinateOrigin:s,modelMatrix:o,fromCoordinateSystem:n,fromCoordinateOrigin:a}=Ew(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=i_,shaderCoordinateOrigin:f=i_,offsetMode:h=!1}=c?Ch(r,i,s):{},u=zh(t,{viewport:r,modelMatrix:o,coordinateSystem:n,coordinateOrigin:a,offsetMode:h});if(h){let d=r.projectPosition(l||f);pe.sub(u,u,d)}return u}var ww=[255,255,255],Rw=1,Pw=[1,0,0],vw=[0,0,1],Mw=0,Mi=class{constructor(e={}){this.type="point";let{color:r=ww}=e,{intensity:i=Rw}=e,{position:s=vw}=e;this.id=e.id||`point-${Mw++}`,this.color=r,this.intensity=i,this.type="point",this.position=s,this.attenuation=Cw(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:s,coordinateOrigin:o}=e.props,n=ga(this.position,{viewport:i,coordinateSystem:s,coordinateOrigin:o,fromCoordinateSystem:i.isGeospatial?k.LNGLAT:k.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=n,r}};function Cw(t){return t.attenuation?t.attenuation:Pw}var Gs=class extends Mi{getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:s,coordinateOrigin:o,modelMatrix:n}=e.props,{cameraPosition:a}=aa({viewport:i,modelMatrix:n,coordinateSystem:s,coordinateOrigin:o});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var Br=Math.PI/180,Iw=1e3*60*60*24,Ow=2440588,Nw=2451545,ma=Br*23.4397,Dw=357.5291,Fw=.98560028,Bw=280.147,Lw=360.9856235;function s_(t,e,r){let i=Br*-r,s=Br*e,o=kw(t),n=Yw(o),a=Hw(o,i)-n.rightAscension;return{azimuth:Ww(a,s,n.declination),altitude:jw(a,s,n.declination)}}function _a(t,e,r){let{azimuth:i,altitude:s}=s_(t,e,r);return[Math.sin(i)*Math.cos(s),Math.cos(i)*Math.cos(s),-Math.sin(s)]}function Uw(t){return(typeof t=="number"?t:t.getTime())/Iw-.5+Ow}function kw(t){return Uw(t)-Nw}function Vw(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(ma)-Math.tan(e)*Math.sin(ma),Math.cos(r))}function zw(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(ma)+Math.cos(e)*Math.sin(ma)*Math.sin(r))}function Ww(t,e,r){let i=t,s=e,o=r;return Math.atan2(Math.sin(i),Math.cos(i)*Math.sin(s)-Math.tan(o)*Math.cos(s))}function jw(t,e,r){let i=t,s=e,o=r;return Math.asin(Math.sin(s)*Math.sin(o)+Math.cos(s)*Math.cos(o)*Math.cos(i))}function Hw(t,e){return Br*(Bw+Lw*t)-e}function $w(t){return Br*(Dw+Fw*t)}function Xw(t){let e=t,r=Br*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),i=Br*102.9372;return e+r+i+Math.PI}function Yw(t){let e=$w(t),r=Xw(e);return{declination:zw(r,0),rightAscension:Vw(r,0)}}var Js=class extends Nt{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[s,o,n]=_a(this.timestamp,0,0);this.direction=[s,-n,o]}else{let{latitude:s,longitude:o}=r;this.direction=_a(this.timestamp,s,o)}return this}};var Zw=`uniform screenUniforms {
|
|
1914
|
+
`}}};var jR=[oa],HR=["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)"],$R=[];function Sa(t){let e=Jt.getDefaultShaderAssembler();for(let i of jR)e.addDefaultModule(i);e._hookFunctions.length=0;let r=t==="glsl"?HR:$R;for(let i of r)e.addShaderHook(i);return e}var XR=[255,255,255],YR=1,KR=0,Ni=class{constructor(e={}){this.type="ambient";let{color:r=XR}=e,{intensity:i=YR}=e;this.id=e.id||`ambient-${KR++}`,this.color=r,this.intensity=i}};var ZR=[255,255,255],qR=1,GR=[0,0,-1],QR=0,Ft=class{constructor(e={}){this.type="directional";let{color:r=ZR}=e,{intensity:i=qR}=e,{direction:s=GR}=e,{_shadow:o=!1}=e;this.id=e.id||`directional-${QR++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new H(s).normalize().toArray(),this.shadow=o}getProjectedLight(e){return this}};var Lr=class{constructor(e,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var Ye=class extends Lr{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let r=this.device.canvasContext,i=e.target??r.getCurrentFramebuffer(),[s,o]=r.getDrawingBufferSize(),n=e.clearCanvas??!0,a=e.clearColor??(n?[0,0,0,0]:!1),c=n?1:!1,l=n?0:!1,f=e.colorMask??15,h={viewport:[0,0,s,o]};e.colorMask&&(h.colorMask=f),e.scissorRect&&(h.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:i,parameters:h,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,r){let{target:i,shaderModuleProps:s,viewports:o,views:n,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let f of o){let h=n&&n[f.id];a?.(f);let u=this._getDrawLayerParams(f,r),d=f.subViewports||[f];for(let p of d){let g=this._drawLayersInViewport(e,{target:i,shaderModuleProps:s,viewport:p,view:h,pass:r.pass,layers:r.layers},u);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:i,isPicking:s=!1,layerFilter:o,cullRect:n,effects:a,shaderModuleProps:c},l=!1){let f=[],h=V_(this._lastRenderIndex+1),u={layer:r[0],viewport:e,isPicking:s,renderPass:i,cullRect:n},d={};for(let p=0;p<r.length;p++){let g=r[p],m=this._shouldDrawLayer(g,u,o,d),_={shouldDrawLayer:m};m&&!l&&(_.shouldDrawLayer=!0,_.layerRenderIndex=h(g,m),_.shaderModuleProps=this._getShaderModuleProps(g,a,i,c),_.layerParameters={...g.context.deck?.props.parameters,...this.getLayerParameters(g,p,e)}),f[p]=_}return f}_drawLayersInViewport(e,{layers:r,shaderModuleProps:i,pass:s,target:o,viewport:n,view:a},c){let l=JR(this.device,{shaderModuleProps:i,target:o,viewport:n});if(a){let{clear:h,clearColor:u,clearDepth:d,clearStencil:p}=a.props;if(h){let g=[0,0,0,0],m=1,_=0;Array.isArray(u)?g=[...u.slice(0,3),u[3]||255].map(y=>y/255):u===!1&&(g=!1),d!==void 0&&(m=d),p!==void 0&&(_=p),this.device.beginRenderPass({framebuffer:o,parameters:{viewport:l,scissorRect:l},clearColor:g,clearDepth:m,clearStencil:_}).end()}}let f={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let h=0;h<r.length;h++){let u=r[h],d=c[h],{shouldDrawLayer:p}=d;if(p&&u.props.pickable&&f.pickableCount++,u.isComposite&&f.compositeCount++,u.isDrawable&&d.shouldDrawLayer){let{layerRenderIndex:g,shaderModuleProps:m,layerParameters:_}=d;f.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,g),m.project&&(m.project.viewport=n),u.context.renderPass=e;try{u._drawLayer({renderPass:e,shaderModuleProps:m,uniforms:{layerIndex:g},parameters:_})}catch(b){u.raiseError(b,`drawing ${u} to ${s}`)}}}return f}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,i){return null}getLayerParameters(e,r,i){return e.props.parameters}_shouldDrawLayer(e,r,i,s){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let n=e.parent;for(;n;){if(!n.props.visible||!n.filterSubLayer(r))return!1;r.layer=n,n=n.parent}if(i){let a=r.layer.id;if(a in s||(s[a]=i(r)),!s[a])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,i,s){let o=this.device.canvasContext.cssToDeviceRatio(),n=e.internalState?.propsInTransition||e.props,a={layer:n,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:o,modelMatrix:n.modelMatrix,coordinateSystem:n.coordinateSystem,coordinateOrigin:n.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let c of r)k_(a,c.getShaderModuleProps?.(e,a));return k_(a,this.getShaderModuleProps(e,r,a),s)}};function V_(t=0,e={}){let r={},i=(s,o)=>{let n=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in e)&&i(s.parent,!1),c in r){let f=r[c]=r[c]||V_(e[c],e);l=f(s,o),r[a]=f}else Number.isFinite(n)?(l=n+(e[c]||0),r[a]=null):l=t;return o&&l>=t&&(t=l+1),e[a]=l,l};return i}function JR(t,{shaderModuleProps:e,target:r,viewport:i}){let s=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,o]=t.canvasContext.getDrawingBufferSize(),n=r?r.height:o,a=i;return[a.x*s,n-(a.y+a.height)*s,a.width*s,a.height*s]}function k_(t,...e){for(let r of e)if(r)for(let i in r)t[i]?Object.assign(t[i],r[i]):t[i]=r[i];return t}var eo=class extends Ye{constructor(e,r){super(e,r);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:s})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],o=s.width*i,n=s.height*i,a=[1,1,1,1];(o!==r.width||n!==r.height)&&r.resize({width:o,height:n}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var e3={color:[255,255,255],intensity:1},z_=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],t3=[0,0,0,200/255],ur=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=t3,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(Oi),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:s,views:o}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let n=0;n<this.shadowPasses.length;n++)this.shadowPasses[n].render({layers:e,layerFilter:r,viewports:i,onViewportActive:s,views:o,shaderModuleProps:{shadow:{shadowLightId:n,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let i=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(n=>n.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},s={enabled:!0,lights:this._getLights(e)},o=e.props.material;return{shadow:i,lighting:s,phongMaterial:o,gouraudMaterial:o}}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Oi))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new z().lookAt({eye:new H(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let i=new eo(e);this.shadowPasses[r]=i}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:i}=this;!e&&r.length===0&&i.length===0&&(this.ambientLight=new Ni(e3),this.directionalLights.push(new Ft(z_[0]),new Ft(z_[1])))}_getLights(e){let r=[];this.ambientLight&&r.push(this.ambientLight);for(let i of this.pointLights)r.push(i.getProjectedLight({layer:e}));for(let i of this.directionalLights)r.push(i.getProjectedLight({layer:e}));return r}};var fu=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,r,{size:i=1,type:s,padding:o=0,copy:n=!1,initialize:a=!1,maxCount:c}){let l=s||e&&e.constructor||Float32Array,f=r*i+o;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let h=1/0;c&&(h=c*i+o);let u=this._allocate(l,f,a,h);return e&&n?u.set(e):a||u.fill(0,0,4),this._release(e),u}release(e){this._release(e)}_allocate(e,r,i,s){let o=Math.max(Math.ceil(r*this.opts.overAlloc),1);o>s&&(o=s);let n=this._pool,a=e.BYTES_PER_ELEMENT*o,c=n.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(n.splice(c,1)[0],0,o);return i&&l.fill(0),l}return new e(o)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:s}=i,o=r.findIndex(n=>n.byteLength>=s);o<0?r.push(i):(o>0||r.length<this.opts.poolSize)&&r.splice(o,0,i),r.length>this.opts.poolSize&&r.shift()}},Ke=new fu;function Bi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function mt(t,e){let r=t%e;return r<0?e+r:r}function j_(t){return[t[12],t[13],t[14]]}function H_(t){let e=t[10],r=t[14];return{near:r/(e-1),far:r/(e+1)}}function $_(t){return{left:Di(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Di(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Di(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Di(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Di(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Di(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var W_=new H;function Di(t,e,r,i){W_.set(t,e,r);let s=W_.len();return{distance:i/s,normal:new H(-t/s,-e/s,-r/s)}}function hu(t){return t-Math.fround(t)}var to;function Ea(t,e){let{size:r=1,startIndex:i=0}=e,s=e.endIndex!==void 0?e.endIndex:t.length,o=(s-i)/r;to=Ke.allocate(to,o,{type:Float32Array,size:r*2});let n=i,a=0;for(;n<s;){for(let c=0;c<r;c++){let l=t[n++];to[a+c]=l,to[a+c+r]=hu(l)}a+=r*2}return to.subarray(0,o*r*2)}function X_(t){let e=null,r=!1;for(let i of t)i&&(e?(r||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],r=!0),e[0][0]=Math.min(e[0][0],i[0][0]),e[0][1]=Math.min(e[0][1],i[0][1]),e[1][0]=Math.max(e[1][0],i[1][0]),e[1][1]=Math.max(e[1][1],i[1][1])):e=i);return e}var r3=Math.PI/180,i3=Bi(),Y_=[0,0,0],s3={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function o3({width:t,height:e,orthographic:r,fovyRadians:i,focalDistance:s,padding:o,near:n,far:a}){let c=t/e,l=r?new z().orthographic({fovy:i,aspect:c,focalDistance:s,near:n,far:a}):new z().perspective({fovy:i,aspect:c,near:n,far:a});if(o){let{left:f=0,right:h=0,top:u=0,bottom:d=0}=o,p=U((f+t-h)/2,0,t)-t/2,g=U((u+e-d)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=g*2/e}return l}var Fi=class{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||s3,this.focalDistance=e.focalDistance||1,this.position=e.position||Y_,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:i}=e;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(r),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?se.WEB_MERCATOR:se.WEB_MERCATOR_AUTO_OFFSET:se.IDENTITY}equals(e){return e instanceof Fi?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Pe(e.projectionMatrix,this.projectionMatrix)&&Pe(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let i=this.projectPosition(e),s=Ii(i,this.pixelProjectionMatrix),[o,n]=s,a=r?n:this.height-n;return e.length===2?[o,a]:[o,a,s[2]]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[s,o,n]=e,a=r?o:this.height-o,c=i&&i*this.distanceScales.unitsPerMeter[2],l=Ve([s,a,n],this.pixelUnprojectionMatrix,c),[f,h,u]=this.unprojectPosition(l);return Number.isFinite(n)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i]=this.projectFlat(e),s=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,i,s]}unprojectPosition(e){let[r,i]=this.unprojectFlat(e),s=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,i,s]}projectFlat(e){if(this.isGeospatial){let r=Se(e);return r[1]=U(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?ye(e):e}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,0],r),s=this.unproject([this.width,0],r),o=this.unproject([0,this.height],r),n=this.unproject([this.width,this.height],r);return[Math.min(i[0],s[0],o[0],n[0]),Math.min(i[1],s[1],o[1],n[1]),Math.max(i[0],s[0],o[0],n[0]),Math.max(i[1],s[1],o[1],n[1])]}getDistanceScales(e){return e&&this.isGeospatial?Ci({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:i=1,height:s=1}){return e<this.x+this.width&&this.x<e+i&&r<this.y+this.height&&this.y<r+s}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,$_(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r,i){return null}_initProps(e){let r=e.longitude,i=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Gs({latitude:i})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Ci({latitude:i,longitude:r}));let s=Math.pow(2,this.zoom);this.scale=s;let{position:o,modelMatrix:n}=e,a=Y_;if(o&&(a=n?new z(n).transformAsVector(o,[]):o),this.isGeospatial){let c=this.projectPosition([r,i,0]);this.center=new H(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:r=i3,projectionMatrix:i=null,orthographic:s=!1,fovyRadians:o,fovy:n=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new z().multiplyRight(r).translate(new H(this.center).negate()),this.projectionMatrix=i||o3({width:this.width,height:this.height,orthographic:s,fovyRadians:o||n*r3,focalDistance:f,padding:l,near:a,far:c});let h=Bi();re.multiply(h,h,this.projectionMatrix),re.multiply(h,h,this.viewMatrix),this.viewProjectionMatrix=h,this.viewMatrixInverse=re.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=j_(this.viewMatrixInverse);let u=Bi(),d=Bi();re.scale(u,u,[this.width/2,-this.height/2,1]),re.translate(u,u,[1,-1,0]),re.multiply(d,u,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=re.invert(Bi(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||F.warn("Pixel project matrix not invertible")()}};Fi.displayName="Viewport";var Ee=Fi;var Ur=class extends Ee{constructor(e={}){let{latitude:r=0,longitude:i=0,zoom:s=0,pitch:o=0,bearing:n=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:h=!1,projectionMatrix:u,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:_=!1}=e,{width:b,height:y,altitude:T=1.5}=e,S=Math.pow(2,s);b=b||1,y=y||1;let A,w=null;if(u)T=u[5]/2,A=Dt(T);else{e.fovy?(A=e.fovy,T=Bt(A)):A=Dt(T);let R;if(m){let{top:M=0,bottom:O=0}=m;R=[0,U((M+y-O)/2,0,y)-y/2]}w=nu({width:b,height:y,scale:S,center:g&&[0,0,g[2]*Qs(r)],offset:R,pitch:o,fovy:A,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(w.near=l),Number.isFinite(f)&&(w.far=f)}let v=Ta({height:y,pitch:o,bearing:n,scale:S,altitude:T});p&&(v=new z().translate([512*p,0,0]).multiplyLeft(v)),super({...e,width:b,height:y,viewMatrix:v,longitude:i,latitude:r,zoom:s,...w,fovy:A,focalDistance:T}),this.latitude=r,this.longitude=i,this.zoom=s,this.pitch=o,this.bearing=n,this.altitude=T,this.fovy=A,this.orthographic=h,this._subViewports=d?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),i=Math.ceil((e[2]-180)/360);for(let s=r;s<=i;s++){let o=s?new Ur({...this,worldOffset:s}):this;this._subViewports.push(o)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,i]=this.projectFlat(e),s=(e[2]||0)*Qs(e[1]);return[r,i,s]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,i]=this.unprojectFlat(e),s=(e[2]||0)/Qs(i);return[r,i,s]}addMetersToLngLat(e,r){return Js(e,r)}panByPosition(e,r,i){let s=Ve(r,this.pixelUnprojectionMatrix),o=this.projectFlat(e),n=ee.add([],o,ee.negate([],s)),a=ee.add([],this.center,n),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,r){let i=e[2]||0,s=ee.sub([],e,this.unproject(r,{targetZ:i}));return{longitude:this.longitude+s[0],latitude:this.latitude+s[1]}}getBounds(e={}){let r=Aa(this,e.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(e,r={}){let{width:i,height:s}=this,{longitude:o,latitude:n,zoom:a}=xa({width:i,height:s,bounds:e,...r});return new Ur({width:i,height:s,longitude:o,latitude:n,zoom:a})}};Ur.displayName="WebMercatorViewport";var dr=Ur;var K_=[0,0,0];function uu(t,e,r=!1){let i=e.projectPosition(t);if(r&&e instanceof dr){let[s,o,n=0]=t,a=e.getDistanceScales([s,o]);i[2]=n*a.unitsPerMeter[2]}return i}function n3(t){let{viewport:e,modelMatrix:r,coordinateOrigin:i}=t,{coordinateSystem:s,fromCoordinateSystem:o,fromCoordinateOrigin:n}=t;return s===k.DEFAULT&&(s=e.isGeospatial?k.LNGLAT:k.CARTESIAN),o===void 0&&(o=s),n===void 0&&(n=i),{viewport:e,coordinateSystem:s,coordinateOrigin:i,modelMatrix:r,fromCoordinateSystem:o,fromCoordinateOrigin:n}}function du(t,{viewport:e,modelMatrix:r,coordinateSystem:i,coordinateOrigin:s,offsetMode:o}){let[n,a,c=0]=t;switch(r&&([n,a,c]=Ae.transformMat4([],[n,a,c,1],r)),i){case k.LNGLAT:return uu([n,a,c],e,o);case k.LNGLAT_OFFSETS:return uu([n+s[0],a+s[1],c+(s[2]||0)],e,o);case k.METER_OFFSETS:return uu(Js(s,[n,a,c]),e,o);case k.CARTESIAN:default:return e.isGeospatial?[n+s[0],a+s[1],c+s[2]]:e.projectPosition([n,a,c])}}function wa(t,e){let{viewport:r,coordinateSystem:i,coordinateOrigin:s,modelMatrix:o,fromCoordinateSystem:n,fromCoordinateOrigin:a}=n3(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=K_,shaderCoordinateOrigin:f=K_,offsetMode:h=!1}=c?ru(r,i,s):{},u=du(t,{viewport:r,modelMatrix:o,coordinateSystem:n,coordinateOrigin:a,offsetMode:h});if(h){let d=r.projectPosition(l||f);ge.sub(u,u,d)}return u}var a3=[255,255,255],c3=1,l3=[1,0,0],f3=[0,0,1],h3=0,Li=class{constructor(e={}){this.type="point";let{color:r=a3}=e,{intensity:i=c3}=e,{position:s=f3}=e;this.id=e.id||`point-${h3++}`,this.color=r,this.intensity=i,this.type="point",this.position=s,this.attenuation=u3(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:s,coordinateOrigin:o}=e.props,n=wa(this.position,{viewport:i,coordinateSystem:s,coordinateOrigin:o,fromCoordinateSystem:i.isGeospatial?k.LNGLAT:k.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=n,r}};function u3(t){return t.attenuation?t.attenuation:l3}var ro=class extends Li{getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:s,coordinateOrigin:o,modelMatrix:n}=e.props,{cameraPosition:a}=_a({viewport:i,modelMatrix:n,coordinateSystem:s,coordinateOrigin:o});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var kr=Math.PI/180,d3=1e3*60*60*24,p3=2440588,g3=2451545,Ra=kr*23.4397,m3=357.5291,_3=.98560028,y3=280.147,b3=360.9856235;function Z_(t,e,r){let i=kr*-r,s=kr*e,o=x3(t),n=M3(o),a=R3(o,i)-n.rightAscension;return{azimuth:E3(a,s,n.declination),altitude:w3(a,s,n.declination)}}function Pa(t,e,r){let{azimuth:i,altitude:s}=Z_(t,e,r);return[Math.sin(i)*Math.cos(s),Math.cos(i)*Math.cos(s),-Math.sin(s)]}function T3(t){return(typeof t=="number"?t:t.getTime())/d3-.5+p3}function x3(t){return T3(t)-g3}function A3(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(Ra)-Math.tan(e)*Math.sin(Ra),Math.cos(r))}function S3(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(Ra)+Math.cos(e)*Math.sin(Ra)*Math.sin(r))}function E3(t,e,r){let i=t,s=e,o=r;return Math.atan2(Math.sin(i),Math.cos(i)*Math.sin(s)-Math.tan(o)*Math.cos(s))}function w3(t,e,r){let i=t,s=e,o=r;return Math.asin(Math.sin(s)*Math.sin(o)+Math.cos(s)*Math.cos(o)*Math.cos(i))}function R3(t,e){return kr*(y3+b3*t)-e}function P3(t){return kr*(m3+_3*t)}function v3(t){let e=t,r=kr*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),i=kr*102.9372;return e+r+i+Math.PI}function M3(t){let e=P3(t),r=v3(e);return{declination:S3(r,0),rightAscension:A3(r,0)}}var io=class extends Ft{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[s,o,n]=Pa(this.timestamp,0,0);this.direction=[s,-n,o]}else{let{latitude:s,longitude:o}=r;this.direction=Pa(this.timestamp,s,o)}return this}};var C3=`layout(std140) uniform screenUniforms {
|
|
1643
1915
|
vec2 texSize;
|
|
1644
1916
|
} screen;
|
|
1645
|
-
`,
|
|
1917
|
+
`,q_={name:"screen",fs:C3,uniformTypes:{texSize:"vec2<f32>"}};var so=class extends Lr{constructor(e,r){super(e,r);let{module:i,fs:s,id:o}=r,n={depthWriteEnabled:!1,depthCompare:"always",depthBias:0,blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"};this.model=new Es(e,{id:o,fs:s,modules:[i,q_],parameters:n})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,r){let{clearCanvas:i,inputBuffer:s,outputBuffer:o}=r,n=[s.width,s.height],a={texSrc:s.colorAttachments[0],texSize:n};this.model.shaderInputs.setProps({screen:a,...r.moduleProps});let c=this.device.beginRenderPass({framebuffer:o,parameters:{viewport:[0,0,...n]},clearColor:i?[0,0,0,0]:!1,clearDepth:1,clearStencil:!1});this.model.draw(c),c.end()}};var oo=class{constructor(e,r){this.id=`${e.name}-pass`,this.props=r,xn(e),this.module=e}setup({device:e}){this.passes=I3(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){let r=this.passes,{target:i}=e,s=e.inputBuffer,o=e.swapBuffer;for(let n=0;n<r.length;n++){let a=n===r.length-1,c=i!==void 0&&a;c&&(o=i);let l=!c||Boolean(e.clearCanvas),f={},h=this.module.passes[n].uniforms;f[this.module.name]={...this.props,...h},r[n].render({clearCanvas:l,inputBuffer:s,outputBuffer:o,moduleProps:f});let u=o;o=s,s=u}return s}cleanup(){if(this.passes){for(let e of this.passes)e.delete();this.passes=void 0}}};function I3(t,e,r){return e.passes.map((i,s)=>{let o=D3(e,i),n=`${r}-${s}`;return new so(t,{id:n,module:e,fs:o})})}var G_=`#version 300 es
|
|
1646
1918
|
uniform sampler2D texSrc;
|
|
1647
1919
|
|
|
1648
1920
|
in vec2 position;
|
|
@@ -1650,19 +1922,19 @@ in vec2 coordinate;
|
|
|
1650
1922
|
in vec2 uv;
|
|
1651
1923
|
|
|
1652
1924
|
out vec4 fragColor;
|
|
1653
|
-
`,
|
|
1925
|
+
`,O3=t=>`${G_}
|
|
1654
1926
|
void main() {
|
|
1655
1927
|
fragColor = texture(texSrc, coordinate);
|
|
1656
1928
|
fragColor = ${t}(fragColor, screen.texSize, coordinate);
|
|
1657
1929
|
}
|
|
1658
|
-
`,
|
|
1930
|
+
`,N3=t=>`${G_}
|
|
1659
1931
|
void main() {
|
|
1660
1932
|
fragColor = ${t}(texSrc, screen.texSize, coordinate);
|
|
1661
1933
|
}
|
|
1662
|
-
`;function Gw(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor_ext`;return qw(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return Qw(r)}return""}var Jw={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},Dt=class extends $e{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:o,pickingFBO:n,deviceRect:{x:a,y:c,width:l,height:f},cullRect:h,effects:u,pass:d="picking",pickZ:p,shaderModuleProps:g,clearColor:m}){this.pickZ=p;let _=this._resetColorEncoder(p),T=[a,c,l,f],y=super._render({target:n,layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:o,cullRect:h,effects:u?.filter(S=>S.useInPicking),pass:d,isPicking:!0,shaderModuleProps:g,clearColor:m??[0,0,0,0],colorMask:15,scissorRect:T});return this._colorEncoderState=null,{decodePickingColor:_&&tR.bind(null,_),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,r,i){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,r,i){let s={...e.props.parameters},{pickable:o,operation:n}=e.props;return this._colorEncoderState?o&&n.includes("draw")?(Object.assign(s,Jw),s.blend=!0,s.blendColor=eR(this._colorEncoderState,e,i),n.includes("terrain")&&e.state?._hasPickingCover&&(s.blendAlphaSrcFactor="one")):n.includes("terrain")&&(s.blend=!1):s.blend=!1,s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function eR(t,e,r){let{byLayer:i,byAlpha:s}=t,o,n=i.get(e);return n?(n.viewports.push(r),o=n.a):(o=i.size+1,o<=255?(n={a:o,layer:e,viewports:[r]},i.set(e,n),s[o]=n):(L.warn("Too many pickable layers, only picking the first 255")(),o=0)),[0,0,0,o/255]}function tR(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var lr={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"},Ci=Symbol.for("component"),ke=Symbol.for("propTypes"),ya=Symbol.for("deprecatedProps"),Ft=Symbol.for("asyncPropDefaults"),ut=Symbol.for("asyncPropOriginal"),Ye=Symbol.for("asyncPropResolved");function fr(t,e=()=>!0){return Array.isArray(t)?a_(t,e,[]):e(t)?[t]:[]}function a_(t,e,r){let i=-1;for(;++i<t.length;){let s=t[i];Array.isArray(s)?a_(s,e,r):e(s)&&r.push(s)}return r}function Ta({target:t,source:e,start:r=0,count:i=1}){let s=e.length,o=i*s,n=0;for(let a=r;n<s;n++)t[a++]=e[n];for(;n<o;)n<o-n?(t.copyWithin(r+n,r,r+n),n*=2):(t.copyWithin(r+n,r,r+o-n),n=o);return t}Wi();var ro=class{constructor(e,r,i){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=i,this.setData(r)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,s=e;typeof e=="string"&&(s=rr(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(o=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=o)}).catch(o=>{this._loadCount===i&&(this.isLoaded=!0,this._error=o||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let o of this._subscribers)o.onChange(this.getData())}};var io=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:i=!1,persistent:s=!0}){let o=this._resources[e];o?o.setData(r,i):(o=new ro(e,r,this._context),this._resources[e]=o),o.persistent=s}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let s=r[i],o=this._resources[s.resourceId];o&&o.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:s="default"}){let{_resources:o,protocol:n}=this;e.startsWith(n)&&(e=e.replace(n,""),o[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=o[e];if(this._track(i,s,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,i,s){let o=this._consumers,n=o[e]=o[e]||{},a=n[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=s,a.resourceId=i.id):a={onChange:s,resourceId:i.id},n[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var rR="layerManager.setLayers",iR="layerManager.activateViewport",Lr=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{Q(iR,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:s,viewport:o,timeline:n}=r||{};this.layers=[],this.resourceManager=new io({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:da(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[Th],renderPass:void 0,stats:s||new Oe({id:"deck.gl"}),viewport:o||new Se({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:n||new xr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let s=i.getNeedsRedraw(e);r=r||s}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(i=>r.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){Q(rR,this,r,e),this._lastRenderedLayers=e;let i=fr(e,Boolean);for(let s of i)s.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(s=>s.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let n of e)i[n.id]?L.warn(`Multiple old layers with same id ${n.id}`)():i[n.id]=n;if(this._defaultShaderModulesChanged){for(let n of e)n.setNeedsUpdate(),n.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(r,i,s),this._finalizeOldLayers(i);let o=!1;for(let n of s)if(n.hasUniformTransition()){o=`Uniform transition in ${n}`;break}this._needsUpdate=o,this.layers=s}_updateSublayersRecursively(e,r,i){for(let s of e){s.context=this.context;let o=r[s.id];o===null&&L.warn(`Multiple new layers with same id ${s.id}`)(),r[s.id]=null;let n=null;try{this._debug&&o!==s&&s.validateProps(),o?(this._transferLayerState(o,s),this._updateLayer(s)):this._initializeLayer(s),i.push(s),n=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}n&&this._updateSublayersRecursively(n,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=lr.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=lr.MATCHED,r!==e&&(e.lifecycle=lr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=lr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=lr.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function K(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!K(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(let o of i)if(!e.hasOwnProperty(o)||!K(t[o],e[o],r-1))return!1;return!0}return!1}var so=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let r=this.controllers[e];r&&r.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let r=this.controllers[e];r&&r.updateTransition()}}getViewports(e){return e?this._viewports.filter(r=>r.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),s={x:e[0],y:e[1]};for(let o=i.length-1;o>=0;--o){let n=i[o];if(n.containsPixel(s)){let a=e.slice();return a[0]-=n.x,a[1]-=n.y,n.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=fr(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!K(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):L.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:o=>this.getView(e.id)?.makeViewport({viewState:o,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,r,i,s){let o=e.controller;if(o&&i){let n={...r,...o,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!s||s.constructor!==o.type)&&(s=this._createController(e,n)),s&&s.setProps(n),s}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let s=e.length;s--;){let o=e[s],n=this.getViewState(o),a=o.makeViewport({viewState:n,width:this.width,height:this.height}),c=r[o.id],l=Boolean(o.controller);l&&!c&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[o.id]=this._updateController(o,n,a,c),a&&this._viewports.unshift(a)}for(let s in r){let o=r[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,s)=>!e[s].equals(r[s]))}};var sR=/^(?:\d+\.?\d*|\.\d+)$/;function Bt(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{let e=oR(t);return new jh(e).parseExpression()}catch(e){let r=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${r}`)}default:throw new Error(`Could not parse position string ${t}`)}}function Wh(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":let r=Wh(t.left,e),i=Wh(t.right,e);return t.operator==="+"?r+i:r-i;default:throw new Error("Unknown layout expression type")}}function Lt(t,e){return Wh(t,e)}function oR(t){let e=[],r=0;for(;r<t.length;){let i=t[r];if(/\s/.test(i)){r++;continue}if(i==="+"||i==="-"||i==="("||i===")"||i==="%"){e.push({type:"symbol",value:i}),r++;continue}if(c_(i)||i==="."){let s=r,o=i===".";for(r++;r<t.length;){let a=t[r];if(c_(a)){r++;continue}if(a==="."&&!o){o=!0,r++;continue}break}let n=t.slice(s,r);if(!sR.test(n))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(n)});continue}if(l_(i)){let s=r;for(;r<t.length&&l_(t[r]);)r++;let o=t.slice(s,r).toLowerCase();e.push({type:"word",value:o});continue}throw new Error("Invalid token in position string")}return e}var jh=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),r=this.peek();for(;nR(r);){this.index++;let i=this.parseFactor();e={type:"binary",operator:r.value,left:e,right:i},r=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;let r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(e.type==="symbol"&&e.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="number"){this.index++;let r=e.value,i=this.peek();return i&&i.type==="symbol"&&i.value==="%"?(this.index++,{type:"percentage",value:r/100}):i&&i.type==="word"&&i.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let r=this.peek();return r&&r.type==="symbol"&&r.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function c_(t){return t>="0"&&t<="9"}function l_(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function nR(t){return Boolean(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function f_(t,e){let r={...t};for(let i in e)i!=="id"&&(Array.isArray(r[i])&&Array.isArray(e[i])?r[i]=aR(r[i],e[i]):r[i]=e[i]);return r}function aR(t,e){t=t.slice();for(let r=0;r<e.length;r++){let i=e[r];Number.isFinite(i)&&(t[r]=i)}return t}var ye=class{constructor(e){let{id:r,x:i=0,y:s=0,width:o="100%",height:n="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Bt(i),this._y=Bt(s),this._width=Bt(o),this._height=Bt(n),this._padding=a&&{left:Bt(a.left||0),right:Bt(a.right||0),top:Bt(a.top||0),bottom:Bt(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&K(this.props,e.props,2)}clone(e){let r=this.constructor;return new r({...this.props,...e})}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let s=this.getDimensions({width:e,height:r});if(!s.height||!s.width)return null;let o=this.getViewportType(i);return new o({...i,...this.props,...s})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?f_(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:r}){let i={x:Lt(this._x,e),y:Lt(this._y,r),width:Lt(this._width,e),height:Lt(this._height,r)};return this._padding&&(i.padding={left:Lt(this._padding.left,e),top:Lt(this._padding.top,r),right:Lt(this._padding.right,e),bottom:Lt(this._padding.bottom,r)}),i}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var Ze=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var h_=()=>{},oo={BREAK:1,SNAP_TO_END:2,IGNORE:3},cR=t=>t,lR=oo.BREAK,no=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:s,startProps:o,endProps:n,duration:a,easing:c}}=r,l=c(i/a),f=s.interpolateProps(o,n,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Ze(e.timeline),this.onViewStateChange=e.onViewStateChange||h_,this.onStateChange=e.onStateChange||h_}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let s=i;if(this.transition.inProgress){let{interruption:o,endProps:n}=this.transition.settings;s={...i,...o===oo.SNAP_TO_END?n:this.propsInTransition||i}}this._triggerTransition(s,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===oo.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),s=this.getControllerState(r).shortestPathFrom(i),o=r.transitionInterpolator,n=o.getDuration?o.getDuration(e,r):r.transitionDuration;if(n===0)return;let a=o.initializeProps(e,s);this.propsInTransition={};let c={duration:n,easing:r.transitionEasing||cR,interpolator:o,interruption:r.transitionInterruption||lR,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function Y(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var Ut=class{constructor(e){let{compare:r,extract:i,required:s}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=s}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!Re(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},s={};for(let o of this._propsToExtract)(o in e||o in r)&&(i[o]=e[o],s[o]=r[o]);return this._checkRequiredProps(i),this._checkRequiredProps(s),{start:i,end:s}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];Y(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var ba=Math.PI/180,u_=180/Math.PI,xa=6370972,kt=256;function fR(){let t=kt/xa,e=Math.PI/180*kt;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var Aa=class extends Se{constructor(e={}){let{longitude:r=0,zoom:i=0,nearZMultiplier:s=.5,farZMultiplier:o=1,resolution:n=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,me),-me),c=c||1,f?l=Ot(f):f=It(l);let h=Math.pow(2,i-dt(a)),u=e.nearZ??s,d=e.farZ??(l+kt*2*h/c)*o,p=new z().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*ba),p.rotateZ(-r*ba),p.scale(h/c),super({...e,height:c,viewMatrix:p,longitude:r,latitude:a,zoom:i,distanceScales:fR(),fovy:f,focalDistance:l,near:u,far:d}),this.scale=h,this.latitude=a,this.longitude=r,this.fovy=f,this.resolution=n}get projectionMode(){return oe.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,this.height/2],r),s=this.unproject([this.width/2,0],r),o=this.unproject([this.width,this.height/2],r),n=this.unproject([this.width/2,this.height],r);return o[0]<this.longitude&&(o[0]+=360),i[0]>this.longitude&&(i[0]-=360),[Math.min(i[0],o[0],s[0],n[0]),Math.min(i[1],o[1],s[1],n[1]),Math.max(i[0],o[0],s[0],n[0]),Math.max(i[1],o[1],s[1],n[1])]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[s,o,n]=e,a=r?o:this.height-o,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(n))l=Hh(c,[s,a,n,1]);else{let d=Hh(c,[s,a,-1,1]),p=Hh(c,[s,a,1,1]),g=((i||0)/xa+1)*kt,m=pe.sqrLen(pe.sub([],d,p)),_=pe.sqrLen(d),T=pe.sqrLen(p),x=4*((4*_*T-(m-_-T)**2)/16)/m,S=Math.sqrt(_-x),A=Math.sqrt(Math.max(0,g*g-x)),w=(S-A)/Math.sqrt(m);l=pe.lerp([],d,p,w)}let[f,h,u]=this.unprojectPosition(l);return Number.isFinite(n)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i,s=0]=e,o=r*ba,n=i*ba,a=Math.cos(n),c=(s/xa+1)*kt;return[Math.sin(o)*a*c,-Math.cos(o)*a*c,Math.sin(n)*c]}unprojectPosition(e){let[r,i,s]=e,o=pe.len(e),n=Math.asin(s/o),c=Math.atan2(r,-i)*u_,l=n*u_,f=(o/kt-1)*xa;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,r,i],s,o){let a=.25/Math.pow(2,this.zoom-dt(this.latitude)),c=e+a*(o[0]-s[0]),l=r-a*(o[1]-s[1]);l=Math.max(Math.min(l,me),-me);let f={longitude:c,latitude:l,zoom:i-dt(r)};return f.zoom+=dt(f.latitude),f}};Aa.displayName="GlobeViewport";var Ii=Aa;function dt(t){let e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function Hh(t,e){let r=xe.transformMat4([],e,t);return xe.scale(r,r,1/r[3]),r}var hR=["longitude","latitude","zoom","bearing","pitch"],uR=["longitude","latitude","zoom"],ce=class extends Ut{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:hR,required:uR},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:s,around:o}=this.opts;if(s&&o)if(s(e)instanceof Ii)L.warn("around not supported in GlobeView")();else{let a=s(e),c=s(r),l=a.unproject(o);i.start.around=o,Object.assign(i.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let s={};for(let o of this._propsToExtract)s[o]=vt(e[o]||0,r[o]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let o=this.opts.makeViewport({...r,...s});Object.assign(s,o.panByPosition(r.aroundPosition,vt(e.around,r.around,i)))}return s}};var Vt={transitionDuration:0},dR=300,Sa=t=>1-(1-t)*(1-t),Oi={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},Ur={},Te=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new no({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return r?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:i}=this.props,{offsetCenter:s}=e;return[s.x-r,s.y-i]}isPointInBounds(e,r){let{width:i,height:s}=this.props;if(r&&r.handled)return!1;let o=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=s;return o&&r&&r.stopPropagation(),o}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let r=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?dR:0;let{scrollZoom:s=!0,dragPan:o=!0,dragRotate:n=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,h=Boolean(this.onViewStateChange);if(this.toggleEvents(Oi.WHEEL,h&&s),this.toggleEvents(Oi.PAN,h),this.toggleEvents(Oi.PINCH,h&&(c||l)),this.toggleEvents(Oi.MULTI_PAN,h&&l),this.toggleEvents(Oi.DOUBLE_CLICK,h&&a),this.toggleEvents(Oi.KEYBOARD,h&&f),this.scrollZoom=s,this.dragPan=o,this.dragRotate=n,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!r||r.height!==e.height||r.width!==e.width||r.maxBounds!==e.maxBounds)&&e.maxBounds){let d=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=d.getViewportProps();Object.keys(p).some(m=>!K(p[m],e[m],1))&&this.updateViewport(d)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let s={...e.getViewportProps(),...r},o=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),o){let n=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:n,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let s=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(s,Vt,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,Vt,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],o=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(o,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Sa},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Vt,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],o=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(o,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Sa},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:o}=e,n=2/(1+Math.exp(-Math.abs(o*i)));o<0&&n!==0&&(n=1/n);let a=s?{...this._getTransitionProps({around:r}),transitionDuration:250}:Vt,c=this.controllerState.zoom({pos:r,scale:n});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),s||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,Vt,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Vt,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),s=[i[0],i[1]+=e.velocityY*r/2],o=this.controllerState.rotate({pos:s});this.updateViewport(o,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Sa},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return Ur._startPinchRotation=e.rotation,Ur._lastPinchEvent=e,this.updateViewport(i,Vt,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,s=this.getCenter(e);r=r.zoom({pos:s,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:Ur._startPinchRotation-i})}return this.updateViewport(r,Vt,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Ur._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=Ur;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let s=this.getCenter(e),o=this.controllerState.rotateEnd(),n=Math.log2(e.scale),a=(n-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),c=Math.pow(2,n+a*r/2);o=o.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:r,transitionEasing:Sa},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Ur._startPinchRotation=null,Ur._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(s,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:s,rotateSpeedX:o,rotateSpeedY:n}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(o),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(o),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(n),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(n),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?Vt:e?{...r,transitionInterpolator:new ce({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Ke=class{constructor(e,r,i){this.makeViewport=i,this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var d_=5,pR=1.2,p_=512,g_=[[-1/0,-90],[1/0,90]];function Ea([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){let[i,s]=Ae([t,e]);return[i,B(s,0,p_)]}let[,r]=Ae([0,e]);return[t,B(r,0,p_)]}var ao=class extends Ke{constructor(e){let{width:r,height:i,latitude:s,longitude:o,zoom:n,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:h=20,minZoom:u=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:T,startBearing:y,startPitch:x,startZoom:S,normalize:A=!0}=e;Y(Number.isFinite(o)),Y(Number.isFinite(s)),Y(Number.isFinite(n));let w=e.maxBounds||(A?g_:null);super({width:r,height:i,latitude:s,longitude:o,zoom:n,bearing:a,pitch:c,altitude:l,maxZoom:h,minZoom:u,maxPitch:d,minPitch:p,normalize:A,position:f,maxBounds:w},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:T,startBearing:y,startPitch:x,startZoom:S},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(o)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let r=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:r!==void 0?this._unproject3D(e,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startRotateLngLat:o,startBearing:n,startPitch:a}=this.getState();if(!s||n===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,s,a,n):c={bearing:n+r,pitch:a+i},o){let l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](o,s)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomLngLat:o}=this.getState();if(o||(s=this.getViewportProps().zoom,o=this._unproject(r)||this._unproject(e)),!o)return this;let n=this._constrainZoom(s+Math.log2(i)),a=this.makeViewport({...this.getViewportProps(),zoom:n});return this._getUpdatedState({zoom:n,...a.panByPosition(o,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:o}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),Math.abs(o-r.longitude)>180&&(i.longitude=o<0?o+360:o-360),i}applyConstraints(e){let{maxPitch:r,minPitch:i,pitch:s,longitude:o,bearing:n,normalize:a,maxBounds:c}=e;if(a&&((o<-180||o>180)&&(e.longitude=ht(o+180,360)-180),(n<-180||n>180)&&(e.bearing=ht(n+180,360)-180)),e.pitch=B(s,i,r),e.zoom=this._constrainZoom(e.zoom,e),c){let l=Ea(c[0]),f=Ea(c[1]),h=2**e.zoom,u=e.width/2/h,d=e.height/2/h,[p,g]=_e([l[0]+u,l[1]+d]),[m,_]=_e([f[0]-u,f[1]-d]);e.longitude=B(e.longitude,p,m),e.latitude=B(e.latitude,g,_)}return e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:s}=r,o=s!==null&&r.width>0&&r.height>0,{minZoom:n}=r;if(o){let a=Ea(s[0]),c=Ea(s[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(n=Math.max(n,Math.log2(r.width/l))),Number.isFinite(f)&&f>0&&(n=Math.max(n,Math.log2(r.height/f))),n>i&&(n=i)}return B(e,n,i)}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_unproject3D(e,r){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:r})}_getNewRotation(e,r,i,s){let o=e[0]-r[0],n=e[1]-r[1],a=e[1],c=r[1],{width:l,height:f}=this.getViewportProps(),h=o/l,u=0;n>0?Math.abs(f-c)>d_&&(u=n/(c-f)*pR):n<0&&c>d_&&(u=1-a/c),u=B(u,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=s+180*h,m=i;return u>0?m=i+u*(p-i):u<0&&(m=i-u*(d-i)),{pitch:m,bearing:g}}},kr=class extends Te{constructor(){super(...arguments),this.ControllerState=ao,this.transition={transitionDuration:300,transitionInterpolator:new ce({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:i}=this.props,s=this.pickPosition(r+e[0],i+e[1]);if(s&&s.coordinate&&s.coordinate.length>=3)return s.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:g_),super.setProps(e)}updateViewport(e,r=null,i={}){let s=e.getState();i.isDragging&&s.startRotateLngLat?i={...i,rotationPivotPosition:s.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,r,i)}};var wa=class extends ye{constructor(e={}){super(e)}getViewportType(){return cr}get ControllerType(){return kr}};wa.displayName="MapView";var Ra=wa;var gR=new ar;function mR(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var co=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(s=>mR(s,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(K(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let s of this.effects)r[s.id]=s;let i=[];for(let s of e){let o=r[s.id],n=s;o&&o!==s?o.setProps?(o.setProps(s.props),n=o):o.cleanup(this._context):o||s.setup(this._context),i.push(n),delete r[s.id]}for(let s in r)r[s].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(s=>s instanceof ar)||this._resolvedEffects.push(gR),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var lo=class extends $e{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}render(e){return this._render(e)}};var _R="deckRenderer.renderLayers",Vr=class{constructor(e,r={}){this.device=e,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new lo(e),this.pickLayersPass=new Dt(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let s=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let o=r.render({...i,target:s}),n="stats"in o?o.stats:o;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,Q(_R,this,n,e),this._updateStats(n)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers rendered").addCount(r)}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize(),[i,s]=r;e.length===0&&[0,1].map(o=>{let n=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:i,height:s});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[n]}))});for(let o of e)o.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,s={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r.target:void 0;let n=o.postRender(s);s.inputBuffer=n,s.swapBuffer=n===i[0]?i[1]:i[0]}}};var yR={pickedColor:null,pickedObjectIndex:-1};function $h({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:s,deviceRect:o}){let{x:n,y:a,width:c,height:l}=o,f=s*s,h=-1,u=0;for(let d=0;d<l;d++){let p=d+a-i,g=p*p;if(g>f)u+=4*c;else for(let m=0;m<c;m++){if(t[u+3]-1>=0){let T=m+n-r,y=T*T+g;y<=f&&(f=y,h=u)}u+=4}}if(h>=0){let d=t.slice(h,h+4),p=e(d);if(p){let g=Math.floor(h/4/c),m=h/4-g*c;return{...p,pickedColor:d,pickedX:n+m,pickedY:a+g}}L.error("Picked non-existent layer. Is picking buffer corrupt?")()}return yR}function Xh({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i<t.length;i+=4)if(t[i+3]-1>=0){let o=t.slice(i,i+4),n=o.join(",");if(!r.has(n)){let a=e(o);a?r.set(n,{...a,color:o}):L.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function Pa({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:s,z:o}){let n=e[0];e.length>1&&(n=TR(t?.pickedViewports||e,{x:i,y:s}));let a;if(n){let c=[i-n.x,s-n.y];o!==void 0&&(c[2]=o),a=n.unproject(c)}return{color:null,layer:null,viewport:n,index:-1,picked:!1,x:i,y:s,pixel:[i,s],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function Yh(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:s}=t,{pickedColor:o,pickedLayer:n,pickedObjectIndex:a}=e,c=n?[n]:[];if(i==="hover"){let h=r.index,u=r.layerId,d=n?n.props.id:null;if(d!==u||a!==h){if(d!==u){let p=s.find(g=>g.props.id===u);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=Pa(t),f=new Map;return f.set(null,l),c.forEach(h=>{let u={...l};h===n&&(u.color=o,u.index=a,u.picked=!0),u=va({layer:h,info:u,mode:i});let d=u.layer;h===n&&i==="hover"&&(r.info=u),f.set(d.id,u),i==="hover"&&d.updateAutoHighlight(u)}),f}function va({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function TR(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var fo=class{constructor(e,r={}){this._pickable=!0,this.device=e,this.stats=r.stats,this.pickLayersPass=new Dt(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:i,viewports:s},o=this.lastPickedInfo.info){let n=o&&o.layer&&o.layer.id,a=o&&o.viewport&&o.viewport.id,c=n?i.find(u=>u.id===n):null,l=a&&s.find(u=>u.id===a)||s[0],f=l&&l.unproject([e-l.x,r-l.y]);return{...o,...{x:e,y:r,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let r=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=r}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:e,views:r,viewports:i,x:s,y:o,radius:n=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:Pa({viewports:i,x:s,y:o,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(n*u),{width:_,height:T}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:T}),x={x:s-n,y:o-n,width:n*2+1,height:n*2+1},S,A=[],w=new Set;for(let v=0;v<a;v++){let R;if(y){let C=this._drawAndSample({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:x,effects:h,pass:`picking:${c}`});R=$h({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let M,I=this._getDepthLayers(R,d,l);if(I.length>0){let{pickedColors:C}=this._drawAndSample({layers:I,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:x,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(M=C[0])}R.pickedLayer&&v+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=Yh({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:s,y:o,z:M,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let v of w)v.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}_pickClosestObject({layers:e,views:r,viewports:i,x:s,y:o,radius:n=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:Pa({viewports:i,x:s,y:o,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(n*u),{width:_,height:T}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:T}),x={x:s-n,y:o-n,width:n*2+1,height:n*2+1},S,A=[],w=new Set;for(let v=0;v<a;v++){let R;if(y){let C=this._drawAndSample({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:x,effects:h,pass:`picking:${c}`});R=$h({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let M,I=this._getDepthLayers(R,d,l);if(I.length>0){let{pickedColors:C}=this._drawAndSample({layers:I,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:x,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(M=C[0])}R.pickedLayer&&v+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=Yh({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:s,y:o,z:M,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let v of w)v.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:r,viewports:i,x:s,y:o,width:n=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([s+n,o+a],!0),T=_.x+_.width,y=_.y,x={x:g,y,width:T-g,height:m-y},S=this._drawAndSample({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:x,cullRect:{x:s,y:o,width:n,height:a},effects:h,pass:`picking:${c}`}),A=Xh(S),w=new Map,v=[],R=Number.isFinite(l);for(let M=0;M<A.length&&!(R&&v.length>=l);M++){let I=A[M],C={color:I.pickedColor,layer:null,index:I.pickedObjectIndex,picked:!0,x:s,y:o,pixelRatio:d};C=va({layer:I.pickedLayer,info:C,mode:c});let W=C.layer.id;w.has(W)||w.set(W,new Set);let V=w.get(W),J=C.object??C.index;V.has(J)||(V.add(J),v.push(C))}return v}_pickVisibleObjects({layers:e,views:r,viewports:i,x:s,y:o,width:n=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([s+n,o+a],!0),T=_.x+_.width,y=_.y,x={x:g,y,width:T-g,height:m-y},S=this._drawAndSample({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:x,cullRect:{x:s,y:o,width:n,height:a},effects:h,pass:`picking:${c}`}),A=Xh(S),w=new Map,v=[],R=Number.isFinite(l);for(let M=0;M<A.length&&!(R&&v.length>=l);M++){let I=A[M],C={color:I.pickedColor,layer:null,index:I.pickedObjectIndex,picked:!0,x:s,y:o,pixelRatio:d};C=va({layer:I.pickedLayer,info:C,mode:c});let W=C.layer.id;w.has(W)||w.set(W,new Set);let V=w.get(W),J=C.object??C.index;V.has(J)||(V.add(J),v.push(C))}return v}async _drawAndSampleAsync({layers:e,views:r,viewports:i,onViewportActive:s,deviceRect:o,cullRect:n,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,pickingFBO:f,deviceRect:o,cullRect:n,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(h.preRenderStats[y.id]=y.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=o,T=new(l?Float32Array:Uint8Array)(m*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:g,sourceWidth:m,sourceHeight:_,target:T}),{pickedColors:T,decodePickingColor:u}}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:s,deviceRect:o,cullRect:n,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,pickingFBO:f,deviceRect:o,cullRect:n,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(h.preRenderStats[y.id]=y.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=o,T=new(l?Float32Array:Uint8Array)(m*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:g,sourceWidth:m,sourceHeight:_,target:T}),{pickedColors:T,decodePickingColor:u}}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers picked").addCount(r)}_getDepthLayers(e,r,i){if(!i||!this.depthFBO)return[];let{pickedLayer:s}=e,o=s?.state?.terrainDrawMode==="drape";return s&&!o?[s]:r.filter(n=>n.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:s,deviceHeight:o}){let n=Math.max(0,e-i),a=Math.max(0,r-i),c=Math.min(s,e+i+1)-n,l=Math.min(o,r+i+1)-a;return c<=0||l<=0?null:{x:n,y:a,width:c,height:l}}};var bR={"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}},xR="top-left",m_="root",Ma=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!K(e.widgets,this.widgets,1)){let r=e.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:r}){let i=e.reduce((s,o)=>(s[o.id]=o,s),{});for(let s of this.getWidgets()){let{viewId:o}=s;if(o){let n=i[o];n&&(s.onViewportChange&&s.onViewportChange(n),s.onRedraw?.({viewports:[n],layers:r}))}else{if(s.onViewportChange)for(let n of e)s.onViewportChange(n);s.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:s}=i;(!s||s===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=js[r.type];if(i)for(let s of this.getWidgets()){let{viewId:o}=s;(!o||o===e.viewport?.id)&&s[i]?.(e,r)}}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let s=r[i.id];s?s.viewId!==i.viewId||s.placement!==i.placement?(this._removeWidget(s),this._addWidget(i)):i!==s&&(s.setProps(i.props),i=s):this._addWidget(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let s=r[i];s&&this._removeWidget(s)}this.widgets=e}_addWidget(e){let{viewId:r=null,placement:i=xR}=e,s=e.props._container??r;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:r}),e.rootElement&&this._getContainer(s,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,r){if(e&&typeof e!="string")return e;let i=e||m_,s=this.containers[i];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[i]=s);let o=s.querySelector(`.${r}`);return o||(o=globalThis.document.createElement("div"),o.className=r,o.style.position="absolute",o.style.zIndex="2",Object.assign(o.style,bR[r]),s.append(o)),o}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let s=this.lastViewports[i]||null,o=i===m_||s,n=this.containers[i];o?(n.style.display="block",n.style.left=`${s?s.x:0}px`,n.style.top=`${s?s.y:0}px`,n.style.width=`${s?s.width:e}px`,n.style.height=`${s?s.height:r}px`):n.style.display="none"}}};function ho(t,e){e&&Object.entries(e).map(([r,i])=>{r.startsWith("--")?t.style.setProperty(r,i):t.style[r]=i})}function Ca(t,e){e&&Object.keys(e).map(r=>{r.startsWith("--")?t.style.removeProperty(r):t.style[r]=""})}var hr=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let r=this.props,i=this.rootElement;i&&r.className!==e.className&&(r.className&&i.classList.remove(r.className),e.className&&i.classList.add(e.className)),i&&!K(r.style,e.style,1)&&(Ca(i,r.style),ho(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,r){this.deck?._onViewStateChange({viewId:e,viewState:r,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],r=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>r.classList.add(i)),ho(r,this.props.style),r}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,r){}onClick(e,r){}onDrag(e,r){}onDragStart(e,r){}onDragEnd(e,r){}};hr.defaultProps={id:"widget",style:{},_container:null,className:""};var AR={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},uo=class extends hr{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,AR),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:r}=this,i=r&&r.props.getTooltip;if(!i)return;let s=i(e);this.setTooltip(s,e.x,e.y)}setTooltip(e,r,i){let s=this.rootElement;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}};uo.defaultProps={...hr.defaultProps};F();fc();Wi();function dr(){}var O3=({isDragging:t})=>t?"grabbing":"grab",U0={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:dr,onWebGLInitialized:dr,onResize:dr,onViewStateChange:dr,onInteractionStateChange:dr,onBeforeRender:dr,onAfterRender:dr,onLoad:dr,onError:t=>L.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:O3,getTooltip:null,debug:!1,drawPickingColors:!1},Ao=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Oe({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount: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,unproject3D:!1},this._lastPointerDownInfo=null,this._onPointerMove=i=>{let{_pickRequest:s}=this;if(i.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(i.leftButton||i.rightButton)return;{let o=i.offsetCenter;if(!o)return;s.x=o.x,s.y=o.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=i},this._onEvent=i=>{let s=js[i.type],o=i.offsetCenter;if(!s||!o||!this.layerManager)return;let n,a=this.layerManager.getLayers(),c=a.some(d=>d.props.pickable==="3d");if(i.type==="click"&&c){let d=this._pick("pickObject","pickObject Time",{x:o.x,y:o.y,radius:this.props.pickingRadius,unproject3D:!0});n=d.result[0]||d.emptyInfo}else n=this.deckPicker.getLastPickedObject({x:o.x,y:o.y,layers:a,viewports:this.getViewports(o)},this._lastPointerDownInfo);let{layer:l}=n,f=l&&(l[s]||l.props[s]),h=this.props[s],u=!1;f&&(u=f.call(l,n,i)),u||(h?.(n,i),this.widgetManager.onEvent(n,i))},this._onPointerDown=i=>{if(this.device?.type==="webgpu")return;let s=i.offsetCenter,o=this._pick("pickObject","pickObject Time",{x:s.x,y:s.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=o.result[0]||o.emptyInfo},this.props={...U0,...e},e=this.props,e.viewState&&e.initialViewState&&L.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let r=this.device;if(!r&&e.gl){e.gl instanceof WebGLRenderingContext&&L.error("WebGL1 context not supported.")();let i=this.props.deviceProps?.onResize;r=xo.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(s,o)=>{let{width:n,height:a}=s.canvas;s.setDrawingBufferSize(n,a),this._needsRedraw="Canvas resized",i?.(s,o)}})}r||(r=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Xe.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&L.removed("onLayerHover","onHover")(),"onLayerClick"in e&&L.removed("onLayerClick","onClick")(),e.initialViewState&&!K(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),L.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(r),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),o=this.effectManager.needsRedraw(e),n=this.deckRenderer.needsRedraw(e);return r=r||i||s||o||n,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return Y(this.viewManager),this.viewManager.views}getView(e){return Y(this.viewManager),this.viewManager.getView(e)}getViewports(e){return Y(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,r){return this.pickObject({x:e,y:r,radius:0,unproject3D:!0})}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,r,i){Y(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(r).timeStart();let o=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return s.get(r).timeEnd(),o}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),Y(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(r.width=e.width),e.height&&typeof e.height=="number"&&(r.height=e.height),(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let s=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=s}if(i||i===0){let s=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:s}=r;return new ci({device:e,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:s})}_createDevice(e){let r=this.props.deviceProps?.createCanvasContext,i=typeof r=="object"?r:void 0,s={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};s.adapters.includes(xo)||s.adapters.push(xo);let o={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0},n=this.props.deviceProps?.onResize;return Xt.createDevice({_reuseDevices:!0,type:"webgl",...s,createCanvasContext:{...o,...i,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(a,c)=>{this._needsRedraw="Canvas resized",n?.(a,c)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new Ra({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){if(this.device?.type==="webgpu")return;let{_pickRequest:e}=this;if(e.event){let i=(this.layerManager?.getLayers()||[]).some(c=>c.props.pickable==="3d");e.unproject3D=i;let{result:s,emptyInfo:o}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=s.length>0;let n=o,a=!1;for(let c of s)n=c,a=c.layer?.onHover(c,e.event)||a;a||(this.props.onHover?.(n,e.event),this.widgetManager.onHover(n,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new xr;r.play(),this.animationLoop.attachTimeline(r);let i=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new Ws(i,{touchAction:this.props.touchAction,recognizers:Object.keys(Mh).map(n=>{let[a,c,l,f]=Mh[n],h=this.props.eventRecognizerOptions?.[n],u={...c,...h,event:n};return{recognizer:new a(u),recognizeWith:l,requestFailure:f}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let n in js)this.eventManager.on(n,this._onEvent);this.viewManager=new so({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let s=this.viewManager.getViewports()[0];this.layerManager=new Lr(this.device,{deck:this,stats:this.stats,viewport:s,timeline:r}),this.effectManager=new co({deck:this,device:this.device}),this.deckRenderer=new Vr(this.device,{stats:this.stats}),this.deckPicker=new fo(this.device,{stats:this.stats});let o=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new Ma({deck:this,parentElement:o}),this.widgetManager.addDefault(new uo),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:s});let o={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(o),o.pass==="screen"&&this.widgetManager.onRedraw({viewports:o.viewports,layers:o.layers}),this.props.onAfterRender({device:i,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),L.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this.device?.type!=="webgpu"&&this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=r.get("Layers rendered").lastSampleCount,e.pickLayersCount=r.get("Layers picked").lastSampleCount,e.updateAttributesCount=r.get("Layers updated").count,e.updateAttributesCount=r.get("Attributes updated").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=Xt.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};Ao.defaultProps=U0;Ao.VERSION=Zn;var pc=Ao;F();F();function k0(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Et(t)}}var V0=_r;function So(t,e,r){if(e.size>4)return null;let i=r==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${i}x${e.size}`:e.type,byteOffset:e.offset||0}}function pr(t){return t.stride||t.size*t.bytesPerElement}function z0(t,e){return t.type===e.type&&t.size===e.size&&pr(t)===pr(e)&&(t.offset||0)===(e.offset||0)}function bu(t,e){e.offset&&L.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=pr(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,s=e.elementOffset||0,o=i*r+s*t.bytesPerElement+(t.offset||0);return{...e,offset:o,stride:r}}function N3(t,e){let r=bu(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Eo=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let s=r.logicalType||r.type,o=s==="float64",{defaultValue:n}=r;n=Number.isFinite(n)?[n]:n||new Array(this.size).fill(0);let a;o?a="float32":!s&&r.isIndexed?a="uint32":a=s||"float32";let c=k0(s||a);this.doublePrecision=o,o&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:n,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*pr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Xe.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let s=this.value;if(r){let o=bu(this.getAccessor(),r),n=o.offset/s.BYTES_PER_ELEMENT,a=o.size||this.size;i[e]=s.subarray(n,n+a)}else i[e]=s}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),s=[],o={name:this.id,byteStride:pr(i)};if(this.doublePrecision){let n=N3(i,r||{});s.push(So(e,{...i,...n.high},this.device.type),So(`${e}64Low`,{...i,...n.low},this.device.type))}else if(r){let n=bu(i,r);s.push(So(e,{...i,...n},this.device.type))}else s.push(So(e,i,this.device.type));return o.attributes=s.filter(Boolean),o}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:s}=this,o=i*s;if(r&&o&&r.length>=o){let n=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;c<o;)for(let l=0;l<s;l++){let f=r[c++];f<n[l]&&(n[l]=f),f>a[l]&&(a[l]=f)}e=[n,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof D?i={buffer:e}:i=e;let s={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)s.type="float32";else{let n=V0(i.value);s.type=s.normalized?n.replace("int","norm"):n}s.bytesPerElement=i.value.BYTES_PER_ELEMENT,s.stride=pr(s)}if(r.bounds=null,i.constant){let o=i.value;if(o=this._normalizeValue(o,[],0),this.settings.normalized&&(o=this.normalizeConstant(o)),!(!r.constant||!this._areValuesEqual(o,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(o)?o:new Float32Array(o)}else if(i.buffer){let o=i.buffer;r.externalBuffer=o,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let o=i.value;r.externalBuffer=null,r.constant=!1,this.value=o;let{buffer:n}=this,a=pr(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&o instanceof Float64Array&&(o=pa(o,s)),this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let l=o.byteLength+c+a*2;(!n||n.byteLength<l)&&(n=this._createBuffer(l)),n.write(o,c)}return this.setAccessor(s),!0}updateSubBuffer(e={}){this.state.bounds=null;let r=this.value,{startOffset:i=0,endOffset:s}=e;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?pa(r,{size:this.size,startIndex:i,endIndex:s}):r.subarray(i,s),i*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,r=!1){let{state:i}=this,s=i.allocatedValue,o=Xe.allocate(s,e+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=o;let{byteOffset:n}=this,{buffer:a}=this;return(!a||a.byteLength<o.byteLength+n)&&(a=this._createBuffer(o.byteLength+n),r&&s&&a.write(s instanceof Float64Array?pa(s,this):s,n)),i.allocatedValue=o,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:r}=e;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let i=this.settings.defaultType,s=!1;if(this.doublePrecision&&(s=r.BYTES_PER_ELEMENT<4),s)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof i)&&this.settings.normalized&&!("normalized"in e)&&L.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:s,size:o}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let n=o;for(;--n>=0;)r[i+n]=s[n];return r}switch(o){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let n=o;for(;--n>=0;)r[i+n]=Number.isFinite(e[n])?e[n]:s[n]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let s=0;s<i;s++)if(e[s]!==r[s])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(r?D.INDEX:D.VERTEX)|D.COPY_DST,indexType:r?i:void 0,byteLength:e}),this._buffer}};var W0=[],j0=[];function Ui(t,e=0,r=1/0){let i=W0,s={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?i=t:t.length>0&&(j0.length=t.length,i=j0):i=W0,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),s.index=e-1),{iterable:i,objectInfo:s}}function gc(t){return t&&t[Symbol.asyncIterator]}function mc(t,e){let{size:r,stride:i,offset:s,startIndices:o,nested:n}=e,a=t.BYTES_PER_ELEMENT,c=i?i/a:r,l=s?s/a:0,f=Math.floor((t.length-l)/c);return(h,{index:u,target:d})=>{if(!o){let _=u*c+l;for(let T=0;T<r;T++)d[T]=t[_+T];return d}let p=o[u],g=o[u+1]||f,m;if(n){m=new Array(g-p);for(let _=p;_<g;_++){let T=_*c+l;d=new Array(r);for(let y=0;y<r;y++)d[y]=t[T+y];m[_-p]=d}}else if(c===r)m=t.subarray(p*r+l,g*r+l);else{m=new t.constructor((g-p)*r);let _=0;for(let T=p;T<g;T++){let y=T*c+l;for(let x=0;x<r;x++)m[_++]=t[y+x]}}return m}}var H0=[],wo=[[0,1/0]];function $0(t,e){if(t===wo||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;let r=[],i=t.length,s=0;for(let o=0;o<i;o++){let n=t[o];n[1]<e[0]?(r.push(n),s=o+1):n[0]>e[1]?r.push(n):e=[Math.min(n[0],e[0]),Math.max(n[1],e[1])]}return r.splice(s,0,e),r}var F3={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function _c(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...F3[r],...e,...t,type:r}}var zt=class extends Eo{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:wo}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!z0(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,i=this.settings.transition,s=Array.isArray(r)?e[r.find(o=>e[o])]:e[r];return _c(s,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:s=1/0}=r;this.state.updateRanges=$0(this.state.updateRanges,[i,s])}else this.state.updateRanges=wo}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=H0}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==wo),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:s}){if(!this.needsUpdate())return!1;let{state:{updateRanges:o},settings:{update:n,noAlloc:a}}=this,c=!0;if(n){for(let[l,f]of o)n.call(s,this,{data:r,startRow:l,endRow:f,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,f]of o){let h=Number.isFinite(l)?this.getVertexOffset(l):0,u=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:h,endOffset:u})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,r){let i=this.device.type==="webgpu";if(i||r===void 0||typeof r=="function"){if(i&&typeof r!="function"){let n=this._normalizeValue(r,[],0);this._areValuesEqual(n,this.value)||this.setNeedsUpdate("WebGPU constant updated")}return!1}let s=this.settings.transform&&e?this.settings.transform.call(e,r):r;return this.setData({constant:!0,value:s})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){let{state:r}=this;return e?(this.clearNeedsUpdate(),r.lastExternalBuffer===e||(r.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(e,r=null){let{state:i,settings:s}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(s.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;if(i.binaryValue=e,this.setNeedsRedraw(),s.transform||r!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let n=e;Y(ArrayBuffer.isView(n.value),`invalid ${s.accessor}`);let a=Boolean(n.size)&&n.size!==this.size;return i.binaryAccessor=mc(n.value,{size:n.size||this.size,stride:n.stride,offset:n.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:r}=this;return(r?e<r.length?r[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,r=super.getValue();if(!e)return r;for(let i in e)Object.assign(r,super.getValue(i,e[i]));return r}getBufferLayout(e){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,i=super._getBufferLayout(),{stepMode:s}=this.settings;if(s==="dynamic"?i.stepMode=e?e.isInstanced?"instance":"vertex":"instance":i.stepMode=s??"vertex",!r)return i;for(let o in r){let n=super._getBufferLayout(o,r[o]);i.attributes.push(...n.attributes)}return i}_autoUpdater(e,{data:r,startRow:i,endRow:s,props:o,numInstances:n}){if(e.constant&&this.context.device.type!=="webgpu")return;let{settings:a,state:c,value:l,size:f,startIndices:h}=e,{accessor:u,transform:d}=a,p=c.binaryAccessor||(typeof u=="function"?u:o[u]);typeof p!="function"&&typeof u=="string"&&(p=()=>o[u]),Y(typeof p=="function",`accessor "${u}" is not a function`);let g=e.getVertexOffset(i),{iterable:m,objectInfo:_}=Ui(r,i,s);for(let T of m){_.index++;let y=p(T,_);if(d&&(y=d.call(this,y)),h){let x=(_.index<h.length-1?h[_.index+1]:n)-h[_.index];if(y&&Array.isArray(y[0])){let S=g;for(let A of y)e._normalizeValue(A,l,S),S+=f}else y&&y.length>f?l.set(y,g):(e._normalizeValue(y,_.target,0),Ta({target:l,source:_.target,start:g,count:x}));g+=x*f}else e._normalizeValue(y,l,g),g+=f}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function xu(t){let{source:e,target:r,start:i=0,size:s,getData:o}=t,n=t.end||r.length,a=e.length,c=n-i;if(a>c){r.set(e.subarray(0,c),i);return}if(r.set(e,i),!o)return;let l=a;for(;l<c;){let f=o(l,e);for(let h=0;h<s;h++)r[i+l]=f[h]||0,l++}}function X0({source:t,target:e,size:r,getData:i,sourceStartIndices:s,targetStartIndices:o}){if(!s||!o)return xu({source:t,target:e,size:r,getData:i}),e;let n=0,a=0,c=i&&((f,h)=>i(f+a,h)),l=Math.min(s.length,o.length);for(let f=1;f<l;f++){let h=s[f]*r,u=o[f]*r;xu({source:t.subarray(n,h),target:e,start:a,end:u,size:r,getData:c}),n=h,a=u}return a<e.length&&xu({source:[],target:e,start:a,size:r,getData:c}),e}function Y0(t){let{device:e,settings:r,value:i}=t,s=new zt(e,r);return s.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),s}function yc(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function Tc(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function bc(t){t.push(t.shift())}function Z0(t,e){let{doublePrecision:r,settings:i,value:s,size:o}=t,n=r&&s instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=t.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(i.noAlloc?s.length:(e+a)*o)*n}function xc({device:t,source:e,target:r}){return(!r||r.byteLength<e.byteLength)&&(r?.destroy(),r=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),r}function Ac({device:t,buffer:e,attribute:r,fromLength:i,toLength:s,fromStartIndices:o,getData:n=a=>a}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,f=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,h=r.startIndices,u=o&&h,d=r.isConstant;if(!u&&e&&i>=s)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let y=n;n=(x,S)=>r.normalizeConstant(y(x,S))}let m=d?(y,x)=>n(g,x):(y,x)=>n(g.subarray(y+l,y+l+c),x),_=e?new Float32Array(e.readSyncWebGL(f,i*4).buffer):new Float32Array(0),T=new Float32Array(s);return X0({source:_,target:T,sourceStartIndices:o,targetStartIndices:h,size:c,getData:m}),(!e||e.byteLength<T.byteLength+f)&&(e?.destroy(),e=t.createBuffer({byteLength:T.byteLength+f,usage:35050})),e.write(T,f),e}var ki=class{constructor({device:e,attribute:r,timeline:i}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new Ze(i),this.attribute=r,this.attributeInTransition=Y0(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(e,r,i=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=Z0(this.attribute,r),this.transition.start({...e,duration:i})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}};var Ro=class extends ki{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="interpolation",this.transform=k3(e,r)}start(e,r){let i=this.currentLength,s=this.currentStartIndices;if(super.start(e,r,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:o,attribute:n}=this;bc(o),o[0]=Ac({device:this.device,buffer:o[0],attribute:n,fromLength:i,toLength:this.currentLength,fromStartIndices:s,getData:e.enter}),o[1]=xc({device:this.device,source:o[0],target:o[1]}),this.setBuffer(o[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/n.size);q0(n)&&(l/=2),c.setVertexCount(l),n.isConstant?(c.setAttributes({aFrom:o[0]}),c.setConstantAttributes({aTo:n.value})):c.setAttributes({aFrom:o[0],aTo:n.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:o[1]})}onUpdate(){let{duration:e,easing:r}=this.settings,{time:i}=this.transition,s=i/e;r&&(s=r(s));let{model:o}=this.transform,n={time:s};o.shaderInputs.setProps({interpolation:n}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},B3=`uniform interpolationUniforms {
|
|
1934
|
+
`;function D3(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor_ext`;return O3(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return N3(r)}return""}var B3={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},Lt=class extends Ye{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:o,pickingFBO:n,deviceRect:{x:a,y:c,width:l,height:f},cullRect:h,effects:u,pass:d="picking",pickZ:p,shaderModuleProps:g,clearColor:m}){this.pickZ=p;let _=this._resetColorEncoder(p),b=[a,c,l,f],y=super._render({target:n,layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:o,cullRect:h,effects:u?.filter(S=>S.useInPicking),pass:d,isPicking:!0,shaderModuleProps:g,clearColor:m??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:_&&F3.bind(null,_),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,r,i){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,r,i){let s={...e.props.parameters},{pickable:o,operation:n}=e.props;return this._colorEncoderState?o&&n.includes("draw")?(Object.assign(s,B3),s.blend=!0,this.device.type==="webgpu"?s.blendConstant=Q_(this._colorEncoderState,e,i):s.blendColor=Q_(this._colorEncoderState,e,i),n.includes("terrain")&&e.state?._hasPickingCover&&(s.blendAlphaSrcFactor="one")):n.includes("terrain")&&(s.blend=!1):s.blend=!1,s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function Q_(t,e,r){let{byLayer:i,byAlpha:s}=t,o,n=i.get(e);return n?(n.viewports.push(r),o=n.a):(o=i.size+1,o<=255?(n={a:o,layer:e,viewports:[r]},i.set(e,n),s[o]=n):(F.warn("Too many pickable layers, only picking the first 255")(),o=0)),[0,0,0,o/255]}function F3(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var pr={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"},Ui=Symbol.for("component"),ze=Symbol.for("propTypes"),va=Symbol.for("deprecatedProps"),Ut=Symbol.for("asyncPropDefaults"),_t=Symbol.for("asyncPropOriginal"),Ze=Symbol.for("asyncPropResolved");function gr(t,e=()=>!0){return Array.isArray(t)?J_(t,e,[]):e(t)?[t]:[]}function J_(t,e,r){let i=-1;for(;++i<t.length;){let s=t[i];Array.isArray(s)?J_(s,e,r):e(s)&&r.push(s)}return r}function Ma({target:t,source:e,start:r=0,count:i=1}){let s=e.length,o=i*s,n=0;for(let a=r;n<s;n++)t[a++]=e[n];for(;n<o;)n<o-n?(t.copyWithin(r+n,r,r+n),n*=2):(t.copyWithin(r+n,r,r+o-n),n=o);return t}qi();var no=class{constructor(e,r,i){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=i,this.setData(r)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,s=e;typeof e=="string"&&(s=ar(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(o=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=o)}).catch(o=>{this._loadCount===i&&(this.isLoaded=!0,this._error=o||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let o of this._subscribers)o.onChange(this.getData())}};var ao=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:i=!1,persistent:s=!0}){let o=this._resources[e];o?o.setData(r,i):(o=new no(e,r,this._context),this._resources[e]=o),o.persistent=s}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let s=r[i],o=this._resources[s.resourceId];o&&o.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:s="default"}){let{_resources:o,protocol:n}=this;e.startsWith(n)&&(e=e.replace(n,""),o[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=o[e];if(this._track(i,s,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,i,s){let o=this._consumers,n=o[e]=o[e]||{},a=n[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=s,a.resourceId=i.id):a={onChange:s,resourceId:i.id},n[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var L3="layerManager.setLayers",U3="layerManager.activateViewport",Vr=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{G(U3,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:s,viewport:o,timeline:n}=r||{};this.layers=[],this.resourceManager=new ao({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:Sa(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[$h],renderPass:void 0,stats:s||new Ne({id:"deck.gl"}),viewport:o||new Ee({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:n||new Er,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let s=i.getNeedsRedraw(e);r=r||s}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(i=>r.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){G(L3,this,r,e),this._lastRenderedLayers=e;let i=gr(e,Boolean);for(let s of i)s.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(s=>s.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let n of e)i[n.id]?F.warn(`Multiple old layers with same id ${n.id}`)():i[n.id]=n;if(this._defaultShaderModulesChanged){for(let n of e)n.setNeedsUpdate(),n.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(r,i,s),this._finalizeOldLayers(i);let o=!1;for(let n of s)if(n.hasUniformTransition()){o=`Uniform transition in ${n}`;break}this._needsUpdate=o,this.layers=s}_updateSublayersRecursively(e,r,i){for(let s of e){s.context=this.context;let o=r[s.id];o===null&&F.warn(`Multiple new layers with same id ${s.id}`)(),r[s.id]=null;let n=null;try{this._debug&&o!==s&&s.validateProps(),o?(this._transferLayerState(o,s),this._updateLayer(s)):this._initializeLayer(s),i.push(s),n=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}n&&this._updateSublayersRecursively(n,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=pr.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=pr.MATCHED,r!==e&&(e.lifecycle=pr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=pr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=pr.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function Z(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Z(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(let o of i)if(!e.hasOwnProperty(o)||!Z(t[o],e[o],r-1))return!1;return!0}return!1}var co=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let r=this.controllers[e];r&&r.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let r=this.controllers[e];r&&r.updateTransition()}}getViewports(e){return e?this._viewports.filter(r=>r.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),s={x:e[0],y:e[1]};for(let o=i.length-1;o>=0;--o){let n=i[o];if(n.containsPixel(s)){let a=e.slice();return a[0]-=n.x,a[1]-=n.y,n.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=gr(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Z(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):F.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:o=>this.getView(e.id)?.makeViewport({viewState:o,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,r,i,s){let o=e.controller;if(o&&i){let n={...r,...o,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!s||s.constructor!==o.type)&&(s=this._createController(e,n)),s&&s.setProps(n),s}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let s=e.length;s--;){let o=e[s],n=this.getViewState(o),a=o.makeViewport({viewState:n,width:this.width,height:this.height}),c=r[o.id],l=Boolean(o.controller);l&&!c&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[o.id]=this._updateController(o,n,a,c),a&&this._viewports.unshift(a)}for(let s in r){let o=r[s];o&&!this.controllers[s]&&o.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,s)=>!e[s].equals(r[s]))}};var k3=/^(?:\d+\.?\d*|\.\d+)$/;function kt(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{let e=V3(t);return new gu(e).parseExpression()}catch(e){let r=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${r}`)}default:throw new Error(`Could not parse position string ${t}`)}}function pu(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":let r=pu(t.left,e),i=pu(t.right,e);return t.operator==="+"?r+i:r-i;default:throw new Error("Unknown layout expression type")}}function Vt(t,e){return pu(t,e)}function V3(t){let e=[],r=0;for(;r<t.length;){let i=t[r];if(/\s/.test(i)){r++;continue}if(i==="+"||i==="-"||i==="("||i===")"||i==="%"){e.push({type:"symbol",value:i}),r++;continue}if(ey(i)||i==="."){let s=r,o=i===".";for(r++;r<t.length;){let a=t[r];if(ey(a)){r++;continue}if(a==="."&&!o){o=!0,r++;continue}break}let n=t.slice(s,r);if(!k3.test(n))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(n)});continue}if(ty(i)){let s=r;for(;r<t.length&&ty(t[r]);)r++;let o=t.slice(s,r).toLowerCase();e.push({type:"word",value:o});continue}throw new Error("Invalid token in position string")}return e}var gu=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),r=this.peek();for(;z3(r);){this.index++;let i=this.parseFactor();e={type:"binary",operator:r.value,left:e,right:i},r=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;let r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(e.type==="symbol"&&e.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="number"){this.index++;let r=e.value,i=this.peek();return i&&i.type==="symbol"&&i.value==="%"?(this.index++,{type:"percentage",value:r/100}):i&&i.type==="word"&&i.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let r=this.peek();return r&&r.type==="symbol"&&r.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function ey(t){return t>="0"&&t<="9"}function ty(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function z3(t){return Boolean(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function ry(t,e){let r={...t};for(let i in e)i!=="id"&&(Array.isArray(r[i])&&Array.isArray(e[i])?r[i]=W3(r[i],e[i]):r[i]=e[i]);return r}function W3(t,e){t=t.slice();for(let r=0;r<e.length;r++){let i=e[r];Number.isFinite(i)&&(t[r]=i)}return t}var be=class{constructor(e){let{id:r,x:i=0,y:s=0,width:o="100%",height:n="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=kt(i),this._y=kt(s),this._width=kt(o),this._height=kt(n),this._padding=a&&{left:kt(a.left||0),right:kt(a.right||0),top:kt(a.top||0),bottom:kt(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&Z(this.props,e.props,2)}clone(e){let r=this.constructor;return new r({...this.props,...e})}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let s=this.getDimensions({width:e,height:r});if(!s.height||!s.width)return null;let o=this.getViewportType(i);return new o({...i,...this.props,...s})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?ry(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:r}){let i={x:Vt(this._x,e),y:Vt(this._y,r),width:Vt(this._width,e),height:Vt(this._height,r)};return this._padding&&(i.padding={left:Vt(this._padding.left,e),top:Vt(this._padding.top,r),right:Vt(this._padding.right,e),bottom:Vt(this._padding.bottom,r)}),i}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var qe=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var iy=()=>{},lo={BREAK:1,SNAP_TO_END:2,IGNORE:3},j3=t=>t,H3=lo.BREAK,fo=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:s,startProps:o,endProps:n,duration:a,easing:c}}=r,l=c(i/a),f=s.interpolateProps(o,n,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new qe(e.timeline),this.onViewStateChange=e.onViewStateChange||iy,this.onStateChange=e.onStateChange||iy}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let s=i;if(this.transition.inProgress){let{interruption:o,endProps:n}=this.transition.settings;s={...i,...o===lo.SNAP_TO_END?n:this.propsInTransition||i}}this._triggerTransition(s,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===lo.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),s=this.getControllerState(r).shortestPathFrom(i),o=r.transitionInterpolator,n=o.getDuration?o.getDuration(e,r):r.transitionDuration;if(n===0)return;let a=o.initializeProps(e,s);this.propsInTransition={};let c={duration:n,easing:r.transitionEasing||j3,interpolator:o,interruption:r.transitionInterruption||H3,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function Y(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var zt=class{constructor(e){let{compare:r,extract:i,required:s}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=s}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!Pe(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},s={};for(let o of this._propsToExtract)(o in e||o in r)&&(i[o]=e[o],s[o]=r[o]);return this._checkRequiredProps(i),this._checkRequiredProps(s),{start:i,end:s}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];Y(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var Ca=Math.PI/180,sy=180/Math.PI,Ia=6370972,Wt=256;function $3(){let t=Wt/Ia,e=Math.PI/180*Wt;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var Oa=class extends Ee{constructor(e={}){let{longitude:r=0,zoom:i=0,nearZMultiplier:s=.5,farZMultiplier:o=1,resolution:n=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,_e),-_e),c=c||1,f?l=Bt(f):f=Dt(l);let h=Math.pow(2,i-yt(a)),u=e.nearZ??s,d=e.farZ??(l+Wt*2*h/c)*o,p=new z().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*Ca),p.rotateZ(-r*Ca),p.scale(h/c),super({...e,height:c,viewMatrix:p,longitude:r,latitude:a,zoom:i,distanceScales:$3(),fovy:f,focalDistance:l,near:u,far:d}),this.scale=h,this.latitude=a,this.longitude=r,this.fovy=f,this.resolution=n}get projectionMode(){return se.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,this.height/2],r),s=this.unproject([this.width/2,0],r),o=this.unproject([this.width,this.height/2],r),n=this.unproject([this.width/2,this.height],r);return o[0]<this.longitude&&(o[0]+=360),i[0]>this.longitude&&(i[0]-=360),[Math.min(i[0],o[0],s[0],n[0]),Math.min(i[1],o[1],s[1],n[1]),Math.max(i[0],o[0],s[0],n[0]),Math.max(i[1],o[1],s[1],n[1])]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[s,o,n]=e,a=r?o:this.height-o,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(n))l=mu(c,[s,a,n,1]);else{let d=mu(c,[s,a,-1,1]),p=mu(c,[s,a,1,1]),g=((i||0)/Ia+1)*Wt,m=ge.sqrLen(ge.sub([],d,p)),_=ge.sqrLen(d),b=ge.sqrLen(p),T=4*((4*_*b-(m-_-b)**2)/16)/m,S=Math.sqrt(_-T),A=Math.sqrt(Math.max(0,g*g-T)),w=(S-A)/Math.sqrt(m);l=ge.lerp([],d,p,w)}let[f,h,u]=this.unprojectPosition(l);return Number.isFinite(n)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i,s=0]=e,o=r*Ca,n=i*Ca,a=Math.cos(n),c=(s/Ia+1)*Wt;return[Math.sin(o)*a*c,-Math.cos(o)*a*c,Math.sin(n)*c]}unprojectPosition(e){let[r,i,s]=e,o=ge.len(e),n=Math.asin(s/o),c=Math.atan2(r,-i)*sy,l=n*sy,f=(o/Wt-1)*Ia;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,r,i],s,o){let a=.25/Math.pow(2,this.zoom-yt(this.latitude)),c=e+a*(o[0]-s[0]),l=r-a*(o[1]-s[1]);l=Math.max(Math.min(l,_e),-_e);let f={longitude:c,latitude:l,zoom:i-yt(r)};return f.zoom+=yt(f.latitude),f}};Oa.displayName="GlobeViewport";var ki=Oa;function yt(t){let e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function mu(t,e){let r=Ae.transformMat4([],e,t);return Ae.scale(r,r,1/r[3]),r}var X3=["longitude","latitude","zoom","bearing","pitch"],Y3=["longitude","latitude","zoom"],ce=class extends zt{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:X3,required:Y3},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:s,around:o}=this.opts;if(s&&o)if(s(e)instanceof ki)F.warn("around not supported in GlobeView")();else{let a=s(e),c=s(r),l=a.unproject(o);i.start.around=o,Object.assign(i.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let s={};for(let o of this._propsToExtract)s[o]=It(e[o]||0,r[o]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let o=this.opts.makeViewport({...r,...s});Object.assign(s,o.panByPosition(r.aroundPosition,It(e.around,r.around,i)))}return s}};var jt={transitionDuration:0},K3=300,Na=t=>1-(1-t)*(1-t),Vi={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},zr={},Te=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new fo({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return r?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:i}=this.props,{offsetCenter:s}=e;return[s.x-r,s.y-i]}isPointInBounds(e,r){let{width:i,height:s}=this.props;if(r&&r.handled)return!1;let o=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=s;return o&&r&&r.stopPropagation(),o}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let r=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?K3:0;let{scrollZoom:s=!0,dragPan:o=!0,dragRotate:n=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,h=Boolean(this.onViewStateChange);if(this.toggleEvents(Vi.WHEEL,h&&s),this.toggleEvents(Vi.PAN,h),this.toggleEvents(Vi.PINCH,h&&(c||l)),this.toggleEvents(Vi.MULTI_PAN,h&&l),this.toggleEvents(Vi.DOUBLE_CLICK,h&&a),this.toggleEvents(Vi.KEYBOARD,h&&f),this.scrollZoom=s,this.dragPan=o,this.dragRotate=n,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!r||r.height!==e.height||r.width!==e.width||r.maxBounds!==e.maxBounds)&&e.maxBounds){let d=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=d.getViewportProps();Object.keys(p).some(m=>!Z(p[m],e[m],1))&&this.updateViewport(d)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let s={...e.getViewportProps(),...r},o=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),o){let n=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:n,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let s=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(s,jt,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,jt,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],o=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(o,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Na},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,jt,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],o=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(o,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Na},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:o}=e,n=2/(1+Math.exp(-Math.abs(o*i)));o<0&&n!==0&&(n=1/n);let a=s?{...this._getTransitionProps({around:r}),transitionDuration:250}:jt,c=this.controllerState.zoom({pos:r,scale:n});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),s||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,jt,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,jt,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),s=[i[0],i[1]+=e.velocityY*r/2],o=this.controllerState.rotate({pos:s});this.updateViewport(o,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Na},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return zr._startPinchRotation=e.rotation,zr._lastPinchEvent=e,this.updateViewport(i,jt,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,s=this.getCenter(e);r=r.zoom({pos:s,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:zr._startPinchRotation-i})}return this.updateViewport(r,jt,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),zr._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=zr;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let s=this.getCenter(e),o=this.controllerState.rotateEnd(),n=Math.log2(e.scale),a=(n-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),c=Math.pow(2,n+a*r/2);o=o.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:r,transitionEasing:Na},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return zr._startPinchRotation=null,zr._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(s,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:s,rotateSpeedX:o,rotateSpeedY:n}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(o),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(o),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(n),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(n),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?jt:e?{...r,transitionInterpolator:new ce({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Ge=class{constructor(e,r,i){this.makeViewport=i,this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var oy=5,Z3=1.2,ny=512,ay=[[-1/0,-90],[1/0,90]];function Da([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){let[i,s]=Se([t,e]);return[i,U(s,0,ny)]}let[,r]=Se([0,e]);return[t,U(r,0,ny)]}var ho=class extends Ge{constructor(e){let{width:r,height:i,latitude:s,longitude:o,zoom:n,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:h=20,minZoom:u=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:b,startBearing:y,startPitch:T,startZoom:S,normalize:A=!0}=e;Y(Number.isFinite(o)),Y(Number.isFinite(s)),Y(Number.isFinite(n));let w=e.maxBounds||(A?ay:null);super({width:r,height:i,latitude:s,longitude:o,zoom:n,bearing:a,pitch:c,altitude:l,maxZoom:h,minZoom:u,maxPitch:d,minPitch:p,normalize:A,position:f,maxBounds:w},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:b,startBearing:y,startPitch:T,startZoom:S},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(o)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let r=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:r!==void 0?this._unproject3D(e,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startRotateLngLat:o,startBearing:n,startPitch:a}=this.getState();if(!s||n===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,s,a,n):c={bearing:n+r,pitch:a+i},o){let l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](o,s)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomLngLat:o}=this.getState();if(o||(s=this.getViewportProps().zoom,o=this._unproject(r)||this._unproject(e)),!o)return this;let n=this._constrainZoom(s+Math.log2(i)),a=this.makeViewport({...this.getViewportProps(),zoom:n});return this._getUpdatedState({zoom:n,...a.panByPosition(o,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:o}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),Math.abs(o-r.longitude)>180&&(i.longitude=o<0?o+360:o-360),i}applyConstraints(e){let{maxPitch:r,minPitch:i,pitch:s,longitude:o,bearing:n,normalize:a,maxBounds:c}=e;if(a&&((o<-180||o>180)&&(e.longitude=mt(o+180,360)-180),(n<-180||n>180)&&(e.bearing=mt(n+180,360)-180)),e.pitch=U(s,i,r),e.zoom=this._constrainZoom(e.zoom,e),c){let l=Da(c[0]),f=Da(c[1]),h=2**e.zoom,u=e.width/2/h,d=e.height/2/h,[p,g]=ye([l[0]+u,l[1]+d]),[m,_]=ye([f[0]-u,f[1]-d]);e.longitude=U(e.longitude,p,m),e.latitude=U(e.latitude,g,_)}return e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:s}=r,o=s!==null&&r.width>0&&r.height>0,{minZoom:n}=r;if(o){let a=Da(s[0]),c=Da(s[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(n=Math.max(n,Math.log2(r.width/l))),Number.isFinite(f)&&f>0&&(n=Math.max(n,Math.log2(r.height/f))),n>i&&(n=i)}return U(e,n,i)}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_unproject3D(e,r){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:r})}_getNewRotation(e,r,i,s){let o=e[0]-r[0],n=e[1]-r[1],a=e[1],c=r[1],{width:l,height:f}=this.getViewportProps(),h=o/l,u=0;n>0?Math.abs(f-c)>oy&&(u=n/(c-f)*Z3):n<0&&c>oy&&(u=1-a/c),u=U(u,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=s+180*h,m=i;return u>0?m=i+u*(p-i):u<0&&(m=i-u*(d-i)),{pitch:m,bearing:g}}},Ht=class extends Te{constructor(){super(...arguments),this.ControllerState=ho,this.transition={transitionDuration:300,transitionInterpolator:new ce({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:i}=this.props,s=this.pickPosition(r+e[0],i+e[1]);if(s&&s.coordinate&&s.coordinate.length>=3)return s.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:ay),super.setProps(e)}updateViewport(e,r=null,i={}){let s=e.getState();i.isDragging&&s.startRotateLngLat?i={...i,rotationPivotPosition:s.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,r,i)}};var Ba=class extends be{constructor(e={}){super(e)}getViewportType(){return dr}get ControllerType(){return Ht}};Ba.displayName="MapView";var Fa=Ba;var q3=new ur;function G3(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var uo=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(s=>G3(s,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Z(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let s of this.effects)r[s.id]=s;let i=[];for(let s of e){let o=r[s.id],n=s;o&&o!==s?o.setProps?(o.setProps(s.props),n=o):o.cleanup(this._context):o||s.setup(this._context),i.push(n),delete r[s.id]}for(let s in r)r[s].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(s=>s instanceof ur)||this._resolvedEffects.push(q3),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var po=class extends Ye{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}render(e){return this._render(e)}};var Q3="deckRenderer.renderLayers",Wr=class{constructor(e,r={}){this.device=e,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new po(e),this.pickLayersPass=new Lt(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let s=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let o=r.render({...i,target:s}),n="stats"in o?o.stats:o;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,G(Q3,this,n,e),this._updateStats(n)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers rendered").addCount(r)}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize(),[i,s]=r;e.length===0&&[0,1].map(o=>{let n=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:i,height:s});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${o}`,colorAttachments:[n]}))});for(let o of e)o.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,s={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let o of e)if(o.postRender){s.target=o.id===this.lastPostProcessEffect?r.target:void 0;let n=o.postRender(s);s.inputBuffer=n,s.swapBuffer=n===i[0]?i[1]:i[0]}}};L();var J3={pickedColor:null,pickedObjectIndex:-1};function _u({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:s,deviceRect:o}){let{x:n,y:a,width:c,height:l}=o,f=s*s,h=-1,u=0;for(let d=0;d<l;d++){let p=d+a-i,g=p*p;if(g>f)u+=4*c;else for(let m=0;m<c;m++){if(t[u+3]-1>=0){let b=m+n-r,y=b*b+g;y<=f&&(f=y,h=u)}u+=4}}if(h>=0){let d=t.slice(h,h+4),p=e(d);if(p){let g=Math.floor(h/4/c),m=h/4-g*c;return{...p,pickedColor:d,pickedX:n+m,pickedY:a+g}}F.error("Picked non-existent layer. Is picking buffer corrupt?")()}return J3}function yu({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i<t.length;i+=4)if(t[i+3]-1>=0){let o=t.slice(i,i+4),n=o.join(",");if(!r.has(n)){let a=e(o);a?r.set(n,{...a,color:o}):F.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function La({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:s,z:o}){let n=e[0];e.length>1&&(n=eP(t?.pickedViewports||e,{x:i,y:s}));let a;if(n){let c=[i-n.x,s-n.y];o!==void 0&&(c[2]=o),a=n.unproject(c)}return{color:null,layer:null,viewport:n,index:-1,picked:!1,x:i,y:s,pixel:[i,s],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function bu(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:s}=t,{pickedColor:o,pickedLayer:n,pickedObjectIndex:a}=e,c=n?[n]:[];if(i==="hover"){let h=r.index,u=r.layerId,d=n?n.props.id:null;if(d!==u||a!==h){if(d!==u){let p=s.find(g=>g.props.id===u);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=La(t),f=new Map;return f.set(null,l),c.forEach(h=>{let u={...l};h===n&&(u.color=o,u.index=a,u.picked=!0),u=Ua({layer:h,info:u,mode:i});let d=u.layer;h===n&&i==="hover"&&(r.info=u),f.set(d.id,u),i==="hover"&&d.updateAutoHighlight(u)}),f}function Ua({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function eP(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var go=class{constructor(e,r={}){this._pickable=!0,this.device=e,this.stats=r.stats,this.pickLayersPass=new Lt(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:i,viewports:s},o=this.lastPickedInfo.info){let n=o&&o.layer&&o.layer.id,a=o&&o.viewport&&o.viewport.id,c=n?i.find(u=>u.id===n):null,l=a&&s.find(u=>u.id===a)||s[0],f=l&&l.unproject([e-l.x,r-l.y]);return{...o,...{x:e,y:r,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:B.RENDER_ATTACHMENT|B.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let i=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:B.RENDER_ATTACHMENT|B.COPY_SRC}),s=this.device.createFramebuffer({colorAttachments:[i],depthStencilAttachment:"depth16unorm"});this.depthFBO=s}}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:e,views:r,viewports:i,x:s,y:o,radius:n=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:La({viewports:i,x:s,y:o,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(n*u),{width:_,height:b}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:b}),T={x:s-n,y:o-n,width:n*2+1,height:n*2+1},S,A=[],w=new Set;for(let v=0;v<a;v++){let R;if(y){let C=await this._drawAndSampleAsync({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:T,effects:h,pass:`picking:${c}`});R=_u({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let M,O=this._getDepthLayers(R,d,l);if(O.length>0){let{pickedColors:C}=await this._drawAndSampleAsync({layers:O,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:T,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(M=C[0])}R.pickedLayer&&v+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=bu({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:s,y:o,z:M,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let v of w)v.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}_pickClosestObject({layers:e,views:r,viewports:i,x:s,y:o,radius:n=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:La({viewports:i,x:s,y:o,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(n*u),{width:_,height:b}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:b}),T={x:s-n,y:o-n,width:n*2+1,height:n*2+1},S,A=[],w=new Set;for(let v=0;v<a;v++){let R;if(y){let C=this._drawAndSample({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:T,effects:h,pass:`picking:${c}`});R=_u({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let M,O=this._getDepthLayers(R,d,l);if(O.length>0){let{pickedColors:C}=this._drawAndSample({layers:O,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:T,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(M=C[0])}R.pickedLayer&&v+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=bu({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:s,y:o,z:M,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let v of w)v.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:r,viewports:i,x:s,y:o,width:n=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([s+n,o+a],!0),b=_.x+_.width,y=_.y,T={x:g,y,width:b-g,height:m-y},S=await this._drawAndSampleAsync({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:T,cullRect:{x:s,y:o,width:n,height:a},effects:h,pass:`picking:${c}`}),A=yu(S),w=new Map,v=[],R=Number.isFinite(l);for(let M=0;M<A.length&&!(R&&v.length>=l);M++){let O=A[M],C={color:O.pickedColor,layer:null,index:O.pickedObjectIndex,picked:!0,x:s,y:o,pixelRatio:d};C=Ua({layer:O.pickedLayer,info:C,mode:c});let W=C.layer.id;w.has(W)||w.set(W,new Set);let V=w.get(W),J=C.object??C.index;V.has(J)||(V.add(J),v.push(C))}return v}_pickVisibleObjects({layers:e,views:r,viewports:i,x:s,y:o,width:n=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,o],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([s+n,o+a],!0),b=_.x+_.width,y=_.y,T={x:g,y,width:b-g,height:m-y},S=this._drawAndSample({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:T,cullRect:{x:s,y:o,width:n,height:a},effects:h,pass:`picking:${c}`}),A=yu(S),w=new Map,v=[],R=Number.isFinite(l);for(let M=0;M<A.length&&!(R&&v.length>=l);M++){let O=A[M],C={color:O.pickedColor,layer:null,index:O.pickedObjectIndex,picked:!0,x:s,y:o,pixelRatio:d};C=Ua({layer:O.pickedLayer,info:C,mode:c});let W=C.layer.id;w.has(W)||w.set(W,new Set);let V=w.get(W),J=C.object??C.index;V.has(J)||(V.add(J),v.push(C))}return v}async _drawAndSampleAsync({layers:e,views:r,viewports:i,onViewportActive:s,deviceRect:o,cullRect:n,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,pickingFBO:f,deviceRect:o,cullRect:n,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let T of a)T.useInPicking&&(h.preRenderStats[T.id]=T.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=o,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let y=await this._readTextureDataAsync(b,{x:p,y:g,width:m,height:_},l?Float32Array:Uint8Array);if(!l){let T=!1;for(let S=3;S<y.length;S+=4)if(y[S]!==0){T=!0;break}!T&&y.length>0&&F.warn("Async pick readback returned only zero alpha values",{deviceRect:o,bytes:Array.from(y.subarray(0,Math.min(y.length,16)))})()}return{pickedColors:y,decodePickingColor:u}}async _readTextureDataAsync(e,r,i){let{width:s,height:o}=r,n=e.computeMemoryLayout(r),a=this.device.createBuffer({byteLength:n.byteLength,usage:I.COPY_DST|I.MAP_READ});try{e.readBuffer(r,a);let c=await a.readAsync(0,n.byteLength),l=i.BYTES_PER_ELEMENT;if(n.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${n.bytesPerRow} is not aligned to ${l}-byte elements.`);let f=new i(c.buffer,c.byteOffset,n.byteLength/l),h=s*4,u=n.bytesPerRow/l;if(u<h)throw new Error(`Texture readback row stride ${u} is smaller than packed row length ${h}.`);let d=new i(s*o*4);for(let p=0;p<o;p++){let g=p*u;d.set(f.subarray(g,g+h),p*h)}return d}finally{a.destroy()}}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:s,deviceRect:o,cullRect:n,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,pickingFBO:f,deviceRect:o,cullRect:n,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(h.preRenderStats[y.id]=y.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=o,b=new(l?Float32Array:Uint8Array)(m*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:g,sourceWidth:m,sourceHeight:_,target:b}),{pickedColors:b,decodePickingColor:u}}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers picked").addCount(r)}_getDepthLayers(e,r,i){if(!i||!this.depthFBO)return[];let{pickedLayer:s}=e,o=s?.state?.terrainDrawMode==="drape";return s&&!o?[s]:r.filter(n=>n.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:s,deviceHeight:o}){let n=Math.max(0,e-i),a=Math.max(0,r-i),c=Math.min(s,e+i+1)-n,l=Math.min(o,r+i+1)-a;return c<=0||l<=0?null:{x:n,y:a,width:c,height:l}}};var tP={"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}},rP="top-left",cy="root",ka=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!Z(e.widgets,this.widgets,1)){let r=e.widgets.filter(Boolean);this._setWidgets(r)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:r}){let i=e.reduce((s,o)=>(s[o.id]=o,s),{});for(let s of this.getWidgets()){let{viewId:o}=s;if(o){let n=i[o];n&&(s.onViewportChange&&s.onViewportChange(n),s.onRedraw?.({viewports:[n],layers:r}))}else{if(s.onViewportChange)for(let n of e)s.onViewportChange(n);s.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:s}=i;(!s||s===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=vi[r.type];if(i)for(let s of this.getWidgets()){let{viewId:o}=s;(!o||o===e.viewport?.id)&&s[i]?.(e,r)}}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let s=r[i.id];s?s.viewId!==i.viewId||s.placement!==i.placement?(this._removeWidget(s),this._addWidget(i)):i!==s&&(s.setProps(i.props),i=s):this._addWidget(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let s=r[i];s&&this._removeWidget(s)}this.widgets=e}_addWidget(e){let{viewId:r=null,placement:i=rP}=e,s=e.props._container??r;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:r}),e.rootElement&&this._getContainer(s,i).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,r){if(e&&typeof e!="string")return e;let i=e||cy,s=this.containers[i];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[i]=s);let o=s.querySelector(`.${r}`);return o||(o=globalThis.document.createElement("div"),o.className=r,o.style.position="absolute",o.style.zIndex="2",Object.assign(o.style,tP[r]),s.append(o)),o}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let s=this.lastViewports[i]||null,o=i===cy||s,n=this.containers[i];o?(n.style.display="block",n.style.left=`${s?s.x:0}px`,n.style.top=`${s?s.y:0}px`,n.style.width=`${s?s.width:e}px`,n.style.height=`${s?s.height:r}px`):n.style.display="none"}}};function mo(t,e){e&&Object.entries(e).map(([r,i])=>{r.startsWith("--")?t.style.setProperty(r,i):t.style[r]=i})}function Va(t,e){e&&Object.keys(e).map(r=>{r.startsWith("--")?t.style.removeProperty(r):t.style[r]=""})}var mr=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let r=this.props,i=this.rootElement;i&&r.className!==e.className&&(r.className&&i.classList.remove(r.className),e.className&&i.classList.add(e.className)),i&&!Z(r.style,e.style,1)&&(Va(i,r.style),mo(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,r){this.deck?._onViewStateChange({viewId:e,viewState:r,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],r=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>r.classList.add(i)),mo(r,this.props.style),r}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,r){}onClick(e,r){}onDrag(e,r){}onDragStart(e,r){}onDragEnd(e,r){}};mr.defaultProps={id:"widget",style:{},_container:null,className:""};var iP={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},_o=class extends mr{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,iP),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:r}=this,i=r&&r.props.getTooltip;if(!i)return;let s=i(e);this.setTooltip(s,e.x,e.y)}setTooltip(e,r,i){let s=this.rootElement;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}};_o.defaultProps={...mr.defaultProps};L();Tc();qi();function yr(){}var dv=({isDragging:t})=>t?"grabbing":"grab",Ob={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:yr,onWebGLInitialized:yr,onResize:yr,onViewStateChange:yr,onInteractionStateChange:yr,onBeforeRender:yr,onAfterRender:yr,onLoad:yr,onError:t=>F.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:dv,getTooltip:null,debug:!1,drawPickingColors:!1},Ro=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Ne({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=i=>{let{_pickRequest:s}=this;if(i.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(i.leftButton||i.rightButton)return;{let o=i.offsetCenter;if(!o)return;s.x=o.x,s.y=o.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=i},this._onEvent=i=>{let s=vi[i.type],o=i.offsetCenter;if(!s||!o||!this.layerManager)return;let n=this.layerManager.getLayers(),a=this._getInternalPickingMode();if(!a)return;if(a==="sync"){let l=i.type==="click"&&this._shouldUnproject3D(n)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0},n))):this._getLastPointerDownPickingInfo(o.x,o.y,n);this._dispatchPickingEvent(l,i);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,n))).then(l=>{this._dispatchPickingEvent(l,i)}).catch(l=>this.props.onError?.(l))},this._onPointerDown=i=>{let s=i.offsetCenter;if(!s)return;let o=this._getInternalPickingMode();if(!o)return;let n=this.layerManager?.getLayers()||[],a=++this._pointerDownPickSequence;if(o==="sync"){let l=this._pickPointSync({x:s.x,y:s.y,radius:this.props.pickingRadius}),f=this._getFirstPickedInfo(l);this._lastPointerDownInfo=f,this._lastPointerDownInfoPromise=Promise.resolve(f);return}let c=this._pickPointAsync(this._getPointPickOptions(s.x,s.y,{},n)).then(l=>this._getFirstPickedInfo(l)).then(l=>(a===this._pointerDownPickSequence&&(this._lastPointerDownInfo=l),l)).catch(l=>{this.props.onError?.(l);let f=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(s.x,s.y,n):{};return a===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=c},this.props={...Ob,...e},e=this.props,e.viewState&&e.initialViewState&&F.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let r=this.device;if(!r&&e.gl){e.gl instanceof WebGLRenderingContext&&F.error("WebGL1 context not supported.")();let i=this.props.deviceProps?.onResize;r=wo.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(s,o)=>{let{width:n,height:a}=s.canvas;s.setDrawingBufferSize(n,a),this._needsRedraw="Canvas resized",i?.(s,o)}})}r||(r=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Ke.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&F.removed("onLayerHover","onHover")(),"onLayerClick"in e&&F.removed("onLayerClick","onClick")(),e.initialViewState&&!Z(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),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()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),F.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(r),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),o=this.effectManager.needsRedraw(e),n=this.deckRenderer.needsRedraw(e);return r=r||i||s||o||n,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return Y(this.viewManager),this.viewManager.views}getView(e){return Y(this.viewManager),this.viewManager.getView(e)}getViewports(e){return Y(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return r.length?r[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,r){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:r,radius:0,unproject3D:!0})}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return r==="webgpu"?"async":"sync";if(e==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:r}){return e[0]||r}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(r=>r.props.pickable==="3d")}_getPointPickOptions(e,r,i={},s=this.layerManager?.getLayers()||[]){return{x:e,y:r,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(s),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,r,i=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:r,layers:i,viewports:this.getViewports({x:e,y:r})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:r},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let s=r,o=!1;for(let n of e)s=n,o=n.layer?.onHover(n,i)||o;o||(this.props.onHover?.(s,i),this.widgetManager.onHover(s,i))}_dispatchPickingEvent(e,r){if(!this.layerManager||!this.widgetManager)return;let i=vi[r.type];if(!i)return;let{layer:s}=e,o=s&&(s[i]||s.props[i]),n=this.props[i],a=!1;o&&(a=o.call(s,e,r)),a||(n?.(e,r),this.widgetManager.onEvent(e,r))}_pickAsync(e,r,i){Y(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(r).timeStart();let o=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return s.get(r).timeEnd(),o}_pick(e,r,i){Y(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(r).timeStart();let o=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return s.get(r).timeEnd(),o}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),Y(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(r.width=e.width),e.height&&typeof e.height=="number"&&(r.height=e.height),(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let s=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=s}if(i||i===0){let s=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:s}=r;return new gi({device:e,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:s})}_createDevice(e){let r=this.props.deviceProps?.createCanvasContext,i=typeof r=="object"?r:void 0,s={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};s.adapters.includes(wo)||s.adapters.push(wo);let o={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0},n=this.props.deviceProps?.onResize;return Zt.createDevice({_reuseDevices:!0,type:"webgl",...s,createCanvasContext:{...o,...i,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(a,c)=>{this._needsRedraw="Canvas resized",n?.(a,c)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new Fa({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let r=e.event,i=this.layerManager?.getLayers()||[],s=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},i),o=this._getInternalPickingMode(),n=++this._hoverPickSequence;if(e.event=null,!o)return;if(o==="sync"){this._applyHoverCallbacks(this._pickPointSync(s),r);return}this._pickPointAsync(s).then(({result:a,emptyInfo:c})=>{n===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},r)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let r=new Er;r.play(),this.animationLoop.attachTimeline(r);let i=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new Ys(i,{touchAction:this.props.touchAction,recognizers:Object.keys(tu).map(n=>{let[a,c,l,f]=tu[n],h=this.props.eventRecognizerOptions?.[n],u={...c,...h,event:n};return{recognizer:new a(u),recognizeWith:l,requestFailure:f}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let n in vi)this.eventManager.on(n,this._onEvent);this.viewManager=new co({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let s=this.viewManager.getViewports()[0];this.layerManager=new Vr(this.device,{deck:this,stats:this.stats,viewport:s,timeline:r}),this.effectManager=new uo({deck:this,device:this.device}),this.deckRenderer=new Wr(this.device,{stats:this.stats}),this.deckPicker=new go(this.device,{stats:this.stats});let o=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new ka({deck:this,parentElement:o}),this.widgetManager.addDefault(new _o),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:s});let o={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(o),o.pass==="screen"&&this.widgetManager.onRedraw({viewports:o.viewports,layers:o.layers}),this.props.onAfterRender({device:i,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),F.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=r.get("Layers rendered").lastSampleCount,e.pickLayersCount=r.get("Layers picked").lastSampleCount,e.updateAttributesCount=r.get("Layers updated").count,e.updateAttributesCount=r.get("Attributes updated").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=Zt.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};Ro.defaultProps=Ob;Ro.VERSION=sa;var Ec=Ro;L();L();function Nb(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return cs(t)}}var Db=de.getDataType.bind(de);function Po(t,e,r){if(e.size>4)return null;let i=r==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${i}x${e.size}`:e.type,byteOffset:e.offset||0}}function br(t){return t.stride||t.size*t.bytesPerElement}function Bb(t,e){return t.type===e.type&&t.size===e.size&&br(t)===br(e)&&(t.offset||0)===(e.offset||0)}function Xu(t,e){e.offset&&F.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=br(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,s=e.elementOffset||0,o=i*r+s*t.bytesPerElement+(t.offset||0);return{...e,offset:o,stride:r}}function pv(t,e){let r=Xu(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var vo=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let s=r.logicalType||r.type,o=s==="float64",{defaultValue:n}=r;n=Number.isFinite(n)?[n]:n||new Array(this.size).fill(0);let a;o?a="float32":!s&&r.isIndexed?a="uint32":a=s||"float32";let c=Nb(s||a);this.doublePrecision=o,o&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:n,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*br(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Ke.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let s=this.value;if(r){let o=Xu(this.getAccessor(),r),n=o.offset/s.BYTES_PER_ELEMENT,a=o.size||this.size;i[e]=s.subarray(n,n+a)}else i[e]=s}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),s=[],o={name:this.id,byteStride:br(i)};if(this.doublePrecision){let n=pv(i,r||{});s.push(Po(e,{...i,...n.high},this.device.type),Po(`${e}64Low`,{...i,...n.low},this.device.type))}else if(r){let n=Xu(i,r);s.push(Po(e,{...i,...n},this.device.type))}else s.push(Po(e,i,this.device.type));return o.attributes=s.filter(Boolean),o}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:s}=this,o=i*s;if(r&&o&&r.length>=o){let n=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;c<o;)for(let l=0;l<s;l++){let f=r[c++];f<n[l]&&(n[l]=f),f>a[l]&&(a[l]=f)}e=[n,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof I?i={buffer:e}:i=e;let s={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)s.type="float32";else{let n=Db(i.value);s.type=s.normalized?n.replace("int","norm"):n}s.bytesPerElement=i.value.BYTES_PER_ELEMENT,s.stride=br(s)}if(r.bounds=null,i.constant){let o=i.value;if(o=this._normalizeValue(o,[],0),this.settings.normalized&&(o=this.normalizeConstant(o)),!(!r.constant||!this._areValuesEqual(o,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(o)?o:new Float32Array(o)}else if(i.buffer){let o=i.buffer;r.externalBuffer=o,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let o=i.value;r.externalBuffer=null,r.constant=!1,this.value=o;let{buffer:n}=this,a=br(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&o instanceof Float64Array&&(o=Ea(o,s)),this.settings.isIndexed){let f=this.settings.defaultType;o.constructor!==f&&(o=new f(o))}let l=o.byteLength+c+a*2;(!n||n.byteLength<l)&&(n=this._createBuffer(l)),n.write(o,c)}return this.setAccessor(s),!0}updateSubBuffer(e={}){this.state.bounds=null;let r=this.value,{startOffset:i=0,endOffset:s}=e;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?Ea(r,{size:this.size,startIndex:i,endIndex:s}):r.subarray(i,s),i*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,r=!1){let{state:i}=this,s=i.allocatedValue,o=Ke.allocate(s,e+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=o;let{byteOffset:n}=this,{buffer:a}=this;return(!a||a.byteLength<o.byteLength+n)&&(a=this._createBuffer(o.byteLength+n),r&&s&&a.write(s instanceof Float64Array?Ea(s,this):s,n)),i.allocatedValue=o,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:r}=e;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let i=this.settings.defaultType,s=!1;if(this.doublePrecision&&(s=r.BYTES_PER_ELEMENT<4),s)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof i)&&this.settings.normalized&&!("normalized"in e)&&F.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:s,size:o}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let n=o;for(;--n>=0;)r[i+n]=s[n];return r}switch(o){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let n=o;for(;--n>=0;)r[i+n]=Number.isFinite(e[n])?e[n]:s[n]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let s=0;s<i;s++)if(e[s]!==r[s])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(r?I.INDEX:I.VERTEX)|I.COPY_DST,indexType:r?i:void 0,byteLength:e}),this._buffer}};var Fb=[],Lb=[];function Xi(t,e=0,r=1/0){let i=Fb,s={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?i=t:t.length>0&&(Lb.length=t.length,i=Lb):i=Fb,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),s.index=e-1),{iterable:i,objectInfo:s}}function wc(t){return t&&t[Symbol.asyncIterator]}function Rc(t,e){let{size:r,stride:i,offset:s,startIndices:o,nested:n}=e,a=t.BYTES_PER_ELEMENT,c=i?i/a:r,l=s?s/a:0,f=Math.floor((t.length-l)/c);return(h,{index:u,target:d})=>{if(!o){let _=u*c+l;for(let b=0;b<r;b++)d[b]=t[_+b];return d}let p=o[u],g=o[u+1]||f,m;if(n){m=new Array(g-p);for(let _=p;_<g;_++){let b=_*c+l;d=new Array(r);for(let y=0;y<r;y++)d[y]=t[b+y];m[_-p]=d}}else if(c===r)m=t.subarray(p*r+l,g*r+l);else{m=new t.constructor((g-p)*r);let _=0;for(let b=p;b<g;b++){let y=b*c+l;for(let T=0;T<r;T++)m[_++]=t[y+T]}}return m}}var Ub=[],Mo=[[0,1/0]];function kb(t,e){if(t===Mo||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;let r=[],i=t.length,s=0;for(let o=0;o<i;o++){let n=t[o];n[1]<e[0]?(r.push(n),s=o+1):n[0]>e[1]?r.push(n):e=[Math.min(n[0],e[0]),Math.max(n[1],e[1])]}return r.splice(s,0,e),r}var mv={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Pc(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...mv[r],...e,...t,type:r}}var $t=class extends vo{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Mo}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!Bb(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,i=this.settings.transition,s=Array.isArray(r)?e[r.find(o=>e[o])]:e[r];return Pc(s,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:s=1/0}=r;this.state.updateRanges=kb(this.state.updateRanges,[i,s])}else this.state.updateRanges=Mo}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=Ub}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==Mo),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:s}){if(!this.needsUpdate())return!1;let{state:{updateRanges:o},settings:{update:n,noAlloc:a}}=this,c=!0;if(n){for(let[l,f]of o)n.call(s,this,{data:r,startRow:l,endRow:f,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,f]of o){let h=Number.isFinite(l)?this.getVertexOffset(l):0,u=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:h,endOffset:u})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,r){let i=this.device.type==="webgpu";if(i||r===void 0||typeof r=="function"){if(i&&typeof r!="function"){let n=this._normalizeValue(r,[],0);this._areValuesEqual(n,this.value)||this.setNeedsUpdate("WebGPU constant updated")}return!1}let s=this.settings.transform&&e?this.settings.transform.call(e,r):r;return this.setData({constant:!0,value:s})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){let{state:r}=this;return e?(this.clearNeedsUpdate(),r.lastExternalBuffer===e||(r.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(e,r=null){let{state:i,settings:s}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(s.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;if(i.binaryValue=e,this.setNeedsRedraw(),s.transform||r!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let n=e;Y(ArrayBuffer.isView(n.value),`invalid ${s.accessor}`);let a=Boolean(n.size)&&n.size!==this.size;return i.binaryAccessor=Rc(n.value,{size:n.size||this.size,stride:n.stride,offset:n.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:r}=this;return(r?e<r.length?r[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,r=super.getValue();if(!e)return r;for(let i in e)Object.assign(r,super.getValue(i,e[i]));return r}getBufferLayout(e){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,i=super._getBufferLayout(),{stepMode:s}=this.settings;if(s==="dynamic"?i.stepMode=e?e.isInstanced?"instance":"vertex":"instance":i.stepMode=s??"vertex",!r)return i;for(let o in r){let n=super._getBufferLayout(o,r[o]);i.attributes.push(...n.attributes)}return i}_autoUpdater(e,{data:r,startRow:i,endRow:s,props:o,numInstances:n}){if(e.constant&&this.context.device.type!=="webgpu")return;let{settings:a,state:c,value:l,size:f,startIndices:h}=e,{accessor:u,transform:d}=a,p=c.binaryAccessor||(typeof u=="function"?u:o[u]);typeof p!="function"&&typeof u=="string"&&(p=()=>o[u]),Y(typeof p=="function",`accessor "${u}" is not a function`);let g=e.getVertexOffset(i),{iterable:m,objectInfo:_}=Xi(r,i,s);for(let b of m){_.index++;let y=p(b,_);if(d&&(y=d.call(this,y)),h){let T=(_.index<h.length-1?h[_.index+1]:n)-h[_.index];if(y&&Array.isArray(y[0])){let S=g;for(let A of y)e._normalizeValue(A,l,S),S+=f}else y&&y.length>f?l.set(y,g):(e._normalizeValue(y,_.target,0),Ma({target:l,source:_.target,start:g,count:T}));g+=T*f}else e._normalizeValue(y,l,g),g+=f}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function Yu(t){let{source:e,target:r,start:i=0,size:s,getData:o}=t,n=t.end||r.length,a=e.length,c=n-i;if(a>c){r.set(e.subarray(0,c),i);return}if(r.set(e,i),!o)return;let l=a;for(;l<c;){let f=o(l,e);for(let h=0;h<s;h++)r[i+l]=f[h]||0,l++}}function Vb({source:t,target:e,size:r,getData:i,sourceStartIndices:s,targetStartIndices:o}){if(!s||!o)return Yu({source:t,target:e,size:r,getData:i}),e;let n=0,a=0,c=i&&((f,h)=>i(f+a,h)),l=Math.min(s.length,o.length);for(let f=1;f<l;f++){let h=s[f]*r,u=o[f]*r;Yu({source:t.subarray(n,h),target:e,start:a,end:u,size:r,getData:c}),n=h,a=u}return a<e.length&&Yu({source:[],target:e,start:a,size:r,getData:c}),e}function zb(t){let{device:e,settings:r,value:i}=t,s=new $t(e,r);return s.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),s}function vc(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function Mc(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function Cc(t){t.push(t.shift())}function Wb(t,e){let{doublePrecision:r,settings:i,value:s,size:o}=t,n=r&&s instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=t.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(i.noAlloc?s.length:(e+a)*o)*n}function Ic({device:t,source:e,target:r}){return(!r||r.byteLength<e.byteLength)&&(r?.destroy(),r=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),r}function Oc({device:t,buffer:e,attribute:r,fromLength:i,toLength:s,fromStartIndices:o,getData:n=a=>a}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,f=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,h=r.startIndices,u=o&&h,d=r.isConstant;if(!u&&e&&i>=s)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let y=n;n=(T,S)=>r.normalizeConstant(y(T,S))}let m=d?(y,T)=>n(g,T):(y,T)=>n(g.subarray(y+l,y+l+c),T),_=e?new Float32Array(e.readSyncWebGL(f,i*4).buffer):new Float32Array(0),b=new Float32Array(s);return Vb({source:_,target:b,sourceStartIndices:o,targetStartIndices:h,size:c,getData:m}),(!e||e.byteLength<b.byteLength+f)&&(e?.destroy(),e=t.createBuffer({byteLength:b.byteLength+f,usage:35050})),e.write(b,f),e}var Yi=class{constructor({device:e,attribute:r,timeline:i}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new qe(i),this.attribute=r,this.attributeInTransition=zb(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(e,r,i=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=Wb(this.attribute,r),this.transition.start({...e,duration:i})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}};var Co=class extends Yi{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="interpolation",this.transform=Tv(e,r)}start(e,r){let i=this.currentLength,s=this.currentStartIndices;if(super.start(e,r,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:o,attribute:n}=this;Cc(o),o[0]=Oc({device:this.device,buffer:o[0],attribute:n,fromLength:i,toLength:this.currentLength,fromStartIndices:s,getData:e.enter}),o[1]=Ic({device:this.device,source:o[0],target:o[1]}),this.setBuffer(o[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/n.size);Hb(n)&&(l/=2),c.setVertexCount(l),n.isConstant?(c.setAttributes({aFrom:o[0]}),c.setConstantAttributes({aTo:n.value})):c.setAttributes({aFrom:o[0],aTo:n.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:o[1]})}onUpdate(){let{duration:e,easing:r}=this.settings,{time:i}=this.transition,s=i/e;r&&(s=r(s));let{model:o}=this.transform,n={time:s};o.shaderInputs.setProps({interpolation:n}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},_v=`layout(std140) uniform interpolationUniforms {
|
|
1663
1935
|
float time;
|
|
1664
1936
|
} interpolation;
|
|
1665
|
-
`,
|
|
1937
|
+
`,jb={name:"interpolation",vs:_v,uniformTypes:{time:"f32"}},yv=`#version 300 es
|
|
1666
1938
|
#define SHADER_NAME interpolation-transition-vertex-shader
|
|
1667
1939
|
|
|
1668
1940
|
in ATTRIBUTE_TYPE aFrom;
|
|
@@ -1673,7 +1945,7 @@ void main(void) {
|
|
|
1673
1945
|
vCurrent = mix(aFrom, aTo, interpolation.time);
|
|
1674
1946
|
gl_Position = vec4(0.0);
|
|
1675
1947
|
}
|
|
1676
|
-
`,
|
|
1948
|
+
`,bv=`#version 300 es
|
|
1677
1949
|
#define SHADER_NAME interpolation-transition-vertex-shader
|
|
1678
1950
|
|
|
1679
1951
|
in ATTRIBUTE_TYPE aFrom;
|
|
@@ -1696,11 +1968,11 @@ void main(void) {
|
|
|
1696
1968
|
}
|
|
1697
1969
|
gl_Position = vec4(0.0);
|
|
1698
1970
|
}
|
|
1699
|
-
`;function
|
|
1971
|
+
`;function Hb(t){return t.doublePrecision&&t.value instanceof Float64Array}function Tv(t,e){let r=e.size,i=vc(r),s=Mc(r),o=e.getBufferLayout();return Hb(e)?new je(t,{vs:bv,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:s,byteOffset:0},{attribute:"aFrom64Low",format:s,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:s,byteOffset:0},{attribute:"aTo64Low",format:s,byteOffset:4*r}]}],modules:[Hf,jb],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new je(t,{vs:yv,bufferLayout:[{name:"aFrom",format:s},{name:"aTo",format:o.attributes[0].format}],modules:[jb],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}var Io=class extends Yi{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="spring",this.texture=Rv(e),this.framebuffer=Pv(e,this.texture),this.transform=wv(e,r)}start(e,r){let i=this.currentLength,s=this.currentStartIndices;super.start(e,r);let{buffers:o,attribute:n}=this;for(let c=0;c<2;c++)o[c]=Oc({device:this.device,buffer:o[c],attribute:n,fromLength:i,toLength:this.currentLength,fromStartIndices:s,getData:e.enter});o[2]=Ic({device:this.device,source:o[0],target:o[2]}),this.setBuffer(o[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/n.size)),n.isConstant?a.setConstantAttributes({aTo:n.value}):a.setAttributes({aTo:n.getBuffer()})}onUpdate(){let{buffers:e,transform:r,framebuffer:i,transition:s}=this,o=this.settings;r.model.setAttributes({aPrev:e[0],aCur:e[1]}),r.transformFeedback.setBuffers({vNext:e[2]});let n={stiffness:o.stiffness,damping:o.damping};r.model.shaderInputs.setProps({spring:n}),r.run({framebuffer:i,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),Cc(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(i)[0]>0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},xv=`layout(std140) uniform springUniforms {
|
|
1700
1972
|
float damping;
|
|
1701
1973
|
float stiffness;
|
|
1702
1974
|
} spring;
|
|
1703
|
-
`,
|
|
1975
|
+
`,Av={name:"spring",vs:xv,uniformTypes:{damping:"f32",stiffness:"f32"}},Sv=`#version 300 es
|
|
1704
1976
|
#define SHADER_NAME spring-transition-vertex-shader
|
|
1705
1977
|
|
|
1706
1978
|
#define EPSILON 0.00001
|
|
@@ -1727,7 +1999,7 @@ void main(void) {
|
|
|
1727
1999
|
gl_Position = vec4(0, 0, 0, 1);
|
|
1728
2000
|
gl_PointSize = 100.0;
|
|
1729
2001
|
}
|
|
1730
|
-
`,
|
|
2002
|
+
`,Ev=`#version 300 es
|
|
1731
2003
|
#define SHADER_NAME spring-transition-is-transitioning-fragment-shader
|
|
1732
2004
|
|
|
1733
2005
|
in float vIsTransitioningFlag;
|
|
@@ -1739,6 +2011,6 @@ void main(void) {
|
|
|
1739
2011
|
discard;
|
|
1740
2012
|
}
|
|
1741
2013
|
fragColor = vec4(1.0);
|
|
1742
|
-
}`;function H3(t,e){let r=yc(e.size),i=Tc(e.size);return new ze(t,{vs:W3,fs:j3,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[z3],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function $3(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function X3(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var Y3={interpolation:Ro,spring:Po},vo=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let s in e){let o=e[s],n=o.getTransitionSetting(r);n&&this._updateAttribute(s,o,n)}for(let s in this.transitions){let o=e[s];(!o||!o.getTransitionSetting(r))&&this._removeTransition(s)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,i){let s=this.transitions[e],o=!s||s.type!==i.type;if(o){s&&this._removeTransition(e);let n=Y3[i.type];n?this.transitions[e]=new n({attribute:r,timeline:this.timeline,device:this.device}):(L.error(`unsupported transition type '${i.type}'`)(),o=!1)}(o||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var Q0="attributeManager.invalidate",Z3="attributeManager.updateStart",K3="attributeManager.updateEnd",q3="attribute.updateStart",Q3="attribute.allocate",G3="attribute.updateEnd",jr=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:s}={}){this.mergeBoundsMemoized=Be(t_),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new vo(e,{id:`${r}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);Q(Q0,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);Q(Q0,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:s,props:o={},buffers:n={},context:a={}}){let c=!1;Q(Z3,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let f=this.attributes[l],h=f.settings.accessor;f.startIndices=i,f.numInstances=r,o[l]&&L.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(n[l])||f.setBinaryValue(typeof h=="string"?n[h]:void 0,e.startIndices)||typeof h=="string"&&!n[h]&&f.setConstantValue(a,o[h])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:r,data:e,props:o,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&Q(K3,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:s})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,s={...i.getAttributes()};for(let o in r){let n=r[o];n.needsRedraw(e)&&!i.hasAttribute(o)&&(s[o]=n)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let s=e[i],o={...s,id:i,size:s.isIndexed&&1||s.size||1,...r};this.attributes[i]=new zt(this.device,o)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:s}=this,o=s[e];return o&&o.forEach(n=>{let a=i[n];a&&a.setNeedsUpdate(a.id,r)}),o}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(Q(q3,r),r.constant){r.setConstantValue(e.context,r.value);return}r.allocate(i)&&Q(Q3,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,Q(G3,r,i))}};F();fc();var Mo=class extends Ze{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:s,easing:o}}=this,n=o(e/s);this._value=vt(r,i,n)}};var G0=1e-5;function J0(t,e,r,i,s){let o=e-t,a=(r-e)*s,c=-o*i;return a+c+o+e}function J3(t,e,r,i,s){if(Array.isArray(r)){let o=[];for(let n=0;n<r.length;n++)o[n]=J0(t[n],e[n],r[n],i,s);return o}return J0(t,e,r,i,s)}function ey(t,e){if(Array.isArray(t)){let r=0;for(let i=0;i<t.length;i++){let s=t[i]-e[i];r+=s*s}return Math.sqrt(r)}return Math.abs(t-e)}var Co=class extends Ze{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:r,damping:i,stiffness:s}=this.settings,{_prevValue:o=e,_currValue:n=e}=this,a=J3(o,n,r,i,s),c=ey(a,r),l=ey(a,n);c<G0&&l<G0&&(a=r,this.end()),this._prevValue=n,this._currValue=a}};var eP={interpolation:Mo,spring:Co},Io=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,r,i,s){let{transitions:o}=this;if(o.has(e)){let c=o.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(s=_c(s),!s)return;let n=eP[s.type];if(!n){L.error(`unsupported transition type '${s.type}'`)();return}let a=new n(this.timeline);a.start({...s,fromValue:r,toValue:i}),o.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function ry(t){let e=t[ke];for(let r in e){let i=e[r],{validate:s}=i;if(s&&!s(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function iy(t,e){let r=Sc({newProps:t,oldProps:e,propTypes:t[ke],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=rP(t,e),s=!1;return i||(s=iP(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:s,extensionsChanged:sP(t,e),transitionsChanged:tP(t,e)}}function tP(t,e){if(!t.transitions)return!1;let r={},i=t[ke],s=!1;for(let o in t.transitions){let n=i[o],a=n&&n.type;(a==="number"||a==="color"||a==="array")&&Au(t[o],e[o],n)&&(r[o]=!0,s=!0)}return s?r:!1}function Sc({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:s="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(let o of Object.keys(t))if(!(o in r)){if(!(o in e))return`${s}.${o} added`;let n=Au(t[o],e[o],i[o]);if(n)return`${s}.${o} ${n}`}for(let o of Object.keys(e))if(!(o in r)){if(!(o in t))return`${s}.${o} dropped`;if(!Object.hasOwnProperty.call(t,o)){let n=Au(t[o],e[o],i[o]);if(n)return`${s}.${o} ${n}`}}return!1}function Au(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function rP(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:s}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&s&&(r=s(t.data,e.data)||r),r}function iP(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&ty(t,e,"all"))return{all:!0};let r={},i=!1;for(let s in t.updateTriggers)s!=="all"&&ty(t,e,s)&&(r[s]=!0,i=!0);return i?r:!1}function sP(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let s=0;s<i.length;s++)if(!i[s].equals(r[s]))return!0;return!1}function ty(t,e,r){let i=t.updateTriggers[r];i=i??{};let s=e.updateTriggers[r];return s=s??{},Sc({oldProps:s,newProps:i,triggerName:r})}var oP="count(): argument not an object",nP="count(): argument not a container";function Ec(t){if(!cP(t))throw new Error(oP);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(aP(t))return Object.keys(t).length;throw new Error(nP)}function aP(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function cP(t){return t!==null&&typeof t=="object"}function Oo(t,e){if(!e)return t;let r={...t,...e};if("defines"in e&&(r.defines={...t.defines,...e.defines}),"modules"in e&&(r.modules=(t.modules||[]).concat(e.modules),e.modules.some(i=>i.name==="project64"))){let i=r.modules.findIndex(s=>s.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let s in e.inject)i[s]=(i[s]||"")+e.inject[s];r.inject=i}return r}F();var lP={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Su={};function sy(t,e,r,i){if(r instanceof U)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let s=null;r.compressed&&(s={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:o,height:n}=r.data,a=e.createTexture({...r,sampler:{...lP,...s,...i},mipLevels:e.getMipLevelCount(o,n)});return e.type==="webgl"&&a.generateMipmapsWebGL(),Su[a.id]=t,a}function oy(t,e){!e||!(e instanceof U)||Su[e.id]===t&&(e.delete(),delete Su[e.id])}var fP={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||Eu(t)&&(t.length===3||t.length===4)},equal(t,e,r){return K(t,e,1)}},accessor:{validate(t,e){let r=wc(t);return r==="function"||r===wc(e.value)},equal(t,e,r){return typeof e=="function"?!0:K(t,e,1)}},array:{validate(t,e){return e.optional&&!t||Eu(t)},equal(t,e,r){let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?K(t,e,s):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?K(t,e,s):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:sy(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{oy(r.id,t)}}};function ny(t){let e={},r={},i={};for(let[s,o]of Object.entries(t)){let n=o?.deprecatedFor;if(n)i[s]=Array.isArray(n)?n:[n];else{let a=hP(s,o);e[s]=a,r[s]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function hP(t,e){switch(wc(e)){case"object":return No(t,e);case"array":return No(t,{type:"array",value:e,compare:!1});case"boolean":return No(t,{type:"boolean",value:e});case"number":return No(t,{type:"number",value:e});case"function":return No(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function No(t,e){return"type"in e?{name:t,...fP[e.type],...e}:"value"in e?{name:t,type:wc(e.value),...e}:{name:t,type:"object",value:e}}function Eu(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function wc(t){return Eu(t)?"array":t===null?"null":typeof t}function ay(t,e){let r;for(let o=e.length-1;o>=0;o--){let n=e[o];"extensions"in n&&(r=n.extensions)}let i=wu(t.constructor,r),s=Object.create(i);s[Ci]=t,s[ut]={},s[Ye]={};for(let o=0;o<e.length;++o){let n=e[o];for(let a in n)s[a]=n[a]}return Object.freeze(s),s}var uP="_mergedDefaultProps";function wu(t,e){if(!(t instanceof Vi.constructor))return{};let r=uP;if(e)for(let s of e){let o=s.constructor;o&&(r+=`:${o.extensionName||o.name}`)}let i=cy(t,r);return i||(t[r]=dP(t,e||[]))}function dP(t,e){if(!t.prototype)return null;let i=Object.getPrototypeOf(t),s=wu(i),o=cy(t,"defaultProps")||{},n=ny(o),a=Object.assign(Object.create(null),s,n.defaultProps),c=Object.assign(Object.create(null),s?.[ke],n.propTypes),l=Object.assign(Object.create(null),s?.[ya],n.deprecatedProps);for(let f of e){let h=wu(f.constructor);h&&(Object.assign(a,h),Object.assign(c,h[ke]),Object.assign(l,h[ya]))}return pP(a,t),mP(a,c),gP(a,l),a[ke]=c,a[ya]=l,e.length===0&&!Ru(t,"_propTypes")&&(t._propTypes=c),a}function pP(t,e){let r=yP(e);Object.defineProperties(t,{id:{writable:!0,value:r}})}function gP(t,e){for(let r in e)Object.defineProperty(t,r,{enumerable:!1,set(i){let s=`${this.id}: ${r}`;for(let o of e[r])Ru(this,o)||(this[o]=i);L.deprecated(s,e[r].join("/"))()}})}function mP(t,e){let r={},i={};for(let s in e){let o=e[s],{name:n,value:a}=o;o.async&&(r[n]=a,i[n]=_P(n))}t[Ft]=r,t[ut]={},Object.defineProperties(t,i)}function _P(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||gc(e)?this[ut][t]=e:this[Ye][t]=e},get(){if(this[Ye]){if(t in this[Ye])return this[Ye][t]||this[Ft][t];if(t in this[ut]){let e=this[Ci]&&this[Ci].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[Ft][t]}}return this[Ft][t]}}}function Ru(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function cy(t,e){return Ru(t,e)&&t[e]}function yP(t){let e=t.componentName;return e||L.warn(`${t.name}.componentName not specified`)(),e||t.name}var TP=0,Do=class{constructor(...e){this.props=ay(this,e),this.id=this.props.id,this.count=TP++}clone(e){let{props:r}=this,i={};for(let s in r[Ft])s in r[Ye]?i[s]=r[Ye][s]:s in r[ut]&&(i[s]=r[ut][s]);return new this.constructor({...r,...i,...e})}};Do.componentName="Component";Do.defaultProps={};var Vi=Do;var bP=Object.freeze({}),Hr=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||bP}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[Ci]||this.component;let r=e[Ye]||{},i=e[ut]||e,s=e[Ft]||{};for(let o in r){let n=r[o];this._createAsyncPropData(o,s[o]),this._updateAsyncProp(o,n),r[o]=this.getAsyncProp(o)}for(let o in i){let n=i[o];this._createAsyncPropData(o,s[o]),this._updateAsyncProp(o,n)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(gc(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let s=this.asyncProps[e];s&&i>=s.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=r,s.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let s=i.pendingLoadCount;r.then(o=>{this.component&&(o=this._postProcessValue(i,o),this._setAsyncPropValue(e,o,s),this._onResolve(e,o))}).catch(o=>{this._onError(e,o)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let s=i.pendingLoadCount,o=[],n=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?o=c(a,o):o=o.concat(a),Object.defineProperty(o,"__diff",{enumerable:!1,value:[{startRow:n,endRow:o.length}]}),n=o.length,this._setAsyncPropValue(e,o,s)}this._onResolve(e,o)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let s=this.component&&this.component.props[ke];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var Fo=class extends Hr{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,s=i?.props.fetch;return s?s(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let s=i.props.onDataLoad;e==="data"&&s&&s(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var xP="layer.changeFlag",AP="layer.initialize",SP="layer.update",EP="layer.finalize",wP="layer.matched",ly=2**24-1,RP=Object.freeze([]),PP=Be(({oldViewport:t,viewport:e})=>t.equals(e)),et=new Uint8ClampedArray(0),vP={data:{type:"data",value:RP,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:i,loadOptions:s,signal:o})=>{let{resourceManager:n}=r.context;s=s||r.getLoadOptions(),i=i||r.props.loaders,o&&(s={...s,core:{...s?.core,fetch:{...s?.core?.fetch,signal:o}}});let a=n.contains(t);return!a&&!s&&(n.add({resourceId:t,data:rr(t,i),persistent:!1}),a=!0),a?n.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):rr(t,i,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:k.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},Bo=class extends Vi{constructor(){super(...arguments),this.internalState=null,this.lifecycle=lr.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){Y(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=zh(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,o,n]=Si(i,r.pixelProjectionMatrix);return e.length===2?[s,o]:[s,o,n]}unproject(e){return Y(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){Y(this.internalState);let i=this.internalState.viewport||this.context.viewport;return ga(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===k.DEFAULT||e===k.LNGLAT||e===k.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){Y(e instanceof Uint8Array);let[r,i,s]=e;return r+i*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Ec(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=Oo(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=Oo(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let s of i)r.invalidateAll(s);else r.invalidateAll();if(r){let{props:s}=e,o=this.internalState.hasPickingBuffer,n=Number.isInteger(s.highlightedObjectIndex)||Boolean(s.pickable)||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(o!==n){this.internalState.hasPickingBuffer=n;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(n&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!n&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e.renderPass)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!PP({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),s=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:s,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let o=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(o)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let s in r)Object.defineProperty(i,s,{value:r[s]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(et.length/4);if(this.internalState.usesPickingColorCache=!0,i<r){r>ly&&L.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),et=Xe.allocate(et,r,{size:4,copy:!0,maxCount:Math.max(r,ly)});let s=Math.floor(et.length/4),o=[0,0,0];for(let n=i;n<s;n++)this.encodePickingColor(n,o),et[n*4+0]=o[0],et[n*4+1]=o[1],et[n*4+2]=o[2],et[n*4+3]=0}e.value=et.subarray(0,r*4)}_setModelAttributes(e,r,i=!1){if(!Object.keys(r).length)return;if(i){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),r=a.getAttributes()}let s=e.userData?.excludeAttributes||{},o={},n={};for(let a in r){if(s[a])continue;let c=r[a].getValue();for(let l in c){let f=c[l];f instanceof D?r[a].settings.isIndexed?e.setIndexBuffer(f):o[l]=f:f&&(n[l]=f)}}e.setAttributes(o),e.setConstantAttributes(n)}disablePickingIndex(e){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(e);return}let{pickingColors:i,instancePickingColors:s}=this.getAttributeManager().attributes,o=i||s,n=o&&r.attributes&&r.attributes[o.id];if(n&&n.value){let a=n.value,c=this.encodePickingColor(e);for(let l=0;l<r.length;l++){let f=o.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:r,instancePickingColors:i}=this.getAttributeManager().attributes,s=r||i;if(!s)return;let o=s.getVertexOffset(e),n=s.getVertexOffset(e+1);s.buffer.write(new Uint8Array(n-o),o)}restorePickingColors(){let{pickingColors:e,instancePickingColors:r}=this.getAttributeManager().attributes,i=e||r;i&&(this.internalState.usesPickingColorCache&&i.value.buffer!==et.buffer&&(i.value=et.subarray(0,i.value.length)),i.updateSubBuffer({startOffset:0}))}_initialize(){Y(!this.internalState),Y(Number.isFinite(this.props.coordinateSystem)),Q(AP,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Fo({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(L.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Io(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){Q(wP,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(Q(SP,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,i=this.context,s=this.internalState,o=i.viewport,n=this._updateUniformTransition();s.propsInTransition=n,i.viewport=s.viewport||o,this.props=n;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=o,this.props=r,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){Q(EP,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:r=null,uniforms:i={},parameters:s={}}){this._updateAttributeTransition();let o=this.props,n=this.context;this.props=this.internalState.propsInTransition||o;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];n.device instanceof Tt&&n.device.setParametersWebGL({polygonOffset:c});for(let l of this.getModels())l.device.type==="webgpu"?l.setParameters({...l.parameters,...s}):l.setParameters(s);if(n.device instanceof Tt)n.device.withParametersWebGL(s,()=>{let l={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:s,context:n};for(let f of this.props.extensions)f.draw.call(this,l,f);this.draw(l)});else{let l={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:s,context:n};for(let f of this.props.extensions)f.draw.call(this,l,f);this.draw(l)}}finally{this.props=o}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let s in e)if(e[s]){let o=!1;switch(s){case"dataChanged":let n=e[s],a=r[s];n&&Array.isArray(a)&&(r.dataChanged=Array.isArray(n)?a.concat(n):n,o=!0);default:r[s]||(r[s]=e[s],o=!0)}o&&Q(xP,this,s,e)}let i=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=iy(e,r);if(i.updateTriggersChanged)for(let s in i.updateTriggersChanged)i.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(i.transitionsChanged)for(let s in i.transitionsChanged)this.internalState.uniformTransitions.add(s,r[s],e[s],e.transitions?.[s]);return this.setChangeFlags(i)}validateProps(){ry(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new jr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:s}=e,o=this.state.model;o?.isInstanced&&o.setInstanceCount(this.getNumInstances());let{autoHighlight:n,highlightedObjectIndex:a,highlightColor:c}=i;if(r||s.autoHighlight!==n||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||s.autoHighlight!==n||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),s=i?i.getNeedsRedraw(e):!1;if(r=r||s,r)for(let o of this.props.extensions)o.onNeedsRedraw.call(this,o);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};Bo.defaultProps=vP;Bo.layerName="Layer";var Rc=Bo;var MP="compositeLayer.renderLayers",Pc=class extends Rc{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,s)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,s)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:s,parameters:o,getPolygonOffset:n,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_,_subLayerProps:T}=this.props,y={id:"",updateTriggers:{},opacity:r,pickable:i,visible:s,parameters:o,getPolygonOffset:n,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_},x=T&&e.id&&T[e.id],S=x&&x.updateTriggers,A=e.id||"sublayer";if(x){let w=this.props[ke],v=e.type?e.type._propTypes:{};for(let R in x){let M=v[R]||w[R];M&&M.type==="accessor"&&(x[R]=this.getSubLayerAccessor(x[R]))}}Object.assign(y,e,x),y.id=`${this.props.id}-${A}`,y.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...S};for(let w of g){let v=w.getSubLayerProps.call(this,w);v&&Object.assign(y,v,{updateTriggers:Object.assign(y.updateTriggers,v.updateTriggers)})}return y}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,s=!i||this.needsUpdate();if(s){let o=this.renderLayers();i=fr(o,Boolean),this.internalState.subLayers=i}Q(MP,this,s,i);for(let o of i)o.parent=this}};Pc.layerName="CompositeLayer";var fy=Pc;var Pu=Math.PI/180;function CP({height:t,focalDistance:e,orbitAxis:r,rotationX:i,rotationOrbit:s,zoom:o}){let n=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new z().lookAt({eye:a,up:n});c.rotateX(i*Pu),r==="Z"?c.rotateZ(s*Pu):c.rotateY(s*Pu);let l=Math.pow(2,o)/t;return c.scale(l),c}var vc=class extends Se{constructor(e){let{height:r,projectionMatrix:i,fovy:s=50,orbitAxis:o="Z",target:n=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,f=i?i[5]/2:Ot(s);super({...e,longitude:void 0,viewMatrix:CP({height:r||1,focalDistance:f,orbitAxis:o,rotationX:a,rotationOrbit:c,zoom:l}),fovy:s,focalDistance:f,position:n,zoom:l}),this.target=n,this.orbitAxis=o,this.rotationX=a,this.rotationOrbit=c,this.fovy=s,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[i,s,o=this.projectedCenter[2]]=e,n=r?s:this.height-s,[a,c,l]=Ue([i,n,o],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r,i){let s=this.project(e),{near:o,far:n}=Jm(this.projectionMatrix),a=o*n/(n-s[2]*(n-o)),c=o*n/(n-this.projectedCenter[2]*(n-o)),l=a/c,f=[this.width/2+(s[0]-r[0])*l,this.height/2+(s[1]-r[1])*l,this.projectedCenter[2]];return{target:this.unproject(f)}}};vc.displayName="OrbitViewport";var Mc=vc;var IP=new z().lookAt({eye:[0,0,1]});function OP({width:t,height:e,near:r,far:i,padding:s}){let o=-t/2,n=t/2,a=-e/2,c=e/2;if(s){let{left:l=0,right:f=0,top:h=0,bottom:u=0}=s,d=B((l+t-f)/2,0,t)-t/2,p=B((h+e-u)/2,0,e)-e/2;o-=d,n-=d,a+=p,c+=p}return new z().ortho({left:o,right:n,bottom:a,top:c,near:r,far:i})}var Cc=class extends Se{constructor(e){let{width:r,height:i,near:s=.1,far:o=1e3,zoom:n=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,f=e.zoomX??(Array.isArray(n)?n[0]:n),h=e.zoomY??(Array.isArray(n)?n[1]:n),u=Math.min(f,h),d=Math.pow(2,u),p;if(f!==h){let g=Math.pow(2,f),m=Math.pow(2,h);p={unitsPerMeter:[g/d,m/d,1],metersPerUnit:[d/g,d/m,1]}}super({...e,longitude:void 0,position:a,viewMatrix:IP.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:OP({width:r||1,height:i||1,padding:c,near:s,far:o}),zoom:u,distanceScales:p}),this.target=a,this.zoomX=f,this.zoomY=h,this.flipY=l}projectFlat([e,r]){let{unitsPerMeter:i}=this.distanceScales;return[e*i[0],r*i[1]]}unprojectFlat([e,r]){let{metersPerUnit:i}=this.distanceScales;return[e*i[0],r*i[1]]}panByPosition(e,r,i){let s=Ue(r,this.pixelUnprojectionMatrix),o=this.projectFlat(e),n=ee.add([],o,ee.negate([],s)),a=ee.add([],this.center,n);return{target:this.unprojectFlat(a)}}};Cc.displayName="OrthographicViewport";var Ic=Cc;var Oc=class extends Se{constructor(e){let{longitude:r,latitude:i,modelMatrix:s,bearing:o=0,pitch:n=0,up:a=[0,0,1]}=e,l=new Ve({bearing:o,pitch:n===-90?1e-4:90+n}).toVector3().normalize(),f=s?new z(s).transformAsVector(l):l,h=Number.isFinite(i)?Ys({latitude:i}):0,u=Math.pow(2,h),d=new z().lookAt({eye:[0,0,0],center:f,up:a}).scale(u);super({...e,zoom:h,viewMatrix:d}),this.latitude=i,this.longitude=r,this.pitch=n,this.bearing=o,this.up=a}};Oc.displayName="FirstPersonViewport";var Nc=Oc;var $r=20,hy=500,Lo=class extends Ke{constructor(e){let{width:r,height:i,position:s=[0,0,0],bearing:o=0,pitch:n=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:f=-90,maxBounds:h=null,startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_}=e;super({width:r,height:i,position:s,bearing:o,pitch:n,longitude:a,latitude:c,maxPitch:l,minPitch:f,maxBounds:h},{startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_},e.makeViewport)}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:i=[0,0]}=this.getState(),{width:s,height:o,bearing:n,pitch:a}=this.getViewportProps(),c=hy*(e[0]-r[0])/s,l=hy*(e[1]-r[1])/o,f=new Ve({bearing:n,pitch:a}),h=new Ve({bearing:n,pitch:-90}),u=f.toVector3().normalize(),d=h.toVector3().cross(u).normalize();return this._getUpdatedState({position:new H(i).add(d.scale(c)).add(u.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startBearing:o,startPitch:n}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||o===void 0||n===void 0)return this;let l;if(e){let f=(e[0]-s[0])/a,h=(e[1]-s[1])/c;l={bearing:o-f*180,pitch:n-h*90}}else l={bearing:o-r,pitch:n-i};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:r}){let i=this.getViewportProps(),s=this.getState().startZoomPosition||i.position,o=this.makeViewport(i),{projectionMatrix:n,width:a}=o,l=2*Math.atan(1/n[0])*(e[0]/a-.5),f=this.getDirection(!0);return this._move(f.rotateZ({radians:-l}),Math.log2(r)*$r,s)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=$r){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=$r){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=$r){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=$r){let r=this.getDirection(!0);return this._move(r.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=$r){return this._move(new H(0,0,1),e)}zoomOut(e=$r){return this._move(new H(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:o}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),o!==null&&r.longitude!==null&&Math.abs(o-r.longitude)>180&&(i.longitude=o<0?o+360:o-360),i}_move(e,r,i=this.getViewportProps().position){let s=e.scale(r);return this._getUpdatedState({position:new H(i).add(s)})}getDirection(e=!1){return new Ve({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new Lo({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:i,minPitch:s,longitude:o,position:n,bearing:a,maxBounds:c}=e;if(e.pitch=B(r,s,i),o!==null&&(o<-180||o>180)&&(e.longitude=ht(o+180,360)-180),(a<-180||a>180)&&(e.bearing=ht(a+180,360)-180),c){let l=B(n[0],c[0][0],c[1][0]),f=B(n[1],c[0][1],c[1][1]),h=B(n[2]??0,c[0][2]??0,c[1][2]??0);(l!==n[0]||f!==n[1]||h!==n[2])&&(e.position=[l,f,h])}return e}},Xr=class extends Te{constructor(){super(...arguments),this.ControllerState=Lo,this.transition={transitionDuration:300,transitionInterpolator:new ce(["position","pitch","bearing"])}}};var Dc=class extends ye{constructor(e={}){super(e)}getViewportType(){return Nc}get ControllerType(){return Xr}};Dc.displayName="FirstPersonView";var uy=Dc;var vu=class extends Ke{constructor(e){let{width:r,height:i,rotationX:s=0,rotationOrbit:o=0,target:n=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:f=-1/0,maxZoom:h=1/0,maxBounds:u=null,startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:T}=e;super({width:r,height:i,rotationX:s,rotationOrbit:o,target:n,zoom:a,minRotationX:c,maxRotationX:l,minZoom:f,maxZoom:h,maxBounds:u},{startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:T},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(o)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startRotationX:o,startRotationOrbit:n}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||o===void 0||n===void 0)return this;let l;if(e){let f=(e[0]-s[0])/a,h=(e[1]-s[1])/c;(o<-90||o>90)&&(f*=-1),l={rotationX:o+h*180,rotationOrbit:n+f*180}}else l={rotationX:o+i,rotationOrbit:n+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{rotationOrbit:s}=i;return Math.abs(s-r.rotationOrbit)>180&&(i.rotationOrbit=s<0?s+360:s-360),i}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomPosition:o}=this.getState();if(o||(s=this.getViewportProps().zoom,o=this._unproject(r||e)),!o)return this;let n=this._calculateNewZoom({scale:i,startZoom:s}),a=this.makeViewport({...this.getViewportProps(),zoom:n});return this._getUpdatedState({zoom:n,...a.panByPosition(o,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){let r=this.unproject3D?.(e);return r||this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){r===void 0&&(r=this.getViewportProps().zoom);let i=r+Math.log2(e);return this._constrainZoom(i)}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxRotationX:r,minRotationX:i,rotationOrbit:s}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=B(e.rotationX,i,r),(s<-180||s>180)&&(e.rotationOrbit=ht(s+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:s}=r,{minZoom:o}=r;if(s&&r.width>0&&r.height>0){let n=s[1][0]-s[0][0],a=s[1][1]-s[0][1],c=(s[1][2]??0)-(s[0][2]??0),l=Math.sqrt(n*n+a*a+c*c);l>0&&(o=Math.max(o,Math.log2(Math.min(r.width,r.height)/l)),o>i&&(o=i))}return B(e,o,i)}_constrainTarget(e){let{target:r,maxBounds:i}=e;if(!i)return r;let[[s,o,n=0],[a,c,l=0]]=i;if(r[0]>=s&&r[0]<=a&&r[1]>=o&&r[1]<=c&&r[2]>=n&&r[2]<=l)return r;let f=this.makeViewport?.(e);if(f){let{cameraPosition:h}=f,u=h[0]-r[0],d=h[1]-r[1],p=h[2]-r[2],g=u*r[0]+d*r[1]+p*r[2],m=u*(u>=0?s:a)+d*(d>=0?o:c)+p*(p>=0?n:l),_=u*(u>=0?a:s)+d*(d>=0?c:o)+p*(p>=0?l:n);if((u||d||p)&&g>=m&&g<=_){let T=I=>B(I,s,a),y=I=>B(I,o,c),x=I=>B(I,n,l),S=I=>u*T(r[0]-I*u)+d*y(r[1]-I*d)+p*x(r[2]-I*p)-g,A=-1,w=1,v=S(A),R=S(w);for(;v<0;)w=A,R=v,A*=2,v=S(A);for(;R>0;)A=w,v=R,w*=2,R=S(w);for(let I=0;I<30;I++){let C=(A+w)/2;S(C)>0?A=C:w=C}let M=(A+w)/2;return[T(r[0]-M*u),y(r[1]-M*d),x(r[2]-M*p)]}}return[B(r[0],s,a),B(r[1],o,c),B(r[2],n,l)]}},Yr=class extends Te{constructor(){super(...arguments),this.ControllerState=vu,this.transition={transitionDuration:300,transitionInterpolator:new ce({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){let{x:r,y:i}=this.props,s=this.pickPosition(r+e[0],i+e[1]);if(s&&s.coordinate)return s.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}};var Fc=class extends ye{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return Mc}get ControllerType(){return Yr}};Fc.displayName="OrbitView";var dy=Fc;function py({zoom:t=0,zoomX:e,zoomY:r}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r}}var Mu=class extends Ke{constructor(e){let{width:r,height:i,target:s=[0,0,0],zoom:o=0,zoomAxis:n="all",minZoom:a=-1/0,maxZoom:c=1/0,minZoomX:l=a,maxZoomX:f=c,minZoomY:h=a,maxZoomY:u=c,maxBounds:d=null,startPanPosition:p,startZoomPosition:g,startZoom:m}=e,{zoomX:_,zoomY:T}=py(e);super({width:r,height:i,target:s,zoom:o,zoomX:_,zoomY:T,zoomAxis:n,minZoomX:l,maxZoomX:f,minZoomY:h,maxZoomY:u,maxBounds:d},{startPanPosition:p,startZoomPosition:g,startZoom:m},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(o)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){let r=e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){let{zoomX:r,zoomY:i}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[r,i]})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomPosition:o}=this.getState();if(!o){let{zoomX:c,zoomY:l}=this.getViewportProps();s=[c,l],o=this._unproject(r||e)}if(!o)return this;let n=this._constrainZoom(this._calculateNewZoom({scale:i,startZoom:s})),a=this.makeViewport({...this.getViewportProps(),...n});return this._getUpdatedState({...n,...a.panByPosition(o,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:1/e}))}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{zoomX:i,zoomY:s,zoomAxis:o}=this.getViewportProps();r===void 0&&(r=[i,s]);let n=Math.log2(e),[a,c]=r;switch(o){case"X":a+=n;break;case"Y":c+=n;break;default:a+=n,c+=n}return{zoomX:a,zoomY:c}}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{zoomX:r,zoomY:i}=this._constrainZoom(e,e);e.zoomX=r,e.zoomY=i,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;let{maxBounds:s,target:o}=e;if(s){let n=e.width/2/2**r,a=e.height/2/2**i,c=s[0][0]+n,l=s[1][0]-n,f=s[0][1]+a,h=s[1][1]-a,u=B(o[0],c,l),d=B(o[1],f,h);(u!==o[0]||d!==o[1])&&(e.target=o.slice(),e.target[0]=u,e.target[1]=d)}return e}_constrainZoom({zoomX:e,zoomY:r},i){i||(i=this.getViewportProps());let{zoomAxis:s,maxZoomX:o,maxZoomY:n,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let h=a[0],u=a[1],d=u[0]-h[0],p=u[1]-h[1];Number.isFinite(d)&&d>0&&(c=Math.max(c,Math.log2(i.width/d)),c>o&&(c=o)),Number.isFinite(p)&&p>0&&(l=Math.max(l,Math.log2(i.height/p)),l>n&&(l=n))}switch(s){case"X":e=B(e,c,o);break;case"Y":r=B(r,l,n);break;default:let h=Math.min(o-e,n-r,0);h===0&&(h=Math.max(c-e,l-r,0)),h!==0&&(e+=h,r+=h)}return{zoomX:e,zoomY:r}}},Zr=class extends Te{constructor(){super(...arguments),this.ControllerState=Mu,this.transition={transitionDuration:300,transitionInterpolator:new ce(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,py(e)),super.setProps(e)}_onPanRotate(){return!1}};var Bc=class extends ye{constructor(e={}){super(e)}getViewportType(){return Ic}get ControllerType(){return Zr}};Bc.displayName="OrthographicView";var gy=Bc;var Cu=Math.PI/180,NP=180/Math.PI;function my(t,e=0){let r=Math.min(180,t)*Cu;return kt*2*Math.sin(r/2)*Math.pow(2,e)}function _y(t,e=0){let r=t/Math.pow(2,e);return Math.asin(Math.min(1,r/kt/2))*2*NP}var Iu=class extends ao{constructor(e){let{startPanPos:r,...i}=e;i.normalize=!1,super(i),r!==void 0&&(this._state.startPanPos=r)}panStart({pos:e}){let{latitude:r,longitude:i,zoom:s}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[i,r],startPanPos:e,startZoom:s})}pan({pos:e,startPos:r}){let i=this.getState(),s=i.startPanLngLat||this._unproject(r);if(!s)return this;let o=i.startZoom??this.getViewportProps().zoom,n=i.startPanPos||r,a=[s[0],s[1],o],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,n);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let i=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:i})}applyConstraints(e){let{longitude:r,latitude:i,maxBounds:s}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(r<-180||r>180)&&(e.longitude=ht(r+180,360)-180),e.latitude=B(i,-me,me),s&&(e.longitude=B(e.longitude,s[0][0],s[1][0]),e.latitude=B(e.latitude,s[0][1],s[1][1])),s){let o=e.zoom-dt(i),n=s[1][0]-s[0][0],a=s[1][1]-s[0][1];if(a>0&&a<me*2){let c=Math.min(_y(e.height,o),a)/2;e.latitude=B(e.latitude,s[0][1]+c,s[1][1]-c)}if(n>0&&n<360){let c=Math.min(_y(e.width/Math.cos(e.latitude*Cu),o),n)/2;e.longitude=B(e.longitude,s[0][0]+c,s[1][0]-c)}}return e.latitude!==i&&(e.zoom+=dt(e.latitude)-dt(i)),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{latitude:i,maxZoom:s,maxBounds:o}=r,{minZoom:n}=r,a=dt(0),c=dt(i)-a;if(o!==null&&r.width>0&&r.height>0){let f=o[0][1],h=o[1][1],u=Math.sign(f)===Math.sign(h)?Math.min(Math.abs(f),Math.abs(h)):0,d=my(o[1][0]-o[0][0])*Math.cos(u*Cu),p=my(o[1][1]-o[0][1]);d>0&&(n=Math.max(n,Math.log2(r.width/d)+a)),p>0&&(n=Math.max(n,Math.log2(r.height/p)+a)),n>s&&(n=s)}return B(e,n+c,s+c)}},Kr=class extends Te{constructor(){super(...arguments),this.ControllerState=Iu,this.transition={transitionDuration:300,transitionInterpolator:new ce(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var Lc=class extends ye{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?cr:Ii}get ControllerType(){return Kr}};Lc.displayName="GlobeView";var yy=Lc;var Uo=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&K(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,i={updateTriggers:{}};for(let s in r)if(s in this.props){let o=r[s],n=this.props[s];i[s]=n,o&&o.type==="accessor"&&(i.updateTriggers[s]=this.props.updateTriggers[s],typeof n=="function"&&(i[s]=this.getSubLayerAccessor(n)))}return i}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};Uo.defaultProps={};Uo.extensionName="LayerExtension";var Ty=Uo;var Ou={bearing:0,pitch:0,position:[0,0,0]},DP={speed:1.2,curve:1.414},ko=class extends Ut{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...DP,...e}}interpolateProps(e,r,i){let s=Fh(e,r,i,this.opts);for(let o in Ou)s[o]=vt(e[o]||Ou[o],r[o]||Ou[o],i);return s}getDuration(e,r){let{transitionDuration:i}=r;return i==="auto"&&(i=Bh(e,r,this.opts)),i}};F();var Vo=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Xe,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:s,geometryBuffer:o,positionFormat:n,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=s,this.positionSize=o&&o.size||(n==="XY"?2:3),this.buffers=i,this.normalize=c,o&&(Y(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(o),c||(i.vertexPositions=o)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?mc(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:s,_attributeDefs:o,typedArrayManager:n}=this;for(let a in o)if(a in s)n.release(i[a]),i[a]=null;else{let c=o[a];c.copy=r,i[a]=n.allocate(i[a],e,c)}}_forEachGeometry(e,r,i){let{data:s,getGeometry:o}=this,{iterable:n,objectInfo:a}=Ui(s,r,i);for(let c of n){a.index++;let l=o?o(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:s}=this,{data:o,geometryBuffer:n}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],i=[0]),this.normalize||!n)this._forEachGeometry((h,u)=>{let d=h&&this.normalizeGeometry(h);l[u]=d,i[u+1]=i[u]+(d?this.getGeometrySize(d):0)},a,c),s=i[i.length-1];else if(i=o.startIndices,s=i[o.length]||0,ArrayBuffer.isView(n))s=s||n.length/this.positionSize;else if(n instanceof D){let h=this.positionSize*4;s=s||n.byteLength/h}else if(n.buffer){let h=n.stride||this.positionSize*4;s=s||n.buffer.byteLength/h}else if(n.value){let h=n.value,u=n.stride/h.BYTES_PER_ELEMENT||this.positionSize;s=s||h.length/u}this._allocate(s,Boolean(e)),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=s;let f={};this._forEachGeometry((h,u)=>{let d=l[u]||h;f.vertexStart=i[u],f.indexStart=r[u];let p=u<i.length-1?i[u+1]:s;f.geometrySize=p-i[u],f.geometryIndex=u,this.updateGeometryAttributes(d,f)},a,c),this.vertexCount=r[r.length-1]}};var Uc=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let r=this.props,i={...this.props,...e};if(this.props=i,!this.map)return;this._update(r,i)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:r,container:i}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:i,maxZoom:24,...e.mapOptions,...by(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(i,"offsetWidth",{get:()=>this.width}),Object.defineProperty(i,"clientWidth",{get:()=>this.width}),Object.defineProperty(i,"offsetHeight",{get:()=>this.height}),Object.defineProperty(i,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let s=e.width!==r.width||e.height!==r.height;s&&(this.width=r.width,this.height=r.height,this.map.resize());let o=e.viewState,n=r.viewState,a=n.latitude!==o.latitude||n.longitude!==o.longitude||n.zoom!==o.zoom||n.pitch!==o.pitch||n.bearing!==o.bearing;return a&&this.map.jumpTo(by(n)),s||a}};function by(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var xy={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function FP(t){let{container:e=document.body}=t;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let i=document.createElement("div");e.appendChild(i),Object.assign(i.style,xy);let s=document.createElement("canvas");return e.appendChild(s),Object.assign(s.style,xy),{container:e,mapCanvas:i,deckCanvas:s}}var zo=class extends pc{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:i}=FP(e),s=e.viewState||e.initialViewState,o=Number.isFinite(s&&s.latitude),{map:n=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:i,...e}),n&&n.Map?this._map=o&&new Uc({...e,width:0,height:0,viewState:s,container:r,mapLib:n}):this._map=n}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,r){if(this._map){let i=this.getViewports()[0];i&&this._map.setProps({width:i.width,height:i.height,viewState:i})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,Uf);Object.assign(globalThis.loaders,uh);return Py(BP);})();
|
|
2014
|
+
}`;function wv(t,e){let r=vc(e.size),i=Mc(e.size);return new je(t,{vs:Sv,fs:Ev,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[Av],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function Rv(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function Pv(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var vv={interpolation:Co,spring:Io},Oo=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let s in e){let o=e[s],n=o.getTransitionSetting(r);n&&this._updateAttribute(s,o,n)}for(let s in this.transitions){let o=e[s];(!o||!o.getTransitionSetting(r))&&this._removeTransition(s)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,i){let s=this.transitions[e],o=!s||s.type!==i.type;if(o){s&&this._removeTransition(e);let n=vv[i.type];n?this.transitions[e]=new n({attribute:r,timeline:this.timeline,device:this.device}):(F.error(`unsupported transition type '${i.type}'`)(),o=!1)}(o||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var $b="attributeManager.invalidate",Mv="attributeManager.updateStart",Cv="attributeManager.updateEnd",Iv="attribute.updateStart",Ov="attribute.allocate",Nv="attribute.updateEnd",$r=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:s}={}){this.mergeBoundsMemoized=Ue(X_),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Oo(e,{id:`${r}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);G($b,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);G($b,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:s,props:o={},buffers:n={},context:a={}}){let c=!1;G(Mv,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let f=this.attributes[l],h=f.settings.accessor;f.startIndices=i,f.numInstances=r,o[l]&&F.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(n[l])||f.setBinaryValue(typeof h=="string"?n[h]:void 0,e.startIndices)||typeof h=="string"&&!n[h]&&f.setConstantValue(a,o[h])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:r,data:e,props:o,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&G(Cv,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:s})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,s={...i.getAttributes()};for(let o in r){let n=r[o];n.needsRedraw(e)&&!i.hasAttribute(o)&&(s[o]=n)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let s=e[i],o={...s,id:i,size:s.isIndexed&&1||s.size||1,...r};this.attributes[i]=new $t(this.device,o)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:s}=this,o=s[e];return o&&o.forEach(n=>{let a=i[n];a&&a.setNeedsUpdate(a.id,r)}),o}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(G(Iv,r),r.constant){r.setConstantValue(e.context,r.value);return}r.allocate(i)&&G(Ov,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,G(Nv,r,i))}};L();Tc();var No=class extends qe{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:s,easing:o}}=this,n=o(e/s);this._value=It(r,i,n)}};var Xb=1e-5;function Yb(t,e,r,i,s){let o=e-t,a=(r-e)*s,c=-o*i;return a+c+o+e}function Dv(t,e,r,i,s){if(Array.isArray(r)){let o=[];for(let n=0;n<r.length;n++)o[n]=Yb(t[n],e[n],r[n],i,s);return o}return Yb(t,e,r,i,s)}function Kb(t,e){if(Array.isArray(t)){let r=0;for(let i=0;i<t.length;i++){let s=t[i]-e[i];r+=s*s}return Math.sqrt(r)}return Math.abs(t-e)}var Do=class extends qe{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:r,damping:i,stiffness:s}=this.settings,{_prevValue:o=e,_currValue:n=e}=this,a=Dv(o,n,r,i,s),c=Kb(a,r),l=Kb(a,n);c<Xb&&l<Xb&&(a=r,this.end()),this._prevValue=n,this._currValue=a}};var Bv={interpolation:No,spring:Do},Bo=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,r,i,s){let{transitions:o}=this;if(o.has(e)){let c=o.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(s=Pc(s),!s)return;let n=Bv[s.type];if(!n){F.error(`unsupported transition type '${s.type}'`)();return}let a=new n(this.timeline);a.start({...s,fromValue:r,toValue:i}),o.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function qb(t){let e=t[ze];for(let r in e){let i=e[r],{validate:s}=i;if(s&&!s(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function Gb(t,e){let r=Nc({newProps:t,oldProps:e,propTypes:t[ze],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=Lv(t,e),s=!1;return i||(s=Uv(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:s,extensionsChanged:kv(t,e),transitionsChanged:Fv(t,e)}}function Fv(t,e){if(!t.transitions)return!1;let r={},i=t[ze],s=!1;for(let o in t.transitions){let n=i[o],a=n&&n.type;(a==="number"||a==="color"||a==="array")&&Ku(t[o],e[o],n)&&(r[o]=!0,s=!0)}return s?r:!1}function Nc({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:s="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(let o of Object.keys(t))if(!(o in r)){if(!(o in e))return`${s}.${o} added`;let n=Ku(t[o],e[o],i[o]);if(n)return`${s}.${o} ${n}`}for(let o of Object.keys(e))if(!(o in r)){if(!(o in t))return`${s}.${o} dropped`;if(!Object.hasOwnProperty.call(t,o)){let n=Ku(t[o],e[o],i[o]);if(n)return`${s}.${o} ${n}`}}return!1}function Ku(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function Lv(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:s}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&s&&(r=s(t.data,e.data)||r),r}function Uv(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&Zb(t,e,"all"))return{all:!0};let r={},i=!1;for(let s in t.updateTriggers)s!=="all"&&Zb(t,e,s)&&(r[s]=!0,i=!0);return i?r:!1}function kv(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let s=0;s<i.length;s++)if(!i[s].equals(r[s]))return!0;return!1}function Zb(t,e,r){let i=t.updateTriggers[r];i=i??{};let s=e.updateTriggers[r];return s=s??{},Nc({oldProps:s,newProps:i,triggerName:r})}var Vv="count(): argument not an object",zv="count(): argument not a container";function Dc(t){if(!jv(t))throw new Error(Vv);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(Wv(t))return Object.keys(t).length;throw new Error(zv)}function Wv(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function jv(t){return t!==null&&typeof t=="object"}function Fo(t,e){if(!e)return t;let r={...t,...e};if("defines"in e&&(r.defines={...t.defines,...e.defines}),"modules"in e&&(r.modules=(t.modules||[]).concat(e.modules),e.modules.some(i=>i.name==="project64"))){let i=r.modules.findIndex(s=>s.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let s in e.inject)i[s]=(i[s]||"")+e.inject[s];r.inject=i}return r}L();var Hv={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Zu={};function Qb(t,e,r,i){if(r instanceof B)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let s=null;r.compressed&&(s={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:o,height:n}=r.data,a=e.createTexture({...r,sampler:{...Hv,...s,...i},mipLevels:e.getMipLevelCount(o,n)});return e.type==="webgl"&&a.generateMipmapsWebGL(),Zu[a.id]=t,a}function Jb(t,e){!e||!(e instanceof B)||Zu[e.id]===t&&(e.delete(),delete Zu[e.id])}var $v={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||qu(t)&&(t.length===3||t.length===4)},equal(t,e,r){return Z(t,e,1)}},accessor:{validate(t,e){let r=Bc(t);return r==="function"||r===Bc(e.value)},equal(t,e,r){return typeof e=="function"?!0:Z(t,e,1)}},array:{validate(t,e){return e.optional&&!t||qu(t)},equal(t,e,r){let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?Z(t,e,s):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?Z(t,e,s):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:Qb(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{Jb(r.id,t)}}};function e0(t){let e={},r={},i={};for(let[s,o]of Object.entries(t)){let n=o?.deprecatedFor;if(n)i[s]=Array.isArray(n)?n:[n];else{let a=Xv(s,o);e[s]=a,r[s]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function Xv(t,e){switch(Bc(e)){case"object":return Lo(t,e);case"array":return Lo(t,{type:"array",value:e,compare:!1});case"boolean":return Lo(t,{type:"boolean",value:e});case"number":return Lo(t,{type:"number",value:e});case"function":return Lo(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Lo(t,e){return"type"in e?{name:t,...$v[e.type],...e}:"value"in e?{name:t,type:Bc(e.value),...e}:{name:t,type:"object",value:e}}function qu(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function Bc(t){return qu(t)?"array":t===null?"null":typeof t}function t0(t,e){let r;for(let o=e.length-1;o>=0;o--){let n=e[o];"extensions"in n&&(r=n.extensions)}let i=Gu(t.constructor,r),s=Object.create(i);s[Ui]=t,s[_t]={},s[Ze]={};for(let o=0;o<e.length;++o){let n=e[o];for(let a in n)s[a]=n[a]}return Object.freeze(s),s}var Yv="_mergedDefaultProps";function Gu(t,e){if(!(t instanceof Ki.constructor))return{};let r=Yv;if(e)for(let s of e){let o=s.constructor;o&&(r+=`:${o.extensionName||o.name}`)}let i=r0(t,r);return i||(t[r]=Kv(t,e||[]))}function Kv(t,e){if(!t.prototype)return null;let i=Object.getPrototypeOf(t),s=Gu(i),o=r0(t,"defaultProps")||{},n=e0(o),a=Object.assign(Object.create(null),s,n.defaultProps),c=Object.assign(Object.create(null),s?.[ze],n.propTypes),l=Object.assign(Object.create(null),s?.[va],n.deprecatedProps);for(let f of e){let h=Gu(f.constructor);h&&(Object.assign(a,h),Object.assign(c,h[ze]),Object.assign(l,h[va]))}return Zv(a,t),Gv(a,c),qv(a,l),a[ze]=c,a[va]=l,e.length===0&&!Qu(t,"_propTypes")&&(t._propTypes=c),a}function Zv(t,e){let r=Jv(e);Object.defineProperties(t,{id:{writable:!0,value:r}})}function qv(t,e){for(let r in e)Object.defineProperty(t,r,{enumerable:!1,set(i){let s=`${this.id}: ${r}`;for(let o of e[r])Qu(this,o)||(this[o]=i);F.deprecated(s,e[r].join("/"))()}})}function Gv(t,e){let r={},i={};for(let s in e){let o=e[s],{name:n,value:a}=o;o.async&&(r[n]=a,i[n]=Qv(n))}t[Ut]=r,t[_t]={},Object.defineProperties(t,i)}function Qv(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||wc(e)?this[_t][t]=e:this[Ze][t]=e},get(){if(this[Ze]){if(t in this[Ze])return this[Ze][t]||this[Ut][t];if(t in this[_t]){let e=this[Ui]&&this[Ui].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[Ut][t]}}return this[Ut][t]}}}function Qu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r0(t,e){return Qu(t,e)&&t[e]}function Jv(t){let e=t.componentName;return e||F.warn(`${t.name}.componentName not specified`)(),e||t.name}var e2=0,Uo=class{constructor(...e){this.props=t0(this,e),this.id=this.props.id,this.count=e2++}clone(e){let{props:r}=this,i={};for(let s in r[Ut])s in r[Ze]?i[s]=r[Ze][s]:s in r[_t]&&(i[s]=r[_t][s]);return new this.constructor({...r,...i,...e})}};Uo.componentName="Component";Uo.defaultProps={};var Ki=Uo;var t2=Object.freeze({}),Xr=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||t2}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[Ui]||this.component;let r=e[Ze]||{},i=e[_t]||e,s=e[Ut]||{};for(let o in r){let n=r[o];this._createAsyncPropData(o,s[o]),this._updateAsyncProp(o,n),r[o]=this.getAsyncProp(o)}for(let o in i){let n=i[o];this._createAsyncPropData(o,s[o]),this._updateAsyncProp(o,n)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(wc(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let s=this.asyncProps[e];s&&i>=s.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=r,s.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let s=i.pendingLoadCount;r.then(o=>{this.component&&(o=this._postProcessValue(i,o),this._setAsyncPropValue(e,o,s),this._onResolve(e,o))}).catch(o=>{this._onError(e,o)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let s=i.pendingLoadCount,o=[],n=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?o=c(a,o):o=o.concat(a),Object.defineProperty(o,"__diff",{enumerable:!1,value:[{startRow:n,endRow:o.length}]}),n=o.length,this._setAsyncPropValue(e,o,s)}this._onResolve(e,o)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let s=this.component&&this.component.props[ze];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var ko=class extends Xr{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,s=i?.props.fetch;return s?s(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let s=i.props.onDataLoad;e==="data"&&s&&s(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var r2="layer.changeFlag",i2="layer.initialize",s2="layer.update",o2="layer.finalize",n2="layer.matched",i0=2**24-1,a2=Object.freeze([]),c2=Ue(({oldViewport:t,viewport:e})=>t.equals(e)),it=new Uint8ClampedArray(0),l2={data:{type:"data",value:a2,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:i,loadOptions:s,signal:o})=>{let{resourceManager:n}=r.context;s=s||r.getLoadOptions(),i=i||r.props.loaders,o&&(s={...s,core:{...s?.core,fetch:{...s?.core?.fetch,signal:o}}});let a=n.contains(t);return!a&&!s&&(n.add({resourceId:t,data:ar(t,i),persistent:!1}),a=!0),a?n.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):ar(t,i,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:k.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},Vo=class extends Ki{constructor(){super(...arguments),this.internalState=null,this.lifecycle=pr.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){Y(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=du(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,o,n]=Ii(i,r.pixelProjectionMatrix);return e.length===2?[s,o]:[s,o,n]}unproject(e){return Y(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){Y(this.internalState);let i=this.internalState.viewport||this.context.viewport;return wa(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===k.DEFAULT||e===k.LNGLAT||e===k.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){Y(e instanceof Uint8Array);let[r,i,s]=e;return r+i*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Dc(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=Fo(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=Fo(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let s of i)r.invalidateAll(s);else r.invalidateAll();if(r){let{props:s}=e,o=this.internalState.hasPickingBuffer,n=Number.isInteger(s.highlightedObjectIndex)||Boolean(s.pickable)||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(o!==n){this.internalState.hasPickingBuffer=n;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(n&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!n&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e.renderPass)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!c2({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),s=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:s,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let o=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(o)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let s in r)Object.defineProperty(i,s,{value:r[s]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(it.length/4);if(this.internalState.usesPickingColorCache=!0,i<r){r>i0&&F.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),it=Ke.allocate(it,r,{size:4,copy:!0,maxCount:Math.max(r,i0)});let s=Math.floor(it.length/4),o=[0,0,0];for(let n=i;n<s;n++)this.encodePickingColor(n,o),it[n*4+0]=o[0],it[n*4+1]=o[1],it[n*4+2]=o[2],it[n*4+3]=0}e.value=it.subarray(0,r*4)}_setModelAttributes(e,r,i=!1){if(!Object.keys(r).length)return;if(i){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),r=a.getAttributes()}let s=e.userData?.excludeAttributes||{},o={},n={};for(let a in r){if(s[a])continue;let c=r[a].getValue();for(let l in c){let f=c[l];f instanceof I?r[a].settings.isIndexed?e.setIndexBuffer(f):o[l]=f:f&&(n[l]=f)}}e.setAttributes(o),e.setConstantAttributes(n)}disablePickingIndex(e){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(e);return}let{pickingColors:i,instancePickingColors:s}=this.getAttributeManager().attributes,o=i||s,n=o&&r.attributes&&r.attributes[o.id];if(n&&n.value){let a=n.value,c=this.encodePickingColor(e);for(let l=0;l<r.length;l++){let f=o.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:r,instancePickingColors:i}=this.getAttributeManager().attributes,s=r||i;if(!s)return;let o=s.getVertexOffset(e),n=s.getVertexOffset(e+1);s.buffer.write(new Uint8Array(n-o),o)}restorePickingColors(){let{pickingColors:e,instancePickingColors:r}=this.getAttributeManager().attributes,i=e||r;i&&(this.internalState.usesPickingColorCache&&i.value.buffer!==it.buffer&&(i.value=it.subarray(0,i.value.length)),i.updateSubBuffer({startOffset:0}))}_initialize(){Y(!this.internalState),Y(Number.isFinite(this.props.coordinateSystem)),G(i2,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new ko({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(F.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Bo(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){G(n2,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(G(s2,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,i=this.context,s=this.internalState,o=i.viewport,n=this._updateUniformTransition();s.propsInTransition=n,i.viewport=s.viewport||o,this.props=n;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=o,this.props=r,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){G(o2,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:r=null,uniforms:i={},parameters:s={}}){this._updateAttributeTransition();let o=this.props,n=this.context;this.props=this.internalState.propsInTransition||o;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];n.device instanceof rt&&n.device.setParametersWebGL({polygonOffset:c});let l=n.device instanceof rt?null:f2(s);if(h2(this.getModels(),e,s,l),n.device instanceof rt)n.device.withParametersWebGL(s,()=>{let f={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:s,context:n};for(let h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let f={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:s,context:n};for(let h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)}}finally{this.props=o}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let s in e)if(e[s]){let o=!1;switch(s){case"dataChanged":let n=e[s],a=r[s];n&&Array.isArray(a)&&(r.dataChanged=Array.isArray(n)?a.concat(n):n,o=!0);default:r[s]||(r[s]=e[s],o=!0)}o&&G(r2,this,s,e)}let i=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=Gb(e,r);if(i.updateTriggersChanged)for(let s in i.updateTriggersChanged)i.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(i.transitionsChanged)for(let s in i.transitionsChanged)this.internalState.uniformTransitions.add(s,r[s],e[s],e.transitions?.[s]);return this.setChangeFlags(i)}validateProps(){qb(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new $r(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:s}=e,o=this.state.model;o?.isInstanced&&o.setInstanceCount(this.getNumInstances());let{autoHighlight:n,highlightedObjectIndex:a,highlightColor:c}=i;if(r||s.autoHighlight!==n||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||s.autoHighlight!==n||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),s=i?i.getNeedsRedraw(e):!1;if(r=r||s,r)for(let o of this.props.extensions)o.onNeedsRedraw.call(this,o);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};Vo.defaultProps=l2;Vo.layerName="Layer";var Fc=Vo;function f2(t){let{blendConstant:e,...r}=t;return e?{pipelineParameters:r,renderPassParameters:{blendConstant:e}}:{pipelineParameters:r}}function h2(t,e,r,i){for(let s of t)s.device.type==="webgpu"?(u2(s,e),s.setParameters({...s.parameters,...i?.pipelineParameters})):s.setParameters(r)}function u2(t,e){let r=e.props.framebuffer||(e.framebuffer??null);if(!r)return;let i=r.colorAttachments.map(n=>n?.texture?.format??null),s=r.depthStencilAttachment?.texture?.format,o=t;(!d2(o.props.colorAttachmentFormats,i)||o.props.depthStencilAttachmentFormat!==s)&&(o.props.colorAttachmentFormats=i,o.props.depthStencilAttachmentFormat=s,o._setPipelineNeedsUpdate("attachment formats"))}function d2(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}var p2="compositeLayer.renderLayers",Lc=class extends Fc{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,s)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,s)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:s,parameters:o,getPolygonOffset:n,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_,_subLayerProps:b}=this.props,y={id:"",updateTriggers:{},opacity:r,pickable:i,visible:s,parameters:o,getPolygonOffset:n,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_},T=b&&e.id&&b[e.id],S=T&&T.updateTriggers,A=e.id||"sublayer";if(T){let w=this.props[ze],v=e.type?e.type._propTypes:{};for(let R in T){let M=v[R]||w[R];M&&M.type==="accessor"&&(T[R]=this.getSubLayerAccessor(T[R]))}}Object.assign(y,e,T),y.id=`${this.props.id}-${A}`,y.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...S};for(let w of g){let v=w.getSubLayerProps.call(this,w);v&&Object.assign(y,v,{updateTriggers:Object.assign(y.updateTriggers,v.updateTriggers)})}return y}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,s=!i||this.needsUpdate();if(s){let o=this.renderLayers();i=gr(o,Boolean),this.internalState.subLayers=i}G(p2,this,s,i);for(let o of i)o.parent=this}};Lc.layerName="CompositeLayer";var s0=Lc;var Ju=Math.PI/180;function g2({height:t,focalDistance:e,orbitAxis:r,rotationX:i,rotationOrbit:s,zoom:o}){let n=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new z().lookAt({eye:a,up:n});c.rotateX(i*Ju),r==="Z"?c.rotateZ(s*Ju):c.rotateY(s*Ju);let l=Math.pow(2,o)/t;return c.scale(l),c}var Uc=class extends Ee{constructor(e){let{height:r,projectionMatrix:i,fovy:s=50,orbitAxis:o="Z",target:n=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,f=i?i[5]/2:Bt(s);super({...e,longitude:void 0,viewMatrix:g2({height:r||1,focalDistance:f,orbitAxis:o,rotationX:a,rotationOrbit:c,zoom:l}),fovy:s,focalDistance:f,position:n,zoom:l}),this.target=n,this.orbitAxis=o,this.rotationX=a,this.rotationOrbit=c,this.fovy=s,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[i,s,o=this.projectedCenter[2]]=e,n=r?s:this.height-s,[a,c,l]=Ve([i,n,o],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r,i){let s=this.project(e),{near:o,far:n}=H_(this.projectionMatrix),a=o*n/(n-s[2]*(n-o)),c=o*n/(n-this.projectedCenter[2]*(n-o)),l=a/c,f=[this.width/2+(s[0]-r[0])*l,this.height/2+(s[1]-r[1])*l,this.projectedCenter[2]];return{target:this.unproject(f)}}};Uc.displayName="OrbitViewport";var kc=Uc;var m2=new z().lookAt({eye:[0,0,1]});function _2({width:t,height:e,near:r,far:i,padding:s}){let o=-t/2,n=t/2,a=-e/2,c=e/2;if(s){let{left:l=0,right:f=0,top:h=0,bottom:u=0}=s,d=U((l+t-f)/2,0,t)-t/2,p=U((h+e-u)/2,0,e)-e/2;o-=d,n-=d,a+=p,c+=p}return new z().ortho({left:o,right:n,bottom:a,top:c,near:r,far:i})}var Vc=class extends Ee{constructor(e){let{width:r,height:i,near:s=.1,far:o=1e3,zoom:n=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,f=e.zoomX??(Array.isArray(n)?n[0]:n),h=e.zoomY??(Array.isArray(n)?n[1]:n),u=Math.min(f,h),d=Math.pow(2,u),p;if(f!==h){let g=Math.pow(2,f),m=Math.pow(2,h);p={unitsPerMeter:[g/d,m/d,1],metersPerUnit:[d/g,d/m,1]}}super({...e,longitude:void 0,position:a,viewMatrix:m2.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:_2({width:r||1,height:i||1,padding:c,near:s,far:o}),zoom:u,distanceScales:p}),this.target=a,this.zoomX=f,this.zoomY=h,this.flipY=l}projectFlat([e,r]){let{unitsPerMeter:i}=this.distanceScales;return[e*i[0],r*i[1]]}unprojectFlat([e,r]){let{metersPerUnit:i}=this.distanceScales;return[e*i[0],r*i[1]]}panByPosition(e,r,i){let s=Ve(r,this.pixelUnprojectionMatrix),o=this.projectFlat(e),n=ee.add([],o,ee.negate([],s)),a=ee.add([],this.center,n);return{target:this.unprojectFlat(a)}}};Vc.displayName="OrthographicViewport";var zc=Vc;var Wc=class extends Ee{constructor(e){let{longitude:r,latitude:i,modelMatrix:s,bearing:o=0,pitch:n=0,up:a=[0,0,1]}=e,l=new We({bearing:o,pitch:n===-90?1e-4:90+n}).toVector3().normalize(),f=s?new z(s).transformAsVector(l):l,h=Number.isFinite(i)?Gs({latitude:i}):0,u=Math.pow(2,h),d=new z().lookAt({eye:[0,0,0],center:f,up:a}).scale(u);super({...e,zoom:h,viewMatrix:d}),this.latitude=i,this.longitude=r,this.pitch=n,this.bearing=o,this.up=a}};Wc.displayName="FirstPersonViewport";var jc=Wc;var Yr=20,o0=500,zo=class extends Ge{constructor(e){let{width:r,height:i,position:s=[0,0,0],bearing:o=0,pitch:n=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:f=-90,maxBounds:h=null,startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_}=e;super({width:r,height:i,position:s,bearing:o,pitch:n,longitude:a,latitude:c,maxPitch:l,minPitch:f,maxBounds:h},{startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_},e.makeViewport)}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:i=[0,0]}=this.getState(),{width:s,height:o,bearing:n,pitch:a}=this.getViewportProps(),c=o0*(e[0]-r[0])/s,l=o0*(e[1]-r[1])/o,f=new We({bearing:n,pitch:a}),h=new We({bearing:n,pitch:-90}),u=f.toVector3().normalize(),d=h.toVector3().cross(u).normalize();return this._getUpdatedState({position:new H(i).add(d.scale(c)).add(u.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startBearing:o,startPitch:n}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||o===void 0||n===void 0)return this;let l;if(e){let f=(e[0]-s[0])/a,h=(e[1]-s[1])/c;l={bearing:o-f*180,pitch:n-h*90}}else l={bearing:o-r,pitch:n-i};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:r}){let i=this.getViewportProps(),s=this.getState().startZoomPosition||i.position,o=this.makeViewport(i),{projectionMatrix:n,width:a}=o,l=2*Math.atan(1/n[0])*(e[0]/a-.5),f=this.getDirection(!0);return this._move(f.rotateZ({radians:-l}),Math.log2(r)*Yr,s)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=Yr){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=Yr){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=Yr){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=Yr){let r=this.getDirection(!0);return this._move(r.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=Yr){return this._move(new H(0,0,1),e)}zoomOut(e=Yr){return this._move(new H(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:o}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),o!==null&&r.longitude!==null&&Math.abs(o-r.longitude)>180&&(i.longitude=o<0?o+360:o-360),i}_move(e,r,i=this.getViewportProps().position){let s=e.scale(r);return this._getUpdatedState({position:new H(i).add(s)})}getDirection(e=!1){return new We({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new zo({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:i,minPitch:s,longitude:o,position:n,bearing:a,maxBounds:c}=e;if(e.pitch=U(r,s,i),o!==null&&(o<-180||o>180)&&(e.longitude=mt(o+180,360)-180),(a<-180||a>180)&&(e.bearing=mt(a+180,360)-180),c){let l=U(n[0],c[0][0],c[1][0]),f=U(n[1],c[0][1],c[1][1]),h=U(n[2]??0,c[0][2]??0,c[1][2]??0);(l!==n[0]||f!==n[1]||h!==n[2])&&(e.position=[l,f,h])}return e}},Kr=class extends Te{constructor(){super(...arguments),this.ControllerState=zo,this.transition={transitionDuration:300,transitionInterpolator:new ce(["position","pitch","bearing"])}}};var Hc=class extends be{constructor(e={}){super(e)}getViewportType(){return jc}get ControllerType(){return Kr}};Hc.displayName="FirstPersonView";var n0=Hc;var ed=class extends Ge{constructor(e){let{width:r,height:i,rotationX:s=0,rotationOrbit:o=0,target:n=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:f=-1/0,maxZoom:h=1/0,maxBounds:u=null,startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:b}=e;super({width:r,height:i,rotationX:s,rotationOrbit:o,target:n,zoom:a,minRotationX:c,maxRotationX:l,minZoom:f,maxZoom:h,maxBounds:u},{startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:b},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(o)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startRotationX:o,startRotationOrbit:n}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||o===void 0||n===void 0)return this;let l;if(e){let f=(e[0]-s[0])/a,h=(e[1]-s[1])/c;(o<-90||o>90)&&(f*=-1),l={rotationX:o+h*180,rotationOrbit:n+f*180}}else l={rotationX:o+i,rotationOrbit:n+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{rotationOrbit:s}=i;return Math.abs(s-r.rotationOrbit)>180&&(i.rotationOrbit=s<0?s+360:s-360),i}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomPosition:o}=this.getState();if(o||(s=this.getViewportProps().zoom,o=this._unproject(r||e)),!o)return this;let n=this._calculateNewZoom({scale:i,startZoom:s}),a=this.makeViewport({...this.getViewportProps(),zoom:n});return this._getUpdatedState({zoom:n,...a.panByPosition(o,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){let r=this.unproject3D?.(e);return r||this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){r===void 0&&(r=this.getViewportProps().zoom);let i=r+Math.log2(e);return this._constrainZoom(i)}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxRotationX:r,minRotationX:i,rotationOrbit:s}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=U(e.rotationX,i,r),(s<-180||s>180)&&(e.rotationOrbit=mt(s+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:s}=r,{minZoom:o}=r;if(s&&r.width>0&&r.height>0){let n=s[1][0]-s[0][0],a=s[1][1]-s[0][1],c=(s[1][2]??0)-(s[0][2]??0),l=Math.sqrt(n*n+a*a+c*c);l>0&&(o=Math.max(o,Math.log2(Math.min(r.width,r.height)/l)),o>i&&(o=i))}return U(e,o,i)}_constrainTarget(e){let{target:r,maxBounds:i}=e;if(!i)return r;let[[s,o,n=0],[a,c,l=0]]=i;if(r[0]>=s&&r[0]<=a&&r[1]>=o&&r[1]<=c&&r[2]>=n&&r[2]<=l)return r;let f=this.makeViewport?.(e);if(f){let{cameraPosition:h}=f,u=h[0]-r[0],d=h[1]-r[1],p=h[2]-r[2],g=u*r[0]+d*r[1]+p*r[2],m=u*(u>=0?s:a)+d*(d>=0?o:c)+p*(p>=0?n:l),_=u*(u>=0?a:s)+d*(d>=0?c:o)+p*(p>=0?l:n);if((u||d||p)&&g>=m&&g<=_){let b=O=>U(O,s,a),y=O=>U(O,o,c),T=O=>U(O,n,l),S=O=>u*b(r[0]-O*u)+d*y(r[1]-O*d)+p*T(r[2]-O*p)-g,A=-1,w=1,v=S(A),R=S(w);for(;v<0;)w=A,R=v,A*=2,v=S(A);for(;R>0;)A=w,v=R,w*=2,R=S(w);for(let O=0;O<30;O++){let C=(A+w)/2;S(C)>0?A=C:w=C}let M=(A+w)/2;return[b(r[0]-M*u),y(r[1]-M*d),T(r[2]-M*p)]}}return[U(r[0],s,a),U(r[1],o,c),U(r[2],n,l)]}},Zr=class extends Te{constructor(){super(...arguments),this.ControllerState=ed,this.transition={transitionDuration:300,transitionInterpolator:new ce({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){let{x:r,y:i}=this.props,s=this.pickPosition(r+e[0],i+e[1]);if(s&&s.coordinate)return s.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}};var $c=class extends be{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return kc}get ControllerType(){return Zr}};$c.displayName="OrbitView";var a0=$c;function c0({zoom:t=0,zoomX:e,zoomY:r}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r}}var td=class extends Ge{constructor(e){let{width:r,height:i,target:s=[0,0,0],zoom:o=0,zoomAxis:n="all",minZoom:a=-1/0,maxZoom:c=1/0,minZoomX:l=a,maxZoomX:f=c,minZoomY:h=a,maxZoomY:u=c,maxBounds:d=null,startPanPosition:p,startZoomPosition:g,startZoom:m}=e,{zoomX:_,zoomY:b}=c0(e);super({width:r,height:i,target:s,zoom:o,zoomX:_,zoomY:b,zoomAxis:n,minZoomX:l,maxZoomX:f,minZoomY:h,maxZoomY:u,maxBounds:d},{startPanPosition:p,startZoomPosition:g,startZoom:m},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(o)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){let r=e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){let{zoomX:r,zoomY:i}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[r,i]})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomPosition:o}=this.getState();if(!o){let{zoomX:c,zoomY:l}=this.getViewportProps();s=[c,l],o=this._unproject(r||e)}if(!o)return this;let n=this._constrainZoom(this._calculateNewZoom({scale:i,startZoom:s})),a=this.makeViewport({...this.getViewportProps(),...n});return this._getUpdatedState({...n,...a.panByPosition(o,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:1/e}))}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{zoomX:i,zoomY:s,zoomAxis:o}=this.getViewportProps();r===void 0&&(r=[i,s]);let n=Math.log2(e),[a,c]=r;switch(o){case"X":a+=n;break;case"Y":c+=n;break;default:a+=n,c+=n}return{zoomX:a,zoomY:c}}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{zoomX:r,zoomY:i}=this._constrainZoom(e,e);e.zoomX=r,e.zoomY=i,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;let{maxBounds:s,target:o}=e;if(s){let n=e.width/2/2**r,a=e.height/2/2**i,c=s[0][0]+n,l=s[1][0]-n,f=s[0][1]+a,h=s[1][1]-a,u=U(o[0],c,l),d=U(o[1],f,h);(u!==o[0]||d!==o[1])&&(e.target=o.slice(),e.target[0]=u,e.target[1]=d)}return e}_constrainZoom({zoomX:e,zoomY:r},i){i||(i=this.getViewportProps());let{zoomAxis:s,maxZoomX:o,maxZoomY:n,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let h=a[0],u=a[1],d=u[0]-h[0],p=u[1]-h[1];Number.isFinite(d)&&d>0&&(c=Math.max(c,Math.log2(i.width/d)),c>o&&(c=o)),Number.isFinite(p)&&p>0&&(l=Math.max(l,Math.log2(i.height/p)),l>n&&(l=n))}switch(s){case"X":e=U(e,c,o);break;case"Y":r=U(r,l,n);break;default:let h=Math.min(o-e,n-r,0);h===0&&(h=Math.max(c-e,l-r,0)),h!==0&&(e+=h,r+=h)}return{zoomX:e,zoomY:r}}},qr=class extends Te{constructor(){super(...arguments),this.ControllerState=td,this.transition={transitionDuration:300,transitionInterpolator:new ce(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,c0(e)),super.setProps(e)}_onPanRotate(){return!1}};var Xc=class extends be{constructor(e={}){super(e)}getViewportType(){return zc}get ControllerType(){return qr}};Xc.displayName="OrthographicView";var l0=Xc;var rd=Math.PI/180,y2=180/Math.PI;function f0(t,e=0){let r=Math.min(180,t)*rd;return Wt*2*Math.sin(r/2)*Math.pow(2,e)}function h0(t,e=0){let r=t/Math.pow(2,e);return Math.asin(Math.min(1,r/Wt/2))*2*y2}var id=class extends ho{constructor(e){let{startPanPos:r,...i}=e;i.normalize=!1,super(i),r!==void 0&&(this._state.startPanPos=r)}panStart({pos:e}){let{latitude:r,longitude:i,zoom:s}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[i,r],startPanPos:e,startZoom:s})}pan({pos:e,startPos:r}){let i=this.getState(),s=i.startPanLngLat||this._unproject(r);if(!s)return this;let o=i.startZoom??this.getViewportProps().zoom,n=i.startPanPos||r,a=[s[0],s[1],o],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,n);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let i=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:i})}applyConstraints(e){let{longitude:r,latitude:i,maxBounds:s}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(r<-180||r>180)&&(e.longitude=mt(r+180,360)-180),e.latitude=U(i,-_e,_e),s&&(e.longitude=U(e.longitude,s[0][0],s[1][0]),e.latitude=U(e.latitude,s[0][1],s[1][1])),s){let o=e.zoom-yt(i),n=s[1][0]-s[0][0],a=s[1][1]-s[0][1];if(a>0&&a<_e*2){let c=Math.min(h0(e.height,o),a)/2;e.latitude=U(e.latitude,s[0][1]+c,s[1][1]-c)}if(n>0&&n<360){let c=Math.min(h0(e.width/Math.cos(e.latitude*rd),o),n)/2;e.longitude=U(e.longitude,s[0][0]+c,s[1][0]-c)}}return e.latitude!==i&&(e.zoom+=yt(e.latitude)-yt(i)),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{latitude:i,maxZoom:s,maxBounds:o}=r,{minZoom:n}=r,a=yt(0),c=yt(i)-a;if(o!==null&&r.width>0&&r.height>0){let f=o[0][1],h=o[1][1],u=Math.sign(f)===Math.sign(h)?Math.min(Math.abs(f),Math.abs(h)):0,d=f0(o[1][0]-o[0][0])*Math.cos(u*rd),p=f0(o[1][1]-o[0][1]);d>0&&(n=Math.max(n,Math.log2(r.width/d)+a)),p>0&&(n=Math.max(n,Math.log2(r.height/p)+a)),n>s&&(n=s)}return U(e,n+c,s+c)}},Gr=class extends Te{constructor(){super(...arguments),this.ControllerState=id,this.transition={transitionDuration:300,transitionInterpolator:new ce(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var Yc=class extends be{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?dr:ki}get ControllerType(){return Gr}};Yc.displayName="GlobeView";var u0=Yc;var Wo=class extends Ht{constructor(){super(...arguments),this._terrainAltitude=void 0,this._terrainAltitudeTarget=void 0,this._pickFrameId=null,this._lastPickTime=0}setProps(e){if(super.setProps({rotationPivot:"3d",...e}),this._pickFrameId===null){let r=()=>{let i=Date.now();if(i-this._lastPickTime>500&&!this.isDragging()&&(this._lastPickTime=i,this._pickTerrainCenterAltitude(),this._terrainAltitude===void 0&&this._terrainAltitudeTarget!==void 0)){this._terrainAltitude=this._terrainAltitudeTarget;let s=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),o=this._rebaseViewport(this._terrainAltitudeTarget,s);if(o){let n=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state,...o});super.updateViewport(n)}}this._pickFrameId=requestAnimationFrame(r)};this._pickFrameId=requestAnimationFrame(r)}}finalize(){this._pickFrameId!==null&&(cancelAnimationFrame(this._pickFrameId),this._pickFrameId=null),super.finalize()}updateViewport(e,r=null,i={}){if(this._terrainAltitude===void 0){super.updateViewport(e,r,i);return}let s=.05;this._terrainAltitude+=(this._terrainAltitudeTarget-this._terrainAltitude)*s;let n=e.getViewportProps().position||[0,0,0];r={...r,position:[n[0],n[1],this._terrainAltitude]},super.updateViewport(e,r,i)}_pickTerrainCenterAltitude(){if(!this.pickPosition)return;let{x:e,y:r,width:i,height:s}=this.props,o=this.pickPosition(e+i/2,r+s/2);o?.coordinate&&o.coordinate.length>=3&&(this._terrainAltitudeTarget=o.coordinate[2])}_rebaseViewport(e,r){let i=r.getViewportProps(),s=this.makeViewport({...i,position:[0,0,0]}),o=s.cameraPosition,n=e*s.distanceScales.unitsPerMeter[2],a=o[2],c=a-n;if(c<=0)return null;let l=Math.log2(a/c),f=i.zoom+l,h=this.makeViewport({...i,zoom:f,position:[0,0,e]}),{width:u,height:d}=i,p=[u/2,d/2],g=s.unproject(p,{targetZ:e});if(g&&"panByPosition3D"in h&&typeof h.panByPosition3D=="function"){let m=h.panByPosition3D(g,p);return{position:[0,0,e],zoom:f,...m}}return null}};var jo=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&Z(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,i={updateTriggers:{}};for(let s in r)if(s in this.props){let o=r[s],n=this.props[s];i[s]=n,o&&o.type==="accessor"&&(i.updateTriggers[s]=this.props.updateTriggers[s],typeof n=="function"&&(i[s]=this.getSubLayerAccessor(n)))}return i}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};jo.defaultProps={};jo.extensionName="LayerExtension";var d0=jo;var sd={bearing:0,pitch:0,position:[0,0,0]},b2={speed:1.2,curve:1.414},Ho=class extends zt{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...b2,...e}}interpolateProps(e,r,i){let s=au(e,r,i,this.opts);for(let o in sd)s[o]=It(e[o]||sd[o],r[o]||sd[o],i);return s}getDuration(e,r){let{transitionDuration:i}=r;return i==="auto"&&(i=cu(e,r,this.opts)),i}};L();var $o=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Ke,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:s,geometryBuffer:o,positionFormat:n,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=s,this.positionSize=o&&o.size||(n==="XY"?2:3),this.buffers=i,this.normalize=c,o&&(Y(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(o),c||(i.vertexPositions=o)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Rc(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:s,_attributeDefs:o,typedArrayManager:n}=this;for(let a in o)if(a in s)n.release(i[a]),i[a]=null;else{let c=o[a];c.copy=r,i[a]=n.allocate(i[a],e,c)}}_forEachGeometry(e,r,i){let{data:s,getGeometry:o}=this,{iterable:n,objectInfo:a}=Xi(s,r,i);for(let c of n){a.index++;let l=o?o(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:s}=this,{data:o,geometryBuffer:n}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],i=[0]),this.normalize||!n)this._forEachGeometry((h,u)=>{let d=h&&this.normalizeGeometry(h);l[u]=d,i[u+1]=i[u]+(d?this.getGeometrySize(d):0)},a,c),s=i[i.length-1];else if(i=o.startIndices,s=i[o.length]||0,ArrayBuffer.isView(n))s=s||n.length/this.positionSize;else if(n instanceof I){let h=this.positionSize*4;s=s||n.byteLength/h}else if(n.buffer){let h=n.stride||this.positionSize*4;s=s||n.buffer.byteLength/h}else if(n.value){let h=n.value,u=n.stride/h.BYTES_PER_ELEMENT||this.positionSize;s=s||h.length/u}this._allocate(s,Boolean(e)),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=s;let f={};this._forEachGeometry((h,u)=>{let d=l[u]||h;f.vertexStart=i[u],f.indexStart=r[u];let p=u<i.length-1?i[u+1]:s;f.geometrySize=p-i[u],f.geometryIndex=u,this.updateGeometryAttributes(d,f)},a,c),this.vertexCount=r[r.length-1]}};var Kc=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let r=this.props,i={...this.props,...e};if(this.props=i,!this.map)return;this._update(r,i)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:r,container:i}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:i,maxZoom:24,...e.mapOptions,...p0(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(i,"offsetWidth",{get:()=>this.width}),Object.defineProperty(i,"clientWidth",{get:()=>this.width}),Object.defineProperty(i,"offsetHeight",{get:()=>this.height}),Object.defineProperty(i,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let s=e.width!==r.width||e.height!==r.height;s&&(this.width=r.width,this.height=r.height,this.map.resize());let o=e.viewState,n=r.viewState,a=n.latitude!==o.latitude||n.longitude!==o.longitude||n.zoom!==o.zoom||n.pitch!==o.pitch||n.bearing!==o.bearing;return a&&this.map.jumpTo(p0(n)),s||a}};function p0(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var g0={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function T2(t){let{container:e=document.body}=t;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let i=document.createElement("div");e.appendChild(i),Object.assign(i.style,g0);let s=document.createElement("canvas");return e.appendChild(s),Object.assign(s.style,g0),{container:e,mapCanvas:i,deckCanvas:s}}var Xo=class extends Ec{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:i}=T2(e),s=e.viewState||e.initialViewState,o=Number.isFinite(s&&s.latitude),{map:n=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:i,...e}),n&&n.Map?this._map=o&&new Kc({...e,width:0,height:0,viewState:s,container:r,mapLib:n}):this._map=n}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,r){if(this._map){let i=this.getViewports()[0];i&&this._map.setProps({width:i.width,height:i.height,viewState:i})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,fh);Object.assign(globalThis.loaders,Uh);return x0(x2);})();
|
|
1743
2015
|
return __exports__;
|
|
1744
2016
|
});
|