@deck.gl/jupyter-widget 9.1.7 → 9.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -548,7 +548,7 @@ ${o}${s}${t.type.toUpperCase()}: ${t.message}
548
548
  <code style="user-select:text;"><pre>
549
549
  ${i}
550
550
  </pre></code>`,s.style.top="10px",s.style.left="10px",s.style.position="absolute",s.style.zIndex="9999",s.style.width="100%",s.style.textAlign="left",document.body.appendChild(s),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),s.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},im=_O;Vr(im,"defaultProps",{...ei.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});function bde(t){return L9(t.source)||t.id||rm(`unnamed ${t.stage}-shader`)}function L9(t,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return n?n[1]:e}var GE=class extends ei{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=GE.normalizeProps(e,r),super(e,r,GE.defaultProps)}static normalizeProps(e,r){let n=e?.props?._resourceDefaults?.sampler||{};return{...r,...n}}},om=GE;Vr(om,"defaultProps",{...ei.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 yO=class extends ei{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,yO.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(i=>i.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:r,depthStencilAttachment:n})}resize(e){let r=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];r=r||i!==this.height||n!==this.width,this.width=n,this.height=i}r&&(qt.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,n)=>{if(typeof r=="string"){let i=this.createColorTexture(r,n);return this.attachResource(i),i.view}return r instanceof fi?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 fi?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:fi.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:fi.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,r){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.colorAttachments[n].texture.clone({width:e,height:r});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i.view,this.attachResource(i.view)}if(this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}},Of=yO;Vr(Of,"defaultProps",{...ei.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var xO=class extends ei{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,r){super(e,r,xO.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Mh=xO;Vr(Mh,"defaultProps",{...ei.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},bindings:{},uniforms:{}});var GA=class extends ei{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=GA.normalizeProps(e,r),super(e,r,GA.defaultProps)}static normalizeProps(e,r){return{...e.props._resourceDefaults?.renderPass,...r}}},Up=GA;Vr(Up,"defaultClearColor",[0,0,0,1]),Vr(Up,"defaultClearDepth",1),Vr(Up,"defaultClearStencil",0),Vr(Up,"defaultProps",{...ei.defaultProps,framebuffer:null,parameters:void 0,clearColor:GA.defaultClearColor,clearColors:void 0,clearDepth:GA.defaultClearDepth,clearStencil:GA.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var vO=class extends ei{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,vO.defaultProps),this.shaderLayout=r.shaderLayout}},XA=vO;Vr(XA,"defaultProps",{...ei.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});var bO=class extends ei{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,r){super(e,r,bO.defaultProps)}},P_=bO;Vr(P_,"defaultProps",{...ei.defaultProps,measureExecutionTime:void 0});var wO=class extends ei{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,wO.defaultProps)}},I_=wO;Vr(I_,"defaultProps",{...ei.defaultProps});function O9(t){let[e,r]=Tde[t],n=e==="i32"||e==="u32",i=e!=="u32",o=Ede[e]*r,s=wde(e,r);return{dataType:e,components:r,defaultVertexFormat:s,byteLength:o,integer:n,signed:i}}function wde(t,e){let r;switch(t){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?r:`${r}x${e}`}var Tde={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]},Ede={f32:4,f16:2,i32:4,u32:4};function TO(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,n]=t.split("x"),i=r,o=n?parseInt(n):1,s=VE(i),c={type:i,components:o,byteLength:s.byteLength*o,integer:s.integer,signed:s.signed,normalized:s.normalized};return e&&(c.webglOnly=!0),c}function XE(t,e){let r={};for(let n of t.attributes){let i=Mde(t,e,n.name);i&&(r[n.name]=i)}return r}function B9(t,e,r=16){let n=XE(t,e),i=new Array(r).fill(null);for(let o of Object.values(n))i[o.location]=o;return i}function Mde(t,e,r){let n=Sde(t,r),i=Cde(e,r);if(!n)return null;let o=O9(n.type),s=i?.vertexFormat||o.defaultVertexFormat,c=TO(s);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:s,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:o.integer,stepMode:i?.stepMode||n.stepMode||"vertex",byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function Sde(t,e){let r=t.attributes.find(n=>n.name===e);return r||qt.warn(`shader layout attribute "${e}" not present in shader`),r||null}function Cde(t,e){Pde(t);let r=Ide(t,e);return r||(r=Rde(t,e),r)?r:(qt.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Pde(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&qt.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Ide(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 Rde(t,e){for(let r of t){let n=r.byteStride;if(typeof r.byteStride!="number")for(let o of r.attributes||[]){let s=TO(o.format);n+=s.byteLength}let i=r.attributes?.find(o=>o.attribute===e);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}var EO=class extends ei{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,EO.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null);let{shaderLayout:n,bufferLayout:i}=r.renderPipeline||{};if(!n||!i)throw new Error("VertexArray");this.attributeInfos=B9(n,i,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"))}},R_=EO;Vr(R_,"defaultProps",{...ei.defaultProps,renderPipeline:null});var MO=class extends ei{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,MO.defaultProps)}},L_=MO;Vr(L_,"defaultProps",{...ei.defaultProps,layout:void 0,buffers:{}});var SO=class extends ei{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,SO.defaultProps)}},O_=SO;Vr(O_,"defaultProps",{...ei.defaultProps,type:void 0,count:void 0});var Lde={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16}};function D9(t){return Lde[t]}function N9(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}var YE;function CO(t){return(!YE||YE.byteLength<t)&&(YE=new ArrayBuffer(t)),YE}function PO(t,e){let r=CO(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}function Ode(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function B_(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":Ode(t)}var k9=1024,KE=class{layout={};byteLength;constructor(e){let r=0;for(let[i,o]of Object.entries(e)){let s=D9(o),{type:c,components:l}=s;r=N9(r,l);let h=r;r+=l,this.layout[i]={type:c,size:l,offset:h}}r+=(4-r%4)%4;let n=r*4;this.byteLength=Math.max(n,k9)}getData(e){let r=Math.max(this.byteLength,k9),n=CO(r),i={i32:new Int32Array(n),u32:new Uint32Array(n),f32:new Float32Array(n),f16:new Uint16Array(n)};for(let[o,s]of Object.entries(e)){let c=this.layout[o];if(!c){qt.warn(`Supplied uniform value ${o} not present in uniform block layout`)();continue}let{type:l,size:h,offset:p}=c,x=i[l];if(h===1){if(typeof s!="number"&&typeof s!="boolean"){qt.warn(`Supplied value for single component uniform ${o} is not a number: ${s}`)();continue}x[p]=Number(s)}else{if(!B_(s)){qt.warn(`Supplied value for multi component / array uniform ${o} is not a numeric array: ${s}`)();continue}x.set(s,p)}}return new Uint8Array(n)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}};function F9(t,e,r=16){if(t!==e)return!1;let n=t,i=e;if(!B_(n))return!1;if(B_(i)&&n.length===i.length){for(let o=0;o<n.length;++o)if(i[o]!==n[o])return!1}return!0}function z9(t){return B_(t)?t.slice():t}var ZE=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(i=>i.type==="uniform"&&i.name===e?.name);if(!r)throw new Error(e?.name);let n=r;for(let i of n.uniforms||[])this.bindingLayout[i.name]=i}}setUniforms(e){for(let[r,n]of Object.entries(e))this._setUniform(r,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){F9(this.uniforms[e],r)||(this.uniforms[e]=z9(r),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Iv=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[r,n]of Object.entries(e)){let i=r,o=new KE(n.uniformTypes||{});this.uniformBufferLayouts.set(i,o);let s=new ZE({name:r});s.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(i,s)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,n]of Object.entries(e))this.uniformBlocks.get(r)?.setUniforms(n);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,n){n&&this.setUniforms(n);let i=this.getUniformBufferByteLength(r),o=e.createBuffer({usage:Fn.UNIFORM|Fn.COPY_DST,byteLength:i}),s=this.getUniformBufferData(r);return o.write(s),o}getManagedUniformBuffer(e,r){if(!this.uniformBuffers.get(r)){let n=this.getUniformBufferByteLength(r),i=e.createBuffer({usage:Fn.UNIFORM|Fn.COPY_DST,byteLength:n});this.uniformBuffers.set(r,i)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(r);e||=n}return e&&qt.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),i=!1;if(n&&r?.needsRedraw){i||=r.needsRedraw;let o=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(o);let s=this.uniformBlocks.get(e)?.getAllUniforms();qt.log(4,`Writing to uniform buffer ${String(e)}`,o,s)()}return i}};function $E(t){let e=ArrayBuffer.isView(t)?t.constructor:t;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function Rv(t){switch(t){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(t)}}function IO(t,e,r){if(!e||e>4)throw new Error(`size ${e}`);let n=e,i=$E(t);if(i==="uint8"&&r&&n===1)return"unorm8-webgl";if(i==="uint8"&&r&&n===3)return"unorm8x3-webgl";if(i==="uint8"||i==="sint8"){if(n===1||n===3)throw new Error(`size: ${e}`);return r&&(i=i.replace("int","norm")),`${i}x${n}`}if(i==="uint16"||i==="sint16"){if(n===1||n===3)throw new Error(`size: ${e}`);return r&&(i=i.replace("int","norm")),`${i}x${n}`}return n===1?i:`${i}x${n}`}var YA=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 n=[...e];for(let i of r){let o=n.findIndex(s=>s.name===i.name);o<0?n.push(i):n[o]=i}return n}};var Bf;(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"})(Bf||(Bf={}));var Ov={[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},va=(t,e,r)=>e?t.enable(r):t.disable(r),U9=(t,e,r)=>t.hint(r,e),au=(t,e,r)=>t.pixelStorei(r,e),V9=(t,e,r)=>{let n=r===36006?36009:36008;return t.bindFramebuffer(n,e)},Lv=(t,e,r)=>{let i={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(i,e)};function RO(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var j9={[3042]:va,[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]:va,[2885]:(t,e)=>t.cullFace(e),[2929]:va,[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]:va,[35723]:U9,[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]:V9,[36010]:V9,[34964]:Lv,[36662]:Lv,[36663]:Lv,[35053]:Lv,[35055]:Lv,[2886]:(t,e)=>t.frontFace(e),[33170]:U9,[2849]:(t,e)=>t.lineWidth(e),[32823]:va,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:va,[32926]:va,[32928]:va,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:va,[3088]:(t,e)=>t.scissor(...e),[2960]:va,[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]:va,[10754]:va,[12288]:va,[12289]:va,[12290]:va,[12291]:va,[12292]:va,[12293]:va,[12294]:va,[12295]:va,[3333]:au,[3317]:au,[37440]:au,[37441]:au,[37443]:au,[3330]:au,[3332]:au,[3331]:au,[3314]:au,[32878]:au,[3316]:au,[3315]:au,[32877]:au,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=RO(e)?e:[e,e];let[r,n]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,n)},stencilFunc:(t,e)=>{e=RO(e)&&e.length===3?[...e,...e]:e;let[r,n,i,o,s,c]=e;t.stencilFuncSeparate(1028,r,n,i),t.stencilFuncSeparate(1029,o,s,c)},stencilOp:(t,e)=>{e=RO(e)&&e.length===3?[...e,...e]:e;let[r,n,i,o,s,c]=e;t.stencilOpSeparate(1028,r,n,i),t.stencilOpSeparate(1029,o,s,c)},viewport:(t,e)=>t.viewport(...e)};function qs(t,e,r){return e[t]!==void 0?e[t]:r[t]}var H9={blendEquation:(t,e,r)=>t.blendEquationSeparate(qs(32777,e,r),qs(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(qs(32969,e,r),qs(32968,e,r),qs(32971,e,r),qs(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(qs(32824,e,r),qs(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(qs(32938,e,r),qs(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,qs(2962,e,r),qs(2967,e,r),qs(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,qs(34816,e,r),qs(36003,e,r),qs(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,qs(2964,e,r),qs(2965,e,r),qs(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,qs(34817,e,r),qs(34818,e,r),qs(34819,e,r))},LO={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 n={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return n?t({[n]:r}):{valueChanged:!0}},blendColor:(t,e,r,n,i)=>t({[32773]:new Float32Array([e,r,n,i])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,n,i)=>t({[32969]:e,[32968]:r,[32971]:n,[32970]:i}),clearColor:(t,e,r,n,i)=>t({[3106]:new Float32Array([e,r,n,i])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,n,i)=>t({[3107]:[e,r,n,i]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,n,i)=>t({[3088]:new Int32Array([e,r,n,i])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,n)=>t({[2962]:e,[2967]:r,[2963]:n,[34816]:e,[36003]:r,[36004]:n}),stencilFuncSeparate:(t,e,r,n,i)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:n,[e===1028?2963:36004]:i}),stencilOp:(t,e,r,n)=>t({[2964]:e,[2965]:r,[2966]:n,[34817]:e,[34818]:r,[34819]:n}),stencilOpSeparate:(t,e,r,n,i)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:n,[e===1028?2966:34819]:i}),viewport:(t,e,r,n,i)=>t({[2978]:[e,r,n,i]})},Df=(t,e)=>t.isEnabled(e),OO={[3042]:Df,[2884]:Df,[2929]:Df,[3024]:Df,[32823]:Df,[32926]:Df,[32928]:Df,[3089]:Df,[2960]:Df,[35977]:Df},W9=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 Sh(t,e){if(Bde(e))return;let r={};for(let i in e){let o=Number(i),s=j9[i];s&&(typeof s=="string"?r[s]=!0:s(t,e[i],o))}let n=t.state&&t.state.cache;if(n)for(let i in r){let o=H9[i];o(t,e,n)}}function QE(t,e=Ov){if(typeof e=="number"){let i=e,o=OO[i];return o?o(t,i):t.getParameter(i)}let r=Array.isArray(e)?e:Object.keys(e),n={};for(let i of r){let o=OO[i];n[i]=o?o(t,Number(i)):t.getParameter(Number(i))}return n}function q9(t){Sh(t,Ov)}function Bde(t){for(let e in t)return!1;return!0}function G9(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),n=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&n&&t.length===e.length){for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}return!1}var Ch=class{static get(e){return e.state}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];Sh(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r.copyState?QE(e):Object.assign({},Ov),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,Nde(e);for(let n in LO){let i=LO[n];Dde(e,n,i)}X9(e,"getParameter"),X9(e,"isEnabled")}_updateCache(e){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let o in e){let s=e[o],c=this.cache[o];G9(s,c)||(r=!0,n=c,i&&!(o in i)&&(i[o]=c),this.cache[o]=s)}return{valueChanged:r,oldValue:n}}};function X9(t,e){let r=t[e].bind(t);t[e]=function(i){if(i===void 0||W9.has(i))return r(i);let o=Ch.get(t);return i in o.cache||(o.cache[i]=r(i)),o.enable?o.cache[i]:r(i)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function Dde(t,e,r){if(!t[e])return;let n=t[e].bind(t);t[e]=function(...o){let s=Ch.get(t),{valueChanged:c,oldValue:l}=r(s._updateCache,...o);return c&&n(...o),l},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function Nde(t){let e=t.useProgram.bind(t);t.useProgram=function(n){let i=Ch.get(t);i.program!==n&&(e(n),i.program=n)}}function Y9(t,e,r){let n="",i={preserveDrawingBuffer:!0,...r},o=null;if(o||=t.getContext("webgl2",i),i.failIfMajorPerformanceCaveat&&(n||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow."),!o&&!r.failIfMajorPerformanceCaveat&&(i.failIfMajorPerformanceCaveat=!1,o=t.getContext("webgl2",i),o.luma||={},o.luma.softwareRenderer=!0),o||(o=t.getContext("webgl",{}),o&&(o=null,n||="Your browser only supports WebGL1")),!o)throw n||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${n}`);let{onContextLost:s,onContextRestored:c}=e;return t.addEventListener("webglcontextlost",l=>s(l),!1),t.addEventListener("webglcontextrestored",l=>c(l),!1),o.luma||={},o}function Nf(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function K9(t,e){let r=t.getParameter(7936),n=t.getParameter(7937);Nf(t,"WEBGL_debug_renderer_info",e);let i=e.WEBGL_debug_renderer_info,o=t.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),s=t.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),c=o||r,l=s||n,h=t.getParameter(7938),p=Z9(c,l),x=kde(c,l),w=Fde(c,l);return{type:"webgl",gpu:p,gpuType:w,gpuBackend:x,vendor:c,renderer:l,version:h,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Z9(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 kde(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function Fde(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(Z9(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function JE(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 Bv="WEBGL_compressed_texture_s3tc",Dv="WEBGL_compressed_texture_s3tc_srgb",D_="EXT_texture_compression_rgtc",N_="EXT_texture_compression_bptc",zde="WEBGL_compressed_texture_etc",Ude="WEBGL_compressed_texture_astc",Vde="WEBGL_compressed_texture_etc1",jde="WEBGL_compressed_texture_pvrtc",Hde="WEBGL_compressed_texture_atc",$9="EXT_texture_norm16",Q9="EXT_render_snorm",Wde="EXT_color_buffer_float",eM={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Q9],"norm16-renderable-webgl":[$9],"snorm16-renderable-webgl":[$9,Q9],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Bv,Dv,D_,N_],"texture-compression-bc5-webgl":[D_],"texture-compression-bc7-webgl":[N_],"texture-compression-etc2":[zde],"texture-compression-astc":[Ude],"texture-compression-etc1-webgl":[Vde],"texture-compression-pvrtc-webgl":[jde],"texture-compression-atc-webgl":[Hde]};function J9(t){return t in eM}function e7(t,e,r){return(eM[e]||[]).every(i=>Nf(t,i,r))}var BO={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},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},"r16unorm-webgl":{gl:33322,rb:!0},"r16snorm-webgl":{gl:36760},"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},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},"rg16unorm-webgl":{gl:33324},"rg16snorm-webgl":{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},"rgb10a2uint-webgl":{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},"rgba16unorm-webgl":{gl:32859,rb:!0},"rgba16snorm-webgl":{gl:36763},"rgb32float-webgl":{gl:34837,x:Wde,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},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:Bv},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Dv},"bc1-rgba-unorm":{gl:33777,x:Bv},"bc1-rgba-unorm-srgb":{gl:35916,x:Dv},"bc2-rgba-unorm":{gl:33778,x:Bv},"bc2-rgba-unorm-srgb":{gl:35918,x:Dv},"bc3-rgba-unorm":{gl:33779,x:Bv},"bc3-rgba-unorm-srgb":{gl:35919,x:Dv},"bc4-r-unorm":{gl:36283,x:D_},"bc4-r-snorm":{gl:36284,x:D_},"bc5-rg-unorm":{gl:36285,x:D_},"bc5-rg-snorm":{gl:36286,x:D_},"bc6h-rgb-ufloat":{gl:36495,x:N_},"bc6h-rgb-float":{gl:36494,x:N_},"bc7-rgba-unorm":{gl:36492,x:N_},"bc7-rgba-unorm-srgb":{gl:36493,x:N_},"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:37819},"astc-10x5-unorm-srgb":{gl:37851},"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-rbg2unorm-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}};function t7(t,e,r){let n=e.create,i=BO[e.format];return i?.gl===void 0&&(n=!1),i?.x&&(n=n&&Boolean(Nf(t,i.x,r))),{format:e.format,create:n&&e.create,render:n&&e.render,filter:n&&e.filter,blend:n&&e.blend,store:n&&e.store}}function tM(t){let e=BO[t],r=Gde(t),n=M_(t);return{internalFormat:r,format:e?.dataFormat||qde(n.channels,n.integer,n.normalized,r),type:n.dataType?JE(n.dataType):e?.types?.[0]||5121,compressed:n.compressed||!1}}function r7(t){switch(M_(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 qde(t,e,r,n){if(n===6408||n===6407)return n;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 Gde(t){let r=BO[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var n7={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},rM=class extends Sv{gl;extensions;testedFeatures=new Set;constructor(e,r,n){super([],n),this.gl=e,this.extensions=r,Nf(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),J9(e)&&e7(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(n7),...Object.keys(eM)]}getWebGLFeature(e){let r=n7[e];return Boolean(typeof r=="string"?Nf(this.gl,r,this.extensions):r)}};var nM=class extends Mv{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}};var kf=class extends Of{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let n=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e.setSpectorMetadata(this.handle,{id:this.props.id,props: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 n=this.colorAttachments[r];if(n){let i=36064+r;this._attachTextureView(i,n)}}if(this.depthStencilAttachment){let r=r7(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 ${Yde(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:n}=this.device,{texture:i}=r,o=r.props.baseMipLevel,s=r.props.baseArrayLayer;switch(n.bindTexture(i.glTarget,i.handle),i.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,i.handle,o,s);break;case 34067:let c=Xde(s);n.framebufferTexture2D(36160,e,c,i.handle,o);break;case 3553:n.framebufferTexture2D(36160,e,3553,i.handle,o);break;default:throw new Error("Illegal texture type")}n.bindTexture(i.glTarget,null)}};function Xde(t){return t<34069?t+34069:t}function Yde(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 iM=class extends C_{device;format="rgba8unorm";depthStencilFormat="depth24plus";presentationSize;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new kf(this.device,{handle:null}),this._framebuffer}update(){let e=this.getPixelSize();(e[0]!==this.presentationSize[0]||e[1]!==this.presentationSize[1])&&(this.presentationSize=e,this.resize())}resize(e){if(this.device.gl&&this.canvas){let r=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(r,e);return}}commit(){}};async function oM(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),e&&(n.id=e),new Promise((i,o)=>{n.onload=i,n.onerror=s=>o(new Error(`Unable to load script '${t}': ${s}`)),r.appendChild(n)})}var Kde=1,cu=null,i7=!1,sM={debugSpectorJS:qt.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function o7(t){if(!globalThis.SPECTOR)try{await oM(t.debugSpectorJSUrl||sM.debugSpectorJSUrl)}catch(e){qt.warn(String(e))}}function s7(t){if(t={...sM,...t},!t.debugSpectorJS)return null;if(!cu&&globalThis.SPECTOR&&!globalThis.luma?.spector){qt.probe(Kde,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;cu=new e,globalThis.luma&&(globalThis.luma.spector=cu)}if(!cu)return null;if(i7||(i7=!0,cu.spyCanvases(),cu?.onCaptureStarted.add(e=>qt.info("Spector capture started:",e)()),cu?.onCapture.add(e=>{qt.info("Spector capture complete:",e)(),cu?.getResultUI(),cu?.resultView.display(),cu?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=e.device;cu?.startCapture(t.gl,500),e.device=r,new Promise(n=>setTimeout(n,2e3)).then(n=>{qt.info("Spector capture stopped after 2 seconds")(),cu?.stopCapture()})}return cu}var Zde="https://unpkg.com/webgl-debug@2.0.1/index.js";function c7(t){return t.luma=t.luma||{},t.luma}async function l7(){ul()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await oM(Zde))}function u7(t,e={}){return e.debugWebGL||e.traceWebGL?Qde(t,e):$de(t)}function $de(t){let e=c7(t);return e.realContext?e.realContext:t}function Qde(t,e){if(!globalThis.WebGLDebugUtils)return qt.warn("webgl-debug not loaded")(),t;let r=c7(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Bf,...t});let n=globalThis.WebGLDebugUtils.makeDebugContext(t,Jde.bind(null,e),eme.bind(null,e));for(let s in Bf)!(s in n)&&typeof Bf[s]=="number"&&(n[s]=Bf[s]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.setPrototypeOf(i,n);let o=Object.create(i);return r.realContext=t,r.debugContext=o,o.debug=!0,o}function a7(t,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Jde(t,e,r,n){n=Array.from(n).map(c=>c===void 0?"undefined":c);let i=globalThis.WebGLDebugUtils.glEnumToString(e),o=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,n),s=`${i} in gl.${r}(${o})`;qt.error(s)();debugger}function eme(t,e,r){let n="";qt.level>=1&&(n=a7(e,r),t.traceWebGL&&qt.log(1,n)());for(let i of r)if(i===void 0){n=n||a7(e,r);debugger}}var DO={};function h7(t="id"){DO[t]=DO[t]||1;let e=DO[t]++;return`${t}-${e}`}var Ph=class extends Fn{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=tme(this.props.usage),this.glUsage=rme(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,n=e.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,r,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,e),this.gl.bindBuffer(36663,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let n=new Uint8Array(r),i=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,i,r),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,r),n}};function tme(t){return t&Fn.INDEX?34963:t&Fn.VERTEX?34962:t&Fn.UNIFORM?35345:34962}function rme(t){return t&Fn.INDEX||t&Fn.VERTEX?35044:t&Fn.UNIFORM?35048:35044}function p7(t){let e=t.split(/\r?\n/),r=[];for(let n of e){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[x,w]=i;r.push({message:w.trim(),type:f7(x),lineNum:0,linePos:0});continue}let[o,s,c,...l]=i,h=parseInt(c,10);isNaN(h)&&(h=0);let p=parseInt(s,10);isNaN(p)&&(p=0),r.push({message:l.join(":").trim(),type:f7(o),lineNum:h,linePos:p})}return r}function f7(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var aM=class extends im{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>this.compilationStatus)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return e?p7(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
551
- ${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}qt.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),qt.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(o=>setTimeout(o,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};function m7(t,e,r,n){if(sme(e))return n(t);let i=t;i.pushState();try{return nme(t,e),Sh(i.gl,r),n(t)}finally{i.popState()}}function nme(t,e){let r=t,{gl:n}=r;if(e.cullMode)switch(e.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(e.frontFace&&n.frontFace(KA("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&n.enable(34383),e.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let o=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=KA("provokingVertex",e.provokingVertex,{first:36429,last:36430});o?.provokingVertexWEBGL(s)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let o=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=KA("polygonMode",e.polygonMode,{fill:6914,line:6913});o?.polygonModeWEBGL(1028,s),o?.polygonModeWEBGL(1029,s)}e.polygonOffsetLine&&n.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(12288),e.clipDistance1&&n.enable(12289),e.clipDistance2&&n.enable(12290),e.clipDistance3&&n.enable(12291),e.clipDistance4&&n.enable(12292),e.clipDistance5&&n.enable(12293),e.clipDistance6&&n.enable(12294),e.clipDistance7&&n.enable(12295)),e.depthWriteEnabled!==void 0&&n.depthMask(ome("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(lM("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(1028,i),n.stencilMaskSeparate(1029,i)}if(e.stencilReadMask&&qt.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,o=lM("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,o,0,i),n.stencilFuncSeparate(1029,o,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=NO("stencilPassOperation",e.stencilPassOperation),o=NO("stencilFailOperation",e.stencilFailOperation),s=NO("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(1028,o,s,i),n.stencilOpSeparate(1029,o,s,i)}switch(e.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let i=d7("blendColorOperation",e.blendColorOperation||"add"),o=d7("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,o);let s=cM("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=cM("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=cM("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),h=cM("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(s,c,l,h)}}function lM(t,e){return KA(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function NO(t,e){return KA(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function d7(t,e){return KA(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function cM(t,e){return KA(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function ime(t,e){return`Illegal parameter ${e} for ${t}`}function KA(t,e,r){if(!(e in r))throw new Error(ime(t,e));return r[e]}function ome(t,e){return e}function sme(t){let e=!0;for(let r in t){e=!1;break}return e}function uM(t){let e={};return t.addressModeU&&(e[10242]=kO(t.addressModeU)),t.addressModeV&&(e[10243]=kO(t.addressModeV)),t.addressModeW&&(e[32882]=kO(t.addressModeW)),t.magFilter&&(e[10240]=FO(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=ame(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]=lM("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function kO(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function FO(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function ame(t,e="none"){if(!e)return FO(t);switch(e){case"none":return FO(t);case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var ZA=class extends om{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=uM(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,n]of Object.entries(e)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var Ff=class extends nm{device;gl;handle;texture;constructor(e,r){super(e,{...fi.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var cme="Failed to deduce GL constant from typed array";function A7(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(cme)}}function g7(t,e){let{clamped:r=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}function zO(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 _7(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function $A(t,e,r){if(lme(e))return r(t);let{nocatch:n=!0}=e,i=Ch.get(t);i.push(),Sh(t,e);let o;if(n)o=r(t),i.pop();else try{o=r(t)}finally{i.pop()}return o}function lme(t){for(let e in t)return!1;return!0}function y7(t,e,r){let{dimension:n,width:i,height:o,depth:s=0}=r,{glInternalFormat:c}=r,l=r.glTarget;switch(n){case"2d-array":case"3d":t.texStorage3D(l,e,c,i,o,s);break;default:t.texStorage2D(l,e,c,i,o)}}function UO(t,e,r,n){let{width:i,height:o}=n,{dimension:s,depth:c=0,mipLevel:l=0}=n,{x:h=0,y:p=0,z:x=0}=n,{glFormat:w,glType:E}=n,C=v7(n.glTarget,s,c),B=n.flipY?{[37440]:!0}:{};$A(t,B,()=>{switch(s){case"2d-array":case"3d":t.bindTexture(C,e),t.texSubImage3D(C,l,h,p,x,i,o,c,w,E,r),t.bindTexture(C,null);break;case"2d":case"cube":t.bindTexture(C,e),t.texSubImage2D(C,l,h,p,i,o,w,E,r),t.bindTexture(C,null);break;default:throw new Error(s)}})}function VO(t,e,r){let{dimension:n,width:i,height:o,depth:s=0,mipLevel:c=0,byteOffset:l=0}=r,{x:h=0,y:p=0,z:x=0}=r,{glFormat:w,glType:E,compressed:C}=r,B=v7(r.glTarget,n,s);switch(n){case"2d-array":case"3d":C?t.compressedTexSubImage3D(B,c,h,p,x,i,o,s,w,e,l):t.texSubImage3D(B,c,h,p,x,i,o,s,w,E,e,l);break;case"2d":case"cube":C?t.compressedTexSubImage2D(B,c,h,p,i,o,w,e,l):t.texSubImage2D(B,c,h,p,i,o,w,E,e,l);break;default:throw new Error(n)}}function x7(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 v7(t,e,r){return e==="cube"?34069+r:t}function b7(t,e){let{sourceX:r=0,sourceY:n=0,sourceAttachment:i=0}=e||{},{target:o=null,sourceWidth:s,sourceHeight:c,sourceDepth:l,sourceFormat:h,sourceType:p}=e||{},{framebuffer:x,deleteFramebuffer:w}=T7(t),{gl:E,handle:C}=x;s||=x.width,c||=x.height;let B=x.colorAttachments[i]?.texture;if(!B)throw new Error(`Invalid framebuffer attachment ${i}`);l=B?.depth||1,h||=B?.glFormat||6408,p||=B?.glType||5121,o=hme(o,p,h,s,c,l),p=p||A7(o);let D=E.bindFramebuffer(36160,C);return E.readBuffer(36064+i),E.readPixels(r,n,s,c,h,p,o),E.readBuffer(36064),E.bindFramebuffer(36160,D||null),w&&x.destroy(),o}function w7(t,e){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:o=6408,targetByteOffset:s=0}=e||{},{sourceWidth:c,sourceHeight:l,sourceType:h}=e||{},{framebuffer:p,deleteFramebuffer:x}=T7(t);c=c||p.width,l=l||p.height;let w=p;h=h||5121;let E=r;if(!E){let B=zO(o),D=_7(h),W=s+c*l*B*D;E=w.device.createBuffer({byteLength:W})}let C=t.device.createCommandEncoder();return C.copyTextureToBuffer({sourceTexture:t,width:c,height:l,origin:[n,i],destinationBuffer:E,byteOffset:s}),C.destroy(),x&&p.destroy(),E}function T7(t){return t instanceof Of?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:ume(t),deleteFramebuffer:!0}}function ume(t,e){let{device:r,width:n,height:i,id:o}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${o}`,width:n,height:i,colorAttachments:[t]})}function hme(t,e,r,n,i,o){if(t)return t;e||=5121;let s=g7(e,{clamped:!1}),c=zO(r);return new s(n*i*c)}var zf=class extends fi{device;gl;handle;sampler=void 0;view=void 0;mipmaps;compressed;glTarget;glFormat;glType;glInternalFormat;textureUnit=0;constructor(e,r){super(e,r);let n={...this.props};n.data=r.data,this.device=e,this.gl=this.device.gl,this.glTarget=x7(this.props.dimension);let i=tM(this.props.format);this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.mipmaps=Boolean(this.props.mipmaps),this._initialize(n),Object.seal(this)}_initialize(e){this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:e.data});let{width:r,height:n}=e;if(!r||!n){let i=fi.getTextureDataSize(e.data);r=i?.width||1,n=i?.height||1}if(this.width=r,this.height=n,this.depth=e.depth,this.setSampler(e.sampler),this.view=new Ff(this.device,{...this.props,texture:this}),this.bind(),y7(this.gl,this.mipLevels,this),e.data)switch(e.dimension){case"1d":this.setTexture1DData(e.data);break;case"2d":this.setTexture2DData(e.data);break;case"3d":this.setTexture3DData(e.data);break;case"cube":this.setTextureCubeData(e.data);break;case"2d-array":this.setTextureArrayData(e.data);break;case"cube-array":this.setTextureCubeArrayData(e.data);break;default:throw new Error(e.dimension)}this.mipmaps&&this.generateMipmap()}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(e){return new Ff(this.device,{...e,texture:this})}setSampler(e={}){let r;e instanceof ZA?(this.sampler=e,r=e.props):(this.sampler=new ZA(this.device,e),r=e);let n=uM(r);this._setSamplerParameters(n)}generateMipmap(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(qt.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(n){qt.warn(`Error generating mipmap for ${this}: ${n.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}copyExternalImage(e){let r=fi.getExternalImageSize(e.image),n={...fi.defaultCopyExternalImageOptions,...r,...e},{image:i,depth:o,mipLevel:s,x:c,y:l,z:h,flipY:p}=n,{width:x,height:w}=n,{dimension:E,glTarget:C,glFormat:B,glInternalFormat:D,glType:W}=this;if(x=Math.min(x,this.width-c),w=Math.min(w,this.height-l),e.sourceX||e.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");return UO(this.device.gl,this.handle,i,{dimension:E,mipLevel:s,x:c,y:l,z:h,width:x,height:w,depth:o,glFormat:B,glInternalFormat:D,glType:W,glTarget:C,flipY:p}),{width:n.width,height:n.height}}setTexture1DData(e){throw new Error("setTexture1DData not supported in WebGL.")}setTexture2DData(e,r=0){this.bind();let n=fi.normalizeTextureData(e,this);n.length>1&&this.props.mipmaps!==!1&&qt.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let i=0;i<n.length;i++){let o=n[i];this._setMipLevel(r,i,o)}this.unbind()}setTexture3DData(e){if(this.props.dimension!=="3d")throw new Error(this.id);ArrayBuffer.isView(e)&&(this.bind(),VO(this.device.gl,e,this),this.unbind())}setTextureCubeData(e,r=0){if(this.props.dimension!=="cube")throw new Error(this.id);for(let n of fi.CubeFaces)this.setTextureCubeFaceData(e[n],n)}setTextureArrayData(e){throw this.props.dimension!=="2d-array"?new Error(this.id):new Error("setTextureArrayData not implemented.")}setTextureCubeArrayData(e){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}setTextureCubeFaceData(e,r,n=0){Array.isArray(e)&&e.length>1&&this.props.mipmaps!==!1&&qt.warn(`${this.id} has mipmap and multiple LODs.`)();let i=fi.CubeFaces.indexOf(r);this.setTexture2DData(e,i)}update(){throw new Error("Texture.update() not implemented. Use ExternalTexture")}setImageDataForFace(e){let{face:r,width:n,height:i,pixels:o,data:s,format:c=6408,type:l=5121}=e,{gl:h}=this,p=o||s;this.bind(),p instanceof Promise?p.then(x=>this.setImageDataForFace(Object.assign({},e,{face:r,data:x,pixels:x}))):this.width||this.height?h.texImage2D(r,0,c,n,i,0,c,l,p):h.texImage2D(r,0,c,c,l,p)}_getImageDataMap(e){for(let r=0;r<fi.CubeFaces.length;++r){let n=fi.CubeFaces[r];e[n]&&(e[34069+r]=e[n],delete e[n])}return e}_setSamplerParameters(e){qt.log(1,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,n]of Object.entries(e)){let i=Number(r),o=n;switch(i){case 33082:case 33083:this.gl.texParameterf(this.glTarget,i,o);break;case 10241:this.gl.texParameteri(this.glTarget,i,o);break;case 10242:case 10243:this.gl.texParameteri(this.glTarget,i,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,i,o);break;default:this.gl.texParameteri(this.glTarget,i,o);break}}this.gl.bindTexture(this.glTarget,null)}_setMipLevel(e,r,n,i=this.glTarget){if(fi.isExternalImage(n)){UO(this.device.gl,this.handle,n,{...this,depth:e,mipLevel:r,glTarget:i,flipY:this.props.flipY});return}if(fi.isTextureLevelData(n)){VO(this.device.gl,n.data,{...this,depth:e,mipLevel:r,glTarget:i});return}throw new Error("Texture: invalid image data")}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}};var fme=[1,2,4,8],hM=class extends Up{device;glParameters;constructor(e,r){super(e,r),this.device=e;let n;if(!r?.parameters?.viewport)if(r?.framebuffer){let{width:o,height:s}=r.framebuffer;n=[0,0,o,s]}else{let[o,s]=e.getCanvasContext().getDrawingBufferSize();n=[0,0,o,s]}if(this.device.pushState(),this.setParameters({viewport:n,...this.props.parameters}),this.props.framebuffer?.handle)if(this.props.framebuffer){let o=this.props.framebuffer.colorAttachments.map((s,c)=>36064+c);this.device.gl.drawBuffers(o)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}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&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(r.colorMask=fme.map(n=>Boolean(n&e.colorMask))),this.glParameters=r,Sh(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((n,i)=>{n&&this.clearColorBuffer(i,n)}),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&&$A(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){$A(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")}})}};function E7(t){return pme.includes(t)}var pme=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],M7={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2<f32>","float32x2"],[35665]:[5126,3,"vec3","vec3<f32>","float32x3"],[35666]:[5126,4,"vec4","vec4<f32>","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2<i32>","sint32x2"],[35668]:[5124,3,"ivec3","vec3<i32>","sint32x3"],[35669]:[5124,4,"ivec4","vec4<i32>","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2<u32>","uint32x2"],[36295]:[5125,3,"uvec3","vec3<u32>","uint32x3"],[36296]:[5125,4,"uvec4","vec4<u32>","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2<f32>","float32x2"],[35672]:[5126,3,"bvec3","vec3<f32>","float32x3"],[35673]:[5126,4,"bvec4","vec4<f32>","float32x4"],[35674]:[5126,8,"mat2","mat2x2<f32>"],[35685]:[5126,8,"mat2x3","mat2x3<f32>"],[35686]:[5126,8,"mat2x4","mat2x4<f32>"],[35687]:[5126,12,"mat3x2","mat3x2<f32>"],[35675]:[5126,12,"mat3","mat3x3<f32>"],[35688]:[5126,12,"mat3x4","mat3x4<f32>"],[35689]:[5126,16,"mat4x2","mat4x2<f32>"],[35690]:[5126,16,"mat4x3","mat4x3<f32>"],[35676]:[5126,16,"mat4","mat4x4<f32>"]};function jO(t){let e=M7[t];if(!e)throw new Error("uniform");let[r,n,,i]=e;return{format:i,components:n,glType:r}}function S7(t){let e=M7[t];if(!e)throw new Error("attribute");let[,r,,n,i]=e;return{attributeType:n,vertexFormat:i,components:r}}function C7(t,e){let r={attributes:[],bindings:[]};r.attributes=dme(t,e);let n=gme(t,e);for(let c of n){let l=c.uniforms.map(h=>({name:h.name,format:h.format,byteOffset:h.byteOffset,byteStride:h.byteStride,arrayLength:h.arrayLength}));r.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)&(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let i=Ame(t,e),o=0;for(let c of i)if(E7(c.type)){let{viewDimension:l,sampleType:h}=yme(c.type);r.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:h}),c.textureUnit=o,o+=1}i.length&&(r.uniforms=i);let s=mme(t,e);return s?.length&&(r.varyings=s),r}function dme(t,e){let r=[],n=t.getProgramParameter(e,35721);for(let i=0;i<n;i++){let o=t.getActiveAttrib(e,i);if(!o)throw new Error("activeInfo");let{name:s,type:c}=o,l=t.getAttribLocation(e,s);if(l>=0){let{attributeType:h}=S7(c),p=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:l,stepMode:p,type:h})}}return r.sort((i,o)=>i.location-o.location),r}function mme(t,e){let r=[],n=t.getProgramParameter(e,35971);for(let i=0;i<n;i++){let o=t.getTransformFeedbackVarying(e,i);if(!o)throw new Error("activeInfo");let{name:s,type:c,size:l}=o,{glType:h,components:p}=jO(c),x={location:i,name:s,type:h,size:l*p};r.push(x)}return r.sort((i,o)=>i.location-o.location),r}function Ame(t,e){let r=[],n=t.getProgramParameter(e,35718);for(let i=0;i<n;i++){let o=t.getActiveUniform(e,i);if(!o)throw new Error("activeInfo");let{name:s,size:c,type:l}=o,{name:h,isArray:p}=xme(s),x=t.getUniformLocation(e,h),w={location:x,name:h,size:c,type:l,isArray:p};if(r.push(w),w.size>1)for(let E=0;E<w.size;E++){let C=`${h}[${E}]`;x=t.getUniformLocation(e,C);let B={...w,name:C,location:x};r.push(B)}}return r}function gme(t,e){let r=(o,s)=>t.getActiveUniformBlockParameter(e,o,s),n=[],i=t.getProgramParameter(e,35382);for(let o=0;o<i;o++){let s={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:[]},c=r(o,35395)||[],l=t.getActiveUniforms(e,c,35383),h=t.getActiveUniforms(e,c,35384),p=t.getActiveUniforms(e,c,35387),x=t.getActiveUniforms(e,c,35388);for(let w=0;w<s.uniformCount;++w){let E=t.getActiveUniform(e,c[w]);if(!E)throw new Error("activeInfo");s.uniforms.push({name:E.name,format:jO(l[w]).format,type:l[w],arrayLength:h[w],byteOffset:p[w],byteStride:x[w]})}n.push(s)}return n.sort((o,s)=>o.location-s.location),n}var _me={[35678]:["2d","float"],[35680]:["cube","float"],[35679]:["3d","float"],[35682]:["3d","depth"],[36289]:["2d-array","float"],[36292]:["2d-array","depth"],[36293]:["cube","float"],[36298]:["2d","sint"],[36299]:["3d","sint"],[36300]:["cube","sint"],[36303]:["2d-array","uint"],[36306]:["2d","uint"],[36307]:["3d","uint"],[36308]:["cube","uint"],[36311]:["2d-array","uint"]};function yme(t){let e=_me[t];if(!e)throw new Error("sampler");let[r,n]=e;return{viewDimension:r,sampleType:n}}function xme(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function P7(t,e,r,n){let i=t,o=n;o===!0&&(o=1),o===!1&&(o=0);let s=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 n!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,n);case 5126:return t.uniform1fv(e,s);case 35664:return t.uniform2fv(e,s);case 35665:return t.uniform3fv(e,s);case 35666:return t.uniform4fv(e,s);case 5124:return t.uniform1iv(e,s);case 35667:return t.uniform2iv(e,s);case 35668:return t.uniform3iv(e,s);case 35669:return t.uniform4iv(e,s);case 35670:return t.uniform1iv(e,s);case 35671:return t.uniform2iv(e,s);case 35672:return t.uniform3iv(e,s);case 35673:return t.uniform4iv(e,s);case 5125:return i.uniform1uiv(e,s,1);case 36294:return i.uniform2uiv(e,s,2);case 36295:return i.uniform3uiv(e,s,3);case 36296:return i.uniform4uiv(e,s,4);case 35674:return t.uniformMatrix2fv(e,!1,s);case 35675:return t.uniformMatrix3fv(e,!1,s);case 35676:return t.uniformMatrix4fv(e,!1,s);case 35685:return i.uniformMatrix2x3fv(e,!1,s);case 35686:return i.uniformMatrix2x4fv(e,!1,s);case 35687:return i.uniformMatrix3x2fv(e,!1,s);case 35688:return i.uniformMatrix3x4fv(e,!1,s);case 35689:return i.uniformMatrix4x2fv(e,!1,s);case 35690:return i.uniformMatrix4x3fv(e,!1,s)}throw new Error("Illegal uniform")}function I7(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function R7(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function Nv(t){return I7(t)||R7(t)}function vme(t){return Nv(t)!==null||typeof t=="number"||typeof t=="boolean"}function L7(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];vme(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}function O7(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 B7(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 D7=4,fM=class extends Mh{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:n,bufferMode:i=35981}=r;n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),qt.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=C7(this.device.gl,this.handle),qt.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=bme(this.introspectedLayout,r.shaderLayout)}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,r){for(let[n,i]of Object.entries(e)){let o=this.shaderLayout.bindings.find(s=>s.name===n)||this.shaderLayout.bindings.find(s=>s.name===`${n}Uniforms`);if(!o){let s=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||qt.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${s}`,i)();continue}switch(i||qt.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(i instanceof Ph)&&!(i.buffer instanceof Ph))throw new Error("buffer value");break;case"texture":if(!(i instanceof Ff||i instanceof zf||i instanceof kf))throw new Error("texture value");break;case"sampler":qt.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(o.type)}this.bindings[n]=i}}draw(e){let{renderPass:r,parameters:n=this.props.parameters,topology:i=this.props.topology,vertexArray:o,vertexCount:s,instanceCount:c,isInstanced:l=!1,firstVertex:h=0,transformFeedback:p}=e,x=O7(i),w=Boolean(o.indexBuffer),E=o.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return qt.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return qt.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(r),p&&p.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let C=r;return m7(this.device,n,C.glParameters,()=>{w&&l?this.device.gl.drawElementsInstanced(x,s||0,E,h,c||0):w?this.device.gl.drawElements(x,s||0,E,h):l?this.device.gl.drawArraysInstanced(x,h,s||0,c||0):this.device.gl.drawArrays(x,h,s||0),p&&p.end()}),o.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=L7(e);Object.keys(r).forEach(n=>{qt.warn(`Unsupported value "${JSON.stringify(r[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),qt.time(D7,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),qt.timeEnd(D7,`linkProgram for ${this.id}`)(),qt.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}qt.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),qt.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:switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`);case"pending":this.vs.asyncCompilationStatus.then(()=>this.vs.debugShader());break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`);case"pending":this.fs.asyncCompilationStatus.then(()=>this.fs.debugShader());break;case"success":break}let r=this.device.gl.getProgramInfoLog(this.handle);throw new Error(`Error during ${e}: ${r}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(o=>setTimeout(o,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let r of this.shaderLayout.bindings)!this.bindings[r.name]&&!this.bindings[r.name.replace(/Uniforms$/,"")]&&(qt.warn(`Binding ${r.name} not found in ${this.id}`)(),e=!1);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,n=0;for(let i of this.shaderLayout.bindings){let o=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:s}=i,c=e.getUniformBlockIndex(this.handle,s);if(c===4294967295)throw new Error(`Invalid uniform block name ${s}`);e.uniformBlockBinding(this.handle,n,c),o instanceof Ph?e.bindBufferBase(35345,n,o.handle):e.bindBufferRange(35345,n,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),n+=1;break;case"texture":if(!(o instanceof Ff||o instanceof zf||o instanceof kf))throw new Error("texture");let l;if(o instanceof Ff)l=o.texture;else if(o instanceof zf)l=o;else if(o instanceof kf&&o.colorAttachments[0]instanceof Ff)qt.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=o.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+r),e.bindTexture(l.glTarget,l.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:n,type:i,textureUnit:o}=e,s=this.uniforms[r]??o;s!==void 0&&P7(this.device.gl,n,i,s)}}};function bme(t,e){let r={...t,attributes:t.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=r.attributes.find(o=>o.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):qt.warn(`shader layout attribute ${n.name} not present in shader`)}return r}var pM=class extends I_{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":wme(this.device,r.options);break;case"copy-buffer-to-texture":Tme(this.device,r.options);break;case"copy-texture-to-buffer":Eme(this.device,r.options);break;case"copy-texture-to-texture":Mme(this.device,r.options);break;default:throw new Error(r.name)}}};function wme(t,e){let r=e.sourceBuffer,n=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,n.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 Tme(t,e){throw new Error("Not implemented")}function Eme(t,e){let{sourceTexture:r,mipLevel:n=0,aspect:i="all",width:o=e.sourceTexture.width,height:s=e.sourceTexture.height,depthOrArrayLayers:c=0,origin:l=[0,0],destinationBuffer:h,byteOffset:p=0,bytesPerRow:x,rowsPerImage:w}=e;if(i!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||c!==0||x||w)throw new Error("not implemented");let{framebuffer:E,destroyFramebuffer:C}=N7(r),B;try{let D=h,W=o||E.width,X=s||E.height,q=tM(E.colorAttachments[0].texture.props.format),$=q.format,te=q.type;t.gl.bindBuffer(35051,D.handle),B=t.gl.bindFramebuffer(36160,E.handle),t.gl.readPixels(l[0],l[1],W,X,$,te,p)}finally{t.gl.bindBuffer(35051,null),B!==void 0&&t.gl.bindFramebuffer(36160,B),C&&E.destroy()}}function Mme(t,e){let{sourceTexture:r,destinationMipLevel:n=0,origin:i=[0,0],destinationOrigin:o=[0,0],destinationTexture:s}=e,{width:c=e.destinationTexture.width,height:l=e.destinationTexture.height}=e,{framebuffer:h,destroyFramebuffer:p}=N7(r),[x,w]=i,[E,C,B]=o,D=t.gl.bindFramebuffer(36160,h.handle),W=null,X;if(s instanceof zf)W=s,c=Number.isFinite(c)?c:W.width,l=Number.isFinite(l)?l:W.height,W.bind(0),X=W.glTarget;else throw new Error("invalid destination");switch(X){case 3553:case 34067:t.gl.copyTexSubImage2D(X,n,E,C,x,w,c,l);break;case 35866:case 32879:t.gl.copyTexSubImage3D(X,n,E,C,B,x,w,c,l);break;default:}W&&W.unbind(),t.gl.bindFramebuffer(36160,D),p&&h.destroy()}function N7(t){if(t instanceof fi){let{width:e,height:r,id:n}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var dM=class extends P_{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new pM(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,n){}};function k7(t){let{target:e,source:r,start:n=0,count:i=1}=t,o=r.length,s=i*o,c=0;for(let l=n;c<o;c++)e[l++]=r[c];for(;c<s;)c<s-c?(e.copyWithin(n+c,n,n+c),c*=2):(e.copyWithin(n+c,n,n+s-c),c=s);return t.target}var k_=class extends R_{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 n=r;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:o,stride:s,offset:c,normalized:l,integer:h,divisor:p}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),h?this.device.gl.vertexAttribIPointer(e,i,o,s,c):this.device.gl.vertexAttribPointer(e,i,o,l,s,c),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,p||0),this.attributes[e]=n,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 n=JE(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let i=k_.isConstantAttributeZeroSupported(this.device)||e!==0;(r||i)&&(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 n=Sme(r),i=n.byteLength*e,o=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),s=s||!Cme(n,this.bufferValue),s){let c=PO(r.constructor,o);k7({target:c,source:n,start:0,count:o}),this.buffer.write(c),this.bufferValue=r}return this.buffer}};function Sme(t){return Array.isArray(t)?new Float32Array(t):t}function Cme(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 mM=class extends L_{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(B7(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 in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let n=this._getVaryingIndex(e),{buffer:i,byteLength:o,byteOffset:s}=this._getBufferRange(r);if(n<0){this.unusedBuffers[e]=i,qt.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:o,byteOffset:s},this.bindOnUse||this._bindBuffer(n,i,s,o)}getBuffer(e){if(F7(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Ph)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(F7(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,n=0,i){let o=r&&r.handle;!o||i===void 0?this.gl.bindBufferBase(35982,e,o):this.gl.bindBufferRange(35982,e,o,n,i)}};function F7(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var AM=class extends O_{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((n,i)=>{let o=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):r++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}};var Fc=class extends hl{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;constructor(e){super({...e,id:e.id||h7("webgl-device")});let r=hl._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=r.canvas?.gl?.device;if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new iM(this,r),this.lost=new Promise(p=>{this._resolveContextLost=p});let i={...e.webgl};r.alphaMode==="premultiplied"&&(i.premultipliedAlpha=!0),e.powerPreference!==void 0&&(i.powerPreference=e.powerPreference);let s=this.props._handle||Y9(this.canvasContext.canvas,{onContextLost:p=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:p=>console.log("WebGL context restored")},i);if(!s)throw new Error("WebGL context creation failed");if(n=s.device,n){if(e._reuseDevices)return qt.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=s,this.gl=s,this.spectorJS=s7({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=K9(this.gl,this._extensions),this.limits=new nM(this.gl),this.features=new rM(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),r.autoResize!==!1&&this.canvasContext.resize(),new Ch(this.gl,{log:(...p)=>qt.log(1,...p)()}).trackState(this.gl,{copyState:!1});let l=e.debugWebGL||e.debug,h=e.debugWebGL;l&&(this.gl=u7(this.gl,{debugWebGL:l,traceWebGL:h}),qt.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(qt.level=Math.max(qt.level,1)))}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._normalizeBufferProps(e);return new Ph(this,r)}createTexture(e){return new zf(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ZA(this,e)}createShader(e){return new aM(this,e)}createFramebuffer(e){return new kf(this,e)}createVertexArray(e){return new k_(this,e)}createTransformFeedback(e){return new mM(this,e)}createQuerySet(e){return new AM(this,e)}createRenderPipeline(e){return new fM(this,e)}beginRenderPass(e){return new hM(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e={}){return new dM(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return b7(e,r)}readPixelsToBufferWebGL(e,r){return w7(e,r)}setParametersWebGL(e){Sh(this.gl,e)}getParametersWebGL(e){return QE(this.gl,e)}withParametersWebGL(e,r){return $A(this.gl,e,r)}resetWebGL(){qt.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),q9(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return t7(this.gl,e,this._extensions)}loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Ch.get(this.gl).push()}popState(){Ch.get(this.gl).pop()}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){let n=Number(e);for(let i in this.gl)if(this.gl[i]===n)return`GL.${i}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((n,[i,o])=>(n[`${i}:${this.getGLKey(i,r)}`]=`${o}:${this.getGLKey(o,r)}`,n),{})}_constants;setConstantAttributeWebGL(e,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[e];switch(i&&Lme(i,r)&&qt.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:Pme(this,e,r);break;case Int32Array:Ime(this,e,r);break;case Uint32Array:Rme(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return Nf(this.gl,e,this._extensions),this._extensions}};function Pme(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 Ime(t,e,r){t.gl.vertexAttribI4iv(e,r)}function Rme(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function Lme(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 Ome={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:{}},Bme=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Dme=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)}}),Nme=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)}});function z7(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,n){if(r==="webgl"||r==="experimental-webgl"){let i=this.originalGetContext("webgl2",n);return i instanceof HTMLElement&&kme(i),i}return this.originalGetContext(r,n)}}function kme(t){t.getExtension("EXT_color_buffer_float");let e={...Ome,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Bme(t),OES_vertex_array_object:Dme(t),ANGLE_instanced_arrays:Nme(t)},r=t.getExtension;t.getExtension=function(i){let o=r.call(t,i);return o||(i in e?e[i]:null)};let n=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(n.apply(t)||[])?.concat(Object.keys(e))}}var gM=1,HO=class extends Pv{type="webgl";constructor(){super(),hl.defaultProps={...hl.defaultProps,...sM},Fc.adapter=this}isSupported(){return typeof WebGL2RenderingContext<"u"}enforceWebGL2(e){z7(e)}async attach(e){if(e instanceof Fc)return e;if(e?.device instanceof hl)return e.device;if(!Fme(e))throw new Error("Invalid WebGL2RenderingContext");return new Fc({_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1}})}async create(e={}){qt.groupCollapsed(gM,"WebGLDevice created")();let r=[];(e.debugWebGL||e.debug)&&r.push(l7()),e.debugSpectorJS&&r.push(o7(e));let n=await Promise.allSettled(r);for(let s of n)s.status==="rejected"&&qt.error(`Failed to initialize debug libraries ${s.reason}`)();let i=new Fc(e),o=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return qt.probe(gM,o)(),qt.table(gM,i.info)(),qt.groupEnd(gM)(),i}};function Fme(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&Number.isFinite(t._version))}var _M=new HO;var U7,V7,H7={fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif',display:"flex",flex:"wrap",maxWidth:"500px",flexDirection:"column",zIndex:2};function yM(){return document.createElement("div")}function zme(t){if(!t.picked)return null;if(t.object===U7)return V7;let e={html:Vme(t.object),style:H7};return V7=e,U7=t.object,e}var Ume=new Set(["position","index"]);function Vme(t){let e=yM();for(let r in t){if(Ume.has(r))continue;let n=yM();n.className="header",n.textContent=r;let i=yM();i.className="value",i.textContent=Hme(t[r]);let o=yM();jme(o,n,i),o.appendChild(n),o.appendChild(i),e.appendChild(o)}return e.innerHTML}function jme(t,e,r){Object.assign(e.style,{fontWeight:700,marginRight:"10px",flex:"1 1 0%"}),Object.assign(r.style,{flex:"none",maxWidth:"250px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}),Object.assign(t.style,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"stretch"})}function Hme(t){let e;if(Array.isArray(t)&&t.length>4)e=`Array<${t.length}>`;else if(typeof t=="string")e=t;else if(typeof t=="number")e=String(t);else try{e=JSON.stringify(t)}catch{e="<Non-Serializable Object>"}let r=50;return e.length>r&&(e=e.slice(0,r)),e}function j7(t,e){let r,n=t,i="properties",o=/{[^}]*}/g,s=l=>l.replace(/[{}]/g,""),c=[...new Set(t.match(o).map(s))];for(let l of c){if(l.includes(".")){r=e;let h=l.split(".");for(let p of h)if(r.hasOwnProperty(p))r=r[p];else{r=void 0;break}}else e.hasOwnProperty(l)?r=e[l]:e[i]&&e[i].hasOwnProperty(l)?r=e[i][l]:r=void 0;n=n.replaceAll(`{${l}}`,r)}return n}function WO(t){return t?t.html||t.text?e=>{if(!e.picked)return null;let r={style:t.style||H7};return t.html?r.html=j7(t.html,e.object):r.text=j7(t.text,e.object),r}:zme:null}function W7(t){let e=document.createElement("link");e.type="text/css",e.rel="stylesheet",e.href=t,document.getElementsByTagName("head")[0].appendChild(e)}function q7(t,e){let r=document.createElement("div");return r.style.width=Number.isFinite(t)?`${t}px`:t,r.style.height=`${e}px`,r.style.position="relative",r}var X7=tc(G7()),Wme="https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.2/mapbox-gl.css",XO=X7.default;function Y7(t=Wme){W7(t)}function K7(){let t=["mapboxgl-missing-css"];for(let e of t){let r=document.getElementsByClassName(e)[0];r&&r.style&&(r.style.display="none")}}var YO={};function Z7(t){if(!YO[t]){let e=document.createElement("script");e.type="text/javascript",e.src=t,document.querySelector("head").appendChild(e),YO[t]=new Promise(n=>{e.onload=n})}return YO[t]}var $7="4.2.1";var qme=globalThis.loaders?.parseImageNode,KO=typeof Image<"u",ZO=typeof ImageBitmap<"u",Gme=Boolean(qme),$O=Fp?!0:Gme;function Q7(t){switch(t){case"auto":return ZO||KO||$O;case"imagebitmap":return ZO;case"image":return KO;case"data":return $O;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function J7(){if(ZO)return"imagebitmap";if(KO)return"image";if($O)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function ej(t){let e=Xme(t);if(!e)throw new Error("Not an image");return e}function kv(t){switch(ej(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 Xme(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 Yme=/^data:image\/svg\+xml/,Kme=/\.svg((\?|#).*)?$/;function xM(t){return t&&(Yme.test(t)||Kme.test(t))}function tj(t,e){if(xM(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return QO(t,e)}function QO(t,e){if(xM(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function vM(t,e,r){let n=tj(t,r),i=self.URL||self.webkitURL,o=typeof n!="string"&&i.createObjectURL(n);try{return await Zme(o||n,e)}finally{o&&i.revokeObjectURL(o)}}async function Zme(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,i)=>{try{r.onload=()=>n(r),r.onerror=o=>{let s=o instanceof Error?o.message:"error";i(new Error(s))}}catch(o){i(o)}})}var $me={},rj=!0;async function nj(t,e,r){let n;xM(r)?n=await vM(t,e,r):n=QO(t,r);let i=e&&e.imagebitmap;return await Qme(n,i)}async function Qme(t,e=null){if((Jme(e)||!rj)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),rj=!1}return await createImageBitmap(t)}function Jme(t){for(let e in t||$me)return!1;return!0}function ij(t){return!nAe(t,"ftyp",4)||!(t[8]&96)?null:eAe(t)}function eAe(t){switch(tAe(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function tAe(t,e,r){return String.fromCharCode(...t.slice(e,r))}function rAe(t){return[...t].map(e=>e.charCodeAt(0))}function nAe(t,e,r=0){let n=rAe(e);for(let i=0;i<n.length;++i)if(n[i]!==t[i+r])return!1;return!0}var Uf=!1,Fv=!0;function QA(t){let e=zv(t);return oAe(e)||cAe(e)||sAe(e)||aAe(e)||iAe(e)}function iAe(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=ij(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function oAe(t){let e=zv(t);return e.byteLength>=24&&e.getUint32(0,Uf)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Uf),height:e.getUint32(20,Uf)}:null}function sAe(t){let e=zv(t);return e.byteLength>=10&&e.getUint32(0,Uf)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Fv),height:e.getUint16(8,Fv)}:null}function aAe(t){let e=zv(t);return e.byteLength>=14&&e.getUint16(0,Uf)===16973&&e.getUint32(2,Fv)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Fv),height:e.getUint32(22,Fv)}:null}function cAe(t){let e=zv(t);if(!(e.byteLength>=3&&e.getUint16(0,Uf)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:i}=lAe(),o=2;for(;o+9<e.byteLength;){let s=e.getUint16(o,Uf);if(i.has(s))return{mimeType:"image/jpeg",height:e.getUint16(o+5,Uf),width:e.getUint16(o+7,Uf)};if(!n.has(s))return null;o+=2,o+=e.getUint16(o,Uf)}return null}function lAe(){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 zv(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 oj(t,e){let{mimeType:r}=QA(t)||{},n=globalThis.loaders?.parseImageNode;return Ti(n),await n(t,r)}async function sj(t,e,r){e=e||{};let i=(e.image||{}).type||"auto",{url:o}=r||{},s=uAe(i),c;switch(s){case"imagebitmap":c=await nj(t,e,o);break;case"image":c=await vM(t,e,o);break;case"data":c=await oj(t,e);break;default:Ti(!1)}return i==="data"&&(c=kv(c)),c}function uAe(t){switch(t){case"auto":case"data":return J7();default:return Q7(t),t}}var hAe=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],fAe=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],pAe={image:{type:"auto",decode:!0}},Vf={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:$7,mimeTypes:fAe,extensions:hAe,parse:sj,tests:[t=>Boolean(QA(new DataView(t)))],options:pAe};var JO={};function eB(t){if(JO[t]===void 0){let e=Fp?mAe(t):dAe(t);JO[t]=e}return JO[t]}function dAe(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&r.includes(t)}function mAe(t){switch(t){case"image/avif":case"image/webp":return AAe(t);default:return!0}}function AAe(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var gAe=new Dl({id:"deck"}),br=gAe;var tB={};function aj(t){tB=t}function Gs(t,e,r,n){br.level>0&&tB[t]&&tB[t].call(null,e,r,n)}function _Ae(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var cj={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:_Ae,parseTextSync:JSON.parse};function yAe(){let t="9.1.7",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(br.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:br,_registerLoggers:aj},qA([cj,[Vf,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var bM=yAe();function wM(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var rB={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 uj(t){let e={};for(let[r,n]of Object.entries(t))e[r]=xAe(n);return e}function xAe(t){let e=lj(t);if(e!=="object")return{value:t,...rB[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...rB[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=lj(t.value),{...t,...rB[e],type:e}):{type:"object",value:null};throw new Error("props")}function lj(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var hj=`#ifdef MODULE_LOGDEPTH
551
+ ${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}qt.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),qt.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(o=>setTimeout(o,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};function m7(t,e,r,n){if(sme(e))return n(t);let i=t;i.pushState();try{return nme(t,e),Sh(i.gl,r),n(t)}finally{i.popState()}}function nme(t,e){let r=t,{gl:n}=r;if(e.cullMode)switch(e.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(e.frontFace&&n.frontFace(KA("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&n.enable(34383),e.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let o=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=KA("provokingVertex",e.provokingVertex,{first:36429,last:36430});o?.provokingVertexWEBGL(s)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let o=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=KA("polygonMode",e.polygonMode,{fill:6914,line:6913});o?.polygonModeWEBGL(1028,s),o?.polygonModeWEBGL(1029,s)}e.polygonOffsetLine&&n.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(12288),e.clipDistance1&&n.enable(12289),e.clipDistance2&&n.enable(12290),e.clipDistance3&&n.enable(12291),e.clipDistance4&&n.enable(12292),e.clipDistance5&&n.enable(12293),e.clipDistance6&&n.enable(12294),e.clipDistance7&&n.enable(12295)),e.depthWriteEnabled!==void 0&&n.depthMask(ome("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(lM("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(1028,i),n.stencilMaskSeparate(1029,i)}if(e.stencilReadMask&&qt.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,o=lM("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,o,0,i),n.stencilFuncSeparate(1029,o,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=NO("stencilPassOperation",e.stencilPassOperation),o=NO("stencilFailOperation",e.stencilFailOperation),s=NO("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(1028,o,s,i),n.stencilOpSeparate(1029,o,s,i)}switch(e.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let i=d7("blendColorOperation",e.blendColorOperation||"add"),o=d7("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,o);let s=cM("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=cM("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=cM("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),h=cM("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(s,c,l,h)}}function lM(t,e){return KA(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function NO(t,e){return KA(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function d7(t,e){return KA(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function cM(t,e){return KA(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function ime(t,e){return`Illegal parameter ${e} for ${t}`}function KA(t,e,r){if(!(e in r))throw new Error(ime(t,e));return r[e]}function ome(t,e){return e}function sme(t){let e=!0;for(let r in t){e=!1;break}return e}function uM(t){let e={};return t.addressModeU&&(e[10242]=kO(t.addressModeU)),t.addressModeV&&(e[10243]=kO(t.addressModeV)),t.addressModeW&&(e[32882]=kO(t.addressModeW)),t.magFilter&&(e[10240]=FO(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=ame(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]=lM("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function kO(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function FO(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function ame(t,e="none"){if(!e)return FO(t);switch(e){case"none":return FO(t);case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var ZA=class extends om{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=uM(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,n]of Object.entries(e)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var Ff=class extends nm{device;gl;handle;texture;constructor(e,r){super(e,{...fi.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var cme="Failed to deduce GL constant from typed array";function A7(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(cme)}}function g7(t,e){let{clamped:r=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}function zO(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 _7(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function $A(t,e,r){if(lme(e))return r(t);let{nocatch:n=!0}=e,i=Ch.get(t);i.push(),Sh(t,e);let o;if(n)o=r(t),i.pop();else try{o=r(t)}finally{i.pop()}return o}function lme(t){for(let e in t)return!1;return!0}function y7(t,e,r){let{dimension:n,width:i,height:o,depth:s=0}=r,{glInternalFormat:c}=r,l=r.glTarget;switch(n){case"2d-array":case"3d":t.texStorage3D(l,e,c,i,o,s);break;default:t.texStorage2D(l,e,c,i,o)}}function UO(t,e,r,n){let{width:i,height:o}=n,{dimension:s,depth:c=0,mipLevel:l=0}=n,{x:h=0,y:p=0,z:x=0}=n,{glFormat:w,glType:E}=n,C=v7(n.glTarget,s,c),B=n.flipY?{[37440]:!0}:{};$A(t,B,()=>{switch(s){case"2d-array":case"3d":t.bindTexture(C,e),t.texSubImage3D(C,l,h,p,x,i,o,c,w,E,r),t.bindTexture(C,null);break;case"2d":case"cube":t.bindTexture(C,e),t.texSubImage2D(C,l,h,p,i,o,w,E,r),t.bindTexture(C,null);break;default:throw new Error(s)}})}function VO(t,e,r){let{dimension:n,width:i,height:o,depth:s=0,mipLevel:c=0,byteOffset:l=0}=r,{x:h=0,y:p=0,z:x=0}=r,{glFormat:w,glType:E,compressed:C}=r,B=v7(r.glTarget,n,s);switch(n){case"2d-array":case"3d":C?t.compressedTexSubImage3D(B,c,h,p,x,i,o,s,w,e,l):t.texSubImage3D(B,c,h,p,x,i,o,s,w,E,e,l);break;case"2d":case"cube":C?t.compressedTexSubImage2D(B,c,h,p,i,o,w,e,l):t.texSubImage2D(B,c,h,p,i,o,w,E,e,l);break;default:throw new Error(n)}}function x7(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 v7(t,e,r){return e==="cube"?34069+r:t}function b7(t,e){let{sourceX:r=0,sourceY:n=0,sourceAttachment:i=0}=e||{},{target:o=null,sourceWidth:s,sourceHeight:c,sourceDepth:l,sourceFormat:h,sourceType:p}=e||{},{framebuffer:x,deleteFramebuffer:w}=T7(t),{gl:E,handle:C}=x;s||=x.width,c||=x.height;let B=x.colorAttachments[i]?.texture;if(!B)throw new Error(`Invalid framebuffer attachment ${i}`);l=B?.depth||1,h||=B?.glFormat||6408,p||=B?.glType||5121,o=hme(o,p,h,s,c,l),p=p||A7(o);let D=E.bindFramebuffer(36160,C);return E.readBuffer(36064+i),E.readPixels(r,n,s,c,h,p,o),E.readBuffer(36064),E.bindFramebuffer(36160,D||null),w&&x.destroy(),o}function w7(t,e){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:o=6408,targetByteOffset:s=0}=e||{},{sourceWidth:c,sourceHeight:l,sourceType:h}=e||{},{framebuffer:p,deleteFramebuffer:x}=T7(t);c=c||p.width,l=l||p.height;let w=p;h=h||5121;let E=r;if(!E){let B=zO(o),D=_7(h),W=s+c*l*B*D;E=w.device.createBuffer({byteLength:W})}let C=t.device.createCommandEncoder();return C.copyTextureToBuffer({sourceTexture:t,width:c,height:l,origin:[n,i],destinationBuffer:E,byteOffset:s}),C.destroy(),x&&p.destroy(),E}function T7(t){return t instanceof Of?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:ume(t),deleteFramebuffer:!0}}function ume(t,e){let{device:r,width:n,height:i,id:o}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${o}`,width:n,height:i,colorAttachments:[t]})}function hme(t,e,r,n,i,o){if(t)return t;e||=5121;let s=g7(e,{clamped:!1}),c=zO(r);return new s(n*i*c)}var zf=class extends fi{device;gl;handle;sampler=void 0;view=void 0;mipmaps;compressed;glTarget;glFormat;glType;glInternalFormat;textureUnit=0;constructor(e,r){super(e,r);let n={...this.props};n.data=r.data,this.device=e,this.gl=this.device.gl,this.glTarget=x7(this.props.dimension);let i=tM(this.props.format);this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.compressed,this.mipmaps=Boolean(this.props.mipmaps),this._initialize(n),Object.seal(this)}_initialize(e){this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:e.data});let{width:r,height:n}=e;if(!r||!n){let i=fi.getTextureDataSize(e.data);r=i?.width||1,n=i?.height||1}if(this.width=r,this.height=n,this.depth=e.depth,this.setSampler(e.sampler),this.view=new Ff(this.device,{...this.props,texture:this}),this.bind(),y7(this.gl,this.mipLevels,this),e.data)switch(e.dimension){case"1d":this.setTexture1DData(e.data);break;case"2d":this.setTexture2DData(e.data);break;case"3d":this.setTexture3DData(e.data);break;case"cube":this.setTextureCubeData(e.data);break;case"2d-array":this.setTextureArrayData(e.data);break;case"cube-array":this.setTextureCubeArrayData(e.data);break;default:throw new Error(e.dimension)}this.mipmaps&&this.generateMipmap()}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(e){return new Ff(this.device,{...e,texture:this})}setSampler(e={}){let r;e instanceof ZA?(this.sampler=e,r=e.props):(this.sampler=new ZA(this.device,e),r=e);let n=uM(r);this._setSamplerParameters(n)}generateMipmap(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(qt.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(n){qt.warn(`Error generating mipmap for ${this}: ${n.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}copyExternalImage(e){let r=fi.getExternalImageSize(e.image),n={...fi.defaultCopyExternalImageOptions,...r,...e},{image:i,depth:o,mipLevel:s,x:c,y:l,z:h,flipY:p}=n,{width:x,height:w}=n,{dimension:E,glTarget:C,glFormat:B,glInternalFormat:D,glType:W}=this;if(x=Math.min(x,this.width-c),w=Math.min(w,this.height-l),e.sourceX||e.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");return UO(this.device.gl,this.handle,i,{dimension:E,mipLevel:s,x:c,y:l,z:h,width:x,height:w,depth:o,glFormat:B,glInternalFormat:D,glType:W,glTarget:C,flipY:p}),{width:n.width,height:n.height}}setTexture1DData(e){throw new Error("setTexture1DData not supported in WebGL.")}setTexture2DData(e,r=0){this.bind();let n=fi.normalizeTextureData(e,this);n.length>1&&this.props.mipmaps!==!1&&qt.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let i=0;i<n.length;i++){let o=n[i];this._setMipLevel(r,i,o)}this.unbind()}setTexture3DData(e){if(this.props.dimension!=="3d")throw new Error(this.id);ArrayBuffer.isView(e)&&(this.bind(),VO(this.device.gl,e,this),this.unbind())}setTextureCubeData(e,r=0){if(this.props.dimension!=="cube")throw new Error(this.id);for(let n of fi.CubeFaces)this.setTextureCubeFaceData(e[n],n)}setTextureArrayData(e){throw this.props.dimension!=="2d-array"?new Error(this.id):new Error("setTextureArrayData not implemented.")}setTextureCubeArrayData(e){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}setTextureCubeFaceData(e,r,n=0){Array.isArray(e)&&e.length>1&&this.props.mipmaps!==!1&&qt.warn(`${this.id} has mipmap and multiple LODs.`)();let i=fi.CubeFaces.indexOf(r);this.setTexture2DData(e,i)}update(){throw new Error("Texture.update() not implemented. Use ExternalTexture")}setImageDataForFace(e){let{face:r,width:n,height:i,pixels:o,data:s,format:c=6408,type:l=5121}=e,{gl:h}=this,p=o||s;this.bind(),p instanceof Promise?p.then(x=>this.setImageDataForFace(Object.assign({},e,{face:r,data:x,pixels:x}))):this.width||this.height?h.texImage2D(r,0,c,n,i,0,c,l,p):h.texImage2D(r,0,c,c,l,p)}_getImageDataMap(e){for(let r=0;r<fi.CubeFaces.length;++r){let n=fi.CubeFaces[r];e[n]&&(e[34069+r]=e[n],delete e[n])}return e}_setSamplerParameters(e){qt.log(1,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,n]of Object.entries(e)){let i=Number(r),o=n;switch(i){case 33082:case 33083:this.gl.texParameterf(this.glTarget,i,o);break;case 10241:this.gl.texParameteri(this.glTarget,i,o);break;case 10242:case 10243:this.gl.texParameteri(this.glTarget,i,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,i,o);break;default:this.gl.texParameteri(this.glTarget,i,o);break}}this.gl.bindTexture(this.glTarget,null)}_setMipLevel(e,r,n,i=this.glTarget){if(fi.isExternalImage(n)){UO(this.device.gl,this.handle,n,{...this,depth:e,mipLevel:r,glTarget:i,flipY:this.props.flipY});return}if(fi.isTextureLevelData(n)){VO(this.device.gl,n.data,{...this,depth:e,mipLevel:r,glTarget:i});return}throw new Error("Texture: invalid image data")}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}};var fme=[1,2,4,8],hM=class extends Up{device;glParameters;constructor(e,r){super(e,r),this.device=e;let n;if(!r?.parameters?.viewport)if(r?.framebuffer){let{width:o,height:s}=r.framebuffer;n=[0,0,o,s]}else{let[o,s]=e.getCanvasContext().getDrawingBufferSize();n=[0,0,o,s]}if(this.device.pushState(),this.setParameters({viewport:n,...this.props.parameters}),this.props.framebuffer?.handle)if(this.props.framebuffer){let o=this.props.framebuffer.colorAttachments.map((s,c)=>36064+c);this.device.gl.drawBuffers(o)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}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&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(r.colorMask=fme.map(n=>Boolean(n&e.colorMask))),this.glParameters=r,Sh(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((n,i)=>{n&&this.clearColorBuffer(i,n)}),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&&$A(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){$A(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")}})}};function E7(t){return pme.includes(t)}var pme=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],M7={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2<f32>","float32x2"],[35665]:[5126,3,"vec3","vec3<f32>","float32x3"],[35666]:[5126,4,"vec4","vec4<f32>","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2<i32>","sint32x2"],[35668]:[5124,3,"ivec3","vec3<i32>","sint32x3"],[35669]:[5124,4,"ivec4","vec4<i32>","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2<u32>","uint32x2"],[36295]:[5125,3,"uvec3","vec3<u32>","uint32x3"],[36296]:[5125,4,"uvec4","vec4<u32>","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2<f32>","float32x2"],[35672]:[5126,3,"bvec3","vec3<f32>","float32x3"],[35673]:[5126,4,"bvec4","vec4<f32>","float32x4"],[35674]:[5126,8,"mat2","mat2x2<f32>"],[35685]:[5126,8,"mat2x3","mat2x3<f32>"],[35686]:[5126,8,"mat2x4","mat2x4<f32>"],[35687]:[5126,12,"mat3x2","mat3x2<f32>"],[35675]:[5126,12,"mat3","mat3x3<f32>"],[35688]:[5126,12,"mat3x4","mat3x4<f32>"],[35689]:[5126,16,"mat4x2","mat4x2<f32>"],[35690]:[5126,16,"mat4x3","mat4x3<f32>"],[35676]:[5126,16,"mat4","mat4x4<f32>"]};function jO(t){let e=M7[t];if(!e)throw new Error("uniform");let[r,n,,i]=e;return{format:i,components:n,glType:r}}function S7(t){let e=M7[t];if(!e)throw new Error("attribute");let[,r,,n,i]=e;return{attributeType:n,vertexFormat:i,components:r}}function C7(t,e){let r={attributes:[],bindings:[]};r.attributes=dme(t,e);let n=gme(t,e);for(let c of n){let l=c.uniforms.map(h=>({name:h.name,format:h.format,byteOffset:h.byteOffset,byteStride:h.byteStride,arrayLength:h.arrayLength}));r.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)&(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let i=Ame(t,e),o=0;for(let c of i)if(E7(c.type)){let{viewDimension:l,sampleType:h}=yme(c.type);r.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:h}),c.textureUnit=o,o+=1}i.length&&(r.uniforms=i);let s=mme(t,e);return s?.length&&(r.varyings=s),r}function dme(t,e){let r=[],n=t.getProgramParameter(e,35721);for(let i=0;i<n;i++){let o=t.getActiveAttrib(e,i);if(!o)throw new Error("activeInfo");let{name:s,type:c}=o,l=t.getAttribLocation(e,s);if(l>=0){let{attributeType:h}=S7(c),p=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:l,stepMode:p,type:h})}}return r.sort((i,o)=>i.location-o.location),r}function mme(t,e){let r=[],n=t.getProgramParameter(e,35971);for(let i=0;i<n;i++){let o=t.getTransformFeedbackVarying(e,i);if(!o)throw new Error("activeInfo");let{name:s,type:c,size:l}=o,{glType:h,components:p}=jO(c),x={location:i,name:s,type:h,size:l*p};r.push(x)}return r.sort((i,o)=>i.location-o.location),r}function Ame(t,e){let r=[],n=t.getProgramParameter(e,35718);for(let i=0;i<n;i++){let o=t.getActiveUniform(e,i);if(!o)throw new Error("activeInfo");let{name:s,size:c,type:l}=o,{name:h,isArray:p}=xme(s),x=t.getUniformLocation(e,h),w={location:x,name:h,size:c,type:l,isArray:p};if(r.push(w),w.size>1)for(let E=0;E<w.size;E++){let C=`${h}[${E}]`;x=t.getUniformLocation(e,C);let B={...w,name:C,location:x};r.push(B)}}return r}function gme(t,e){let r=(o,s)=>t.getActiveUniformBlockParameter(e,o,s),n=[],i=t.getProgramParameter(e,35382);for(let o=0;o<i;o++){let s={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:[]},c=r(o,35395)||[],l=t.getActiveUniforms(e,c,35383),h=t.getActiveUniforms(e,c,35384),p=t.getActiveUniforms(e,c,35387),x=t.getActiveUniforms(e,c,35388);for(let w=0;w<s.uniformCount;++w){let E=t.getActiveUniform(e,c[w]);if(!E)throw new Error("activeInfo");s.uniforms.push({name:E.name,format:jO(l[w]).format,type:l[w],arrayLength:h[w],byteOffset:p[w],byteStride:x[w]})}n.push(s)}return n.sort((o,s)=>o.location-s.location),n}var _me={[35678]:["2d","float"],[35680]:["cube","float"],[35679]:["3d","float"],[35682]:["3d","depth"],[36289]:["2d-array","float"],[36292]:["2d-array","depth"],[36293]:["cube","float"],[36298]:["2d","sint"],[36299]:["3d","sint"],[36300]:["cube","sint"],[36303]:["2d-array","uint"],[36306]:["2d","uint"],[36307]:["3d","uint"],[36308]:["cube","uint"],[36311]:["2d-array","uint"]};function yme(t){let e=_me[t];if(!e)throw new Error("sampler");let[r,n]=e;return{viewDimension:r,sampleType:n}}function xme(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function P7(t,e,r,n){let i=t,o=n;o===!0&&(o=1),o===!1&&(o=0);let s=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 n!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,n);case 5126:return t.uniform1fv(e,s);case 35664:return t.uniform2fv(e,s);case 35665:return t.uniform3fv(e,s);case 35666:return t.uniform4fv(e,s);case 5124:return t.uniform1iv(e,s);case 35667:return t.uniform2iv(e,s);case 35668:return t.uniform3iv(e,s);case 35669:return t.uniform4iv(e,s);case 35670:return t.uniform1iv(e,s);case 35671:return t.uniform2iv(e,s);case 35672:return t.uniform3iv(e,s);case 35673:return t.uniform4iv(e,s);case 5125:return i.uniform1uiv(e,s,1);case 36294:return i.uniform2uiv(e,s,2);case 36295:return i.uniform3uiv(e,s,3);case 36296:return i.uniform4uiv(e,s,4);case 35674:return t.uniformMatrix2fv(e,!1,s);case 35675:return t.uniformMatrix3fv(e,!1,s);case 35676:return t.uniformMatrix4fv(e,!1,s);case 35685:return i.uniformMatrix2x3fv(e,!1,s);case 35686:return i.uniformMatrix2x4fv(e,!1,s);case 35687:return i.uniformMatrix3x2fv(e,!1,s);case 35688:return i.uniformMatrix3x4fv(e,!1,s);case 35689:return i.uniformMatrix4x2fv(e,!1,s);case 35690:return i.uniformMatrix4x3fv(e,!1,s)}throw new Error("Illegal uniform")}function I7(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function R7(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function Nv(t){return I7(t)||R7(t)}function vme(t){return Nv(t)!==null||typeof t=="number"||typeof t=="boolean"}function L7(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];vme(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}function O7(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 B7(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 D7=4,fM=class extends Mh{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:n,bufferMode:i=35981}=r;n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),qt.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=C7(this.device.gl,this.handle),qt.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=bme(this.introspectedLayout,r.shaderLayout)}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,r){for(let[n,i]of Object.entries(e)){let o=this.shaderLayout.bindings.find(s=>s.name===n)||this.shaderLayout.bindings.find(s=>s.name===`${n}Uniforms`);if(!o){let s=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||qt.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${s}`,i)();continue}switch(i||qt.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(i instanceof Ph)&&!(i.buffer instanceof Ph))throw new Error("buffer value");break;case"texture":if(!(i instanceof Ff||i instanceof zf||i instanceof kf))throw new Error("texture value");break;case"sampler":qt.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(o.type)}this.bindings[n]=i}}draw(e){let{renderPass:r,parameters:n=this.props.parameters,topology:i=this.props.topology,vertexArray:o,vertexCount:s,instanceCount:c,isInstanced:l=!1,firstVertex:h=0,transformFeedback:p}=e,x=O7(i),w=Boolean(o.indexBuffer),E=o.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return qt.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return qt.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),o.bindBeforeRender(r),p&&p.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let C=r;return m7(this.device,n,C.glParameters,()=>{w&&l?this.device.gl.drawElementsInstanced(x,s||0,E,h,c||0):w?this.device.gl.drawElements(x,s||0,E,h):l?this.device.gl.drawArraysInstanced(x,h,s||0,c||0):this.device.gl.drawArrays(x,h,s||0),p&&p.end()}),o.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=L7(e);Object.keys(r).forEach(n=>{qt.warn(`Unsupported value "${JSON.stringify(r[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),qt.time(D7,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),qt.timeEnd(D7,`linkProgram for ${this.id}`)(),qt.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}qt.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),qt.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:switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`);case"pending":this.vs.asyncCompilationStatus.then(()=>this.vs.debugShader());break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`);case"pending":this.fs.asyncCompilationStatus.then(()=>this.fs.debugShader());break;case"success":break}let r=this.device.gl.getProgramInfoLog(this.handle);throw new Error(`Error during ${e}: ${r}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(o=>setTimeout(o,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let r of this.shaderLayout.bindings)!this.bindings[r.name]&&!this.bindings[r.name.replace(/Uniforms$/,"")]&&(qt.warn(`Binding ${r.name} not found in ${this.id}`)(),e=!1);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,n=0;for(let i of this.shaderLayout.bindings){let o=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:s}=i,c=e.getUniformBlockIndex(this.handle,s);if(c===4294967295)throw new Error(`Invalid uniform block name ${s}`);e.uniformBlockBinding(this.handle,n,c),o instanceof Ph?e.bindBufferBase(35345,n,o.handle):e.bindBufferRange(35345,n,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),n+=1;break;case"texture":if(!(o instanceof Ff||o instanceof zf||o instanceof kf))throw new Error("texture");let l;if(o instanceof Ff)l=o.texture;else if(o instanceof zf)l=o;else if(o instanceof kf&&o.colorAttachments[0]instanceof Ff)qt.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=o.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+r),e.bindTexture(l.glTarget,l.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:n,type:i,textureUnit:o}=e,s=this.uniforms[r]??o;s!==void 0&&P7(this.device.gl,n,i,s)}}};function bme(t,e){let r={...t,attributes:t.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=r.attributes.find(o=>o.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):qt.warn(`shader layout attribute ${n.name} not present in shader`)}return r}var pM=class extends I_{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":wme(this.device,r.options);break;case"copy-buffer-to-texture":Tme(this.device,r.options);break;case"copy-texture-to-buffer":Eme(this.device,r.options);break;case"copy-texture-to-texture":Mme(this.device,r.options);break;default:throw new Error(r.name)}}};function wme(t,e){let r=e.sourceBuffer,n=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,n.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 Tme(t,e){throw new Error("Not implemented")}function Eme(t,e){let{sourceTexture:r,mipLevel:n=0,aspect:i="all",width:o=e.sourceTexture.width,height:s=e.sourceTexture.height,depthOrArrayLayers:c=0,origin:l=[0,0],destinationBuffer:h,byteOffset:p=0,bytesPerRow:x,rowsPerImage:w}=e;if(i!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||c!==0||x||w)throw new Error("not implemented");let{framebuffer:E,destroyFramebuffer:C}=N7(r),B;try{let D=h,W=o||E.width,X=s||E.height,q=tM(E.colorAttachments[0].texture.props.format),$=q.format,te=q.type;t.gl.bindBuffer(35051,D.handle),B=t.gl.bindFramebuffer(36160,E.handle),t.gl.readPixels(l[0],l[1],W,X,$,te,p)}finally{t.gl.bindBuffer(35051,null),B!==void 0&&t.gl.bindFramebuffer(36160,B),C&&E.destroy()}}function Mme(t,e){let{sourceTexture:r,destinationMipLevel:n=0,origin:i=[0,0],destinationOrigin:o=[0,0],destinationTexture:s}=e,{width:c=e.destinationTexture.width,height:l=e.destinationTexture.height}=e,{framebuffer:h,destroyFramebuffer:p}=N7(r),[x,w]=i,[E,C,B]=o,D=t.gl.bindFramebuffer(36160,h.handle),W=null,X;if(s instanceof zf)W=s,c=Number.isFinite(c)?c:W.width,l=Number.isFinite(l)?l:W.height,W.bind(0),X=W.glTarget;else throw new Error("invalid destination");switch(X){case 3553:case 34067:t.gl.copyTexSubImage2D(X,n,E,C,x,w,c,l);break;case 35866:case 32879:t.gl.copyTexSubImage3D(X,n,E,C,B,x,w,c,l);break;default:}W&&W.unbind(),t.gl.bindFramebuffer(36160,D),p&&h.destroy()}function N7(t){if(t instanceof fi){let{width:e,height:r,id:n}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var dM=class extends P_{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new pM(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,n){}};function k7(t){let{target:e,source:r,start:n=0,count:i=1}=t,o=r.length,s=i*o,c=0;for(let l=n;c<o;c++)e[l++]=r[c];for(;c<s;)c<s-c?(e.copyWithin(n+c,n,n+c),c*=2):(e.copyWithin(n+c,n,n+s-c),c=s);return t.target}var k_=class extends R_{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 n=r;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:o,stride:s,offset:c,normalized:l,integer:h,divisor:p}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),h?this.device.gl.vertexAttribIPointer(e,i,o,s,c):this.device.gl.vertexAttribPointer(e,i,o,l,s,c),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,p||0),this.attributes[e]=n,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 n=JE(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let i=k_.isConstantAttributeZeroSupported(this.device)||e!==0;(r||i)&&(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 n=Sme(r),i=n.byteLength*e,o=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),s=s||!Cme(n,this.bufferValue),s){let c=PO(r.constructor,o);k7({target:c,source:n,start:0,count:o}),this.buffer.write(c),this.bufferValue=r}return this.buffer}};function Sme(t){return Array.isArray(t)?new Float32Array(t):t}function Cme(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 mM=class extends L_{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(B7(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 in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let n=this._getVaryingIndex(e),{buffer:i,byteLength:o,byteOffset:s}=this._getBufferRange(r);if(n<0){this.unusedBuffers[e]=i,qt.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:o,byteOffset:s},this.bindOnUse||this._bindBuffer(n,i,s,o)}getBuffer(e){if(F7(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Ph)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(F7(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,n=0,i){let o=r&&r.handle;!o||i===void 0?this.gl.bindBufferBase(35982,e,o):this.gl.bindBufferRange(35982,e,o,n,i)}};function F7(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var AM=class extends O_{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((n,i)=>{let o=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):r++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}};var Fc=class extends hl{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;constructor(e){super({...e,id:e.id||h7("webgl-device")});let r=hl._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=r.canvas?.gl?.device;if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new iM(this,r),this.lost=new Promise(p=>{this._resolveContextLost=p});let i={...e.webgl};r.alphaMode==="premultiplied"&&(i.premultipliedAlpha=!0),e.powerPreference!==void 0&&(i.powerPreference=e.powerPreference);let s=this.props._handle||Y9(this.canvasContext.canvas,{onContextLost:p=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:p=>console.log("WebGL context restored")},i);if(!s)throw new Error("WebGL context creation failed");if(n=s.device,n){if(e._reuseDevices)return qt.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=s,this.gl=s,this.spectorJS=s7({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=K9(this.gl,this._extensions),this.limits=new nM(this.gl),this.features=new rM(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),r.autoResize!==!1&&this.canvasContext.resize(),new Ch(this.gl,{log:(...p)=>qt.log(1,...p)()}).trackState(this.gl,{copyState:!1});let l=e.debugWebGL||e.debug,h=e.debugWebGL;l&&(this.gl=u7(this.gl,{debugWebGL:l,traceWebGL:h}),qt.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(qt.level=Math.max(qt.level,1)))}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._normalizeBufferProps(e);return new Ph(this,r)}createTexture(e){return new zf(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ZA(this,e)}createShader(e){return new aM(this,e)}createFramebuffer(e){return new kf(this,e)}createVertexArray(e){return new k_(this,e)}createTransformFeedback(e){return new mM(this,e)}createQuerySet(e){return new AM(this,e)}createRenderPipeline(e){return new fM(this,e)}beginRenderPass(e){return new hM(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e={}){return new dM(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return b7(e,r)}readPixelsToBufferWebGL(e,r){return w7(e,r)}setParametersWebGL(e){Sh(this.gl,e)}getParametersWebGL(e){return QE(this.gl,e)}withParametersWebGL(e,r){return $A(this.gl,e,r)}resetWebGL(){qt.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),q9(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return t7(this.gl,e,this._extensions)}loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Ch.get(this.gl).push()}popState(){Ch.get(this.gl).pop()}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){let n=Number(e);for(let i in this.gl)if(this.gl[i]===n)return`GL.${i}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((n,[i,o])=>(n[`${i}:${this.getGLKey(i,r)}`]=`${o}:${this.getGLKey(o,r)}`,n),{})}_constants;setConstantAttributeWebGL(e,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[e];switch(i&&Lme(i,r)&&qt.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:Pme(this,e,r);break;case Int32Array:Ime(this,e,r);break;case Uint32Array:Rme(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return Nf(this.gl,e,this._extensions),this._extensions}};function Pme(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 Ime(t,e,r){t.gl.vertexAttribI4iv(e,r)}function Rme(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function Lme(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 Ome={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:{}},Bme=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),Dme=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)}}),Nme=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)}});function z7(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,n){if(r==="webgl"||r==="experimental-webgl"){let i=this.originalGetContext("webgl2",n);return i instanceof HTMLElement&&kme(i),i}return this.originalGetContext(r,n)}}function kme(t){t.getExtension("EXT_color_buffer_float");let e={...Ome,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:Bme(t),OES_vertex_array_object:Dme(t),ANGLE_instanced_arrays:Nme(t)},r=t.getExtension;t.getExtension=function(i){let o=r.call(t,i);return o||(i in e?e[i]:null)};let n=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(n.apply(t)||[])?.concat(Object.keys(e))}}var gM=1,HO=class extends Pv{type="webgl";constructor(){super(),hl.defaultProps={...hl.defaultProps,...sM},Fc.adapter=this}isSupported(){return typeof WebGL2RenderingContext<"u"}enforceWebGL2(e){z7(e)}async attach(e){if(e instanceof Fc)return e;if(e?.device instanceof hl)return e.device;if(!Fme(e))throw new Error("Invalid WebGL2RenderingContext");return new Fc({_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1}})}async create(e={}){qt.groupCollapsed(gM,"WebGLDevice created")();let r=[];(e.debugWebGL||e.debug)&&r.push(l7()),e.debugSpectorJS&&r.push(o7(e));let n=await Promise.allSettled(r);for(let s of n)s.status==="rejected"&&qt.error(`Failed to initialize debug libraries ${s.reason}`)();let i=new Fc(e),o=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return qt.probe(gM,o)(),qt.table(gM,i.info)(),qt.groupEnd(gM)(),i}};function Fme(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&Number.isFinite(t._version))}var _M=new HO;var U7,V7,H7={fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif',display:"flex",flex:"wrap",maxWidth:"500px",flexDirection:"column",zIndex:2};function yM(){return document.createElement("div")}function zme(t){if(!t.picked)return null;if(t.object===U7)return V7;let e={html:Vme(t.object),style:H7};return V7=e,U7=t.object,e}var Ume=new Set(["position","index"]);function Vme(t){let e=yM();for(let r in t){if(Ume.has(r))continue;let n=yM();n.className="header",n.textContent=r;let i=yM();i.className="value",i.textContent=Hme(t[r]);let o=yM();jme(o,n,i),o.appendChild(n),o.appendChild(i),e.appendChild(o)}return e.innerHTML}function jme(t,e,r){Object.assign(e.style,{fontWeight:700,marginRight:"10px",flex:"1 1 0%"}),Object.assign(r.style,{flex:"none",maxWidth:"250px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}),Object.assign(t.style,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"stretch"})}function Hme(t){let e;if(Array.isArray(t)&&t.length>4)e=`Array<${t.length}>`;else if(typeof t=="string")e=t;else if(typeof t=="number")e=String(t);else try{e=JSON.stringify(t)}catch{e="<Non-Serializable Object>"}let r=50;return e.length>r&&(e=e.slice(0,r)),e}function j7(t,e){let r,n=t,i="properties",o=/{[^}]*}/g,s=l=>l.replace(/[{}]/g,""),c=[...new Set(t.match(o).map(s))];for(let l of c){if(l.includes(".")){r=e;let h=l.split(".");for(let p of h)if(r.hasOwnProperty(p))r=r[p];else{r=void 0;break}}else e.hasOwnProperty(l)?r=e[l]:e[i]&&e[i].hasOwnProperty(l)?r=e[i][l]:r=void 0;n=n.replaceAll(`{${l}}`,r)}return n}function WO(t){return t?t.html||t.text?e=>{if(!e.picked)return null;let r={style:t.style||H7};return t.html?r.html=j7(t.html,e.object):r.text=j7(t.text,e.object),r}:zme:null}function W7(t){let e=document.createElement("link");e.type="text/css",e.rel="stylesheet",e.href=t,document.getElementsByTagName("head")[0].appendChild(e)}function q7(t,e){let r=document.createElement("div");return r.style.width=Number.isFinite(t)?`${t}px`:t,r.style.height=`${e}px`,r.style.position="relative",r}var X7=tc(G7()),Wme="https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.2/mapbox-gl.css",XO=X7.default;function Y7(t=Wme){W7(t)}function K7(){let t=["mapboxgl-missing-css"];for(let e of t){let r=document.getElementsByClassName(e)[0];r&&r.style&&(r.style.display="none")}}var YO={};function Z7(t){if(!YO[t]){let e=document.createElement("script");e.type="text/javascript",e.src=t,document.querySelector("head").appendChild(e),YO[t]=new Promise(n=>{e.onload=n})}return YO[t]}var $7="4.2.1";var qme=globalThis.loaders?.parseImageNode,KO=typeof Image<"u",ZO=typeof ImageBitmap<"u",Gme=Boolean(qme),$O=Fp?!0:Gme;function Q7(t){switch(t){case"auto":return ZO||KO||$O;case"imagebitmap":return ZO;case"image":return KO;case"data":return $O;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function J7(){if(ZO)return"imagebitmap";if(KO)return"image";if($O)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function ej(t){let e=Xme(t);if(!e)throw new Error("Not an image");return e}function kv(t){switch(ej(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 Xme(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 Yme=/^data:image\/svg\+xml/,Kme=/\.svg((\?|#).*)?$/;function xM(t){return t&&(Yme.test(t)||Kme.test(t))}function tj(t,e){if(xM(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return QO(t,e)}function QO(t,e){if(xM(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function vM(t,e,r){let n=tj(t,r),i=self.URL||self.webkitURL,o=typeof n!="string"&&i.createObjectURL(n);try{return await Zme(o||n,e)}finally{o&&i.revokeObjectURL(o)}}async function Zme(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,i)=>{try{r.onload=()=>n(r),r.onerror=o=>{let s=o instanceof Error?o.message:"error";i(new Error(s))}}catch(o){i(o)}})}var $me={},rj=!0;async function nj(t,e,r){let n;xM(r)?n=await vM(t,e,r):n=QO(t,r);let i=e&&e.imagebitmap;return await Qme(n,i)}async function Qme(t,e=null){if((Jme(e)||!rj)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),rj=!1}return await createImageBitmap(t)}function Jme(t){for(let e in t||$me)return!1;return!0}function ij(t){return!nAe(t,"ftyp",4)||!(t[8]&96)?null:eAe(t)}function eAe(t){switch(tAe(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function tAe(t,e,r){return String.fromCharCode(...t.slice(e,r))}function rAe(t){return[...t].map(e=>e.charCodeAt(0))}function nAe(t,e,r=0){let n=rAe(e);for(let i=0;i<n.length;++i)if(n[i]!==t[i+r])return!1;return!0}var Uf=!1,Fv=!0;function QA(t){let e=zv(t);return oAe(e)||cAe(e)||sAe(e)||aAe(e)||iAe(e)}function iAe(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=ij(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function oAe(t){let e=zv(t);return e.byteLength>=24&&e.getUint32(0,Uf)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Uf),height:e.getUint32(20,Uf)}:null}function sAe(t){let e=zv(t);return e.byteLength>=10&&e.getUint32(0,Uf)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Fv),height:e.getUint16(8,Fv)}:null}function aAe(t){let e=zv(t);return e.byteLength>=14&&e.getUint16(0,Uf)===16973&&e.getUint32(2,Fv)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Fv),height:e.getUint32(22,Fv)}:null}function cAe(t){let e=zv(t);if(!(e.byteLength>=3&&e.getUint16(0,Uf)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:i}=lAe(),o=2;for(;o+9<e.byteLength;){let s=e.getUint16(o,Uf);if(i.has(s))return{mimeType:"image/jpeg",height:e.getUint16(o+5,Uf),width:e.getUint16(o+7,Uf)};if(!n.has(s))return null;o+=2,o+=e.getUint16(o,Uf)}return null}function lAe(){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 zv(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 oj(t,e){let{mimeType:r}=QA(t)||{},n=globalThis.loaders?.parseImageNode;return Ti(n),await n(t,r)}async function sj(t,e,r){e=e||{};let i=(e.image||{}).type||"auto",{url:o}=r||{},s=uAe(i),c;switch(s){case"imagebitmap":c=await nj(t,e,o);break;case"image":c=await vM(t,e,o);break;case"data":c=await oj(t,e);break;default:Ti(!1)}return i==="data"&&(c=kv(c)),c}function uAe(t){switch(t){case"auto":case"data":return J7();default:return Q7(t),t}}var hAe=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],fAe=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],pAe={image:{type:"auto",decode:!0}},Vf={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:$7,mimeTypes:fAe,extensions:hAe,parse:sj,tests:[t=>Boolean(QA(new DataView(t)))],options:pAe};var JO={};function eB(t){if(JO[t]===void 0){let e=Fp?mAe(t):dAe(t);JO[t]=e}return JO[t]}function dAe(t){let e=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||e,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&r.includes(t)}function mAe(t){switch(t){case"image/avif":case"image/webp":return AAe(t);default:return!0}}function AAe(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}var gAe=new Dl({id:"deck"}),br=gAe;var tB={};function aj(t){tB=t}function Gs(t,e,r,n){br.level>0&&tB[t]&&tB[t].call(null,e,r,n)}function _Ae(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var cj={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:_Ae,parseTextSync:JSON.parse};function yAe(){let t="9.1.8",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(br.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:br,_registerLoggers:aj},qA([cj,[Vf,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var bM=yAe();function wM(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var rB={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 uj(t){let e={};for(let[r,n]of Object.entries(t))e[r]=xAe(n);return e}function xAe(t){let e=lj(t);if(e!=="object")return{value:t,...rB[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...rB[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=lj(t.value),{...t,...rB[e],type:e}):{type:"object",value:null};throw new Error("props")}function lj(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var hj=`#ifdef MODULE_LOGDEPTH
552
552
  logdepth_adjustPosition(gl_Position);
553
553
  #endif
554
554
  `,fj=`#ifdef MODULE_MATERIAL
@@ -2587,7 +2587,7 @@ ${Hye}
2587
2587
 
2588
2588
  // use picking color if rendering to picking FBO.
2589
2589
  color = picking_filterPickingColor(color);
2590
- `}}};var Jye=[aS],e1e=["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)"],t1e=[];function ES(t){let e=sm.getDefaultShaderAssembler();for(let n of Jye)e.addDefaultModule(n);let r=t==="glsl"?e1e:t1e;for(let n of r)e.addShaderHook(n);return e}var r1e=[255,255,255],n1e=1,i1e=0,oy=class{constructor(e={}){this.type="ambient";let{color:r=r1e}=e,{intensity:n=n1e}=e;this.id=e.id||`ambient-${i1e++}`,this.color=r,this.intensity=n}};var o1e=[255,255,255],s1e=1,a1e=[0,0,-1],c1e=0,Kp=class{constructor(e={}){this.type="directional";let{color:r=o1e}=e,{intensity:n=s1e}=e,{direction:i=a1e}=e,{_shadow:o=!1}=e;this.id=e.id||`directional-${c1e++}`,this.color=r,this.intensity=n,this.type="directional",this.direction=new ur(i).normalize().toArray(),this.shadow=o}getProjectedLight(e){return this}};var a0=class{constructor(e,r={id:"pass"}){let{id:n}=r;this.id=n,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var Bh=class extends a0{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[r,n]=this.device.canvasContext.getDrawingBufferSize(),i=e.clearCanvas??!0,o=e.clearColor??(i?[0,0,0,0]:!1),s=i?1:!1,c=i?0:!1,l=e.colorMask??15,h={viewport:[0,0,r,n]};e.colorMask&&(h.colorMask=l),e.scissorRect&&(h.scissorRect=e.scissorRect);let p=this.device.beginRenderPass({framebuffer:e.target,parameters:h,clearColor:o,clearDepth:s,clearStencil:c});try{return this._drawLayers(p,e)}finally{p.end(),this.device.submit()}}_drawLayers(e,r){let{target:n,shaderModuleProps:i,viewports:o,views:s,onViewportActive:c,clearStack:l=!0}=r;r.pass=r.pass||"unknown",l&&(this._lastRenderIndex=-1);let h=[];for(let p of o){let x=s&&s[p.id];c?.(p);let w=this._getDrawLayerParams(p,r),E=p.subViewports||[p];for(let C of E){let B=this._drawLayersInViewport(e,{target:n,shaderModuleProps:i,viewport:C,view:x,pass:r.pass,layers:r.layers},w);h.push(B)}}return h}_getDrawLayerParams(e,{layers:r,pass:n,isPicking:i=!1,layerFilter:o,cullRect:s,effects:c,shaderModuleProps:l},h=!1){let p=[],x=IW(this._lastRenderIndex+1),w={layer:r[0],viewport:e,isPicking:i,renderPass:n,cullRect:s},E={};for(let C=0;C<r.length;C++){let B=r[C],D=this._shouldDrawLayer(B,w,o,E),W={shouldDrawLayer:D};D&&!h&&(W.shouldDrawLayer=!0,W.layerRenderIndex=x(B,D),W.shaderModuleProps=this._getShaderModuleProps(B,c,n,l),W.layerParameters={...B.context.deck?.props.parameters,...this.getLayerParameters(B,C,e)}),p[C]=W}return p}_drawLayersInViewport(e,{layers:r,shaderModuleProps:n,pass:i,target:o,viewport:s,view:c},l){let h=l1e(this.device,{shaderModuleProps:n,target:o,viewport:s});if(c&&c.props.clear){let x=c.props.clear===!0?{color:!0,depth:!0}:c.props.clear;this.device.beginRenderPass({framebuffer:o,parameters:{viewport:h,scissorRect:h},clearColor:x.color?[0,0,0,0]:!1,clearDepth:x.depth?1:!1}).end()}let p={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:h});for(let x=0;x<r.length;x++){let w=r[x],E=l[x],{shouldDrawLayer:C}=E;if(C&&w.props.pickable&&p.pickableCount++,w.isComposite&&p.compositeCount++,w.isDrawable&&E.shouldDrawLayer){let{layerRenderIndex:B,shaderModuleProps:D,layerParameters:W}=E;p.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,B),D.project&&(D.project.viewport=s),w.context.renderPass=e;try{w._drawLayer({renderPass:e,shaderModuleProps:D,uniforms:{layerIndex:B},parameters:W})}catch(X){w.raiseError(X,`drawing ${w} to ${i}`)}}}return p}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,n){return null}getLayerParameters(e,r,n){return e.props.parameters}_shouldDrawLayer(e,r,n,i){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let s=e.parent;for(;s;){if(!s.props.visible||!s.filterSubLayer(r))return!1;r.layer=s,s=s.parent}if(n){let c=r.layer.id;if(c in i||(i[c]=n(r)),!i[c])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,n,i){let o=this.device.canvasContext.cssToDeviceRatio(),s=e.internalState?.propsInTransition||e.props,c={layer:s,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:o,modelMatrix:s.modelMatrix,coordinateSystem:s.coordinateSystem,coordinateOrigin:s.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let l of r)PW(c,l.getShaderModuleProps?.(e,c));return PW(c,this.getShaderModuleProps(e,r,c),i)}};function IW(t=0,e={}){let r={},n=(i,o)=>{let s=i.props._offset,c=i.id,l=i.parent&&i.parent.id,h;if(l&&!(l in e)&&n(i.parent,!1),l in r){let p=r[l]=r[l]||IW(e[l],e);h=p(i,o),r[c]=p}else Number.isFinite(s)?(h=s+(e[l]||0),r[c]=null):h=t;return o&&h>=t&&(t=h+1),e[c]=h,h};return n}function l1e(t,{shaderModuleProps:e,target:r,viewport:n}){let i=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,o]=t.canvasContext.getDrawingBufferSize(),s=r?r.height:o,c=n;return[c.x*i,s-(c.y+c.height)*i,c.width*i,c.height*i,0,1]}function PW(t,...e){for(let r of e)if(r)for(let n in r)t[n]?Object.assign(t[n],r[n]):t[n]=r[n];return t}var g2=class extends Bh{constructor(e,r){super(e,r);let n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},mipmaps:!0}),i=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:i})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),i=e.viewports[0],o=i.width*n,s=i.height*n,c=[1,1,1,1];(o!==r.width||s!==r.height)&&r.resize({width:o,height:s}),super.render({...e,clearColor:c,target:r,pass:"shadow"})}getLayerParameters(e,r,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}};var u1e={color:[255,255,255],intensity:1},RW=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],h1e=[0,0,0,200/255],ym=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=h1e,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),n._addDefaultShaderModule(iy),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let n=e[r];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n);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:n,onViewportActive:i,views:o}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:r,viewports:n,onViewportActive:i,views:o,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let n=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(s=>s.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},i={enabled:!0,ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(s=>s.getProjectedLight({layer:e})),pointLights:this.pointLights.map(s=>s.getProjectedLight({layer:e}))},o=e.props.material;return{shadow:n,lighting:i,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(iy))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let n=new zn().lookAt({eye:new ur(r.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let n=new g2(e);this.shadowPasses[r]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:n}=this;!e&&r.length===0&&n.length===0&&(this.ambientLight=new oy(u1e),this.directionalLights.push(new Kp(RW[0]),new Kp(RW[1])))}};var iD=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:n=1,type:i,padding:o=0,copy:s=!1,initialize:c=!1,maxCount:l}){let h=i||e&&e.constructor||Float32Array,p=r*n+o;if(ArrayBuffer.isView(e)){if(p<=e.length)return e;if(p*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new h(e.buffer,0,p)}let x=1/0;l&&(x=l*n+o);let w=this._allocate(h,p,c,x);return e&&s?w.set(e):c||w.fill(0,0,4),this._release(e),w}release(e){this._release(e)}_allocate(e,r,n,i){let o=Math.max(Math.ceil(r*this.opts.overAlloc),1);o>i&&(o=i);let s=this._pool,c=e.BYTES_PER_ELEMENT*o,l=s.findIndex(h=>h.byteLength>=c);if(l>=0){let h=new e(s.splice(l,1)[0],0,o);return n&&h.fill(0),h}return new e(o)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:n}=e,{byteLength:i}=n,o=r.findIndex(s=>s.byteLength>=i);o<0?r.push(n):(o>0||r.length<this.opts.poolSize)&&r.splice(o,0,n),r.length>this.opts.poolSize&&r.shift()}},Dh=new iD;function ay(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function c0(t,e){let r=t%e;return r<0?e+r:r}function OW(t){return[t[12],t[13],t[14]]}function BW(t){return{left:sy(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:sy(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:sy(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:sy(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:sy(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:sy(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var LW=new ur;function sy(t,e,r,n){LW.set(t,e,r);let i=LW.len();return{distance:n/i,normal:new ur(-t/i,-e/i,-r/i)}}function oD(t){return t-Math.fround(t)}var _2;function MS(t,e){let{size:r=1,startIndex:n=0}=e,i=e.endIndex!==void 0?e.endIndex:t.length,o=(i-n)/r;_2=Dh.allocate(_2,o,{type:Float32Array,size:r*2});let s=n,c=0;for(;s<i;){for(let l=0;l<r;l++){let h=t[s++];_2[c+l]=h,_2[c+l+r]=oD(h)}c+=r*2}return _2.subarray(0,o*r*2)}function DW(t){let e=null,r=!1;for(let n of t)n&&(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],n[0][0]),e[0][1]=Math.min(e[0][1],n[0][1]),e[1][0]=Math.max(e[1][0],n[1][0]),e[1][1]=Math.max(e[1][1],n[1][1])):e=n);return e}var f1e=Math.PI/180,p1e=ay(),NW=[0,0,0],d1e={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function m1e({width:t,height:e,orthographic:r,fovyRadians:n,focalDistance:i,padding:o,near:s,far:c}){let l=t/e,h=r?new zn().orthographic({fovy:n,aspect:l,focalDistance:i,near:s,far:c}):new zn().perspective({fovy:n,aspect:l,near:s,far:c});if(o){let{left:p=0,right:x=0,top:w=0,bottom:E=0}=o,C=ro((p+t-x)/2,0,t)-t/2,B=ro((w+e-E)/2,0,e)-e/2;h[8]-=C*2/t,h[9]+=B*2/e}return h}var cy=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||d1e,this.focalDistance=e.focalDistance||1,this.position=e.position||NW,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&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?Fa.WEB_MERCATOR:Fa.WEB_MERCATOR_AUTO_OFFSET:Fa.IDENTITY}equals(e){return e instanceof cy?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&ka(e.projectionMatrix,this.projectionMatrix)&&ka(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let n=this.projectPosition(e),i=ny(n,this.pixelProjectionMatrix),[o,s]=i,c=r?s:this.height-s;return e.length===2?[o,c]:[o,c,i[2]]}unproject(e,{topLeft:r=!0,targetZ:n}={}){let[i,o,s]=e,c=r?o:this.height-o,l=n&&n*this.distanceScales.unitsPerMeter[2],h=Zu([i,c,s],this.pixelUnprojectionMatrix,l),[p,x,w]=this.unprojectPosition(h);return Number.isFinite(s)?[p,x,w]:Number.isFinite(n)?[p,x,n]:[p,x]}projectPosition(e){let[r,n]=this.projectFlat(e),i=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,n,i]}unprojectPosition(e){let[r,n]=this.unprojectFlat(e),i=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,n,i]}projectFlat(e){if(this.isGeospatial){let r=za(e);return r[1]=ro(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?Ec(e):e}getBounds(e={}){let r={targetZ:e.z||0},n=this.unproject([0,0],r),i=this.unproject([this.width,0],r),o=this.unproject([0,this.height],r),s=this.unproject([this.width,this.height],r);return[Math.min(n[0],i[0],o[0],s[0]),Math.min(n[1],i[1],o[1],s[1]),Math.max(n[0],i[0],o[0],s[0]),Math.max(n[1],i[1],o[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?ry({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:n=1,height:i=1}){return e<this.x+this.width&&this.x<e+n&&r<this.y+this.height&&this.y<r+i}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,BW(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r){return null}_initProps(e){let r=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=d2({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||ry({latitude:n,longitude:r}));let i=Math.pow(2,this.zoom);this.scale=i;let{position:o,modelMatrix:s}=e,c=NW;if(o&&(c=s?new zn(s).transformAsVector(o,[]):o),this.isGeospatial){let l=this.projectPosition([r,n,0]);this.center=new ur(c).scale(this.distanceScales.unitsPerMeter).add(l)}else this.center=this.projectPosition(c)}_initMatrices(e){let{viewMatrix:r=p1e,projectionMatrix:n=null,orthographic:i=!1,fovyRadians:o,fovy:s=75,near:c=.1,far:l=1e3,padding:h=null,focalDistance:p=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new zn().multiplyRight(r).translate(new ur(this.center).negate()),this.projectionMatrix=n||m1e({width:this.width,height:this.height,orthographic:i,fovyRadians:o||s*f1e,focalDistance:p,padding:h,near:c,far:l});let x=ay();Xs.multiply(x,x,this.projectionMatrix),Xs.multiply(x,x,this.viewMatrix),this.viewProjectionMatrix=x,this.viewMatrixInverse=Xs.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=OW(this.viewMatrixInverse);let w=ay(),E=ay();Xs.scale(w,w,[this.width/2,-this.height/2,1]),Xs.translate(w,w,[1,-1,0]),Xs.multiply(E,w,this.viewProjectionMatrix),this.pixelProjectionMatrix=E,this.pixelUnprojectionMatrix=Xs.invert(ay(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||br.warn("Pixel project matrix not invertible")()}};cy.displayName="Viewport";var wa=cy;var l0=class extends wa{constructor(e={}){let{latitude:r=0,longitude:n=0,zoom:i=0,pitch:o=0,bearing:s=0,nearZMultiplier:c=.1,farZMultiplier:l=1.01,nearZ:h,farZ:p,orthographic:x=!1,projectionMatrix:w,repeat:E=!1,worldOffset:C=0,position:B,padding:D,legacyMeterSizes:W=!1}=e,{width:X,height:q,altitude:$=1.5}=e,te=Math.pow(2,i);X=X||1,q=q||1;let F,ue=null;if(w)$=w[5]/2,F=Xp($);else{e.fovy?(F=e.fovy,$=Yp(F)):F=Xp($);let J;if(D){let{top:G=0,bottom:me=0}=D;J=[0,ro((G+q-me)/2,0,q)-q/2]}ue=eD({width:X,height:q,scale:te,center:B&&[0,0,B[2]*m2(r)],offset:J,pitch:o,fovy:F,nearZMultiplier:c,farZMultiplier:l}),Number.isFinite(h)&&(ue.near=h),Number.isFinite(p)&&(ue.far=p)}let oe=bS({height:q,pitch:o,bearing:s,scale:te,altitude:$});C&&(oe=new zn().translate([512*C,0,0]).multiplyLeft(oe)),super({...e,width:X,height:q,viewMatrix:oe,longitude:n,latitude:r,zoom:i,...ue,fovy:F,focalDistance:$}),this.latitude=r,this.longitude=n,this.zoom=i,this.pitch=o,this.bearing=s,this.altitude=$,this.fovy=F,this.orthographic=x,this._subViewports=E?[]:null,this._pseudoMeters=W,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),n=Math.ceil((e[2]-180)/360);for(let i=r;i<=n;i++){let o=i?new l0({...this,worldOffset:i}):this;this._subViewports.push(o)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,n]=this.projectFlat(e),i=(e[2]||0)*m2(e[1]);return[r,n,i]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,n]=this.unprojectFlat(e),i=(e[2]||0)/m2(n);return[r,n,i]}addMetersToLngLat(e,r){return A2(e,r)}panByPosition(e,r){let n=Zu(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),o=ba.add([],i,ba.negate([],n)),s=ba.add([],this.center,o),[c,l]=this.unprojectFlat(s);return{longitude:c,latitude:l}}getBounds(e={}){let r=TS(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:n,height:i}=this,{longitude:o,latitude:s,zoom:c}=wS({width:n,height:i,bounds:e,...r});return new l0({width:n,height:i,longitude:o,latitude:s,zoom:c})}};l0.displayName="WebMercatorViewport";var Uc=l0;var kW=[0,0,0];function sD(t,e,r=!1){let n=e.projectPosition(t);if(r&&e instanceof Uc){let[i,o,s=0]=t,c=e.getDistanceScales([i,o]);n[2]=s*c.unitsPerMeter[2]}return n}function A1e(t){let{viewport:e,modelMatrix:r,coordinateOrigin:n}=t,{coordinateSystem:i,fromCoordinateSystem:o,fromCoordinateOrigin:s}=t;return i===Hr.DEFAULT&&(i=e.isGeospatial?Hr.LNGLAT:Hr.CARTESIAN),o===void 0&&(o=i),s===void 0&&(s=n),{viewport:e,coordinateSystem:i,coordinateOrigin:n,modelMatrix:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}}function aD(t,{viewport:e,modelMatrix:r,coordinateSystem:n,coordinateOrigin:i,offsetMode:o}){let[s,c,l=0]=t;switch(r&&([s,c,l]=fl.transformMat4([],[s,c,l,1],r)),n){case Hr.LNGLAT:return sD([s,c,l],e,o);case Hr.LNGLAT_OFFSETS:return sD([s+i[0],c+i[1],l+(i[2]||0)],e,o);case Hr.METER_OFFSETS:return sD(A2(i,[s,c,l]),e,o);case Hr.CARTESIAN:default:return e.isGeospatial?[s+i[0],c+i[1],l+i[2]]:e.projectPosition([s,c,l])}}function SS(t,e){let{viewport:r,coordinateSystem:n,coordinateOrigin:i,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:c}=A1e(e),{autoOffset:l=!0}=e,{geospatialOrigin:h=kW,shaderCoordinateOrigin:p=kW,offsetMode:x=!1}=l?Z4(r,n,i):{},w=aD(t,{viewport:r,modelMatrix:o,coordinateSystem:s,coordinateOrigin:c,offsetMode:x});if(x){let E=r.projectPosition(h||p);zc.sub(w,w,E)}return w}var g1e=[255,255,255],_1e=1,y1e=[1,0,0],x1e=[0,0,1],v1e=0,ly=class{constructor(e={}){this.type="point";let{color:r=g1e}=e,{intensity:n=_1e}=e,{position:i=x1e}=e;this.id=e.id||`point-${v1e++}`,this.color=r,this.intensity=n,this.type="point",this.position=i,this.attenuation=b1e(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,n=e.context.viewport,{coordinateSystem:i,coordinateOrigin:o}=e.props,s=SS(this.position,{viewport:n,coordinateSystem:i,coordinateOrigin:o,fromCoordinateSystem:n.isGeospatial?Hr.LNGLAT:Hr.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=s,r}};function b1e(t){return t.attenuation?t.attenuation:y1e}var y2=class extends ly{getProjectedLight({layer:e}){let{projectedLight:r}=this,n=e.context.viewport,{coordinateSystem:i,coordinateOrigin:o,modelMatrix:s}=e.props,{cameraPosition:c}=yS({viewport:n,modelMatrix:s,coordinateSystem:i,coordinateOrigin:o});return r.color=this.color,r.intensity=this.intensity,r.position=c,r}};var u0=Math.PI/180,w1e=1e3*60*60*24,T1e=2440588,E1e=2451545,CS=u0*23.4397,M1e=357.5291,S1e=.98560028,C1e=280.147,P1e=360.9856235;function FW(t,e,r){let n=u0*-r,i=u0*e,o=R1e(t),s=z1e(o),c=N1e(o,n)-s.rightAscension;return{azimuth:B1e(c,i,s.declination),altitude:D1e(c,i,s.declination)}}function PS(t,e,r){let{azimuth:n,altitude:i}=FW(t,e,r);return[Math.sin(n)*Math.cos(i),Math.cos(n)*Math.cos(i),-Math.sin(i)]}function I1e(t){return(typeof t=="number"?t:t.getTime())/w1e-.5+T1e}function R1e(t){return I1e(t)-E1e}function L1e(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(CS)-Math.tan(e)*Math.sin(CS),Math.cos(r))}function O1e(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(CS)+Math.cos(e)*Math.sin(CS)*Math.sin(r))}function B1e(t,e,r){let n=t,i=e,o=r;return Math.atan2(Math.sin(n),Math.cos(n)*Math.sin(i)-Math.tan(o)*Math.cos(i))}function D1e(t,e,r){let n=t,i=e,o=r;return Math.asin(Math.sin(i)*Math.sin(o)+Math.cos(i)*Math.cos(o)*Math.cos(n))}function N1e(t,e){return u0*(C1e+P1e*t)-e}function k1e(t){return u0*(M1e+S1e*t)}function F1e(t){let e=t,r=u0*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),n=u0*102.9372;return e+r+n+Math.PI}function z1e(t){let e=k1e(t),r=F1e(e);return{declination:O1e(r,0),rightAscension:L1e(r,0)}}var x2=class extends Kp{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[i,o,s]=PS(this.timestamp,0,0);this.direction=[i,-s,o]}else{let{latitude:i,longitude:o}=r;this.direction=PS(this.timestamp,i,o)}return this}};var U1e=1,V1e=1,h0=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:n=Number.POSITIVE_INFINITY,rate:i=1,repeat:o=1}=e,s=U1e++,c={time:0,delay:r,duration:n,rate:i,repeat:o};return this._setChannelTime(c,this.time),this.channels.set(s,c),s}removeChannel(e){this.channels.delete(e);for(let[r,n]of this.animations)n.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let i of r)this._setChannelTime(i,this.time);let n=this.animations.values();for(let i of n){let{animation:o,channel:s}=i;o.setTime(this.getTime(s))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let n=V1e++;return this.animations.set(n,{animation:e,channel:r}),e.setTime(this.getTime(r)),n}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 n=r-e.delay,i=e.duration*e.repeat;n>=i?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}};function zW(t){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,1e3/60)}function UW(t){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(t):clearTimeout(t)}var j1e=0,H1e={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:Lf.stats.get(`animation-loop-${j1e++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},v2=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;constructor(e){if(this.props={...H1e,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=e.stats||new Nc({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:r}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setError(e){if(this.props.onError(e),this._error=Error(),this.device?.canvasContext?.canvas instanceof HTMLCanvasElement){let n=document.createElement("h1");n.innerHTML=e.message,n.style.position="absolute",n.style.top="20%",n.style.left="10px",n.style.color="black",n.style.backgroundColor="red",document.body.appendChild(n)}}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||this._error?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=zW(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(UW(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.canvasContext?.canvas;if(!this.device||!e)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:e,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let n=this.props.onAddHTML(r);n&&(r.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device?.canvasContext?.getPixelSize()||[1,1],n=1,i=this.device?.canvasContext?.canvas;return i&&i.clientHeight?n=i.clientWidth/i.clientHeight:e>0&&r>0&&(n=e/r),{width:e,height:r,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var cD={};function Vc(t="id"){cD[t]=cD[t]||1;let e=cD[t]++;return`${t}-${e}`}var IS=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Vc("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&Fn.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 VW(t,e){if(e instanceof IS)return e;let r=W1e(t,e),{attributes:n,bufferLayout:i}=q1e(t,e);return new IS({topology:e.topology||"triangle-list",bufferLayout:i,vertexCount:e.vertexCount,indices:r,attributes:n})}function W1e(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:Fn.INDEX,data:r})}function q1e(t,e){let r=[],n={};for(let[o,s]of Object.entries(e.attributes)){let c=o;switch(o){case"POSITION":c="positions";break;case"NORMAL":c="normals";break;case"TEXCOORD_0":c="texCoords";break;case"COLOR_0":c="colors";break}if(s){n[c]=t.createBuffer({data:s.value,id:`${o}-buffer`});let{value:l,size:h,normalized:p}=s;r.push({name:c,format:IO(l,h,p)})}}let i=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:r,vertexCount:i}}var lD=class{static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new lD(e),e._lumaData.defaultPipelineFactory}device;destroyPolicy;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};constructor(e){this.device=e,this.destroyPolicy=e.props._factoryDestroyPolicy}createRenderPipeline(e){let r={...Mh.defaultProps,...e},n=this._hashRenderPipeline(r);if(!this._renderPipelineCache[n]){let i=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=n,this._renderPipelineCache[n]={pipeline:i,useCount:0}}return this._renderPipelineCache[n].useCount++,this._renderPipelineCache[n].pipeline}createComputePipeline(e){let r={...XA.defaultProps,...e},n=this._hashComputePipeline(r);if(!this._computePipelineCache[n]){let i=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=n,this._computePipelineCache[n]={pipeline:i,useCount:0}}return this._computePipelineCache[n].useCount++,this._computePipelineCache[n].pipeline}release(e){let r=e.hash,n=e instanceof XA?this._computePipelineCache:this._renderPipelineCache;n[r].useCount--,n[r].useCount===0&&this.destroyPolicy==="unused"&&(n[r].pipeline.destroy(),delete n[r])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,i="-",o=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${n}V${i}BL${o}`;default:let s=this._getHash(JSON.stringify(e.parameters));return`${r}/${n}V${i}T${e.topology}P${s}BL${o}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},b2=lD;Vr(b2,"defaultProps",{...Mh.defaultProps});var uD=class{static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new uD(e),e._lumaData.defaultShaderFactory}device;destroyPolicy;_cache={};constructor(e){this.device=e,this.destroyPolicy=e.props._factoryDestroyPolicy}createShader(e){let r=this._hashShader(e),n=this._cache[r];if(!n){let i=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=n={shader:i,useCount:0}}return n.useCount++,n.shader}release(e){let r=this._hashShader(e),n=this._cache[r];n&&(n.useCount--,n.useCount===0&&this.destroyPolicy==="unused"&&(delete this._cache[r],n.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}},w2=uD;Vr(w2,"defaultProps",{...im.defaultProps});function jW(t,e){let r={},n="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(let i of t.attributes)if(i){let o=`${i.location} ${i.name}: ${i.type}`;r[`in ${o}`]={[n]:i.stepMode||"vertex"}}for(let i of t.varyings||[]){let o=`${i.location} ${i.name}`;r[`out ${o}`]={[n]:JSON.stringify(i)}}return r}var nc=null,hD=null;function HW(t,{id:e,minimap:r,opaque:n,top:i="0",left:o="0",rgbaScale:s=1}){nc||(nc=document.createElement("canvas"),nc.id=e,nc.title=e,nc.style.zIndex="100",nc.style.position="absolute",nc.style.top=i,nc.style.left=o,nc.style.border="blue 5px solid",nc.style.transform="scaleY(-1)",document.body.appendChild(nc),hD=nc.getContext("2d")),(nc.width!==t.width||nc.height!==t.height)&&(nc.width=t.width/2,nc.height=t.height/2,nc.style.width="400px",nc.style.height="400px");let c=t.device.readPixelsToArrayWebGL(t),l=hD?.createImageData(t.width,t.height);if(l){for(let p=0;p<c.length;p+=4)l.data[0+p+0]=c[p+0]*s,l.data[0+p+1]=c[p+1]*s,l.data[0+p+2]=c[p+2]*s,l.data[0+p+3]=n?255:c[p+3]*s;hD?.putImageData(l,0,0)}}function RS(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 n=0;n<t.length;n++)if(!RS(t[n],e[n],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(let o of n)if(!e.hasOwnProperty(o)||!RS(t[o],e[o],r-1))return!1;return!0}return!1}function G1e(t){return Nv(t)||typeof t=="number"||typeof t=="boolean"}function LS(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];G1e(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}var OS=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let n=F_(Object.values(e).filter(i=>i.dependencies));for(let i of n)e[i.name]=i;qt.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[i,o]of Object.entries(e))this._addModule(o),o.name&&i!==o.name&&!this.options.disableWarnings&&qt.warn(`Module name: ${i} vs ${o.name}`)()}destroy(){}setProps(e){for(let r of Object.keys(e)){let n=r,i=e[n]||{},o=this.modules[n];if(!o){this.options.disableWarnings||qt.warn(`Module ${r} not found`)();continue}let s=this.moduleUniforms[n],c=this.moduleBindings[n],l=o.getUniforms?.(i,s)||i,{uniforms:h,bindings:p}=LS(l);this.moduleUniforms[n]={...s,...h},this.moduleBindings[n]={...c,...p}}}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,n]of Object.entries(this.moduleUniforms))for(let[i,o]of Object.entries(n))e[`${r}.${i}`]={type:this.modules[r].uniformTypes?.[i],value:String(o)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=e.defaultUniforms||{},this.moduleBindings[r]={}}};var X1e="";async function WW(t,e){let r=new Image;return r.crossOrigin=e?.crossOrigin||"anonymous",r.src=t.startsWith("http")?t:X1e+t,await r.decode(),e?await createImageBitmap(r,e):await createImageBitmap(r)}var uy=class{device;id;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(e,r){this.device=e,this.id=r.id||Vc("async-texture"),typeof r?.data=="string"&&r.dimension==="2d"&&(r={...r,data:WW(r.data)}),this.ready=new Promise((n,i)=>{this.resolveReady=()=>{this.isReady=!0,n()},this.rejectReady=i}),this.initAsync(r)}async initAsync(e){let r,n,i=e.data,o=await qW(i).then(r,n);if(this.destroyed)return;let s={...e,data:o};this.texture=this.device.createTexture(s),this.sampler=this.texture.sampler,this.view=this.texture.view,this.isReady=!0}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){let r=this.texture;this.texture=r.clone(e),r.destroy()}return!0}};async function qW(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(qW));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e)),n=Object.keys(e),i={};for(let o=0;o<n.length;o++)i[n[o]]=r[o];return i}return t}var f0=2,Y1e=1e4,pD=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...pD.defaultProps,...r},r=this.props,this.id=r.id||Vc("model"),this.device=e,Object.assign(this.userData,r.userData);let n=Object.fromEntries(this.props.modules?.map(l=>[l.name,l])||[]),i=r.shaderInputs||new OS(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);let o=Z1e(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:l,getUniforms:h}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:o,...this.props,modules:s});this.source=l,this._getModuleUniforms=h,this.props.shaderLayout||=WB(this.source)}else{let{vs:l,fs:h,getUniforms:p}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:o,...this.props,modules:s});this.vs=l,this.fs=h,this._getModuleUniforms=p}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||b2.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||w2.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniformsWebGL(r.uniforms),r.moduleSettings&&this.updateModuleSettingsWebGL(r.moduleSettings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return qt.info(f0,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let i=this._getBindings();this.pipeline.setBindings(i,{disableWarnings:this.props.disableWarnings}),fD(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:o}=this.vertexArray,s=o?o.byteLength/(o.indexType==="uint32"?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",n}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&VW(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let n=new YA(this.bufferLayout);this.bufferLayout=n.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 YA(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({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){RS(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 Iv(this.shaderInputs.modules);for(let[r,n]of Object.entries(this.shaderInputs.modules))if(K1e(n)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}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 n=r?.disableWarnings??this.props.disableWarnings;e.indices&&qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();let i=new YA(this.bufferLayout);for(let[o,s]of Object.entries(e)){let c=i.getBufferLayout(o);if(!c){n||qt.warn(`Model(${this.id}): Missing layout for buffer "${o}".`)();continue}let l=i.getAttributeNamesForBuffer(c),h=!1;for(let p of l){let x=this._attributeInfos[p];x&&(this.vertexArray.setBuffer(x.location,s),h=!0)}!h&&!n&&qt.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${o}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[n,i]of Object.entries(e)){let o=this._attributeInfos[n];o?this.vertexArray.setConstantWebGL(o.location,i):(r?.disableWarnings??this.props.disableWarnings)||qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){this.setUniformsWebGL(e)}setUniformsWebGL(e){fD(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettingsWebGL(e){let{bindings:r,uniforms:n}=LS(this._getModuleUniforms(e));Object.assign(this.bindings,r),Object.assign(this.uniforms,n),this.setNeedsRedraw("moduleSettings")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof uy&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,n]of Object.entries(this.bindings))n instanceof uy?n.isReady&&(e[r]=n.texture):e[r]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof nm?e=Math.max(e,r.texture.updateTimestamp):r instanceof Fn||r instanceof fi?e=Math.max(e,r.updateTimestamp):r instanceof uy?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof om||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[n]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(i=>i.name===n)&&n!=="positions"&&delete r[n];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&&(qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),i=null;this.source?i=n:this.fs&&(i=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:n,fs:i}),this._attributeInfos=XE(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=qt.level>3?0:Y1e;qt.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,qt.group(f0,`>>> DRAWING MODEL ${this.id}`,{collapsed:qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=jW(this.pipeline.shaderLayout,this.id);qt.table(f0,e)();let r=this.shaderInputs.getDebugTable();for(let[i,o]of Object.entries(this.uniforms))r[i]={value:o};qt.table(f0,r)();let n=this._getAttributeDebugTable();qt.table(f0,this._attributeInfos)(),qt.table(f0,n)(),qt.groupEnd(f0)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let n=e.props.framebuffer;n&&HW(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,n]of Object.entries(this._attributeInfos)){let i=this.vertexArray.attributes[n.location];e[n.location]={name:r,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,n=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,r){let n=Rv(r);return(e instanceof Fn?new n(e.debugData):e).toString()}},jn=pD;Vr(jn,"defaultProps",{...Mh.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:sm.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function K1e(t){return Boolean(t.uniformTypes&&!fD(t.uniformTypes))}function Z1e(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function fD(t){for(let e in t)return!1;return!0}var BS=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=BS.defaultProps){if(!BS.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new jn(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||jv(),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 Fn)return r.readAsync();let{buffer:n,byteOffset:i=0,byteLength:o=n.byteLength}=r;return n.readAsync(i,o)}},hu=BS;Vr(hu,"defaultProps",{...jn.defaultProps,outputs:void 0,feedbackBuffers:void 0});var $1e="transform_output",xm=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 jn(this.device,{id:r.id||"texture-transform-model",fs:r.fs||jv({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:$1e}),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],n=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(n),n.end()}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:n,targetTexture:i}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,n),Object.assign(e.sourceBuffers,r),i){e.targetTexture=i;let{width:o,height:s}=i;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:o,height:s,colorAttachments:[i]}),e.framebuffer.resize({width:o,height:s})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let n in r)r[n].sampler=this.sampler}};var Si=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:n=null,vertexCount:i=null}=e;this.id=e.id||Vc("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[o,s]of Object.entries(r)){let c=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(c.value))throw new Error(`${this._print(o)}: must be typed array or object with value as typed array`);if((o==="POSITION"||o==="positions")&&!c.size&&(c.size=3),o==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=c}else this.attributes[o]=c}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let n=1/0;for(let i of Object.values(e)){let{value:o,size:s,constant:c}=i;!c&&o&&s!==void 0&&s>=1&&(n=Math.min(n,o.length/s))}return n}};var Q1e=`struct VertexInputs {
2590
+ `}}};var Jye=[aS],e1e=["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)"],t1e=[];function ES(t){let e=sm.getDefaultShaderAssembler();for(let n of Jye)e.addDefaultModule(n);let r=t==="glsl"?e1e:t1e;for(let n of r)e.addShaderHook(n);return e}var r1e=[255,255,255],n1e=1,i1e=0,oy=class{constructor(e={}){this.type="ambient";let{color:r=r1e}=e,{intensity:n=n1e}=e;this.id=e.id||`ambient-${i1e++}`,this.color=r,this.intensity=n}};var o1e=[255,255,255],s1e=1,a1e=[0,0,-1],c1e=0,Kp=class{constructor(e={}){this.type="directional";let{color:r=o1e}=e,{intensity:n=s1e}=e,{direction:i=a1e}=e,{_shadow:o=!1}=e;this.id=e.id||`directional-${c1e++}`,this.color=r,this.intensity=n,this.type="directional",this.direction=new ur(i).normalize().toArray(),this.shadow=o}getProjectedLight(e){return this}};var a0=class{constructor(e,r={id:"pass"}){let{id:n}=r;this.id=n,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var Bh=class extends a0{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[r,n]=this.device.canvasContext.getDrawingBufferSize(),i=e.clearCanvas??!0,o=e.clearColor??(i?[0,0,0,0]:!1),s=i?1:!1,c=i?0:!1,l=e.colorMask??15,h={viewport:[0,0,r,n]};e.colorMask&&(h.colorMask=l),e.scissorRect&&(h.scissorRect=e.scissorRect);let p=this.device.beginRenderPass({framebuffer:e.target,parameters:h,clearColor:o,clearDepth:s,clearStencil:c});try{return this._drawLayers(p,e)}finally{p.end(),this.device.submit()}}_drawLayers(e,r){let{target:n,shaderModuleProps:i,viewports:o,views:s,onViewportActive:c,clearStack:l=!0}=r;r.pass=r.pass||"unknown",l&&(this._lastRenderIndex=-1);let h=[];for(let p of o){let x=s&&s[p.id];c?.(p);let w=this._getDrawLayerParams(p,r),E=p.subViewports||[p];for(let C of E){let B=this._drawLayersInViewport(e,{target:n,shaderModuleProps:i,viewport:C,view:x,pass:r.pass,layers:r.layers},w);h.push(B)}}return h}_getDrawLayerParams(e,{layers:r,pass:n,isPicking:i=!1,layerFilter:o,cullRect:s,effects:c,shaderModuleProps:l},h=!1){let p=[],x=IW(this._lastRenderIndex+1),w={layer:r[0],viewport:e,isPicking:i,renderPass:n,cullRect:s},E={};for(let C=0;C<r.length;C++){let B=r[C],D=this._shouldDrawLayer(B,w,o,E),W={shouldDrawLayer:D};D&&!h&&(W.shouldDrawLayer=!0,W.layerRenderIndex=x(B,D),W.shaderModuleProps=this._getShaderModuleProps(B,c,n,l),W.layerParameters={...B.context.deck?.props.parameters,...this.getLayerParameters(B,C,e)}),p[C]=W}return p}_drawLayersInViewport(e,{layers:r,shaderModuleProps:n,pass:i,target:o,viewport:s,view:c},l){let h=l1e(this.device,{shaderModuleProps:n,target:o,viewport:s});if(c&&c.props.clear){let x=c.props.clear===!0?{color:!0,depth:!0}:c.props.clear;this.device.beginRenderPass({framebuffer:o,parameters:{viewport:h,scissorRect:h},clearColor:x.color?[0,0,0,0]:!1,clearDepth:x.depth?1:!1}).end()}let p={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:h});for(let x=0;x<r.length;x++){let w=r[x],E=l[x],{shouldDrawLayer:C}=E;if(C&&w.props.pickable&&p.pickableCount++,w.isComposite&&p.compositeCount++,w.isDrawable&&E.shouldDrawLayer){let{layerRenderIndex:B,shaderModuleProps:D,layerParameters:W}=E;p.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,B),D.project&&(D.project.viewport=s),w.context.renderPass=e;try{w._drawLayer({renderPass:e,shaderModuleProps:D,uniforms:{layerIndex:B},parameters:W})}catch(X){w.raiseError(X,`drawing ${w} to ${i}`)}}}return p}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,n){return null}getLayerParameters(e,r,n){return e.props.parameters}_shouldDrawLayer(e,r,n,i){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let s=e.parent;for(;s;){if(!s.props.visible||!s.filterSubLayer(r))return!1;r.layer=s,s=s.parent}if(n){let c=r.layer.id;if(c in i||(i[c]=n(r)),!i[c])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,n,i){let o=this.device.canvasContext.cssToDeviceRatio(),s=e.internalState?.propsInTransition||e.props,c={layer:s,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:o,modelMatrix:s.modelMatrix,coordinateSystem:s.coordinateSystem,coordinateOrigin:s.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let l of r)PW(c,l.getShaderModuleProps?.(e,c));return PW(c,this.getShaderModuleProps(e,r,c),i)}};function IW(t=0,e={}){let r={},n=(i,o)=>{let s=i.props._offset,c=i.id,l=i.parent&&i.parent.id,h;if(l&&!(l in e)&&n(i.parent,!1),l in r){let p=r[l]=r[l]||IW(e[l],e);h=p(i,o),r[c]=p}else Number.isFinite(s)?(h=s+(e[l]||0),r[c]=null):h=t;return o&&h>=t&&(t=h+1),e[c]=h,h};return n}function l1e(t,{shaderModuleProps:e,target:r,viewport:n}){let i=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,o]=t.canvasContext.getDrawingBufferSize(),s=r?r.height:o,c=n;return[c.x*i,s-(c.y+c.height)*i,c.width*i,c.height*i]}function PW(t,...e){for(let r of e)if(r)for(let n in r)t[n]?Object.assign(t[n],r[n]):t[n]=r[n];return t}var g2=class extends Bh{constructor(e,r){super(e,r);let n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},mipmaps:!0}),i=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:i})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),i=e.viewports[0],o=i.width*n,s=i.height*n,c=[1,1,1,1];(o!==r.width||s!==r.height)&&r.resize({width:o,height:s}),super.render({...e,clearColor:c,target:r,pass:"shadow"})}getLayerParameters(e,r,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}};var u1e={color:[255,255,255],intensity:1},RW=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],h1e=[0,0,0,200/255],ym=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=h1e,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),n._addDefaultShaderModule(iy),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let n=e[r];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n);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:n,onViewportActive:i,views:o}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:r,viewports:n,onViewportActive:i,views:o,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let n=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(s=>s.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},i={enabled:!0,ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(s=>s.getProjectedLight({layer:e})),pointLights:this.pointLights.map(s=>s.getProjectedLight({layer:e}))},o=e.props.material;return{shadow:n,lighting:i,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(iy))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let n=new zn().lookAt({eye:new ur(r.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let n=new g2(e);this.shadowPasses[r]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:n}=this;!e&&r.length===0&&n.length===0&&(this.ambientLight=new oy(u1e),this.directionalLights.push(new Kp(RW[0]),new Kp(RW[1])))}};var iD=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:n=1,type:i,padding:o=0,copy:s=!1,initialize:c=!1,maxCount:l}){let h=i||e&&e.constructor||Float32Array,p=r*n+o;if(ArrayBuffer.isView(e)){if(p<=e.length)return e;if(p*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new h(e.buffer,0,p)}let x=1/0;l&&(x=l*n+o);let w=this._allocate(h,p,c,x);return e&&s?w.set(e):c||w.fill(0,0,4),this._release(e),w}release(e){this._release(e)}_allocate(e,r,n,i){let o=Math.max(Math.ceil(r*this.opts.overAlloc),1);o>i&&(o=i);let s=this._pool,c=e.BYTES_PER_ELEMENT*o,l=s.findIndex(h=>h.byteLength>=c);if(l>=0){let h=new e(s.splice(l,1)[0],0,o);return n&&h.fill(0),h}return new e(o)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:n}=e,{byteLength:i}=n,o=r.findIndex(s=>s.byteLength>=i);o<0?r.push(n):(o>0||r.length<this.opts.poolSize)&&r.splice(o,0,n),r.length>this.opts.poolSize&&r.shift()}},Dh=new iD;function ay(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function c0(t,e){let r=t%e;return r<0?e+r:r}function OW(t){return[t[12],t[13],t[14]]}function BW(t){return{left:sy(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:sy(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:sy(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:sy(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:sy(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:sy(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var LW=new ur;function sy(t,e,r,n){LW.set(t,e,r);let i=LW.len();return{distance:n/i,normal:new ur(-t/i,-e/i,-r/i)}}function oD(t){return t-Math.fround(t)}var _2;function MS(t,e){let{size:r=1,startIndex:n=0}=e,i=e.endIndex!==void 0?e.endIndex:t.length,o=(i-n)/r;_2=Dh.allocate(_2,o,{type:Float32Array,size:r*2});let s=n,c=0;for(;s<i;){for(let l=0;l<r;l++){let h=t[s++];_2[c+l]=h,_2[c+l+r]=oD(h)}c+=r*2}return _2.subarray(0,o*r*2)}function DW(t){let e=null,r=!1;for(let n of t)n&&(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],n[0][0]),e[0][1]=Math.min(e[0][1],n[0][1]),e[1][0]=Math.max(e[1][0],n[1][0]),e[1][1]=Math.max(e[1][1],n[1][1])):e=n);return e}var f1e=Math.PI/180,p1e=ay(),NW=[0,0,0],d1e={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function m1e({width:t,height:e,orthographic:r,fovyRadians:n,focalDistance:i,padding:o,near:s,far:c}){let l=t/e,h=r?new zn().orthographic({fovy:n,aspect:l,focalDistance:i,near:s,far:c}):new zn().perspective({fovy:n,aspect:l,near:s,far:c});if(o){let{left:p=0,right:x=0,top:w=0,bottom:E=0}=o,C=ro((p+t-x)/2,0,t)-t/2,B=ro((w+e-E)/2,0,e)-e/2;h[8]-=C*2/t,h[9]+=B*2/e}return h}var cy=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||d1e,this.focalDistance=e.focalDistance||1,this.position=e.position||NW,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&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?Fa.WEB_MERCATOR:Fa.WEB_MERCATOR_AUTO_OFFSET:Fa.IDENTITY}equals(e){return e instanceof cy?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&ka(e.projectionMatrix,this.projectionMatrix)&&ka(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let n=this.projectPosition(e),i=ny(n,this.pixelProjectionMatrix),[o,s]=i,c=r?s:this.height-s;return e.length===2?[o,c]:[o,c,i[2]]}unproject(e,{topLeft:r=!0,targetZ:n}={}){let[i,o,s]=e,c=r?o:this.height-o,l=n&&n*this.distanceScales.unitsPerMeter[2],h=Zu([i,c,s],this.pixelUnprojectionMatrix,l),[p,x,w]=this.unprojectPosition(h);return Number.isFinite(s)?[p,x,w]:Number.isFinite(n)?[p,x,n]:[p,x]}projectPosition(e){let[r,n]=this.projectFlat(e),i=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,n,i]}unprojectPosition(e){let[r,n]=this.unprojectFlat(e),i=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,n,i]}projectFlat(e){if(this.isGeospatial){let r=za(e);return r[1]=ro(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?Ec(e):e}getBounds(e={}){let r={targetZ:e.z||0},n=this.unproject([0,0],r),i=this.unproject([this.width,0],r),o=this.unproject([0,this.height],r),s=this.unproject([this.width,this.height],r);return[Math.min(n[0],i[0],o[0],s[0]),Math.min(n[1],i[1],o[1],s[1]),Math.max(n[0],i[0],o[0],s[0]),Math.max(n[1],i[1],o[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?ry({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:n=1,height:i=1}){return e<this.x+this.width&&this.x<e+n&&r<this.y+this.height&&this.y<r+i}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,BW(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r){return null}_initProps(e){let r=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=d2({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||ry({latitude:n,longitude:r}));let i=Math.pow(2,this.zoom);this.scale=i;let{position:o,modelMatrix:s}=e,c=NW;if(o&&(c=s?new zn(s).transformAsVector(o,[]):o),this.isGeospatial){let l=this.projectPosition([r,n,0]);this.center=new ur(c).scale(this.distanceScales.unitsPerMeter).add(l)}else this.center=this.projectPosition(c)}_initMatrices(e){let{viewMatrix:r=p1e,projectionMatrix:n=null,orthographic:i=!1,fovyRadians:o,fovy:s=75,near:c=.1,far:l=1e3,padding:h=null,focalDistance:p=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new zn().multiplyRight(r).translate(new ur(this.center).negate()),this.projectionMatrix=n||m1e({width:this.width,height:this.height,orthographic:i,fovyRadians:o||s*f1e,focalDistance:p,padding:h,near:c,far:l});let x=ay();Xs.multiply(x,x,this.projectionMatrix),Xs.multiply(x,x,this.viewMatrix),this.viewProjectionMatrix=x,this.viewMatrixInverse=Xs.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=OW(this.viewMatrixInverse);let w=ay(),E=ay();Xs.scale(w,w,[this.width/2,-this.height/2,1]),Xs.translate(w,w,[1,-1,0]),Xs.multiply(E,w,this.viewProjectionMatrix),this.pixelProjectionMatrix=E,this.pixelUnprojectionMatrix=Xs.invert(ay(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||br.warn("Pixel project matrix not invertible")()}};cy.displayName="Viewport";var wa=cy;var l0=class extends wa{constructor(e={}){let{latitude:r=0,longitude:n=0,zoom:i=0,pitch:o=0,bearing:s=0,nearZMultiplier:c=.1,farZMultiplier:l=1.01,nearZ:h,farZ:p,orthographic:x=!1,projectionMatrix:w,repeat:E=!1,worldOffset:C=0,position:B,padding:D,legacyMeterSizes:W=!1}=e,{width:X,height:q,altitude:$=1.5}=e,te=Math.pow(2,i);X=X||1,q=q||1;let F,ue=null;if(w)$=w[5]/2,F=Xp($);else{e.fovy?(F=e.fovy,$=Yp(F)):F=Xp($);let J;if(D){let{top:G=0,bottom:me=0}=D;J=[0,ro((G+q-me)/2,0,q)-q/2]}ue=eD({width:X,height:q,scale:te,center:B&&[0,0,B[2]*m2(r)],offset:J,pitch:o,fovy:F,nearZMultiplier:c,farZMultiplier:l}),Number.isFinite(h)&&(ue.near=h),Number.isFinite(p)&&(ue.far=p)}let oe=bS({height:q,pitch:o,bearing:s,scale:te,altitude:$});C&&(oe=new zn().translate([512*C,0,0]).multiplyLeft(oe)),super({...e,width:X,height:q,viewMatrix:oe,longitude:n,latitude:r,zoom:i,...ue,fovy:F,focalDistance:$}),this.latitude=r,this.longitude=n,this.zoom=i,this.pitch=o,this.bearing=s,this.altitude=$,this.fovy=F,this.orthographic=x,this._subViewports=E?[]:null,this._pseudoMeters=W,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),n=Math.ceil((e[2]-180)/360);for(let i=r;i<=n;i++){let o=i?new l0({...this,worldOffset:i}):this;this._subViewports.push(o)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,n]=this.projectFlat(e),i=(e[2]||0)*m2(e[1]);return[r,n,i]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,n]=this.unprojectFlat(e),i=(e[2]||0)/m2(n);return[r,n,i]}addMetersToLngLat(e,r){return A2(e,r)}panByPosition(e,r){let n=Zu(r,this.pixelUnprojectionMatrix),i=this.projectFlat(e),o=ba.add([],i,ba.negate([],n)),s=ba.add([],this.center,o),[c,l]=this.unprojectFlat(s);return{longitude:c,latitude:l}}getBounds(e={}){let r=TS(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:n,height:i}=this,{longitude:o,latitude:s,zoom:c}=wS({width:n,height:i,bounds:e,...r});return new l0({width:n,height:i,longitude:o,latitude:s,zoom:c})}};l0.displayName="WebMercatorViewport";var Uc=l0;var kW=[0,0,0];function sD(t,e,r=!1){let n=e.projectPosition(t);if(r&&e instanceof Uc){let[i,o,s=0]=t,c=e.getDistanceScales([i,o]);n[2]=s*c.unitsPerMeter[2]}return n}function A1e(t){let{viewport:e,modelMatrix:r,coordinateOrigin:n}=t,{coordinateSystem:i,fromCoordinateSystem:o,fromCoordinateOrigin:s}=t;return i===Hr.DEFAULT&&(i=e.isGeospatial?Hr.LNGLAT:Hr.CARTESIAN),o===void 0&&(o=i),s===void 0&&(s=n),{viewport:e,coordinateSystem:i,coordinateOrigin:n,modelMatrix:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}}function aD(t,{viewport:e,modelMatrix:r,coordinateSystem:n,coordinateOrigin:i,offsetMode:o}){let[s,c,l=0]=t;switch(r&&([s,c,l]=fl.transformMat4([],[s,c,l,1],r)),n){case Hr.LNGLAT:return sD([s,c,l],e,o);case Hr.LNGLAT_OFFSETS:return sD([s+i[0],c+i[1],l+(i[2]||0)],e,o);case Hr.METER_OFFSETS:return sD(A2(i,[s,c,l]),e,o);case Hr.CARTESIAN:default:return e.isGeospatial?[s+i[0],c+i[1],l+i[2]]:e.projectPosition([s,c,l])}}function SS(t,e){let{viewport:r,coordinateSystem:n,coordinateOrigin:i,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:c}=A1e(e),{autoOffset:l=!0}=e,{geospatialOrigin:h=kW,shaderCoordinateOrigin:p=kW,offsetMode:x=!1}=l?Z4(r,n,i):{},w=aD(t,{viewport:r,modelMatrix:o,coordinateSystem:s,coordinateOrigin:c,offsetMode:x});if(x){let E=r.projectPosition(h||p);zc.sub(w,w,E)}return w}var g1e=[255,255,255],_1e=1,y1e=[1,0,0],x1e=[0,0,1],v1e=0,ly=class{constructor(e={}){this.type="point";let{color:r=g1e}=e,{intensity:n=_1e}=e,{position:i=x1e}=e;this.id=e.id||`point-${v1e++}`,this.color=r,this.intensity=n,this.type="point",this.position=i,this.attenuation=b1e(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,n=e.context.viewport,{coordinateSystem:i,coordinateOrigin:o}=e.props,s=SS(this.position,{viewport:n,coordinateSystem:i,coordinateOrigin:o,fromCoordinateSystem:n.isGeospatial?Hr.LNGLAT:Hr.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=s,r}};function b1e(t){return t.attenuation?t.attenuation:y1e}var y2=class extends ly{getProjectedLight({layer:e}){let{projectedLight:r}=this,n=e.context.viewport,{coordinateSystem:i,coordinateOrigin:o,modelMatrix:s}=e.props,{cameraPosition:c}=yS({viewport:n,modelMatrix:s,coordinateSystem:i,coordinateOrigin:o});return r.color=this.color,r.intensity=this.intensity,r.position=c,r}};var u0=Math.PI/180,w1e=1e3*60*60*24,T1e=2440588,E1e=2451545,CS=u0*23.4397,M1e=357.5291,S1e=.98560028,C1e=280.147,P1e=360.9856235;function FW(t,e,r){let n=u0*-r,i=u0*e,o=R1e(t),s=z1e(o),c=N1e(o,n)-s.rightAscension;return{azimuth:B1e(c,i,s.declination),altitude:D1e(c,i,s.declination)}}function PS(t,e,r){let{azimuth:n,altitude:i}=FW(t,e,r);return[Math.sin(n)*Math.cos(i),Math.cos(n)*Math.cos(i),-Math.sin(i)]}function I1e(t){return(typeof t=="number"?t:t.getTime())/w1e-.5+T1e}function R1e(t){return I1e(t)-E1e}function L1e(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(CS)-Math.tan(e)*Math.sin(CS),Math.cos(r))}function O1e(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(CS)+Math.cos(e)*Math.sin(CS)*Math.sin(r))}function B1e(t,e,r){let n=t,i=e,o=r;return Math.atan2(Math.sin(n),Math.cos(n)*Math.sin(i)-Math.tan(o)*Math.cos(i))}function D1e(t,e,r){let n=t,i=e,o=r;return Math.asin(Math.sin(i)*Math.sin(o)+Math.cos(i)*Math.cos(o)*Math.cos(n))}function N1e(t,e){return u0*(C1e+P1e*t)-e}function k1e(t){return u0*(M1e+S1e*t)}function F1e(t){let e=t,r=u0*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),n=u0*102.9372;return e+r+n+Math.PI}function z1e(t){let e=k1e(t),r=F1e(e);return{declination:O1e(r,0),rightAscension:L1e(r,0)}}var x2=class extends Kp{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[i,o,s]=PS(this.timestamp,0,0);this.direction=[i,-s,o]}else{let{latitude:i,longitude:o}=r;this.direction=PS(this.timestamp,i,o)}return this}};var U1e=1,V1e=1,h0=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:n=Number.POSITIVE_INFINITY,rate:i=1,repeat:o=1}=e,s=U1e++,c={time:0,delay:r,duration:n,rate:i,repeat:o};return this._setChannelTime(c,this.time),this.channels.set(s,c),s}removeChannel(e){this.channels.delete(e);for(let[r,n]of this.animations)n.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let i of r)this._setChannelTime(i,this.time);let n=this.animations.values();for(let i of n){let{animation:o,channel:s}=i;o.setTime(this.getTime(s))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let n=V1e++;return this.animations.set(n,{animation:e,channel:r}),e.setTime(this.getTime(r)),n}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 n=r-e.delay,i=e.duration*e.repeat;n>=i?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}};function zW(t){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,1e3/60)}function UW(t){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(t):clearTimeout(t)}var j1e=0,H1e={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:Lf.stats.get(`animation-loop-${j1e++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},v2=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;constructor(e){if(this.props={...H1e,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=e.stats||new Nc({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:r}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setError(e){if(this.props.onError(e),this._error=Error(),this.device?.canvasContext?.canvas instanceof HTMLCanvasElement){let n=document.createElement("h1");n.innerHTML=e.message,n.style.position="absolute",n.style.top="20%",n.style.left="10px",n.style.color="black",n.style.backgroundColor="red",document.body.appendChild(n)}}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||this._error?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=zW(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(UW(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.canvasContext?.canvas;if(!this.device||!e)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:e,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let n=this.props.onAddHTML(r);n&&(r.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device?.canvasContext?.getPixelSize()||[1,1],n=1,i=this.device?.canvasContext?.canvas;return i&&i.clientHeight?n=i.clientWidth/i.clientHeight:e>0&&r>0&&(n=e/r),{width:e,height:r,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var cD={};function Vc(t="id"){cD[t]=cD[t]||1;let e=cD[t]++;return`${t}-${e}`}var IS=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||Vc("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&Fn.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 VW(t,e){if(e instanceof IS)return e;let r=W1e(t,e),{attributes:n,bufferLayout:i}=q1e(t,e);return new IS({topology:e.topology||"triangle-list",bufferLayout:i,vertexCount:e.vertexCount,indices:r,attributes:n})}function W1e(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:Fn.INDEX,data:r})}function q1e(t,e){let r=[],n={};for(let[o,s]of Object.entries(e.attributes)){let c=o;switch(o){case"POSITION":c="positions";break;case"NORMAL":c="normals";break;case"TEXCOORD_0":c="texCoords";break;case"COLOR_0":c="colors";break}if(s){n[c]=t.createBuffer({data:s.value,id:`${o}-buffer`});let{value:l,size:h,normalized:p}=s;r.push({name:c,format:IO(l,h,p)})}}let i=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:r,vertexCount:i}}var lD=class{static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new lD(e),e._lumaData.defaultPipelineFactory}device;destroyPolicy;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};constructor(e){this.device=e,this.destroyPolicy=e.props._factoryDestroyPolicy}createRenderPipeline(e){let r={...Mh.defaultProps,...e},n=this._hashRenderPipeline(r);if(!this._renderPipelineCache[n]){let i=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=n,this._renderPipelineCache[n]={pipeline:i,useCount:0}}return this._renderPipelineCache[n].useCount++,this._renderPipelineCache[n].pipeline}createComputePipeline(e){let r={...XA.defaultProps,...e},n=this._hashComputePipeline(r);if(!this._computePipelineCache[n]){let i=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});i.hash=n,this._computePipelineCache[n]={pipeline:i,useCount:0}}return this._computePipelineCache[n].useCount++,this._computePipelineCache[n].pipeline}release(e){let r=e.hash,n=e instanceof XA?this._computePipelineCache:this._renderPipelineCache;n[r].useCount--,n[r].useCount===0&&this.destroyPolicy==="unused"&&(n[r].pipeline.destroy(),delete n[r])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,i="-",o=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${n}V${i}BL${o}`;default:let s=this._getHash(JSON.stringify(e.parameters));return`${r}/${n}V${i}T${e.topology}P${s}BL${o}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},b2=lD;Vr(b2,"defaultProps",{...Mh.defaultProps});var uD=class{static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new uD(e),e._lumaData.defaultShaderFactory}device;destroyPolicy;_cache={};constructor(e){this.device=e,this.destroyPolicy=e.props._factoryDestroyPolicy}createShader(e){let r=this._hashShader(e),n=this._cache[r];if(!n){let i=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=n={shader:i,useCount:0}}return n.useCount++,n.shader}release(e){let r=this._hashShader(e),n=this._cache[r];n&&(n.useCount--,n.useCount===0&&this.destroyPolicy==="unused"&&(delete this._cache[r],n.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}},w2=uD;Vr(w2,"defaultProps",{...im.defaultProps});function jW(t,e){let r={},n="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(let i of t.attributes)if(i){let o=`${i.location} ${i.name}: ${i.type}`;r[`in ${o}`]={[n]:i.stepMode||"vertex"}}for(let i of t.varyings||[]){let o=`${i.location} ${i.name}`;r[`out ${o}`]={[n]:JSON.stringify(i)}}return r}var nc=null,hD=null;function HW(t,{id:e,minimap:r,opaque:n,top:i="0",left:o="0",rgbaScale:s=1}){nc||(nc=document.createElement("canvas"),nc.id=e,nc.title=e,nc.style.zIndex="100",nc.style.position="absolute",nc.style.top=i,nc.style.left=o,nc.style.border="blue 5px solid",nc.style.transform="scaleY(-1)",document.body.appendChild(nc),hD=nc.getContext("2d")),(nc.width!==t.width||nc.height!==t.height)&&(nc.width=t.width/2,nc.height=t.height/2,nc.style.width="400px",nc.style.height="400px");let c=t.device.readPixelsToArrayWebGL(t),l=hD?.createImageData(t.width,t.height);if(l){for(let p=0;p<c.length;p+=4)l.data[0+p+0]=c[p+0]*s,l.data[0+p+1]=c[p+1]*s,l.data[0+p+2]=c[p+2]*s,l.data[0+p+3]=n?255:c[p+3]*s;hD?.putImageData(l,0,0)}}function RS(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 n=0;n<t.length;n++)if(!RS(t[n],e[n],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(let o of n)if(!e.hasOwnProperty(o)||!RS(t[o],e[o],r-1))return!1;return!0}return!1}function G1e(t){return Nv(t)||typeof t=="number"||typeof t=="boolean"}function LS(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];G1e(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}var OS=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let n=F_(Object.values(e).filter(i=>i.dependencies));for(let i of n)e[i.name]=i;qt.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[i,o]of Object.entries(e))this._addModule(o),o.name&&i!==o.name&&!this.options.disableWarnings&&qt.warn(`Module name: ${i} vs ${o.name}`)()}destroy(){}setProps(e){for(let r of Object.keys(e)){let n=r,i=e[n]||{},o=this.modules[n];if(!o){this.options.disableWarnings||qt.warn(`Module ${r} not found`)();continue}let s=this.moduleUniforms[n],c=this.moduleBindings[n],l=o.getUniforms?.(i,s)||i,{uniforms:h,bindings:p}=LS(l);this.moduleUniforms[n]={...s,...h},this.moduleBindings[n]={...c,...p}}}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,n]of Object.entries(this.moduleUniforms))for(let[i,o]of Object.entries(n))e[`${r}.${i}`]={type:this.modules[r].uniformTypes?.[i],value:String(o)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=e.defaultUniforms||{},this.moduleBindings[r]={}}};var X1e="";async function WW(t,e){let r=new Image;return r.crossOrigin=e?.crossOrigin||"anonymous",r.src=t.startsWith("http")?t:X1e+t,await r.decode(),e?await createImageBitmap(r,e):await createImageBitmap(r)}var uy=class{device;id;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(e,r){this.device=e,this.id=r.id||Vc("async-texture"),typeof r?.data=="string"&&r.dimension==="2d"&&(r={...r,data:WW(r.data)}),this.ready=new Promise((n,i)=>{this.resolveReady=()=>{this.isReady=!0,n()},this.rejectReady=i}),this.initAsync(r)}async initAsync(e){let r,n,i=e.data,o=await qW(i).then(r,n);if(this.destroyed)return;let s={...e,data:o};this.texture=this.device.createTexture(s),this.sampler=this.texture.sampler,this.view=this.texture.view,this.isReady=!0}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){let r=this.texture;this.texture=r.clone(e),r.destroy()}return!0}};async function qW(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(qW));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e)),n=Object.keys(e),i={};for(let o=0;o<n.length;o++)i[n[o]]=r[o];return i}return t}var f0=2,Y1e=1e4,pD=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...pD.defaultProps,...r},r=this.props,this.id=r.id||Vc("model"),this.device=e,Object.assign(this.userData,r.userData);let n=Object.fromEntries(this.props.modules?.map(l=>[l.name,l])||[]),i=r.shaderInputs||new OS(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(i);let o=Z1e(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:l,getUniforms:h}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:o,...this.props,modules:s});this.source=l,this._getModuleUniforms=h,this.props.shaderLayout||=WB(this.source)}else{let{vs:l,fs:h,getUniforms:p}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:o,...this.props,modules:s});this.vs=l,this.fs=h,this._getModuleUniforms=p}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||b2.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||w2.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniformsWebGL(r.uniforms),r.moduleSettings&&this.updateModuleSettingsWebGL(r.moduleSettings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return qt.info(f0,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let i=this._getBindings();this.pipeline.setBindings(i,{disableWarnings:this.props.disableWarnings}),fD(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:o}=this.vertexArray,s=o?o.byteLength/(o.indexType==="uint32"?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",n}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&VW(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let n=new YA(this.bufferLayout);this.bufferLayout=n.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 YA(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({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){RS(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 Iv(this.shaderInputs.modules);for(let[r,n]of Object.entries(this.shaderInputs.modules))if(K1e(n)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}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 n=r?.disableWarnings??this.props.disableWarnings;e.indices&&qt.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();let i=new YA(this.bufferLayout);for(let[o,s]of Object.entries(e)){let c=i.getBufferLayout(o);if(!c){n||qt.warn(`Model(${this.id}): Missing layout for buffer "${o}".`)();continue}let l=i.getAttributeNamesForBuffer(c),h=!1;for(let p of l){let x=this._attributeInfos[p];x&&(this.vertexArray.setBuffer(x.location,s),h=!0)}!h&&!n&&qt.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${o}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[n,i]of Object.entries(e)){let o=this._attributeInfos[n];o?this.vertexArray.setConstantWebGL(o.location,i):(r?.disableWarnings??this.props.disableWarnings)||qt.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){this.setUniformsWebGL(e)}setUniformsWebGL(e){fD(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettingsWebGL(e){let{bindings:r,uniforms:n}=LS(this._getModuleUniforms(e));Object.assign(this.bindings,r),Object.assign(this.uniforms,n),this.setNeedsRedraw("moduleSettings")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof uy&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,n]of Object.entries(this.bindings))n instanceof uy?n.isReady&&(e[r]=n.texture):e[r]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof nm?e=Math.max(e,r.texture.updateTimestamp):r instanceof Fn||r instanceof fi?e=Math.max(e,r.updateTimestamp):r instanceof uy?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof om||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[n]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(i=>i.name===n)&&n!=="positions"&&delete r[n];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&&(qt.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),i=null;this.source?i=n:this.fs&&(i=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:n,fs:i}),this._attributeInfos=XE(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=qt.level>3?0:Y1e;qt.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,qt.group(f0,`>>> DRAWING MODEL ${this.id}`,{collapsed:qt.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=jW(this.pipeline.shaderLayout,this.id);qt.table(f0,e)();let r=this.shaderInputs.getDebugTable();for(let[i,o]of Object.entries(this.uniforms))r[i]={value:o};qt.table(f0,r)();let n=this._getAttributeDebugTable();qt.table(f0,this._attributeInfos)(),qt.table(f0,n)(),qt.groupEnd(f0)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let n=e.props.framebuffer;n&&HW(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,n]of Object.entries(this._attributeInfos)){let i=this.vertexArray.attributes[n.location];e[n.location]={name:r,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,n=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,r){let n=Rv(r);return(e instanceof Fn?new n(e.debugData):e).toString()}},jn=pD;Vr(jn,"defaultProps",{...Mh.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:sm.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function K1e(t){return Boolean(t.uniformTypes&&!fD(t.uniformTypes))}function Z1e(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function fD(t){for(let e in t)return!1;return!0}var BS=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=BS.defaultProps){if(!BS.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new jn(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||jv(),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 Fn)return r.readAsync();let{buffer:n,byteOffset:i=0,byteLength:o=n.byteLength}=r;return n.readAsync(i,o)}},hu=BS;Vr(hu,"defaultProps",{...jn.defaultProps,outputs:void 0,feedbackBuffers:void 0});var $1e="transform_output",xm=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 jn(this.device,{id:r.id||"texture-transform-model",fs:r.fs||jv({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:$1e}),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],n=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(n),n.end()}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:n,targetTexture:i}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,n),Object.assign(e.sourceBuffers,r),i){e.targetTexture=i;let{width:o,height:s}=i;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:o,height:s,colorAttachments:[i]}),e.framebuffer.resize({width:o,height:s})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let n in r)r[n].sampler=this.sampler}};var Si=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:n=null,vertexCount:i=null}=e;this.id=e.id||Vc("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[o,s]of Object.entries(r)){let c=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(c.value))throw new Error(`${this._print(o)}: must be typed array or object with value as typed array`);if((o==="POSITION"||o==="positions")&&!c.size&&(c.size=3),o==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=c}else this.attributes[o]=c}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let n=1/0;for(let i of Object.values(e)){let{value:o,size:s,constant:c}=i;!c&&o&&s!==void 0&&s>=1&&(n=Math.min(n,o.length/s))}return n}};var Q1e=`struct VertexInputs {
2591
2591
  @location(0) clipSpacePosition: vec2<f32>,
2592
2592
  @location(1) texCoord: vec2<f32>,
2593
2593
  @location(2) coordinate: vec2<f32>