UNPKG

wgsl_reflect

Version:
1 lines 215 kB
class e{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}get isPointer(){return!1}getTypeName(){return this.name}}class t{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class n extends e{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class s extends e{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}getTypeName(){return`array<${this.format.getTypeName()}, ${this.count}>`}}class r extends e{constructor(e,t,n){super(e,n),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class a extends e{constructor(e,t,n,s){super(e,n),this.format=t,this.access=s}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if('vec2'===e||'vec3'===e||'vec4'===e||'mat2x2'===e||'mat2x3'===e||'mat2x4'===e||'mat3x2'===e||'mat3x3'===e||'mat3x4'===e||'mat4x2'===e||'mat4x3'===e||'mat4x4'===e){if('f32'===this.format.name)return e+='f',e;if('i32'===this.format.name)return e+='i',e;if('u32'===this.format.name)return e+='u',e;if('bool'===this.format.name)return e+='b',e;if('f16'===this.format.name)return e+='h',e}e+=`<${this.format.name}>`}else if('vec2'===e||'vec3'===e||'vec4'===e)return e;return e}}var i;(e=>{e[e.Uniform=0]='Uniform',e[e.Storage=1]='Storage',e[e.Texture=2]='Texture',e[e.Sampler=3]='Sampler',e[e.StorageTexture=4]='StorageTexture'})(i||(i={}));class o{constructor(e,t,n,s,r,a,i){this.name=e,this.type=t,this.group=n,this.binding=s,this.attributes=r,this.resourceType=a,this.access=i}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class l{constructor(e,t){this.name=e,this.type=t}}class c{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s,this.interpolation=null}}class u{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s}}class h{constructor(e,t,n,s){this.name=e,this.type=t,this.attributes=n,this.id=s}}class f{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}}class p{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}}class d{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}const m=new Float32Array(1),_=new Int32Array(m.buffer),g=new Uint16Array(1);function x(e){m[0]=e;const t=_[0],n=t>>31&1;let s=t>>23&255,r=8388607&t;if(255===s)return g[0]=n<<15|31744|(0!==r?512:0),g[0];if(0===s){if(0===r)return g[0]=n<<15,g[0];r|=8388608;let e=113;for(;!(8388608&r);)r<<=1,e--;return s=127-e,r&=8388607,s>0?(r=(r>>126-s)+(r>>127-s&1),g[0]=n<<15|s<<10|r>>13,g[0]):(g[0]=n<<15,g[0])}return s=s-127+15,s>=31?(g[0]=n<<15|31744,g[0]):s<=0?s<-10?(g[0]=n<<15,g[0]):(r=(8388608|r)>>1-s,g[0]=n<<15|r>>13,g[0]):(r>>=13,g[0]=n<<15|s<<10|r,g[0])}const y=new Uint32Array(1),b=new Float32Array(y.buffer,0,1);function v(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return y[0]=t,b[0]}function w(e,t,n,s,r,a,i,o,l){const c=s*(i>>=r)*(a>>=r)+n*i+t*o;switch(l){case'r8unorm':return[k(e,c,'8unorm',1)[0]];case'r8snorm':return[k(e,c,'8snorm',1)[0]];case'r8uint':return[k(e,c,'8uint',1)[0]];case'r8sint':return[k(e,c,'8sint',1)[0]];case'rg8unorm':{const t=k(e,c,'8unorm',2);return[t[0],t[1]]}case'rg8snorm':{const t=k(e,c,'8snorm',2);return[t[0],t[1]]}case'rg8uint':{const t=k(e,c,'8uint',2);return[t[0],t[1]]}case'rg8sint':{const t=k(e,c,'8sint',2);return[t[0],t[1]]}case'rgba8unorm-srgb':case'rgba8unorm':{const t=k(e,c,'8unorm',4);return[t[0],t[1],t[2],t[3]]}case'rgba8snorm':{const t=k(e,c,'8snorm',4);return[t[0],t[1],t[2],t[3]]}case'rgba8uint':{const t=k(e,c,'8uint',4);return[t[0],t[1],t[2],t[3]]}case'rgba8sint':{const t=k(e,c,'8sint',4);return[t[0],t[1],t[2],t[3]]}case'bgra8unorm-srgb':case'bgra8unorm':{const t=k(e,c,'8unorm',4);return[t[2],t[1],t[0],t[3]]}case'r16uint':return[k(e,c,'16uint',1)[0]];case'r16sint':return[k(e,c,'16sint',1)[0]];case'r16float':return[k(e,c,'16float',1)[0]];case'rg16uint':{const t=k(e,c,'16uint',2);return[t[0],t[1]]}case'rg16sint':{const t=k(e,c,'16sint',2);return[t[0],t[1]]}case'rg16float':{const t=k(e,c,'16float',2);return[t[0],t[1]]}case'rgba16uint':{const t=k(e,c,'16uint',4);return[t[0],t[1],t[2],t[3]]}case'rgba16sint':{const t=k(e,c,'16sint',4);return[t[0],t[1],t[2],t[3]]}case'rgba16float':{const t=k(e,c,'16float',4);return[t[0],t[1],t[2],t[3]]}case'r32uint':return[k(e,c,'32uint',1)[0]];case'r32sint':return[k(e,c,'32sint',1)[0]];case'depth16unorm':case'depth24plus':case'depth24plus-stencil8':case'depth32float':case'depth32float-stencil8':case'r32float':return[k(e,c,'32float',1)[0]];case'rg32uint':{const t=k(e,c,'32uint',2);return[t[0],t[1]]}case'rg32sint':{const t=k(e,c,'32sint',2);return[t[0],t[1]]}case'rg32float':{const t=k(e,c,'32float',2);return[t[0],t[1]]}case'rgba32uint':{const t=k(e,c,'32uint',4);return[t[0],t[1],t[2],t[3]]}case'rgba32sint':{const t=k(e,c,'32sint',4);return[t[0],t[1],t[2],t[3]]}case'rgba32float':{const t=k(e,c,'32float',4);return[t[0],t[1],t[2],t[3]]}case'rg11b10ufloat':{const t=new Uint32Array(e.buffer,c,1)[0],n=(4192256&t)>>11,s=(4290772992&t)>>22;return[v(2047&t),v(n),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return y[0]=t,b[0]}(s),1]}}return null}function k(e,t,n,s){const r=[0,0,0,0];for(let c=0;c<s;++c)switch(n){case'8unorm':r[c]=e[t]/255,t++;break;case'8snorm':r[c]=e[t]/255*2-1,t++;break;case'8uint':r[c]=e[t],t++;break;case'8sint':r[c]=e[t]-127,t++;break;case'16uint':r[c]=e[t]|e[t+1]<<8,t+=2;break;case'16sint':r[c]=(e[t]|e[t+1]<<8)-32768,t+=2;break;case'16float':r[c]=(a=e[t]|e[t+1]<<8,i=void 0,o=void 0,l=void 0,i=(32768&a)>>15,l=1023&a,0==(o=(31744&a)>>10)?(i?-1:1)*Math.pow(2,-14)*(l/Math.pow(2,10)):31==o?l?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+l/Math.pow(2,10))),t+=2;break;case'32uint':case'32sint':r[c]=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,t+=4;break;case'32float':r[c]=new Float32Array(e.buffer,t,1)[0],t+=4}var a,i,o,l;return r}function I(e,t,n,s,r){for(let a=0;a<s;++a)switch(n){case'8unorm':e[t]=255*r[a],t++;break;case'8snorm':e[t]=.5*(r[a]+1)*255,t++;break;case'8uint':e[t]=r[a],t++;break;case'8sint':e[t]=r[a]+127,t++;break;case'16uint':new Uint16Array(e.buffer,t,1)[0]=r[a],t+=2;break;case'16sint':new Int16Array(e.buffer,t,1)[0]=r[a],t+=2;break;case'16float':{const n=x(r[a]);new Uint16Array(e.buffer,t,1)[0]=n,t+=2;break}case'32uint':new Uint32Array(e.buffer,t,1)[0]=r[a],t+=4;break;case'32sint':new Int32Array(e.buffer,t,1)[0]=r[a],t+=4;break;case'32float':new Float32Array(e.buffer,t,1)[0]=r[a],t+=4}return r}const T={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},'rgba8unorm-srgb':{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},'bgra8unorm-srgb':{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:'depth32float',channels:1},'depth24plus-stencil8':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:'depth32float',channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},'depth32float-stencil8':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:'depth32float',channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},'bc1-rgba-unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc1-rgba-unorm-srgb':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc2-rgba-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc2-rgba-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc3-rgba-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc3-rgba-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc4-r-unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},'bc4-r-snorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},'bc5-rg-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},'bc5-rg-snorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},'bc6h-rgb-ufloat':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc6h-rgb-float':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc7-rgba-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'bc7-rgba-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8unorm-srgb':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8a1unorm':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgb8a1unorm-srgb':{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgba8unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'etc2-rgba8unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'eac-r11unorm':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},'eac-r11snorm':{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},'eac-rg11unorm':{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},'eac-rg11snorm':{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},'astc-4x4-unorm':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'astc-4x4-unorm-srgb':{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},'astc-5x4-unorm':{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},'astc-5x4-unorm-srgb':{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},'astc-5x5-unorm':{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},'astc-5x5-unorm-srgb':{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},'astc-6x5-unorm':{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},'astc-6x5-unorm-srgb':{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},'astc-6x6-unorm':{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},'astc-6x6-unorm-srgb':{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},'astc-8x5-unorm':{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},'astc-8x5-unorm-srgb':{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},'astc-8x6-unorm':{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},'astc-8x6-unorm-srgb':{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},'astc-8x8-unorm':{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},'astc-8x8-unorm-srgb':{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},'astc-10x5-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},'astc-10x5-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},'astc-10x6-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},'astc-10x6-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},'astc-10x8-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},'astc-10x8-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},'astc-10x10-unorm':{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},'astc-10x10-unorm-srgb':{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},'astc-12x10-unorm':{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},'astc-12x10-unorm-srgb':{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},'astc-12x12-unorm':{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},'astc-12x12-unorm-srgb':{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}};class S{constructor(){this.id=S._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return''}search(e){e(this)}searchBlock(e,t){if(e){t(A.instance);for(const n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(E.instance)}}constEvaluate(e,t){throw new Error('Cannot evaluate node')}constEvaluateString(e){return this.constEvaluate(e).toString()}}S._id=0;class A extends S{}A.instance=new A;class E extends S{}E.instance=new E;const $=new Set(['all','all','any','select','arrayLength','abs','acos','acosh','asin','asinh','atan','atanh','atan2','ceil','clamp','cos','cosh','countLeadingZeros','countOneBits','countTrailingZeros','cross','degrees','determinant','distance','dot','dot4U8Packed','dot4I8Packed','exp','exp2','extractBits','faceForward','firstLeadingBit','firstTrailingBit','floor','fma','fract','frexp','insertBits','inverseSqrt','ldexp','length','log','log2','max','min','mix','modf','normalize','pow','quantizeToF16','radians','reflect','refract','reverseBits','round','saturate','sign','sin','sinh','smoothStep','sqrt','step','tan','tanh','transpose','trunc','dpdx','dpdxCoarse','dpdxFine','dpdy','dpdyCoarse','dpdyFine','fwidth','fwidthCoarse','fwidthFine','textureDimensions','textureGather','textureGatherCompare','textureLoad','textureNumLayers','textureNumLevels','textureNumSamples','textureSample','textureSampleBias','textureSampleCompare','textureSampleCompareLevel','textureSampleGrad','textureSampleLevel','textureSampleBaseClampToEdge','textureStore','atomicLoad','atomicStore','atomicAdd','atomicSub','atomicMax','atomicMin','atomicAnd','atomicOr','atomicXor','atomicExchange','atomicCompareExchangeWeak','pack4x8snorm','pack4x8unorm','pack4xI8','pack4xU8','pack4x8Clamp','pack4xU8Clamp','pack2x16snorm','pack2x16unorm','pack2x16float','unpack4x8snorm','unpack4x8unorm','unpack4xI8','unpack4xU8','unpack2x16snorm','unpack2x16unorm','unpack2x16float','storageBarrier','textureBarrier','workgroupBarrier','workgroupUniformLoad','subgroupAdd','subgroupExclusiveAdd','subgroupInclusiveAdd','subgroupAll','subgroupAnd','subgroupAny','subgroupBallot','subgroupBroadcast','subgroupBroadcastFirst','subgroupElect','subgroupMax','subgroupMin','subgroupMul','subgroupExclusiveMul','subgroupInclusiveMul','subgroupOr','subgroupShuffle','subgroupShuffleDown','subgroupShuffleUp','subgroupShuffleXor','subgroupXor','quadBroadcast','quadSwapDiagonal','quadSwapX','quadSwapY']);class L extends S{constructor(){super()}}class C extends L{constructor(e,t,n,s,r,a){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=s,this.startLine=r,this.endLine=a}get astNodeType(){return'function'}search(e){if(this.attributes)for(const t of this.attributes)e(t);e(this);for(const t of this.args)e(t);this.searchBlock(this.body,e)}}class D extends L{constructor(e){super(),this.expression=e}get astNodeType(){return'staticAssert'}search(e){this.expression.search(e)}}class N extends L{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return'while'}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class V extends L{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return'continuing'}search(e){this.searchBlock(this.body,e)}}class O extends L{constructor(e,t,n,s){super(),this.init=e,this.condition=t,this.increment=n,this.body=s}get astNodeType(){return'for'}search(e){var t,n,s;null===(t=this.init)||void 0===t||t.search(e),null===(n=this.condition)||void 0===n||n.search(e),null===(s=this.increment)||void 0===s||s.search(e),this.searchBlock(this.body,e)}}class B extends L{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return'var'}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class F extends L{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return'override'}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class M extends L{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return'let'}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}class U extends L{constructor(e,t,n,s,r){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=r}get astNodeType(){return'const'}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),null===(t=this.value)||void 0===t||t.search(e)}}var P,W,q,H;(e=>{e.increment='++',e.decrement='--'})(P||(P={})),(e=>{e.parse=function(t){const n=t;if('parse'==n)throw new Error('Invalid value for IncrementOperator');return e[n]}})(P||(P={}));class z extends L{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return'increment'}search(e){this.variable.search(e)}}(e=>{e.assign='=',e.addAssign='+=',e.subtractAssin='-=',e.multiplyAssign='*=',e.divideAssign='/=',e.moduloAssign='%=',e.andAssign='&=',e.orAssign='|=',e.xorAssign='^=',e.shiftLeftAssign='<<=',e.shiftRightAssign='>>='})(W||(W={})),(e=>{e.parse=function(e){const t=e;if('parse'==t)throw new Error('Invalid value for AssignOperator');return t}})(W||(W={}));class R extends L{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return'assign'}search(e){this.variable.search(e),this.value.search(e)}}class G extends L{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return'call'}isBuiltin(){return $.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class X extends L{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return'loop'}}class j extends L{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return'switch'}search(e){e(this);for(const t of this.cases)t.search(e)}}class Z extends L{constructor(e,t,n,s){super(),this.condition=e,this.body=t,this.elseif=n,this.else=s}get astNodeType(){return'if'}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class Q extends L{constructor(e){super(),this.value=e}get astNodeType(){return'return'}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class Y extends L{constructor(e){super(),this.name=e}get astNodeType(){return'enable'}}class K extends L{constructor(e){super(),this.extensions=e}get astNodeType(){return'requires'}}class J extends L{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return'diagnostic'}}class ee extends L{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return'alias'}}class te extends L{constructor(){super()}get astNodeType(){return'discard'}}class ne extends L{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return'break'}}class se extends L{constructor(){super(),this.loopId=-1}get astNodeType(){return'continue'}}class re extends L{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return'type'}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if('f32'===t.name)return t;for(let n=1;n<e.length;++n){const s=re._priority.get(t.name);re._priority.get(e[n].name)<s&&(t=e[n])}return'x32'===t.name?re.i32:t}getTypeName(){return this.name}}re.x32=new re('x32'),re.f32=new re('f32'),re.i32=new re('i32'),re.u32=new re('u32'),re.f16=new re('f16'),re.bool=new re('bool'),re.void=new re('void'),re._priority=new Map([['f32',0],['f16',1],['u32',2],['i32',3],['x32',3]]);class ae extends re{constructor(e){super(e)}}class ie extends re{constructor(e,t,n,s){super(e),this.members=t,this.startLine=n,this.endLine=s}get astNodeType(){return'struct'}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(const t of this.members)e(t)}}class oe extends re{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return'template'}getTypeName(){let e=this.name;if(null!==this.format){if('vec2'===e||'vec3'===e||'vec4'===e||'mat2x2'===e||'mat2x3'===e||'mat2x4'===e||'mat3x2'===e||'mat3x3'===e||'mat3x4'===e||'mat4x2'===e||'mat4x3'===e||'mat4x4'===e){if('f32'===this.format.name)return e+='f',e;if('i32'===this.format.name)return e+='i',e;if('u32'===this.format.name)return e+='u',e;if('bool'===this.format.name)return e+='b',e;if('f16'===this.format.name)return e+='h',e}e+=`<${this.format.name}>`}else if('vec2'===e||'vec3'===e||'vec4'===e)return e;return e}}oe.vec2f=new oe('vec2',re.f32,null),oe.vec3f=new oe('vec3',re.f32,null),oe.vec4f=new oe('vec4',re.f32,null),oe.vec2i=new oe('vec2',re.i32,null),oe.vec3i=new oe('vec3',re.i32,null),oe.vec4i=new oe('vec4',re.i32,null),oe.vec2u=new oe('vec2',re.u32,null),oe.vec3u=new oe('vec3',re.u32,null),oe.vec4u=new oe('vec4',re.u32,null),oe.vec2h=new oe('vec2',re.f16,null),oe.vec3h=new oe('vec3',re.f16,null),oe.vec4h=new oe('vec4',re.f16,null),oe.vec2b=new oe('vec2',re.bool,null),oe.vec3b=new oe('vec3',re.bool,null),oe.vec4b=new oe('vec4',re.bool,null),oe.mat2x2f=new oe('mat2x2',re.f32,null),oe.mat2x3f=new oe('mat2x3',re.f32,null),oe.mat2x4f=new oe('mat2x4',re.f32,null),oe.mat3x2f=new oe('mat3x2',re.f32,null),oe.mat3x3f=new oe('mat3x3',re.f32,null),oe.mat3x4f=new oe('mat3x4',re.f32,null),oe.mat4x2f=new oe('mat4x2',re.f32,null),oe.mat4x3f=new oe('mat4x3',re.f32,null),oe.mat4x4f=new oe('mat4x4',re.f32,null),oe.mat2x2h=new oe('mat2x2',re.f16,null),oe.mat2x3h=new oe('mat2x3',re.f16,null),oe.mat2x4h=new oe('mat2x4',re.f16,null),oe.mat3x2h=new oe('mat3x2',re.f16,null),oe.mat3x3h=new oe('mat3x3',re.f16,null),oe.mat3x4h=new oe('mat3x4',re.f16,null),oe.mat4x2h=new oe('mat4x2',re.f16,null),oe.mat4x3h=new oe('mat4x3',re.f16,null),oe.mat4x4h=new oe('mat4x4',re.f16,null),oe.mat2x2i=new oe('mat2x2',re.i32,null),oe.mat2x3i=new oe('mat2x3',re.i32,null),oe.mat2x4i=new oe('mat2x4',re.i32,null),oe.mat3x2i=new oe('mat3x2',re.i32,null),oe.mat3x3i=new oe('mat3x3',re.i32,null),oe.mat3x4i=new oe('mat3x4',re.i32,null),oe.mat4x2i=new oe('mat4x2',re.i32,null),oe.mat4x3i=new oe('mat4x3',re.i32,null),oe.mat4x4i=new oe('mat4x4',re.i32,null),oe.mat2x2u=new oe('mat2x2',re.u32,null),oe.mat2x3u=new oe('mat2x3',re.u32,null),oe.mat2x4u=new oe('mat2x4',re.u32,null),oe.mat3x2u=new oe('mat3x2',re.u32,null),oe.mat3x3u=new oe('mat3x3',re.u32,null),oe.mat3x4u=new oe('mat3x4',re.u32,null),oe.mat4x2u=new oe('mat4x2',re.u32,null),oe.mat4x3u=new oe('mat4x3',re.u32,null),oe.mat4x4u=new oe('mat4x4',re.u32,null);class le extends re{constructor(e,t,n,s){super(e),this.storage=t,this.type=n,this.access=s}get astNodeType(){return'pointer'}}class ce extends re{constructor(e,t,n,s){super(e),this.attributes=t,this.format=n,this.count=s}get astNodeType(){return'array'}get isArray(){return!0}}class ue extends re{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return'sampler'}}class he extends S{constructor(){super(),this.postfix=null}}class fe extends he{constructor(e){super(),this.value=e}get astNodeType(){return'stringExpr'}toString(){return this.value}constEvaluateString(){return this.value}}class pe extends he{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return'createExpr'}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class de extends he{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return'callExpr'}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return $.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class me extends he{constructor(e){super(),this.name=e}get astNodeType(){return'varExpr'}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class _e extends he{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return'constExpr'}constEvaluate(e,t){if(this.initializer){const t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class ge extends he{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return'literalExpr'}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof Oe}get isVector(){return this.value instanceof Fe||this.value instanceof Me}get scalarValue(){return this.value instanceof Oe?this.value.value:(console.error('Value is not scalar.'),0)}get vectorValue(){return this.value instanceof Fe||this.value instanceof Me?this.value.data:(console.error('Value is not a vector or matrix.'),new Float32Array(0))}}class xe extends he{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return'bitcastExpr'}search(e){this.value.search(e)}}class ye extends he{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return'typecastExpr'}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.searchBlock(this.args,e)}}class be extends he{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class ve extends he{constructor(){super()}}class we extends ve{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return'unaryOp'}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class ke extends ve{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return'binaryOp'}_getPromotedType(e,t){return e.name===t.name?e:'f32'===e.name||'f32'===t.name?re.f32:'u32'===e.name||'u32'===t.name?re.u32:re.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class Ie extends S{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Te extends he{constructor(){super()}get astNodeType(){return'default'}}class Se extends Ie{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return'case'}search(e){this.searchBlock(this.body,e)}}class Ae extends Ie{constructor(e){super(e)}get astNodeType(){return'default'}search(e){this.searchBlock(this.body,e)}}class Ee extends S{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return'argument'}}class $e extends S{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return'elseif'}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Le extends S{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return'member'}}class Ce extends S{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return'attribute'}}class De{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=De._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,s){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}De._id=0;class Ne extends De{constructor(){super(new e('void',null),null)}toString(){return'void'}}Ne.void=new Ne;class Ve extends De{constructor(e){super(new r('pointer',e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,s){this.reference.setDataValue(e,t,n,s)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}toString(){return`&${this.reference.toString()}`}}class Oe extends De{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:'x32'===this.typeInfo.name?e-Math.floor(e)!=0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):'i32'===this.typeInfo.name||'bool'===this.typeInfo.name?this.data=new Int32Array([e]):'u32'===this.typeInfo.name?this.data=new Uint32Array([e]):'f32'===this.typeInfo.name||'f16'===this.typeInfo.name?this.data=new Float32Array([e]):console.error('ScalarData2: Invalid type',t)}clone(){if(this.data instanceof Float32Array)return new Oe(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Oe(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Oe(new Uint32Array(this.data),this.typeInfo,null);throw'ScalarData: Invalid data type'}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,s){if(n)return void console.error('SetDataValue: Scalar data does not support postfix',n);if(!(t instanceof Oe))return void console.error('SetDataValue: Invalid value',t);let r=t.data[0];'i32'===this.typeInfo.name||'u32'===this.typeInfo.name?r=Math.floor(r):'bool'===this.typeInfo.name&&(r=r?1:0),this.data[0]=r}getSubData(e,t,n){return t?(console.error('getSubData: Scalar data does not support postfix',t),null):this}toString(){return`${this.value}`}}function Be(e,t,n){const s=t.length;return 2===s?'f32'===n?new Fe(new Float32Array(t),e.getTypeInfo('vec2f')):'i32'===n||'bool'===n?new Fe(new Int32Array(t),e.getTypeInfo('vec2i')):'u32'===n?new Fe(new Uint32Array(t),e.getTypeInfo('vec2u')):'f16'===n?new Fe(new Float32Array(t),e.getTypeInfo('vec2h')):(console.error(`getSubData: Unknown format ${n}`),null):3===s?'f32'===n?new Fe(new Float32Array(t),e.getTypeInfo('vec3f')):'i32'===n||'bool'===n?new Fe(new Int32Array(t),e.getTypeInfo('vec3i')):'u32'===n?new Fe(new Uint32Array(t),e.getTypeInfo('vec3u')):'f16'===n?new Fe(new Float32Array(t),e.getTypeInfo('vec3h')):(console.error(`getSubData: Unknown format ${n}`),null):4===s?'f32'===n?new Fe(new Float32Array(t),e.getTypeInfo('vec4f')):'i32'===n||'bool'===n?new Fe(new Int32Array(t),e.getTypeInfo('vec4i')):'u32'===n?new Fe(new Uint32Array(t),e.getTypeInfo('vec4u')):'f16'===n?new Fe(new Float32Array(t),e.getTypeInfo('vec4h')):(console.error(`getSubData: Unknown format ${n}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}class Fe extends De{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;'vec2f'===t||'vec3f'===t||'vec4f'===t?this.data=new Float32Array(e):'vec2i'===t||'vec3i'===t||'vec4i'===t?this.data=new Int32Array(e):'vec2u'===t||'vec3u'===t||'vec4u'===t?this.data=new Uint32Array(e):'vec2h'===t||'vec3h'===t||'vec4h'===t?this.data=new Float32Array(e):'vec2b'===t||'vec3b'===t||'vec4b'===t?this.data=new Int32Array(e):'vec2'===t||'vec3'===t||'vec4'===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new Fe(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Fe(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Fe(new Uint32Array(this.data),this.typeInfo,null);throw'VectorData: Invalid data type'}setDataValue(e,t,n,s){n instanceof fe?console.error('TODO: Set vector postfix'):t instanceof Fe?this.data=t.data:console.error('SetDataValue: Invalid value',t)}getSubData(e,t,n){if(null===t)return this;let s=e.getTypeInfo('f32');if(this.typeInfo instanceof a)s=this.typeInfo.format||s;else{const t=this.typeInfo.name;'vec2f'===t||'vec3f'===t||'vec4f'===t?s=e.getTypeInfo('f32'):'vec2i'===t||'vec3i'===t||'vec4i'===t?s=e.getTypeInfo('i32'):'vec2b'===t||'vec3b'===t||'vec4b'===t?s=e.getTypeInfo('bool'):'vec2u'===t||'vec3u'===t||'vec4u'===t?s=e.getTypeInfo('u32'):'vec2h'===t||'vec3h'===t||'vec4h'===t?s=e.getTypeInfo('f16'):console.error(`GetSubData: Unknown type ${t}`)}let r=this;for(;null!==t&&null!==r;){if(t instanceof be){const a=t.index;let i=-1;if(a instanceof ge){if(!(a.value instanceof Oe))return console.error(`GetSubData: Invalid array index ${a.value}`),null;i=a.value.value}else{const t=e.evalExpression(a,n);if(!(t instanceof Oe))return console.error('GetSubData: Unknown index type',a),null;i=t.value}if(i<0||i>=r.data.length)return console.error('GetSubData: Index out of range',i),null;if(r.data instanceof Float32Array){const e=new Float32Array(r.data.buffer,r.data.byteOffset+4*i,1);return new Oe(e,s)}if(r.data instanceof Int32Array){const e=new Int32Array(r.data.buffer,r.data.byteOffset+4*i,1);return new Oe(e,s)}if(r.data instanceof Uint32Array){const e=new Uint32Array(r.data.buffer,r.data.byteOffset+4*i,1);return new Oe(e,s)}throw'GetSubData: Invalid data type'}if(!(t instanceof fe))return console.error('GetSubData: Unknown postfix',t),null;{const n=t.value.toLowerCase();if(1===n.length){let e=0;if('x'===n||'r'===n)e=0;else if('y'===n||'g'===n)e=1;else if('z'===n||'b'===n)e=2;else{if('w'!==n&&'a'!==n)return console.error(`GetSubData: Unknown member ${n}`),null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Oe(t,s,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Oe(t,s,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Oe(t,s,this)}}const a=[];for(const e of n)'x'===e||'r'===e?a.push(this.data[0]):'y'===e||'g'===e?a.push(this.data[1]):'z'===e||'b'===e?a.push(this.data[2]):'w'===e||'a'===e?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);r=Be(e,a,s.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class Me extends De{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new Me(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,s){n instanceof fe?console.error('TODO: Set matrix postfix'):t instanceof Me?this.data=t.data:console.error('SetDataValue: Invalid value',t)}getSubData(e,t,n){if(null===t)return this;const s=this.typeInfo.name;if(e.getTypeInfo('f32'),this.typeInfo instanceof a)this.typeInfo.format;else if(s.endsWith('f'))e.getTypeInfo('f32');else if(s.endsWith('i'))e.getTypeInfo('i32');else if(s.endsWith('u'))e.getTypeInfo('u32');else{if(!s.endsWith('h'))return console.error(`GetDataValue: Unknown type ${s}`),null;e.getTypeInfo('f16')}if(t instanceof be){const r=t.index;let a=-1;if(r instanceof ge){if(!(r.value instanceof Oe))return console.error(`GetDataValue: Invalid array index ${r.value}`),null;a=r.value.value}else{const t=e.evalExpression(r,n);if(!(t instanceof Oe))return console.error('GetDataValue: Unknown index type',r),null;a=t.value}if(a<0||a>=this.data.length)return console.error('GetDataValue: Index out of range',a),null;const i=s.endsWith('h')?'h':'f';let o;if('mat2x2'===s||'mat2x2f'===s||'mat2x2h'===s||'mat3x2'===s||'mat3x2f'===s||'mat3x2h'===s||'mat4x2'===s||'mat4x2f'===s||'mat4x2h'===s)o=new Fe(new Float32Array(this.data.buffer,this.data.byteOffset+2*a*4,2),e.getTypeInfo(`vec2${i}`));else if('mat2x3'===s||'mat2x3f'===s||'mat2x3h'===s||'mat3x3'===s||'mat3x3f'===s||'mat3x3h'===s||'mat4x3'===s||'mat4x3f'===s||'mat4x3h'===s)o=new Fe(new Float32Array(this.data.buffer,this.data.byteOffset+3*a*4,3),e.getTypeInfo(`vec3${i}`));else{if('mat2x4'!==s&&'mat2x4f'!==s&&'mat2x4h'!==s&&'mat3x4'!==s&&'mat3x4f'!==s&&'mat3x4h'!==s&&'mat4x4'!==s&&'mat4x4f'!==s&&'mat4x4h'!==s)return console.error(`GetDataValue: Unknown type ${s}`),null;o=new Fe(new Float32Array(this.data.buffer,this.data.byteOffset+4*a*4,4),e.getTypeInfo(`vec4${i}`))}return t.postfix?o.getSubData(e,t.postfix,n):o}return console.error('GetDataValue: Invalid postfix',t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}}class Ue extends De{constructor(e,t,n=0,s=null){super(t,s),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){const e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new Ue(e.buffer,this.typeInfo,0,null)}setDataValue(t,r,a,i){if(null===r)return void console.log('setDataValue: NULL data.');let o=this.offset,l=this.typeInfo;for(;a;){if(a instanceof be)if(l instanceof s){const e=a.index;if(e instanceof ge){if(!(e.value instanceof Oe))return void console.error(`SetDataValue: Invalid index type ${e.value}`);o+=e.value.value*l.stride}else{const n=t.evalExpression(e,i);if(!(n instanceof Oe))return void console.error('SetDataValue: Unknown index type',e);o+=n.value*l.stride}l=l.format}else console.error(`SetDataValue: Type ${l.getTypeName()} is not an array`);else{if(!(a instanceof fe))return void console.error('SetDataValue: Unknown postfix type',a);{const t=a.value;if(l instanceof n){let e=!1;for(const n of l.members)if(n.name===t){o+=n.offset,l=n.type,e=!0;break}if(!e)return void console.error(`SetDataValue: Member ${t} not found`)}else if(l instanceof e){const e=l.getTypeName();let n=0;if('x'===t||'r'===t)n=0;else if('y'===t||'g'===t)n=1;else if('z'===t||'b'===t)n=2;else{if('w'!==t&&'a'!==t)return void console.error(`SetDataValue: Unknown member ${t}`);n=3}if(!(r instanceof Oe))return void console.error('SetDataValue: Invalid value',r);const s=r.value;return'vec2f'===e?void(new Float32Array(this.buffer,o,2)[n]=s):'vec3f'===e?void(new Float32Array(this.buffer,o,3)[n]=s):'vec4f'===e?void(new Float32Array(this.buffer,o,4)[n]=s):'vec2i'===e?void(new Int32Array(this.buffer,o,2)[n]=s):'vec3i'===e?void(new Int32Array(this.buffer,o,3)[n]=s):'vec4i'===e?void(new Int32Array(this.buffer,o,4)[n]=s):'vec2u'===e?void(new Uint32Array(this.buffer,o,2)[n]=s):'vec3u'===e?void(new Uint32Array(this.buffer,o,3)[n]=s):'vec4u'===e?void(new Uint32Array(this.buffer,o,4)[n]=s):void console.error(`SetDataValue: Type ${e} is not a struct`)}}}a=a.postfix}this.setData(t,r,l,o,i)}setData(e,t,n,s,r){const a=n.getTypeName();if('f32'!==a&&'f16'!==a)if('i32'!==a&&'atomic<i32>'!==a&&'x32'!==a)if('u32'!==a&&'atomic<u32>'!==a)if('bool'!==a)if('vec2f'!==a&&'vec2h'!==a)if('vec3f'!==a&&'vec3h'!==a)if('vec4f'!==a&&'vec4h'!==a)if('vec2i'!==a)if('vec3i'!==a)if('vec4i'!==a)if('vec2u'!==a)if('vec3u'!==a)if('vec4u'!==a)if('vec2b'!==a)if('vec3b'!==a)if('vec4b'!==a)if('mat2x2f'!==a&&'mat2x2h'!==a)if('mat2x3f'!==a&&'mat2x3h'!==a)if('mat2x4f'!==a&&'mat2x4h'!==a)if('mat3x2f'!==a&&'mat3x2h'!==a)if('mat3x3f'!==a&&'mat3x3h'!==a)if('mat3x4f'!==a&&'mat3x4h'!==a)if('mat4x2f'!==a&&'mat4x2h'!==a)if('mat4x3f'!==a&&'mat4x3h'!==a)if('mat4x4f'!==a&&'mat4x4h'!==a)if(t instanceof Ue){if(n===t.typeInfo){return void new Uint8Array(this.buffer,s,t.buffer.byteLength).set(new Uint8Array(t.buffer))}console.error('SetDataValue: Type mismatch',a,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${a}`);else{const e=new Float32Array(this.buffer,s,16);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15])}else{const e=new Float32Array(this.buffer,s,12);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11])}else{const e=new Float32Array(this.buffer,s,8);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7])}else{const e=new Float32Array(this.buffer,s,12);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11])}else{const e=new Float32Array(this.buffer,s,9);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8])}else{const e=new Float32Array(this.buffer,s,6);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5])}else{const e=new Float32Array(this.buffer,s,8);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7])}else{const e=new Float32Array(this.buffer,s,6);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5])}else{const e=new Float32Array(this.buffer,s,4);t instanceof Me?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3])}else{const e=new Uint32Array(this.buffer,s,4);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3])}else{const e=new Uint32Array(this.buffer,s,3);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2])}else{const e=new Uint32Array(this.buffer,s,2);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1])}else{const e=new Uint32Array(this.buffer,s,4);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3])}else{const e=new Uint32Array(this.buffer,s,3);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2])}else{const e=new Uint32Array(this.buffer,s,2);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1])}else{const e=new Int32Array(this.buffer,s,4);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3])}else{const e=new Int32Array(this.buffer,s,3);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2])}else{const e=new Int32Array(this.buffer,s,2);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1])}else{const e=new Float32Array(this.buffer,s,4);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3])}else{const e=new Float32Array(this.buffer,s,3);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2])}else{const e=new Float32Array(this.buffer,s,2);t instanceof Fe?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1])}else t instanceof Oe&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof Oe&&(new Uint32Array(this.buffer,s,1)[0]=t.value);else t instanceof Oe&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof Oe&&(new Float32Array(this.buffer,s,1)[0]=t.value)}getSubData(t,r,i){var o,l,c;if(null===r)return this;let u=this.offset,h=this.typeInfo;for(;r;){if(r instanceof be){const e=r.index,n=e instanceof he?t.evalExpression(e,i):e;let a=0;if(n instanceof Oe?a=n.value:'number'==typeof n?a=n:console.error('GetDataValue: Invalid index type',e),h instanceof s)u+=a*h.stride,h=h.format;else{const e=h.getTypeName();'mat4x4'===e||'mat4x4f'===e||'mat4x4h'===e?(u+=16*a,h=t.getTypeInfo('vec4f')):console.error(`getDataValue: Type ${h.getTypeName()} is not an array`)}}else{if(!(r instanceof fe))return console.error('GetDataValue: Unknown postfix type',r),null;{const s=r.value;if(h instanceof n){let e=!1;for(const t of h.members)if(t.name===s){u+=t.offset,h=t.type,e=!0;break}if(!e)return console.error(`GetDataValue: Member ${s} not found`),null}else if(h instanceof e){const e=h.getTypeName();if('vec2f'===e||'vec3f'===e||'vec4f'===e||'vec2i'===e||'vec3i'===e||'vec4i'===e||'vec2u'===e||'vec3u'===e||'vec4u'===e||'vec2b'===e||'vec3b'===e||'vec4b'===e||'vec2h'===e||'vec3h'===e||'vec4h'===e||'vec2'===e||'vec3'===e||'vec4'===e){if(s.length>0&&s.length<5){let n='f';const r=[];for(let a=0;a<s.length;++a){const i=s[a].toLowerCase();let o=0;if('x'===i||'r'===i)o=0;else if('y'===i||'g'===i)o=1;else if('z'===i||'b'===i)o=2;else{if('w'!==i&&'a'!==i)return console.error(`Unknown member ${s}`),null;o=3}if(1===s.length){if(e.endsWith('f'))return this.buffer.byteLength<u+4*o+4?(console.log('Insufficient buffer data'),null):new Oe(new Float32Array(this.buffer,u+4*o,1),t.getTypeInfo('f32'),this);if(e.endsWith('h'))return new Oe(new Float32Array(this.buffer,u+4*o,1),t.getTypeInfo('f16'),this);if(e.endsWith('i'))return new Oe(new Int32Array(this.buffer,u+4*o,1),t.getTypeInfo('i32'),this);if(e.endsWith('b'))return new Oe(new Int32Array(this.buffer,u+4*o,1),t.getTypeInfo('bool'),this);if(e.endsWith('u'))return new Oe(new Uint32Array(this.buffer,u+4*o,1),t.getTypeInfo('i32'),this)}if('vec2f'===e)r.push(new Float32Array(this.buffer,u,2)[o]);else if('vec3f'===e){if(u+12>=this.buffer.byteLength)return console.log('Insufficient buffer data'),null;const e=new Float32Array(this.buffer,u,3);r.push(e[o])}else if('vec4f'===e)r.push(new Float32Array(this.buffer,u,4)[o]);else if('vec2i'===e)n='i',r.push(new Int32Array(this.buffer,u,2)[o]);else if('vec3i'==