typegpu 0.5.2 → 0.5.3

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/index.cjs CHANGED
@@ -1,26 +1,26 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3QXCKMEJcjs = require('./chunk-3QXCKMEJ.cjs');var _chunk3JTP2ATRcjs = require('./chunk-3JTP2ATR.cjs');var _chunkQRLTUOBJcjs = require('./chunk-QRLTUOBJ.cjs');var zn=["vec2f","vec2h","vec2i","vec2u","vec3f","vec3h","vec3i","vec3u","vec4f","vec4h","vec4i","vec4u","struct"],jn={f:{1:_chunkQRLTUOBJcjs.N,2:_chunkQRLTUOBJcjs.s,3:_chunkQRLTUOBJcjs.w,4:_chunkQRLTUOBJcjs.A},h:{1:_chunkQRLTUOBJcjs.O,2:_chunkQRLTUOBJcjs.t,3:_chunkQRLTUOBJcjs.x,4:_chunkQRLTUOBJcjs.B},i:{1:_chunkQRLTUOBJcjs.M,2:_chunkQRLTUOBJcjs.u,3:_chunkQRLTUOBJcjs.y,4:_chunkQRLTUOBJcjs.C},u:{1:_chunkQRLTUOBJcjs.L,2:_chunkQRLTUOBJcjs.v,3:_chunkQRLTUOBJcjs.z,4:_chunkQRLTUOBJcjs.D}},Wr={vec2f:_chunkQRLTUOBJcjs.s,vec2h:_chunkQRLTUOBJcjs.t,vec2i:_chunkQRLTUOBJcjs.u,vec2u:_chunkQRLTUOBJcjs.v,vec3f:_chunkQRLTUOBJcjs.w,vec3h:_chunkQRLTUOBJcjs.x,vec3i:_chunkQRLTUOBJcjs.y,vec3u:_chunkQRLTUOBJcjs.z,vec4f:_chunkQRLTUOBJcjs.A,vec4h:_chunkQRLTUOBJcjs.B,vec4i:_chunkQRLTUOBJcjs.C,vec4u:_chunkQRLTUOBJcjs.D,mat2x2f:_chunkQRLTUOBJcjs.E,mat3x3f:_chunkQRLTUOBJcjs.F,mat4x4f:_chunkQRLTUOBJcjs.G},Mr={vec2f:_chunkQRLTUOBJcjs.N,vec2h:_chunkQRLTUOBJcjs.O,vec2i:_chunkQRLTUOBJcjs.M,vec2u:_chunkQRLTUOBJcjs.L,vec3f:_chunkQRLTUOBJcjs.N,vec3h:_chunkQRLTUOBJcjs.O,vec3i:_chunkQRLTUOBJcjs.M,vec3u:_chunkQRLTUOBJcjs.L,vec4f:_chunkQRLTUOBJcjs.N,vec4h:_chunkQRLTUOBJcjs.O,vec4i:_chunkQRLTUOBJcjs.M,vec4u:_chunkQRLTUOBJcjs.L,mat2x2f:_chunkQRLTUOBJcjs.s,mat3x3f:_chunkQRLTUOBJcjs.w,mat4x4f:_chunkQRLTUOBJcjs.A};function Ee(e,t){var o;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return _chunk3JTP2ATRcjs.f;if(_chunk3JTP2ATRcjs.c.call(void 0, e)||_chunk3JTP2ATRcjs.b.call(void 0, e)){let i=_chunkQRLTUOBJcjs.m.call(void 0, );if(!i)throw new Error("Resolution context not found when unwrapping slot or derived");let s=i.unwrap(e);return Se(s)}let r=e;for(_chunk3JTP2ATRcjs.l.call(void 0, r)&&(r=r[_chunk3JTP2ATRcjs.a].dataType);_chunkQRLTUOBJcjs.da.call(void 0, r);)r=r.inner;let n="kind"in r?r.kind:r.type;if(n==="struct")return(o=r.propTypes[t])!=null?o:_chunk3JTP2ATRcjs.f;let a=t.length;if(zn.includes(n)&&a>=1&&a<=4){let i=n[4],s=jn[i][a];if(s)return s}return _chunkQRLTUOBJcjs.V.call(void 0, r)?r:_chunk3JTP2ATRcjs.f}function Nr(e){if(_chunkQRLTUOBJcjs.V.call(void 0, e)){if(_chunkQRLTUOBJcjs.W.call(void 0, e))return e.elementType;if(e.type in Mr)return Mr[e.type]}return _chunk3JTP2ATRcjs.f}function Se(e){var t,r;if(_chunk3JTP2ATRcjs.c.call(void 0, e)||_chunk3JTP2ATRcjs.b.call(void 0, e))return Se(e.value);if(typeof e=="string")return _chunk3JTP2ATRcjs.f;if(typeof e=="number")return(r=(t=Lt(String(e)))==null?void 0:t.dataType)!=null?r:_chunk3JTP2ATRcjs.f;if(typeof e=="boolean")return _chunkQRLTUOBJcjs.K;if("kind"in e){let n=e.kind;if(n in Wr)return Wr[n]}return _chunkQRLTUOBJcjs.V.call(void 0, e)?e:_chunk3JTP2ATRcjs.f}function Lt(e){if(/^0x[0-9a-f]+$/i.test(e))return{value:e,dataType:_chunkQRLTUOBJcjs.I};if(/^0b[01]+$/i.test(e))return{value:`${Number.parseInt(e.slice(2),2)}`,dataType:_chunkQRLTUOBJcjs.I};if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return{value:e,dataType:_chunkQRLTUOBJcjs.J};if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return{value:e,dataType:_chunkQRLTUOBJcjs.J};if(/^-?\d+$/i.test(e))return{value:e,dataType:_chunkQRLTUOBJcjs.I}}var M={get(e,t){if(t in e)return Reflect.get(e,t);if(t!=="~providing")return t==="toString"||t===Symbol.toStringTag||t===Symbol.toPrimitive?()=>e.toString():new Proxy({"~resolve":r=>`${r.resolve(e)}.${String(t)}`,toString:()=>{var r;return`.value(...).${String(t)}:${(r=e.label)!=null?r:"<unnamed>"}`},[_chunk3JTP2ATRcjs.a]:{dataType:Ee(e[_chunk3JTP2ATRcjs.a].dataType,String(t))}},M)}};function Ve(e){let t=e;for(;_chunk3JTP2ATRcjs.b.call(void 0, t)||_chunk3JTP2ATRcjs.c.call(void 0, t)||_chunk3JTP2ATRcjs.e.call(void 0, t)||_chunk3JTP2ATRcjs.k.call(void 0, t);)t=t.value;return t}function jr(e,t){return new Ct(e,t)}var zr;zr=_chunk3JTP2ATRcjs.a;var Ct=class{constructor(t,r){this.dataType=t;this._value=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");_chunkQRLTUOBJcjs.c.call(void 0, this,zr);this[_chunk3JTP2ATRcjs.a]={dataType:t}}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),n=t.resolveValue(this._value,this.dataType);return t.addDeclaration(`const ${r} = ${n};`),r}toString(){var t;return`const:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){return _chunkQRLTUOBJcjs.p.call(void 0, )?new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`},[_chunk3JTP2ATRcjs.a]:{dataType:this.dataType}},M):this._value}};function N(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function le(e,t){for(let[r,n]of Object.entries(t))e[r]=n,N(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function Kr(e,t,r){let n=[...e.matchAll(new RegExp(":\\s*(?<arg>.*?)\\s*[,)]","g"))].map(a=>a?a[1]:void 0);r(Object.fromEntries(t.flatMap((a,o)=>{let i=n?n[o]:void 0;return _chunkQRLTUOBJcjs.X.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function De(e,t,r){var o;let n=e.match(new RegExp("->(?<output>.*?){","s")),a=n?(o=n[1])==null?void 0:o.trim():void 0;_chunkQRLTUOBJcjs.X.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function Kn(e){return new RegExp(`(?<![\\w_.])${e.replaceAll(".","\\.")}(?![\\w_])`,"g")}function de(e,t,r){return Object.entries(t).reduce((n,[a,o])=>{var i;return _chunk3JTP2ATRcjs.i.call(void 0, o)||_chunk3QXCKMEJcjs.c.call(void 0, o)?n.replaceAll(Kn(a),e.resolve(o)):o!==null&&typeof o=="object"?((i=[...r.matchAll(new RegExp(`${a.replaceAll(".","\\.")}\\.(?<prop>.*?)(?![\\w_])`,"g"))].map(l=>l[1]))!=null?i:[]).reduce((l,u)=>u&&u in o?de(e,{[`${a}.${u}`]:o[u]},l):l,n):n},r)}function qr(e){return new Et(e)}var Et=class{constructor(t){this.declaration=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"externalsToApply",[])}$uses(t){return this.externalsToApply.push(t),this}"~resolve"(t){let r={};for(let a of this.externalsToApply)le(r,a);let n=de(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}};var Jr=new WeakMap;function Hr(e){return Jr.get(e)}function Yr(e,t,r){return Jr.set(e,{ast:t,externals:r}),e}function te(e,t){let r=[];return typeof t=="string"&&(Kr(t,e.argTypes,n=>r.push(n)),De(t,e.returnType,n=>r.push(n))),{label:void 0,applyExternals(n){r.push(n)},resolve(n,a=""){var s;let o={};for(let l of r)le(o,l);let i=n.names.makeUnique(this.label);if(typeof t=="string"){let l=de(n,o,t.trim());n.addDeclaration(`${a}fn ${i}${l}`)}else{let l=Hr(t);if(l!=null&&l.externals){let c=Object.fromEntries(Object.entries(l.externals).filter(([T])=>!(T in o)));le(o,c)}let u=(s=l==null?void 0:l.ast)!=null?s:n.transpileFn(String(t)),d=u.externalNames.filter(c=>!(c in o));if(d.length>0)throw new (0, _chunkQRLTUOBJcjs.h)(this.label,d);let f=u.argNames.map((c,T)=>({value:c,dataType:e.argTypes[T]})),{head:g,body:w}=n.fnToWgsl({args:f,returnType:e.returnType,body:u.body,externalMap:o});n.addDeclaration(`${a}fn ${i}${n.resolve(g)}${n.resolve(w)}`)}return i}}}function Qr(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunk3QXCKMEJcjs.ta.call(void 0, n))return[r,n];let a=_chunk3QXCKMEJcjs.g.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunk3QXCKMEJcjs.oa.call(void 0, n,{type:"@location",value:t++})]}))}function rt(e){return _chunk3QXCKMEJcjs.h.call(void 0, e)?_chunk3QXCKMEJcjs.g.call(void 0, e)!==void 0?e:_chunk3QXCKMEJcjs.ra.call(void 0, 0,e):_chunk3QXCKMEJcjs.i.call(void 0, Qr(e))}function Fe(e){return _chunk3QXCKMEJcjs.i.call(void 0, Qr(e))}function Xr(e){var t,r,n,a;return{argTypes:[Fe((t=e.in)!=null?t:{})],returnType:void 0,workgroupSize:[(r=e.workgroupSize[0])!=null?r:1,(n=e.workgroupSize[1])!=null?n:1,(a=e.workgroupSize[2])!=null?a:1],does(o){return qn(this,e.workgroupSize,o)}}}function qn(e,t,r){let n=te(e,r),a=e.argTypes[0];return{shell:e,get label(){return n.label},$uses(o){return n.applyExternals(o),this},$name(o){return n.label=o,N(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){return n.resolve(o,`@compute @workgroup_size(${t.join(", ")}) `)},toString(){var o;return`computeFn:${(o=this.label)!=null?o:"<unnamed>"}`}}}function Zr(e,t){return{argTypes:e,returnType:t,does(r){return Hn(this,r)}}}function Vt(e){return(e==null?void 0:e.resourceType)==="function"}function Jn([e,t]){var r;return`${(r=e.label)!=null?r:"<unnamed>"}=${t}`}function Hn(e,t){let r=te(e,t),n={shell:e,resourceType:"function",$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,this},with(i,s){return en(o,[[_chunk3JTP2ATRcjs.e.call(void 0, i)?i.slot:i,s]])},"~resolve"(i){return r.resolve(i)}},a=_chunkQRLTUOBJcjs.r.call(void 0, (...i)=>{if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");return t(...i)},(...i)=>{var s;return{value:new nt(o,i.map(l=>l.value)),dataType:(s=e.returnType)!=null?s:_chunk3JTP2ATRcjs.f}});Object.defineProperty(a,_chunk3JTP2ATRcjs.a,{value:{implementation:t}});let o=Object.assign(a,n);return Object.defineProperty(o,"label",{get:()=>r.label}),Object.defineProperty(o,"toString",{value:()=>{var i;return`fn:${(i=r.label)!=null?i:"<unnamed>"}`}}),o}function en(e,t){let r={resourceType:"function",shell:e.shell,"~providing":{inner:e,pairs:t},$uses(o){return e.$uses(o),this},$name(o){return e.$name(o),this},with(o,i){return en(a,[...t,[_chunk3JTP2ATRcjs.e.call(void 0, o)?o.slot:o,i]])}},n=_chunkQRLTUOBJcjs.r.call(void 0, (...o)=>e(...o),(...o)=>{var i;return{value:new nt(a,o.map(s=>s.value)),dataType:(i=e.shell.returnType)!=null?i:_chunk3JTP2ATRcjs.f}}),a=Object.assign(n,r);return Object.defineProperty(a,"label",{get:()=>e.label}),Object.defineProperty(a,"toString",{value(){var i;return`fn:${(i=e.label)!=null?i:"<unnamed>"}[${t.map(Jn).join(", ")}]`}}),Object.defineProperty(a,_chunk3JTP2ATRcjs.a,{value:{implementation:e[_chunk3JTP2ATRcjs.a].implementation}}),a}var nt=class{constructor(t,r){this._fn=t;this._params=r}get label(){return this._fn.label}"~resolve"(t){return t.resolve(`${t.resolve(this._fn)}(${this._params.map(r=>t.resolve(r)).join(", ")})`)}toString(){var t;return`call:${(t=this.label)!=null?t:"<unnamed>"}`}};function tn(e){var t;return{argTypes:[Fe((t=e.in)!=null?t:{})],targets:e.out,returnType:rt(e.out),does(r){return Yn(this,r)}}}function Yn(e,t){let r=te(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&De(t,n,i=>r.applyExternals(i)),{shell:e,outputType:n,get label(){return r.label},$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,N(n)&&n.$name(`${i}_Output`),N(a)&&a.$name(`${i}_Input`),this},"~resolve"(i){if(typeof t=="string")return r.resolve(i,"@fragment ");let s=i;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(n),r.resolve(i,"@fragment ")}finally{s.callStack.pop()}},toString(){var i;return`fragmentFn:${(i=this.label)!=null?i:"<unnamed>"}`}}}function rn(e){var t,r;return{attributes:[(t=e.in)!=null?t:{}],returnType:rt(e.out),argTypes:[Fe((r=e.in)!=null?r:{})],does(n){return Qn(this,n)}}}function Qn(e,t){let r=te(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&De(t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,inputType:a,get label(){return r.label},$uses(o){return r.applyExternals(o),this},$name(o){return r.label=o,N(n)&&n.$name(`${o}_Output`),N(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){if(typeof t=="string")return r.resolve(o,"@vertex ");let i=o;if(i.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return i.callStack.push(n),r.resolve(o,"@vertex ")}finally{i.callStack.pop()}},toString(){var o;return`vertexFn:${(o=this.label)!=null?o:"<unnamed>"}`}}}var re=class{constructor(){_chunkQRLTUOBJcjs.c.call(void 0, this,"lastUniqueId",0)}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}},ne= exports.StrictNameRegistry =class{constructor(){_chunkQRLTUOBJcjs.c.call(void 0, this,"_usedNames",new Set)}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}};function nn(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}function Ge(e){return typeof(e==null?void 0:e.format)=="string"}function an(e,t){var i,s;let r=[];if(_chunk3QXCKMEJcjs.h.call(void 0, e)){if(!Ge(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:(i=_chunk3QXCKMEJcjs.g.call(void 0, e))!=null?i:0}]}]}}let n=[],a=new WeakMap,o=0;for(let[l,u]of Object.entries(e)){if(_chunk3QXCKMEJcjs.ta.call(void 0, u))continue;let d=t[l];if(!d)throw new Error(`An attribute by the name of '${l}' was not provided to the shader.`);let f=d._layout,g=a.get(f);g||(r.push(f),g=[],n.push({arrayStride:f.stride,stepMode:f.stepMode,attributes:g}),a.set(f,g)),o=(s=_chunk3QXCKMEJcjs.g.call(void 0, u))!=null?s:o,g.push({format:d.format,offset:d.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Xn=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"];function Zn(e){return Xn.includes(e.type)}function Gt(e,[t,r]){return` ${_chunk3QXCKMEJcjs.ua.call(void 0, r)}${t}: ${e.resolve(r)},
2
- `}function ea(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24; var _class25; var _class26; var _class27; var _class28;var _chunkUPPJES6Wcjs = require('./chunk-UPPJES6W.cjs');var _chunkFM3TKZFZcjs = require('./chunk-FM3TKZFZ.cjs');var _chunkM4VUFFPZcjs = require('./chunk-M4VUFFPZ.cjs');var Cn=["vec2f","vec2h","vec2i","vec2u","vec3f","vec3h","vec3i","vec3u","vec4f","vec4h","vec4i","vec4u","struct"],En={f:{1:_chunkM4VUFFPZcjs.K,2:_chunkM4VUFFPZcjs.p,3:_chunkM4VUFFPZcjs.t,4:_chunkM4VUFFPZcjs.x},h:{1:_chunkM4VUFFPZcjs.L,2:_chunkM4VUFFPZcjs.q,3:_chunkM4VUFFPZcjs.u,4:_chunkM4VUFFPZcjs.y},i:{1:_chunkM4VUFFPZcjs.J,2:_chunkM4VUFFPZcjs.r,3:_chunkM4VUFFPZcjs.v,4:_chunkM4VUFFPZcjs.z},u:{1:_chunkM4VUFFPZcjs.I,2:_chunkM4VUFFPZcjs.s,3:_chunkM4VUFFPZcjs.w,4:_chunkM4VUFFPZcjs.A}},Er={vec2f:_chunkM4VUFFPZcjs.p,vec2h:_chunkM4VUFFPZcjs.q,vec2i:_chunkM4VUFFPZcjs.r,vec2u:_chunkM4VUFFPZcjs.s,vec3f:_chunkM4VUFFPZcjs.t,vec3h:_chunkM4VUFFPZcjs.u,vec3i:_chunkM4VUFFPZcjs.v,vec3u:_chunkM4VUFFPZcjs.w,vec4f:_chunkM4VUFFPZcjs.x,vec4h:_chunkM4VUFFPZcjs.y,vec4i:_chunkM4VUFFPZcjs.z,vec4u:_chunkM4VUFFPZcjs.A,mat2x2f:_chunkM4VUFFPZcjs.B,mat3x3f:_chunkM4VUFFPZcjs.C,mat4x4f:_chunkM4VUFFPZcjs.D},Vr={vec2f:_chunkM4VUFFPZcjs.K,vec2h:_chunkM4VUFFPZcjs.L,vec2i:_chunkM4VUFFPZcjs.J,vec2u:_chunkM4VUFFPZcjs.I,vec3f:_chunkM4VUFFPZcjs.K,vec3h:_chunkM4VUFFPZcjs.L,vec3i:_chunkM4VUFFPZcjs.J,vec3u:_chunkM4VUFFPZcjs.I,vec4f:_chunkM4VUFFPZcjs.K,vec4h:_chunkM4VUFFPZcjs.L,vec4i:_chunkM4VUFFPZcjs.J,vec4u:_chunkM4VUFFPZcjs.I,mat2x2f:_chunkM4VUFFPZcjs.p,mat3x3f:_chunkM4VUFFPZcjs.t,mat4x4f:_chunkM4VUFFPZcjs.x};function Be(e,t){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return _chunkFM3TKZFZcjs.f;if(_chunkFM3TKZFZcjs.c.call(void 0, e)||_chunkFM3TKZFZcjs.b.call(void 0, e)){let o=_chunkM4VUFFPZcjs.j.call(void 0, );if(!o)throw new Error("Resolution context not found when unwrapping slot or derived");let i=o.unwrap(e);return ce(i)}let r=e;for(_chunkFM3TKZFZcjs.l.call(void 0, r)&&(r=r[_chunkFM3TKZFZcjs.a].dataType);_chunkM4VUFFPZcjs.aa.call(void 0, r);)r=r.inner;let n="kind"in r?r.kind:r.type;if(n==="struct")return _nullishCoalesce(r.propTypes[t], () => (_chunkFM3TKZFZcjs.f));let a=t.length;if(Cn.includes(n)&&a>=1&&a<=4){let o=n[4],i=En[o][a];if(i)return i}return _chunkM4VUFFPZcjs.S.call(void 0, r)?r:_chunkFM3TKZFZcjs.f}function Gr(e){if(_chunkM4VUFFPZcjs.S.call(void 0, e)){if(_chunkM4VUFFPZcjs.T.call(void 0, e))return e.elementType;if(e.type in Vr)return Vr[e.type]}return _chunkFM3TKZFZcjs.f}function ce(e){if(_chunkFM3TKZFZcjs.c.call(void 0, e)||_chunkFM3TKZFZcjs.b.call(void 0, e))return ce(e.value);if(typeof e=="string")return _chunkFM3TKZFZcjs.f;if(typeof e=="number")return _nullishCoalesce(_optionalChain([Rt, 'call', _2 => _2(String(e)), 'optionalAccess', _3 => _3.dataType]), () => (_chunkFM3TKZFZcjs.f));if(typeof e=="boolean")return _chunkM4VUFFPZcjs.H;if("kind"in e){let t=e.kind;if(t in Er)return Er[t]}return _chunkM4VUFFPZcjs.S.call(void 0, e)?e:_chunkFM3TKZFZcjs.f}function Rt(e){if(/^0x[0-9a-f]+$/i.test(e))return{value:e,dataType:_chunkM4VUFFPZcjs.F};if(/^0b[01]+$/i.test(e))return{value:`${Number.parseInt(e.slice(2),2)}`,dataType:_chunkM4VUFFPZcjs.F};if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return{value:e,dataType:_chunkM4VUFFPZcjs.G};if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return{value:e,dataType:_chunkM4VUFFPZcjs.G};if(/^-?\d+$/i.test(e))return{value:e,dataType:_chunkM4VUFFPZcjs.F}}var G={get(e,t){if(t in e)return Reflect.get(e,t);if(t!=="~providing")return t==="toString"||t===Symbol.toStringTag||t===Symbol.toPrimitive?()=>e.toString():new Proxy({"~resolve":r=>`${r.resolve(e)}.${String(t)}`,toString:()=>`.value(...).${String(t)}:${_nullishCoalesce(e.label, () => ("<unnamed>"))}`,[_chunkFM3TKZFZcjs.a]:{dataType:Be(e[_chunkFM3TKZFZcjs.a].dataType,String(t))}},G)}};function _e(e){let t=e;for(;_chunkFM3TKZFZcjs.b.call(void 0, t)||_chunkFM3TKZFZcjs.c.call(void 0, t)||_chunkFM3TKZFZcjs.e.call(void 0, t)||_chunkFM3TKZFZcjs.k.call(void 0, t);)t=t.value;return t}function $r(e,t){return new Bt(e,t)}var Bt=class{constructor(t,r){this.dataType=t;this._value=r;this[_chunkFM3TKZFZcjs.a]={dataType:t}}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),n=t.resolveValue(this._value,this.dataType);return t.addDeclaration(`const ${r} = ${n};`),r}toString(){return`const:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){return _chunkM4VUFFPZcjs.m.call(void 0, )?new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkFM3TKZFZcjs.a]:{dataType:this.dataType}},G):this._value}};function $(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function oe(e,t){for(let[r,n]of Object.entries(t))e[r]=n,$(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function kr(e,t,r){let n=[...e.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(a=>a?a[1]:void 0);r(Object.fromEntries(t.flatMap((a,o)=>{let i=n?n[o]:void 0;return _chunkM4VUFFPZcjs.U.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function ye(e,t,r){let n=e.match(/->(?<output>.*?){/s),a=n?_optionalChain([n, 'access', _4 => _4[1], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]):void 0;_chunkM4VUFFPZcjs.U.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function Vn(e){return new RegExp(`(?<![\\w_.])${e.replaceAll(".","\\.")}(?![\\w_])`,"g")}function ie(e,t,r){return Object.entries(t).reduce((n,[a,o])=>_chunkFM3TKZFZcjs.i.call(void 0, o)||_chunkUPPJES6Wcjs.c.call(void 0, o)?n.replaceAll(Vn(a),e.resolve(o)):o!==null&&typeof o=="object"?(_nullishCoalesce([...r.matchAll(new RegExp(`${a.replaceAll(".","\\.")}\\.(?<prop>.*?)(?![\\w_])`,"g"))].map(s=>s[1]), () => ([]))).reduce((s,l)=>l&&l in o?ie(e,{[`${a}.${l}`]:o[l]},s):s,n):n,r)}function Or(e){return new _t(e)}var _t= (_class =class{constructor(t){;_class.prototype.__init.call(this);this.declaration=t}__init() {this.externalsToApply=[]}$uses(t){return this.externalsToApply.push(t),this}"~resolve"(t){let r={};for(let a of this.externalsToApply)oe(r,a);let n=ie(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}}, _class);var Wr=new WeakMap;function Mr(e){return Wr.get(e)}function Nr(e,t,r){return Wr.set(e,{ast:t,externals:r}),e}function Y(e,t){let r=[];return typeof t=="string"&&(kr(t,e.argTypes,n=>r.push(n)),ye(t,e.returnType,n=>r.push(n))),{label:void 0,applyExternals(n){r.push(n)},resolve(n,a=""){let o={};for(let s of r)oe(o,s);let i=n.names.makeUnique(this.label);if(typeof t=="string"){let s=ie(n,o,t.trim());n.addDeclaration(`${a}fn ${i}${s}`)}else{let s=Mr(t);if(_optionalChain([s, 'optionalAccess', _7 => _7.externals])){let T=Object.fromEntries(Object.entries(s.externals).filter(([f])=>!(f in o)));oe(o,T)}let l=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _8 => _8.ast]), () => (n.transpileFn(String(t)))),u=l.externalNames.filter(T=>!(T in o));if(u.length>0)throw new (0, _chunkM4VUFFPZcjs.e)(this.label,u);let d=l.argNames.map((T,f)=>({value:T,dataType:e.argTypes[f]})),{head:m,body:g}=n.fnToWgsl({args:d,returnType:e.returnType,body:l.body,externalMap:o});n.addDeclaration(`${a}fn ${i}${n.resolve(m)}${n.resolve(g)}`)}return i}}}function zr(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunkUPPJES6Wcjs.ta.call(void 0, n))return[r,n];let a=_chunkUPPJES6Wcjs.g.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunkUPPJES6Wcjs.oa.call(void 0, n,{type:"@location",value:t++})]}))}function Qe(e){return _chunkUPPJES6Wcjs.h.call(void 0, e)?_chunkUPPJES6Wcjs.g.call(void 0, e)!==void 0?e:_chunkUPPJES6Wcjs.ra.call(void 0, 0,e):_chunkUPPJES6Wcjs.i.call(void 0, zr(e))}function xe(e){return _chunkUPPJES6Wcjs.i.call(void 0, zr(e))}function jr(e){return{argTypes:[xe(_nullishCoalesce(e.in, () => ({})))],returnType:void 0,workgroupSize:[_nullishCoalesce(e.workgroupSize[0], () => (1)),_nullishCoalesce(e.workgroupSize[1], () => (1)),_nullishCoalesce(e.workgroupSize[2], () => (1))],does(t){return Gn(this,e.workgroupSize,t)}}}function Gn(e,t,r){let n=Y(e,r),a=e.argTypes[0];return{shell:e,get label(){return n.label},$uses(o){return n.applyExternals(o),this},$name(o){return n.label=o,$(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){return n.resolve(o,`@compute @workgroup_size(${t.join(", ")}) `)},toString(){return`computeFn:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}}function Kr(e,t){return{argTypes:e,returnType:t,does(r){return kn(this,r)}}}function Pt(e){return _optionalChain([e, 'optionalAccess', _9 => _9.resourceType])==="function"}function $n([e,t]){return`${_nullishCoalesce(e.label, () => ("<unnamed>"))}=${t}`}function kn(e,t){let r=Y(e,t),n={shell:e,resourceType:"function",$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,this},with(i,s){return qr(o,[[_chunkFM3TKZFZcjs.e.call(void 0, i)?i.slot:i,s]])},"~resolve"(i){return r.resolve(i)}},a=_chunkM4VUFFPZcjs.o.call(void 0, (...i)=>{if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");return t(...i)},(...i)=>({value:new Xe(o,i.map(s=>s.value)),dataType:_nullishCoalesce(e.returnType, () => (_chunkFM3TKZFZcjs.f))}));Object.defineProperty(a,_chunkFM3TKZFZcjs.a,{value:{implementation:t}});let o=Object.assign(a,n);return Object.defineProperty(o,"label",{get:()=>r.label}),Object.defineProperty(o,"toString",{value:()=>`fn:${_nullishCoalesce(r.label, () => ("<unnamed>"))}`}),o}function qr(e,t){let r={resourceType:"function",shell:e.shell,"~providing":{inner:e,pairs:t},$uses(o){return e.$uses(o),this},$name(o){return e.$name(o),this},with(o,i){return qr(a,[...t,[_chunkFM3TKZFZcjs.e.call(void 0, o)?o.slot:o,i]])}},n=_chunkM4VUFFPZcjs.o.call(void 0, (...o)=>e(...o),(...o)=>({value:new Xe(a,o.map(i=>i.value)),dataType:_nullishCoalesce(e.shell.returnType, () => (_chunkFM3TKZFZcjs.f))})),a=Object.assign(n,r);return Object.defineProperty(a,"label",{get:()=>e.label}),Object.defineProperty(a,"toString",{value(){return`fn:${_nullishCoalesce(e.label, () => ("<unnamed>"))}[${t.map($n).join(", ")}]`}}),Object.defineProperty(a,_chunkFM3TKZFZcjs.a,{value:{implementation:e[_chunkFM3TKZFZcjs.a].implementation}}),a}var Xe=class{constructor(t,r){this._fn=t;this._params=r}get label(){return this._fn.label}"~resolve"(t){return t.resolve(`${t.resolve(this._fn)}(${this._params.map(r=>t.resolve(r)).join(", ")})`)}toString(){return`call:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}};function Jr(e){return{argTypes:[xe(_nullishCoalesce(e.in, () => ({})))],targets:e.out,returnType:Qe(e.out),does(t){return On(this,t)}}}function On(e,t){let r=Y(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&ye(t,n,i=>r.applyExternals(i)),{shell:e,outputType:n,get label(){return r.label},$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,$(n)&&n.$name(`${i}_Output`),$(a)&&a.$name(`${i}_Input`),this},"~resolve"(i){if(typeof t=="string")return r.resolve(i,"@fragment ");let s=i;if(s.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return s.callStack.push(n),r.resolve(i,"@fragment ")}finally{s.callStack.pop()}},toString(){return`fragmentFn:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}}function Hr(e){return{attributes:[_nullishCoalesce(e.in, () => ({}))],returnType:Qe(e.out),argTypes:[xe(_nullishCoalesce(e.in, () => ({})))],does(t){return Wn(this,t)}}}function Wn(e,t){let r=Y(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&ye(t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,inputType:a,get label(){return r.label},$uses(o){return r.applyExternals(o),this},$name(o){return r.label=o,$(n)&&n.$name(`${o}_Output`),$(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){if(typeof t=="string")return r.resolve(o,"@vertex ");let i=o;if(i.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return i.callStack.push(n),r.resolve(o,"@vertex ")}finally{i.callStack.pop()}},toString(){return`vertexFn:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}}var Q= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.lastUniqueId=0}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}}, _class2),X= exports.StrictNameRegistry = (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this._usedNames=new Set}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}}, _class3);function Yr(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}function Pe(e){return typeof _optionalChain([e, 'optionalAccess', _10 => _10.format])=="string"}function Qr(e,t){let r=[];if(_chunkUPPJES6Wcjs.h.call(void 0, e)){if(!Pe(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:_nullishCoalesce(_chunkUPPJES6Wcjs.g.call(void 0, e), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[i,s]of Object.entries(e)){if(_chunkUPPJES6Wcjs.ta.call(void 0, s))continue;let l=t[i];if(!l)throw new Error(`An attribute by the name of '${i}' was not provided to the shader.`);let u=l._layout,d=a.get(u);d||(r.push(u),d=[],n.push({arrayStride:u.stride,stepMode:u.stepMode,attributes:d}),a.set(u,d)),o=_nullishCoalesce(_chunkUPPJES6Wcjs.g.call(void 0, s), () => (o)),d.push({format:l.format,offset:l.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Mn=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"];function Nn(e){return Mn.includes(e.type)}function Lt(e,[t,r]){return` ${_chunkUPPJES6Wcjs.ua.call(void 0, r)}${t}: ${e.resolve(r)},
2
+ `}function zn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
3
3
  struct ${r} {
4
- ${Object.entries(t.propTypes).map(n=>Gt(e,n)).join("")}}
5
- `),r}function ta(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
4
+ ${Object.entries(t.propTypes).map(n=>Lt(e,n)).join("")}}
5
+ `),r}function jn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
6
6
  struct ${r} {
7
- ${Object.entries(t.propTypes).map(n=>Ge(n[1])?Gt(e,[n[0],_chunk3QXCKMEJcjs.k[n[1].format]]):Gt(e,n)).join("")}
7
+ ${Object.entries(t.propTypes).map(n=>Pe(n[1])?Lt(e,[n[0],_chunkUPPJES6Wcjs.k[n[1].format]]):Lt(e,n)).join("")}
8
8
  }
9
- `),r}function ra(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function na(e,t){let r=e.resolve(Ge(t.elementType)?_chunk3QXCKMEJcjs.k[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function $t(e,t){if(_chunk3QXCKMEJcjs.c.call(void 0, t))return t.type==="unstruct"?ta(e,t):t.type==="disarray"?na(e,t):t.type==="loose-decorated"?e.resolve(Ge(t.inner)?_chunk3QXCKMEJcjs.k[t.inner.format]:t.inner):e.resolve(_chunk3QXCKMEJcjs.k[t.type]);if(Zn(t))return t.type;if(t.type==="struct")return ea(e,t);if(t.type==="array")return ra(e,t);if(t.type==="atomic")return`atomic<${$t(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);if(t.type==="ptr")return t.addressSpace==="storage"?`ptr<storage, ${e.resolve(t.inner)}, ${t.access==="read-write"?"read_write":t.access}>`:`ptr<${t.addressSpace}, ${e.resolve(t.inner)}>`;if(t.type==="abstractInt"||t.type==="abstractFloat")throw new Error("Abstract types have no concrete representation in WGSL");nn(t,"resolveData")}var oa=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],ia=["&&","||","==","!=","<","<=",">",">="];function on(e,t,r){return r?ia.includes(t)?_chunkQRLTUOBJcjs.K:t==="="?r:e:t==="!"||t==="~"?_chunkQRLTUOBJcjs.K:e}function v(e,t){return _chunk3JTP2ATRcjs.i.call(void 0, t.value)?e.resolve(t.value):String(t.value)}function sa(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function sn(e,t){return{value:t?"true":"false",dataType:_chunkQRLTUOBJcjs.K}}function un(e,t){e.pushBlockScope();try{return`${e.indent()}{
10
- ${t.b.map(r=>me(e,r)).join(`
9
+ `),r}function Kn(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function qn(e,t){let r=e.resolve(Pe(t.elementType)?_chunkUPPJES6Wcjs.k[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Ct(e,t){if(_chunkUPPJES6Wcjs.c.call(void 0, t))return t.type==="unstruct"?jn(e,t):t.type==="disarray"?qn(e,t):t.type==="loose-decorated"?e.resolve(Pe(t.inner)?_chunkUPPJES6Wcjs.k[t.inner.format]:t.inner):e.resolve(_chunkUPPJES6Wcjs.k[t.type]);if(Nn(t))return t.type;if(t.type==="struct")return zn(e,t);if(t.type==="array")return Kn(e,t);if(t.type==="atomic")return`atomic<${Ct(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);if(t.type==="ptr")return t.addressSpace==="storage"?`ptr<storage, ${e.resolve(t.inner)}, ${t.access==="read-write"?"read_write":t.access}>`:`ptr<${t.addressSpace}, ${e.resolve(t.inner)}>`;if(t.type==="abstractInt"||t.type==="abstractFloat")throw new Error("Abstract types have no concrete representation in WGSL");Yr(t,"resolveData")}var Hn=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],Yn=["&&","||","==","!=","<","<=",">",">="];function Xr(e,t,r){return r?Yn.includes(t)?_chunkM4VUFFPZcjs.H:t==="="?r:e:t==="!"||t==="~"?_chunkM4VUFFPZcjs.H:e}function w(e,t){return _chunkFM3TKZFZcjs.i.call(void 0, t.value)?e.resolve(t.value):String(t.value)}function Qn(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function Zr(e,t){return{value:t?"true":"false",dataType:_chunkM4VUFFPZcjs.H}}function en(e,t){e.pushBlockScope();try{return`${e.indent()}{
10
+ ${t.b.map(r=>se(e,r)).join(`
11
11
  `)}
12
- ${e.dedent()}}`}finally{e.popBlockScope()}}function ua(e,t,r){return e.defineVariable(t,r)}function Ot(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function I(e,t){var r;if(typeof t=="string")return Ot(e,t);if(typeof t=="boolean")return sn(e,t);if("x"in t){let[n,a,o]=t.x,i=I(e,n),s=I(e,o),l=v(e,i),u=v(e,s),d=on(i.dataType,a,s.dataType);return{value:oa.includes(a)?`(${l} ${a} ${u})`:`${l} ${a} ${u}`,dataType:d}}if("p"in t){let[n,a]=t.p,o=I(e,a);return{value:`${v(e,o)}${n}`,dataType:o.dataType}}if("u"in t){let[n,a]=t.u,o=I(e,a),i=v(e,o),s=on(o.dataType,n);return{value:`${n}${i}`,dataType:s}}if("a"in t){let[n,a]=t.a,o=I(e,n);if(typeof o.value=="string")return{value:`${o.value}.${a}`,dataType:Ee(o.dataType,a)};let i=o.value[a];if(_chunk3JTP2ATRcjs.i.call(void 0, o.value))return{value:i,dataType:Ee(o.value,a)};if(typeof o.value=="object"){let s=_chunk3JTP2ATRcjs.i.call(void 0, i)?Se(i):_chunk3JTP2ATRcjs.f;return{value:i,dataType:s}}throw new Error(`Cannot access member ${a} of ${o.value}`)}if("i"in t){let[n,a]=t.i,o=I(e,n),i=I(e,a),s=v(e,o),l=v(e,i);return{value:`${s}[${l}]`,dataType:Nr(o.dataType)}}if("n"in t){let n=Lt(t.n);if(!n)throw new Error(`Invalid numeric literal ${t.n}`);return n}if("f"in t){let[n,a]=t.f,o=I(e,n),i=o.value;e.callStack.push(i);let l=a.map(d=>I(e,d)).map(d=>({value:v(e,d),dataType:d.dataType})),u=l.map(d=>d.value);return e.callStack.pop(),typeof i=="string"?{value:`${i}(${u.join(", ")})`,dataType:o.dataType}:_chunkQRLTUOBJcjs.X.call(void 0, i)?{value:`${e.resolve(i)}(${u.join(", ")})`,dataType:o.dataType}:i(...l)}if("o"in t){let n=t.o,a=e.callStack[e.callStack.length-1],o=i=>i.map(s=>{let l=I(e,s);return v(e,l)}).join(", ");if(_chunkQRLTUOBJcjs.X.call(void 0, a)){let s=Object.keys(a.propTypes).map(l=>{let u=n[l];if(u===void 0)throw new Error(`Missing property ${l} in object literal for struct ${a}`);return u});return{value:o(s),dataType:a}}return{value:o(Object.values(n)),dataType:_chunk3JTP2ATRcjs.f}}if("y"in t){let n=t.y.map(u=>I(e,u));if(n.length===0)throw new Error("Cannot create empty array literal.");let a=(r=n[0])==null?void 0:r.dataType,o=n.find(u=>u.dataType!==a);if(o)throw new Error(`Cannot mix types in array literal. Type ${o.dataType.type} does not match expected type ${a==null?void 0:a.type}.`);if(!_chunkQRLTUOBJcjs.V.call(void 0, a))throw new Error("Cannot use non-WGSL data types in array literals.");a=a.type==="abstractInt"?_chunkQRLTUOBJcjs.L:a.type==="abstractFloat"?_chunkQRLTUOBJcjs.N:a;let s=`array<${e.resolve(a)}, ${n.length}>`,l=n.map(u=>v(e,u));return{value:`${s}( ${l.join(", ")} )`,dataType:_chunk3QXCKMEJcjs.ea.call(void 0, a,n.length)}}if("s"in t)throw new Error("Cannot use string literals in TGSL.");sa(t)}function me(e,t){if(typeof t=="string")return`${e.pre}${v(e,Ot(e,t))};`;if(typeof t=="boolean")return`${e.pre}${v(e,sn(e,t))};`;if("r"in t){if(_chunkQRLTUOBJcjs.X.call(void 0, e.callStack[e.callStack.length-1])&&t.r!==null&&typeof t.r=="object"&&"o"in t.r){let r=v(e,I(e,t.r)),n=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}return ${n}(${r});`}return t.r===null?`${e.pre}return;`:`${e.pre}return ${v(e,I(e,t.r))};`}if("q"in t){let[r,n,a]=t.q,o=v(e,I(e,r));e.indent();let i=me(e,n);e.dedent(),e.indent();let s=a?me(e,a):void 0;return e.dedent(),s?`${e.pre}if (${o})
12
+ ${e.dedent()}}`}finally{e.popBlockScope()}}function Xn(e,t,r){return e.defineVariable(t,r)}function Et(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function F(e,t){if(typeof t=="string")return Et(e,t);if(typeof t=="boolean")return Zr(e,t);if("x"in t){let[r,n,a]=t.x,o=F(e,r),i=F(e,a),s=w(e,o),l=w(e,i),u=Xr(o.dataType,n,i.dataType);return{value:Hn.includes(n)?`(${s} ${n} ${l})`:`${s} ${n} ${l}`,dataType:u}}if("p"in t){let[r,n]=t.p,a=F(e,n);return{value:`${w(e,a)}${r}`,dataType:a.dataType}}if("u"in t){let[r,n]=t.u,a=F(e,n),o=w(e,a),i=Xr(a.dataType,r);return{value:`${r}${o}`,dataType:i}}if("a"in t){let[r,n]=t.a,a=F(e,r);if(typeof a.value=="string")return{value:`${a.value}.${n}`,dataType:Be(a.dataType,n)};let o=a.value[n];if(_chunkFM3TKZFZcjs.i.call(void 0, a.value))return{value:o,dataType:Be(a.value,n)};if(typeof a.value=="object"){let i=_chunkFM3TKZFZcjs.i.call(void 0, o)?ce(o):_chunkFM3TKZFZcjs.f;return{value:o,dataType:i}}throw new Error(`Cannot access member ${n} of ${a.value}`)}if("i"in t){let[r,n]=t.i,a=F(e,r),o=F(e,n),i=w(e,a),s=w(e,o);return{value:`${i}[${s}]`,dataType:Gr(a.dataType)}}if("n"in t){let r=Rt(t.n);if(!r)throw new Error(`Invalid numeric literal ${t.n}`);return r}if("f"in t){let[r,n]=t.f,a=F(e,r),o=a.value;e.callStack.push(o);let s=n.map(u=>F(e,u)).map(u=>({value:w(e,u),dataType:u.dataType})),l=s.map(u=>u.value);return e.callStack.pop(),typeof o=="string"?{value:`${o}(${l.join(", ")})`,dataType:a.dataType}:_chunkM4VUFFPZcjs.U.call(void 0, o)?{value:`${e.resolve(o)}(${l.join(", ")})`,dataType:a.dataType}:o(...s)}if("o"in t){let r=t.o,n=e.callStack[e.callStack.length-1],a=o=>o.map(i=>{let s=F(e,i);return w(e,s)}).join(", ");if(_chunkM4VUFFPZcjs.U.call(void 0, n)){let i=Object.keys(n.propTypes).map(s=>{let l=r[s];if(l===void 0)throw new Error(`Missing property ${s} in object literal for struct ${n}`);return l});return{value:a(i),dataType:n}}return{value:a(Object.values(r)),dataType:_chunkFM3TKZFZcjs.f}}if("y"in t){let r=t.y.map(l=>F(e,l));if(r.length===0)throw new Error("Cannot create empty array literal.");let n=_optionalChain([r, 'access', _11 => _11[0], 'optionalAccess', _12 => _12.dataType]),a=r.find(l=>l.dataType!==n);if(a)throw new Error(`Cannot mix types in array literal. Type ${a.dataType.type} does not match expected type ${_optionalChain([n, 'optionalAccess', _13 => _13.type])}.`);if(!_chunkM4VUFFPZcjs.S.call(void 0, n))throw new Error("Cannot use non-WGSL data types in array literals.");n=n.type==="abstractInt"?_chunkM4VUFFPZcjs.I:n.type==="abstractFloat"?_chunkM4VUFFPZcjs.K:n;let i=`array<${e.resolve(n)}, ${r.length}>`,s=r.map(l=>w(e,l));return{value:`${i}( ${s.join(", ")} )`,dataType:_chunkUPPJES6Wcjs.ea.call(void 0, n,r.length)}}if("s"in t)throw new Error("Cannot use string literals in TGSL.");Qn(t)}function se(e,t){if(typeof t=="string")return`${e.pre}${w(e,Et(e,t))};`;if(typeof t=="boolean")return`${e.pre}${w(e,Zr(e,t))};`;if("r"in t){if(_chunkM4VUFFPZcjs.U.call(void 0, e.callStack[e.callStack.length-1])&&t.r!==null&&typeof t.r=="object"&&"o"in t.r){let r=w(e,F(e,t.r)),n=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}return ${n}(${r});`}return t.r===null?`${e.pre}return;`:`${e.pre}return ${w(e,F(e,t.r))};`}if("q"in t){let[r,n,a]=t.q,o=w(e,F(e,r));e.indent();let i=se(e,n);e.dedent(),e.indent();let s=a?se(e,a):void 0;return e.dedent(),s?`${e.pre}if (${o})
13
13
  ${i}
14
14
  ${e.pre}else
15
15
  ${s}`:`${e.pre}if (${o})
16
- ${i}`}if("l"in t||"c"in t){let[r,n]="l"in t?t.l:t.c,a=n?I(e,n):void 0;if(!a||!n)throw new Error("Cannot create variable without an initial value.");ua(e,r,a.dataType);let o=v(e,Ot(e,r));if(typeof n=="object"&&"o"in n&&_chunkQRLTUOBJcjs.X.call(void 0, e.callStack[e.callStack.length-1])){let i=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}var ${o} = ${i}(${v(e,a)});`}return`${e.pre}var ${o} = ${v(e,a)};`}if("b"in t){e.pushBlockScope();try{return un(e,t)}finally{e.popBlockScope()}}if("j"in t){let[r,n,a,o]=t.j,i=r?me(e,r):void 0,s=i?i.slice(0,-1):"",l=n?I(e,n):void 0,u=l?v(e,l):"",d=a?me(e,a):void 0,f=d?d.slice(0,-1):"";e.indent();let g=me(e,o);return e.dedent(),`${e.pre}for (${s}; ${u}; ${f})
17
- ${g}`}if("w"in t){let[r,n]=t.w,a=v(e,I(e,r));e.indent();let o=me(e,n);return e.dedent(),`${e.pre}while (${a})
18
- ${o}`}return"k"in t?`${e.pre}continue;`:"d"in t?`${e.pre}break;`:`${e.pre}${v(e,I(e,t))};`}function kt(e,t){return un(e,t)}var _typedbinary = require('typed-binary');function pa(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var D=pa;var pn=new WeakMap;function at(e){let t=pn.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let i=e.propTypes[o];if(i===void 0)throw new Error(`Property ${o} is undefined in struct`);let s=r.size;D(r,_chunk3QXCKMEJcjs.e.call(void 0, e)?_chunk3QXCKMEJcjs.aa.call(void 0, i):_chunk3QXCKMEJcjs.$.call(void 0, i)),a&&(a.padding=r.size-s);let l=_chunk3QXCKMEJcjs.ca.call(void 0, i);n[o]={offset:r.size,size:l},a=n[o],r.add(l)}return a&&(a.padding=_chunk3QXCKMEJcjs.j.call(void 0, _chunk3QXCKMEJcjs.ca.call(void 0, e),_chunk3QXCKMEJcjs.$.call(void 0, e))-r.size),pn.set(e,n),n}var ot=(()=>{try{return new Function("return true"),!0}catch(e){return!1}})(),Wt=new WeakMap,Mt={u32:"u32",vec2u:"u32",vec3u:"u32",vec4u:"u32",i32:"i32",vec2i:"i32",vec3i:"i32",vec4i:"i32",f32:"f32",vec2f:"f32",vec3f:"f32",vec4f:"f32",vec2h:"f32",vec3h:"f32",vec4h:"f32",mat2x2f:"f32",mat3x3f:"f32",mat4x4f:"f32"},Nt={u32:"setUint32",i32:"setInt32",f32:"setFloat32"};function zt(e,t,r){if(_chunkQRLTUOBJcjs.X.call(void 0, e)||_chunk3QXCKMEJcjs.e.call(void 0, e)){let o=at(e),i=Object.entries(o).sort((l,u)=>l[1].offset-u[1].offset),s="";for(let[l,u]of i){let d=e.propTypes[l];d&&(s+=zt(d,`(${t} + ${u.offset})`,`${r}.${l}`))}return s}if(_chunkQRLTUOBJcjs.W.call(void 0, e)||_chunk3QXCKMEJcjs.d.call(void 0, e)){let o=e,i=_chunk3QXCKMEJcjs.j.call(void 0, _chunk3QXCKMEJcjs.ca.call(void 0, o.elementType),_chunk3QXCKMEJcjs.$.call(void 0, o.elementType)),s="";return s+=`for (let i = 0; i < ${o.elementCount}; i++) {
19
- `,s+=zt(o.elementType,`(${t} + i * ${i})`,`${r}[i]`),s+=`}
20
- `,s}if(_chunkQRLTUOBJcjs.R.call(void 0, e)){let o=Mt[e.type],i="",s=Nt[o],l=["x","y","z","w"],u=_chunkQRLTUOBJcjs.P.call(void 0, e)?2:_chunkQRLTUOBJcjs.Q.call(void 0, e)?3:4;for(let d=0;d<u;d++)i+=`output.${s}((${t} + ${d*4}), ${r}.${l[d]}, littleEndian);
21
- `;return i}if(_chunkQRLTUOBJcjs.U.call(void 0, e)){let o=Mt[e.type],i=Nt[o],s=_chunkQRLTUOBJcjs.S.call(void 0, e)?2:_chunkQRLTUOBJcjs.T.call(void 0, e)?3:4,l=s*s,u=_chunk3QXCKMEJcjs.j.call(void 0, s*4,8),d="";for(let f=0;f<l;f++){let g=Math.floor(f/s),w=f%s,c=g*u+w*4;d+=`output.${i}((${t} + ${c}), ${r}.columns[${g}].${["x","y","z","w"][w]}, littleEndian);
22
- `}return d}let n=e;for(;_chunkQRLTUOBJcjs.Z.call(void 0, n)||_chunkQRLTUOBJcjs.da.call(void 0, n);)n=n.inner;let a=Mt[n.type];return`output.${Nt[a]}(${t}, ${r}, littleEndian);
23
- `}function it(e){if(Wt.has(e))return Wt.get(e);let t=zt(e,"offset","value"),r=new Function("output","offset","value","littleEndian=true",t);return Wt.set(e,r),r}var V={bool(e,t,r){e.writeBool(r)},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunk3QXCKMEJcjs.$.call(void 0, t);D(e,n);for(let[a,o]of Object.entries(t.propTypes))D(e,_chunk3QXCKMEJcjs.$.call(void 0, o)),ae(e,o,r[a]);D(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunk3QXCKMEJcjs.$.call(void 0, t);D(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)D(e,n),ae(e,t.elementType,r[o]);e.seekTo(a+_chunk3QXCKMEJcjs.ca.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){var n;(n=V[t.inner.type])==null||n.call(V,e,t,r)},decorated(e,t,r){var o,i;let n=_chunk3QXCKMEJcjs.aa.call(void 0, t);D(e,n);let a=e.currentByteOffset;(i=V[(o=t.inner)==null?void 0:o.type])==null||i.call(V,e,t.inner,r),e.seekTo(a+_chunk3QXCKMEJcjs.ca.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(r*255)},unorm8x2(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255)},unorm8x4(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255),e.writeUint8(r.z*255),e.writeUint8(r.w*255)},snorm8(e,t,r){e.writeUint8(r*127+128)},snorm8x2(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128)},snorm8x4(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128),e.writeUint8(r.z*127+128),e.writeUint8(r.w*127+128)},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeUint16(r*32767+32768)},snorm16x2(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768)},snorm16x4(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768),e.writeUint16(r.z*32767+32768),e.writeUint16(r.w*32767+32768)},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.x*1023&1023)<<12,n|=(r.y*1023&1023)<<2,n|=r.z*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){var o,i;let n=_chunk3QXCKMEJcjs.$.call(void 0, t);D(e,n);let a=e.currentByteOffset;for(let s=0;s<Math.min(t.elementCount,r.length);s++)D(e,n),(i=V[(o=t.elementType)==null?void 0:o.type])==null||i.call(V,e,t.elementType,r[s]);e.seekTo(a+_chunk3QXCKMEJcjs.ca.call(void 0, t))},unstruct(e,t,r){var n;for(let[a,o]of Object.entries(t.propTypes))(n=V[o.type])==null||n.call(V,e,o,r[a])},"loose-decorated"(e,t,r){var i;let n=_chunk3QXCKMEJcjs.aa.call(void 0, t);D(e,n);let a=e.currentByteOffset,o=V[(i=t.inner)==null?void 0:i.type];return o==null||o(e,t.inner,r),e.seekTo(a+_chunk3QXCKMEJcjs.ca.call(void 0, t)),r}};function ae(e,t,r){let n=V[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var fe={bool(e){return e.readBool()},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunkQRLTUOBJcjs.s.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkQRLTUOBJcjs.w.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkQRLTUOBJcjs.A.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunkQRLTUOBJcjs.t.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunkQRLTUOBJcjs.x.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunkQRLTUOBJcjs.B.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunkQRLTUOBJcjs.u.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkQRLTUOBJcjs.y.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkQRLTUOBJcjs.C.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkQRLTUOBJcjs.v.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkQRLTUOBJcjs.z.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkQRLTUOBJcjs.D.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},mat2x2f(e){return _chunkQRLTUOBJcjs.E.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkQRLTUOBJcjs.F.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkQRLTUOBJcjs.G.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunk3QXCKMEJcjs.$.call(void 0, t);D(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))D(e,_chunk3QXCKMEJcjs.$.call(void 0, o)),n[a]=O(e,o);return D(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunk3QXCKMEJcjs.$.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){D(e,r);let o=t.elementType,i=O(e,o);n.push(i)}return D(e,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return O(e,t.inner)},decorated(e,t){let r=_chunk3QXCKMEJcjs.aa.call(void 0, t);D(e,r);let n=e.currentByteOffset,a=O(e,t.inner);return e.seekTo(n+_chunk3QXCKMEJcjs.ca.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunkQRLTUOBJcjs.v.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunkQRLTUOBJcjs.D.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunkQRLTUOBJcjs.u.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunkQRLTUOBJcjs.C.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunkQRLTUOBJcjs.s.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunkQRLTUOBJcjs.A.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunkQRLTUOBJcjs.s.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunkQRLTUOBJcjs.A.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunkQRLTUOBJcjs.v.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunkQRLTUOBJcjs.D.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunkQRLTUOBJcjs.u.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunkQRLTUOBJcjs.C.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunkQRLTUOBJcjs.s.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunkQRLTUOBJcjs.A.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunkQRLTUOBJcjs.s.call(void 0, fe.snorm16(e),fe.snorm16(e)),snorm16x4:e=>_chunkQRLTUOBJcjs.A.call(void 0, fe.snorm16(e),fe.snorm16(e),fe.snorm16(e),fe.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunkQRLTUOBJcjs.s.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkQRLTUOBJcjs.A.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkQRLTUOBJcjs.s.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkQRLTUOBJcjs.w.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkQRLTUOBJcjs.A.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkQRLTUOBJcjs.v.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkQRLTUOBJcjs.z.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkQRLTUOBJcjs.D.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkQRLTUOBJcjs.u.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkQRLTUOBJcjs.y.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkQRLTUOBJcjs.C.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunkQRLTUOBJcjs.A.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunkQRLTUOBJcjs.A.call(void 0, n,r,t,a)},unstruct(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=O(e,a);return r},disarray(e,t){let r=_chunk3QXCKMEJcjs.$.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)D(e,r),n.push(O(e,t.elementType));return D(e,r),n},"loose-decorated"(e,t){D(e,_chunk3QXCKMEJcjs.aa.call(void 0, t));let r=e.currentByteOffset,n=O(e,t.inner);return e.seekTo(r+_chunk3QXCKMEJcjs.ca.call(void 0, t)),n}};function O(e,t){let r=fe[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function ln(e,t){var u;let r=_chunk3QXCKMEJcjs.ca.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function i(d,f,g,w){var c;if(f!=null){if(_chunkQRLTUOBJcjs.X.call(void 0, d)||_chunk3QXCKMEJcjs.e.call(void 0, d)){let T=at(d);for(let[F,y]of Object.entries(T)){let x=d.propTypes[F];if(!x)continue;let ce=f[F];ce!==void 0&&i(x,ce,g+y.offset,(c=y.padding)!=null?c:w)}return}if(_chunkQRLTUOBJcjs.W.call(void 0, d)||_chunk3QXCKMEJcjs.d.call(void 0, d)){let T=d,F=_chunk3QXCKMEJcjs.j.call(void 0, _chunk3QXCKMEJcjs.ca.call(void 0, T.elementType),_chunk3QXCKMEJcjs.$.call(void 0, T.elementType));if(!Array.isArray(f))throw new Error("Partial value for array must be an array");let y=f;y.sort((x,ce)=>x.idx-ce.idx);for(let{idx:x,value:ce}of y)i(T.elementType,ce,g+x*F,F-_chunk3QXCKMEJcjs.ca.call(void 0, T.elementType))}else{let T=_chunk3QXCKMEJcjs.ca.call(void 0, d);a.seekTo(g),ae(a,d,f),o.push({start:g,end:g+T,padding:w})}}}if(i(e,t,0),o.length===0)return[];let s=[],l=o[0];for(let d=1;d<o.length;d++){let f=o[d];if(!f||!l)throw new Error("Internal error: missing segment");f.start===l.end+((u=l.padding)!=null?u:0)?(l.end=f.end,l.padding=f.padding):(s.push({data:new Uint8Array(n,l.start,l.end-l.start)}),l=f)}if(!l)throw new Error("Internal error: missing segment");return s.push({data:new Uint8Array(n,l.start,l.end-l.start)}),s}function ge(e){return!!(e!=null&&e.usableAsStorage)}var $e=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function st(e){return!!e.usableAsUniform}var cn={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},gn;gn=_chunk3JTP2ATRcjs.a;var Oe=class{constructor(t,r){this.usage=t;this.buffer=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"~repr");_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","buffer-usage");_chunkQRLTUOBJcjs.c.call(void 0, this,gn);this[_chunk3JTP2ATRcjs.a]={dataType:r.dataType}}get label(){return this.buffer.label}$name(t){return this.buffer.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:this.buffer.dataType}:{storage:this.buffer.dataType,access:this.usage},this.buffer),o=cn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${a}) var<${o}> ${r}: ${t.resolve(this.buffer.dataType)};`),r}write(t){this.buffer.write(t)}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunkQRLTUOBJcjs.p.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`},[_chunk3JTP2ATRcjs.a]:{dataType:this.buffer.dataType}},M)}},Tn;Tn=_chunk3JTP2ATRcjs.a;var ke=class{constructor(t,r,n){this.usage=t;this.dataType=r;this._membership=n;_chunkQRLTUOBJcjs.c.call(void 0, this,"~repr");_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","buffer-usage");_chunkQRLTUOBJcjs.c.call(void 0, this,Tn);this[_chunk3JTP2ATRcjs.a]={dataType:r}}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=cn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunkQRLTUOBJcjs.p.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`},[_chunk3JTP2ATRcjs.a]:{dataType:this.dataType}},M)}},dn=new WeakMap;function jt(e){if(!ge(e))throw new Error(`Cannot pass ${e} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=dn.get(e);return t||(t=new Oe("mutable",e),dn.set(e,t)),t}var mn=new WeakMap;function Kt(e){if(!ge(e))throw new Error(`Cannot pass ${e} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=mn.get(e);return t||(t=new Oe("readonly",e),mn.set(e,t)),t}var fn=new WeakMap;function qt(e){if(!st(e))throw new Error(`Cannot pass ${e} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);let t=fn.get(e);return t||(t=new Oe("uniform",e),fn.set(e,t)),t}var Yt={uniform:qt,mutable:jt,readonly:Kt};function xn(e,t,r){return _chunkQRLTUOBJcjs.V.call(void 0, t)?new ut(e,t,r):new ut(e,t,r,["storage","uniform"])}function oe(e){return e.resourceType==="buffer"}function fa(e){return!!e.usableAsVertex}var yn=_typedbinary.getSystemEndianness.call(void 0, ),ut=class{constructor(t,r,n,a){this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","buffer");_chunkQRLTUOBJcjs.c.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunkQRLTUOBJcjs.c.call(void 0, this,"_buffer",null);_chunkQRLTUOBJcjs.c.call(void 0, this,"_ownBuffer");_chunkQRLTUOBJcjs.c.call(void 0, this,"_destroyed",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"_hostBuffer");_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");_chunkQRLTUOBJcjs.c.call(void 0, this,"initial");_chunkQRLTUOBJcjs.c.call(void 0, this,"usableAsUniform",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"usableAsStorage",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"usableAsVertex",!1);_chunk3JTP2ATRcjs.j.call(void 0, n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}get label(){return this._label}get buffer(){var r;let t=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=t.createBuffer({size:_chunk3QXCKMEJcjs.ca.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:(r=this.label)!=null?r:"<unnamed>"}),this.initial)){let n=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());ae(n,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get destroyed(){return this._destroyed}$name(t){return this._label=t,this._buffer&&(this._buffer.label=t),this}$usage(...t){var r;for(let n of t){if((r=this._disallowedUsages)!=null&&r.includes(n))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${n}`);this.flags|=n==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=n==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=n==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||n==="uniform",this.usableAsStorage=this.usableAsStorage||n==="storage",this.usableAsVertex=this.usableAsVertex||n==="vertex"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}compileWriter(){if(ot)it(this.dataType);else throw new Error("This environment does not allow eval")}write(t){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let o=r.getMappedRange();if(ot){it(this.dataType)(new DataView(o),0,t,yn==="little");return}ae(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunk3QXCKMEJcjs.ca.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),ot?it(this.dataType)(new DataView(this._hostBuffer),0,t,yn==="little"):ae(new (0, _typedbinary.BufferWriter)(this._hostBuffer),this.dataType,t),n.queue.writeBuffer(r,0,this._hostBuffer,0,a)}writePartial(t){let r=this.buffer,n=this._group.device,a=ln(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),i=new Uint8Array(o);for(let s of a)i.set(s.data,s.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunk3QXCKMEJcjs.ca.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(t.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let t=this.buffer,r=this._group.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return O(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),s=O(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),s}let n=r.createBuffer({size:_chunk3QXCKMEJcjs.ca.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunk3QXCKMEJcjs.ca.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunk3QXCKMEJcjs.ca.call(void 0, this.dataType));let o=O(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){var r;return(r=Yt[t])==null?void 0:r.call(Yt,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,this._ownBuffer&&((t=this._buffer)==null||t.destroy()))}toString(){var t;return`buffer:${(t=this._label)!=null?t:"<unnamed>"}`}};function hn(e){return new Qt(e)}function bn(e){return new Xt(e)}function We(e){return(e==null?void 0:e.resourceType)==="sampler"}function Me(e){return(e==null?void 0:e.resourceType)==="sampler-comparison"}var pt=class{constructor(t){this._membership=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","sampler")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},lt=class{constructor(t){this._membership=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","sampler-comparison")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},Qt=class{constructor(t){this._props=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","sampler");_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");_chunkQRLTUOBJcjs.c.call(void 0, this,"_filtering");_chunkQRLTUOBJcjs.c.call(void 0, this,"_sampler",null);this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}unwrap(t){var r;return this._sampler||(this._sampler=t.device.createSampler(_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this._props),{label:(r=this._label)!=null?r:"<unnamed>"}))),this._sampler}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),{group:n,binding:a}=t.allocateFixedEntry({sampler:this._filtering?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},Xt=class{constructor(t){this._props=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","sampler-comparison");_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");_chunkQRLTUOBJcjs.c.call(void 0, this,"_sampler",null)}unwrap(t){var r;return this._sampler||(this._sampler=t.device.createSampler(_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this._props),{label:(r=this._label)!=null?r:"<unnamed>"}))),this._sampler}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({sampler:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};var dt=class{constructor(t){this._membership=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","external-texture")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};var wn={r8unorm:_chunkQRLTUOBJcjs.N,r8snorm:_chunkQRLTUOBJcjs.N,r8uint:_chunkQRLTUOBJcjs.L,r8sint:_chunkQRLTUOBJcjs.M,r16uint:_chunkQRLTUOBJcjs.L,r16sint:_chunkQRLTUOBJcjs.M,r16float:_chunkQRLTUOBJcjs.N,rg8unorm:_chunkQRLTUOBJcjs.N,rg8snorm:_chunkQRLTUOBJcjs.N,rg8uint:_chunkQRLTUOBJcjs.L,rg8sint:_chunkQRLTUOBJcjs.M,r32uint:_chunkQRLTUOBJcjs.L,r32sint:_chunkQRLTUOBJcjs.M,r32float:_chunkQRLTUOBJcjs.N,rg16uint:_chunkQRLTUOBJcjs.L,rg16sint:_chunkQRLTUOBJcjs.M,rg16float:_chunkQRLTUOBJcjs.N,rgba8unorm:_chunkQRLTUOBJcjs.N,"rgba8unorm-srgb":_chunkQRLTUOBJcjs.N,rgba8snorm:_chunkQRLTUOBJcjs.N,rgba8uint:_chunkQRLTUOBJcjs.L,rgba8sint:_chunkQRLTUOBJcjs.M,bgra8unorm:_chunkQRLTUOBJcjs.N,"bgra8unorm-srgb":_chunkQRLTUOBJcjs.N,rgb9e5ufloat:_chunkQRLTUOBJcjs.N,rgb10a2uint:_chunkQRLTUOBJcjs.L,rgb10a2unorm:_chunkQRLTUOBJcjs.N,rg11b10ufloat:_chunkQRLTUOBJcjs.N,rg32uint:_chunkQRLTUOBJcjs.L,rg32sint:_chunkQRLTUOBJcjs.M,rg32float:_chunkQRLTUOBJcjs.N,rgba16uint:_chunkQRLTUOBJcjs.L,rgba16sint:_chunkQRLTUOBJcjs.M,rgba16float:_chunkQRLTUOBJcjs.N,rgba32uint:_chunkQRLTUOBJcjs.L,rgba32sint:_chunkQRLTUOBJcjs.M,rgba32float:_chunkQRLTUOBJcjs.N,stencil8:_chunkQRLTUOBJcjs.N,depth16unorm:_chunkQRLTUOBJcjs.N,depth24plus:_chunkQRLTUOBJcjs.N,"depth24plus-stencil8":_chunkQRLTUOBJcjs.N,depth32float:_chunkQRLTUOBJcjs.N,"depth32float-stencil8":_chunkQRLTUOBJcjs.N,"bc1-rgba-unorm":_chunkQRLTUOBJcjs.N,"bc1-rgba-unorm-srgb":_chunkQRLTUOBJcjs.N,"bc2-rgba-unorm":_chunkQRLTUOBJcjs.N,"bc2-rgba-unorm-srgb":_chunkQRLTUOBJcjs.N,"bc3-rgba-unorm":_chunkQRLTUOBJcjs.N,"bc3-rgba-unorm-srgb":_chunkQRLTUOBJcjs.N,"bc4-r-unorm":_chunkQRLTUOBJcjs.N,"bc4-r-snorm":_chunkQRLTUOBJcjs.N,"bc5-rg-unorm":_chunkQRLTUOBJcjs.N,"bc5-rg-snorm":_chunkQRLTUOBJcjs.N,"bc6h-rgb-ufloat":_chunkQRLTUOBJcjs.N,"bc6h-rgb-float":_chunkQRLTUOBJcjs.N,"bc7-rgba-unorm":_chunkQRLTUOBJcjs.N,"bc7-rgba-unorm-srgb":_chunkQRLTUOBJcjs.N,"etc2-rgb8unorm":_chunkQRLTUOBJcjs.N,"etc2-rgb8unorm-srgb":_chunkQRLTUOBJcjs.N,"etc2-rgb8a1unorm":_chunkQRLTUOBJcjs.N,"etc2-rgb8a1unorm-srgb":_chunkQRLTUOBJcjs.N,"etc2-rgba8unorm":_chunkQRLTUOBJcjs.N,"etc2-rgba8unorm-srgb":_chunkQRLTUOBJcjs.N,"eac-r11unorm":_chunkQRLTUOBJcjs.N,"eac-r11snorm":_chunkQRLTUOBJcjs.N,"eac-rg11unorm":_chunkQRLTUOBJcjs.N,"eac-rg11snorm":_chunkQRLTUOBJcjs.N,"astc-4x4-unorm":_chunkQRLTUOBJcjs.N,"astc-4x4-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-5x4-unorm":_chunkQRLTUOBJcjs.N,"astc-5x4-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-5x5-unorm":_chunkQRLTUOBJcjs.N,"astc-5x5-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-6x5-unorm":_chunkQRLTUOBJcjs.N,"astc-6x5-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-6x6-unorm":_chunkQRLTUOBJcjs.N,"astc-6x6-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-8x5-unorm":_chunkQRLTUOBJcjs.N,"astc-8x5-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-8x6-unorm":_chunkQRLTUOBJcjs.N,"astc-8x6-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-8x8-unorm":_chunkQRLTUOBJcjs.N,"astc-8x8-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-10x5-unorm":_chunkQRLTUOBJcjs.N,"astc-10x5-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-10x6-unorm":_chunkQRLTUOBJcjs.N,"astc-10x6-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-10x8-unorm":_chunkQRLTUOBJcjs.N,"astc-10x8-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-10x10-unorm":_chunkQRLTUOBJcjs.N,"astc-10x10-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-12x10-unorm":_chunkQRLTUOBJcjs.N,"astc-12x10-unorm-srgb":_chunkQRLTUOBJcjs.N,"astc-12x12-unorm":_chunkQRLTUOBJcjs.N,"astc-12x12-unorm-srgb":_chunkQRLTUOBJcjs.N},Ne={rgba8unorm:_chunkQRLTUOBJcjs.A,rgba8snorm:_chunkQRLTUOBJcjs.A,rgba8uint:_chunkQRLTUOBJcjs.D,rgba8sint:_chunkQRLTUOBJcjs.C,rgba16uint:_chunkQRLTUOBJcjs.D,rgba16sint:_chunkQRLTUOBJcjs.C,rgba16float:_chunkQRLTUOBJcjs.A,r32uint:_chunkQRLTUOBJcjs.D,r32sint:_chunkQRLTUOBJcjs.C,r32float:_chunkQRLTUOBJcjs.A,rg32uint:_chunkQRLTUOBJcjs.D,rg32sint:_chunkQRLTUOBJcjs.C,rg32float:_chunkQRLTUOBJcjs.A,rgba32uint:_chunkQRLTUOBJcjs.D,rgba32sint:_chunkQRLTUOBJcjs.C,rgba32float:_chunkQRLTUOBJcjs.A,bgra8unorm:_chunkQRLTUOBJcjs.A},Sn={f32:"float",u32:"uint",i32:"sint"},Dn={float:_chunkQRLTUOBJcjs.N,"unfilterable-float":_chunkQRLTUOBJcjs.N,uint:_chunkQRLTUOBJcjs.L,sint:_chunkQRLTUOBJcjs.M,depth:_chunkQRLTUOBJcjs.N};function Fn(e,t){return new Zt(e,t)}function J(e){return(e==null?void 0:e.resourceType)==="texture"}function ze(e){return(e==null?void 0:e.resourceType)==="texture-storage-view"}function je(e){return(e==null?void 0:e.resourceType)==="texture-sampled-view"}var vn={mutable:"read_write",readonly:"read",writeonly:"write"},Zt=class{constructor(t,r){this.props=t;this._branch=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","texture");_chunkQRLTUOBJcjs.c.call(void 0, this,"usableAsSampled",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"usableAsStorage",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"usableAsRender",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"_destroyed",!1);_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");_chunkQRLTUOBJcjs.c.call(void 0, this,"_flags",GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC);_chunkQRLTUOBJcjs.c.call(void 0, this,"_texture",null)}get label(){return this._label}$name(t){return this._label=t,this}unwrap(){var t,r,n,a,o;if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:(t=this._label)!=null?t:"<unnamed>",format:this.props.format,size:this.props.size,usage:this._flags,dimension:(r=this.props.dimension)!=null?r:"2d",viewFormats:(n=this.props.viewFormats)!=null?n:[],mipLevelCount:(a=this.props.mipLevelCount)!=null?a:1,sampleCount:(o=this.props.sampleCount)!=null?o:1})),this._texture}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||(this.usableAsStorage=r),this.usableAsSampled||(this.usableAsSampled=n),this.usableAsRender||(this.usableAsRender=a),this}createView(t,r){if(t==="sampled")return this._asSampled(r);let n=r;switch(t){case"mutable":return this._asMutable(n);case"readonly":return this._asReadonly(n);case"writeonly":return this._asWriteonly(n)}}_asStorage(t,r){var o;if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=(o=t==null?void 0:t.format)!=null?o:this.props.format,a=Ne[n];return _chunkQRLTUOBJcjs.d.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new er(t!=null?t:{},r,this)}_asReadonly(t){return this._asStorage(t,"readonly")}_asWriteonly(t){return this._asStorage(t,"writeonly")}_asMutable(t){return this._asStorage(t,"mutable")}_asSampled(t){var a;if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=(a=t==null?void 0:t.format)!=null?a:this.props.format;if(!Ne[r])throw new Error(`Unsupported storage texture format: ${r}`);return new tr(t,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._texture)==null||t.destroy())}},gt={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},er=class{constructor(t,r,n){this.access=r;this._texture=n;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunkQRLTUOBJcjs.c.call(void 0, this,"texelDataType");_chunkQRLTUOBJcjs.c.call(void 0, this,"dimension");_chunkQRLTUOBJcjs.c.call(void 0, this,"_view");_chunkQRLTUOBJcjs.c.call(void 0, this,"_format");var a,o,i;this.dimension=(o=(a=t==null?void 0:t.dimension)!=null?a:n.props.dimension)!=null?o:"2d",this._format=(i=t==null?void 0:t.format)!=null?i:n.props.format,this.texelDataType=Ne[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView({label:`${(t=this.label)!=null?t:"<unnamed>"} - View`,format:this._format,dimension:this.dimension})),this._view}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${gt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${vn[this.access]}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},mt=class{constructor(t,r,n,a){this._format=t;this.dimension=r;this.access=n;this._membership=a;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunkQRLTUOBJcjs.c.call(void 0, this,"texelDataType");this.texelDataType=Ne[this._format]}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${gt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${vn[this.access]}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},tr=class{constructor(t,r){this._props=t;this._texture=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunkQRLTUOBJcjs.c.call(void 0, this,"channelDataType");_chunkQRLTUOBJcjs.c.call(void 0, this,"dimension");_chunkQRLTUOBJcjs.c.call(void 0, this,"_format");_chunkQRLTUOBJcjs.c.call(void 0, this,"_view");var n,a,o;this.dimension=(a=(n=t==null?void 0:t.dimension)!=null?n:r.props.dimension)!=null?a:"2d",this._format=(o=t==null?void 0:t.format)!=null?o:r.props.format,this.channelDataType=wn[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView(_chunkQRLTUOBJcjs.a.call(void 0, {label:`${(t=this.label)!=null?t:"<unnamed>"} - View`},this._props))),this._view}"~resolve"(t){var s;let r=t.names.makeUnique(this.label),n=((s=this._texture.props.sampleCount)!=null?s:1)>1,{group:a,binding:o}=t.allocateFixedEntry({texture:Sn[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${gt[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},ft=class{constructor(t,r,n,a){this.dimension=r;this._multisampled=n;this._membership=a;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunkQRLTUOBJcjs.c.call(void 0, this,"channelDataType");this.channelDataType=Dn[t]}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${gt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};function rr(e){return!!(e!=null&&e.usableAsSampled)}function ga(e){return!!(e!=null&&e.usableAsRender)}var Tt=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function ct(e){return new ar(e)}function yt(e){return!!e&&e.resourceType==="bind-group-layout"}function or(e){return!!e&&e.resourceType==="bind-group"}var nr=class e extends Error{constructor(t,r){super(`Bind group '${t!=null?t:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},Un=["compute"],ve=["compute","vertex","fragment"],ar=class{constructor(t){this.entries=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");_chunkQRLTUOBJcjs.c.call(void 0, this,"_index");_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","bind-group-layout");_chunkQRLTUOBJcjs.c.call(void 0, this,"bound",{});var n,a,o,i,s;let r=0;for(let[l,u]of Object.entries(t)){if(u===null){r++;continue}let d={idx:r,key:l,layout:this};if("uniform"in u&&(this.bound[l]=new ke("uniform",u.uniform,d)),"storage"in u){let f="type"in u.storage?u.storage:u.storage(0);this.bound[l]=new ke((n=u.access)!=null?n:"readonly",f,d)}"texture"in u&&(this.bound[l]=new ft(u.texture,(a=u.viewDimension)!=null?a:"2d",(o=u.multisampled)!=null?o:!1,d)),"storageTexture"in u&&(this.bound[l]=new mt(u.storageTexture,(i=u.viewDimension)!=null?i:"2d",(s=u.access)!=null?s:"writeonly",d)),"externalTexture"in u&&(this.bound[l]=new dt(d)),"sampler"in u&&(u.sampler==="comparison"?this.bound[l]=new lt(d):this.bound[l]=new pt(d)),r++}}get label(){return this._label}get index(){return this._index}$name(t){return this._label=t,this}$idx(t){return this._index=t,this}unwrap(t){var n;return t.device.createBindGroupLayout({label:(n=this.label)!=null?n:"<unnamed>",entries:Object.values(this.entries).map((a,o)=>{var l,u,d,f;if(a===null)return null;let i=a.visibility,s={binding:o,visibility:0};if("uniform"in a)i=i!=null?i:ve,s.buffer={type:"uniform"};else if("storage"in a)i=i!=null?i:a.access==="mutable"?Un:ve,s.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)i=i!=null?i:ve,s.sampler={type:a.sampler};else if("texture"in a)i=i!=null?i:ve,s.texture={sampleType:a.texture,viewDimension:(l=a.viewDimension)!=null?l:"2d",multisampled:(u=a.multisampled)!=null?u:!1};else if("storageTexture"in a){let g=(d=a.access)!=null?d:"writeonly";i=i!=null?i:g==="readonly"?ve:Un,s.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[g],viewDimension:(f=a.viewDimension)!=null?f:"2d"}}else"externalTexture"in a&&(i=i!=null?i:ve,s.externalTexture={});return i!=null&&i.includes("compute")&&(s.visibility|=GPUShaderStage.COMPUTE),i!=null&&i.includes("vertex")&&(s.visibility|=GPUShaderStage.VERTEX),i!=null&&i.includes("fragment")&&(s.visibility|=GPUShaderStage.FRAGMENT),s}).filter(a=>a!==null)})}populate(t){return new Te(this,t)}},Te=class{constructor(t,r){this.layout=t;this.entries=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new nr(t.label,n)}unwrap(t){var n;return t.device.createBindGroup({label:(n=this.layout.label)!=null?n:"<unnamed>",layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,o],i)=>{var l;if(o===null)return null;let s=this.entries[a];if(s===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(l=this.layout.label)!=null?l:"<unnamed>"}'.`);if("uniform"in o){let u;if(oe(s)){if(!st(s))throw new (0, _chunkQRLTUOBJcjs.g)(s);u={buffer:t.unwrap(s)}}else u={buffer:s};return{binding:i,resource:u}}if("storage"in o){let u;if(oe(s)){if(!ge(s))throw new $e(s);u={buffer:t.unwrap(s)}}else u={buffer:s};return{binding:i,resource:u}}if("texture"in o){let u;if(J(s)){if(!rr(s))throw new Tt(s);u=t.unwrap(s.createView("sampled"))}else je(s)?u=t.unwrap(s):u=s;return{binding:i,resource:u}}if("storageTexture"in o){let u;if(J(s)){if(!ge(s))throw new $e(s);o.access==="readonly"?u=t.unwrap(s.createView("readonly")):o.access==="mutable"?u=t.unwrap(s.createView("mutable")):u=t.unwrap(s.createView("writeonly"))}else ze(s)?u=t.unwrap(s):u=s;return{binding:i,resource:u}}if("sampler"in o)return We(s)||Me(s)?{binding:i,resource:t.unwrap(s)}:{binding:i,resource:s};if("externalTexture"in o)return{binding:i,resource:s};throw new Error(`Malformed bind group entry: ${s} (${JSON.stringify(s)})`)}).filter(a=>a!==null)})}};var In="#CATCHALL#",sr=class{constructor(){_chunkQRLTUOBJcjs.c.call(void 0, this,"_stack",[]);_chunkQRLTUOBJcjs.c.call(void 0, this,"_itemDepth",0)}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}popItem(){this.pop("item")}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}popSlotBindings(){this.pop("slotBinding")}pushFunctionScope(t,r,n){this._stack.push({type:"functionScope",args:t,returnType:r,externalMap:n})}popFunctionScope(){this.pop("functionScope")}pushBlockScope(){this._stack.push({type:"blockScope",declarations:new Map})}popBlockScope(){this.pop("blockScope")}pop(t){let r=this._stack[this._stack.length-1];if(!r||t&&r.type!==t)throw new Error(`Internal error, expected a ${t} layer to be on top.`);this._stack.pop(),t==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="item")n.usedSlots.add(t);else if((n==null?void 0:n.type)==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!((n==null?void 0:n.type)==="functionScope"||(n==null?void 0:n.type)==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getResourceById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:_chunk3JTP2ATRcjs.i.call(void 0, o)?Se(o):_chunk3JTP2ATRcjs.f}:void 0}if((n==null?void 0:n.type)==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return{value:t,dataType:a}}}}defineBlockVariable(t,r){for(let n=this._stack.length-1;n>=0;--n){let a=this._stack[n];if((a==null?void 0:a.type)==="blockScope")return a.declarations.set(t,r),{value:t,dataType:r}}throw new Error("No block scope found to define a variable in.")}},xt=[""," "," "," "," "," "," "," "," "],ir=xt.length-1,ur=class{constructor(){_chunkQRLTUOBJcjs.c.call(void 0, this,"identLevel",0)}get pre(){var t;return(t=xt[this.identLevel])!=null?t:xt[ir].repeat(this.identLevel/ir)+xt[this.identLevel%ir]}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}},An;An=_chunk3JTP2ATRcjs.a;var pr=class{constructor(t){_chunkQRLTUOBJcjs.c.call(void 0, this,"_memoizedResolves",new WeakMap);_chunkQRLTUOBJcjs.c.call(void 0, this,"_memoizedDerived",new WeakMap);_chunkQRLTUOBJcjs.c.call(void 0, this,"_indentController",new ur);_chunkQRLTUOBJcjs.c.call(void 0, this,"_jitTranspiler");_chunkQRLTUOBJcjs.c.call(void 0, this,"_itemStateStack",new sr);_chunkQRLTUOBJcjs.c.call(void 0, this,"_declarations",[]);_chunkQRLTUOBJcjs.c.call(void 0, this,An,{itemStateStack:this._itemStateStack});_chunkQRLTUOBJcjs.c.call(void 0, this,"bindGroupLayoutsToPlaceholderMap",new Map);_chunkQRLTUOBJcjs.c.call(void 0, this,"_nextFreeLayoutPlaceholderIdx",0);_chunkQRLTUOBJcjs.c.call(void 0, this,"fixedBindings",[]);_chunkQRLTUOBJcjs.c.call(void 0, this,"callStack",[]);_chunkQRLTUOBJcjs.c.call(void 0, this,"names");this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){let r=this._itemStateStack.getResourceById(t);return r===void 0?null:r}defineVariable(t,r){return this._itemStateStack.defineBlockVariable(t,r)}pushBlockScope(){this._itemStateStack.pushBlockScope()}popBlockScope(){this._itemStateStack.popBlockScope()}transpileFn(t){if(!this._jitTranspiler)throw new Error("Tried to execute a tgpu.fn function without providing a JIT transpiler, or transpiling at build time.");return this._jitTranspiler.transpileFn(t)}fnToWgsl(t){this._itemStateStack.pushFunctionScope(t.args,t.returnType,t.externalMap);try{let r=kt(this,t.body),n=t.args.map(a=>`${a.value}: ${this.resolve(a.dataType)}`).join(", ");return{head:t.returnType!==void 0?`(${n}) -> ${_chunk3QXCKMEJcjs.ua.call(void 0, t.returnType)} ${this.resolve(t.returnType)}`:`(${n})`,body:r}}finally{this._itemStateStack.popFunctionScope()}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:In,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunkQRLTUOBJcjs.f)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}unwrap(t){if(_chunk3JTP2ATRcjs.d.call(void 0, t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if(_chunk3JTP2ATRcjs.b.call(void 0, r))r=this.readSlot(r);else if(_chunk3JTP2ATRcjs.c.call(void 0, r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){var n;let r=(n=this._memoizedDerived.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([l,u])=>l.areEqual(this._itemStateStack.readSlot(l),u)))return i.result;_chunkQRLTUOBJcjs.n.call(void 0, _chunkQRLTUOBJcjs.k.CPU);let a;try{a=t["~compute"]()}finally{_chunkQRLTUOBJcjs.o.call(void 0, _chunkQRLTUOBJcjs.k.CPU)}let o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedDerived.set(t,r),a}catch(a){throw a instanceof _chunkQRLTUOBJcjs.e?a.appendToTrace(t):new (0, _chunkQRLTUOBJcjs.e)(a,[t])}finally{this._itemStateStack.popItem()}}_getOrInstantiate(t){var n;let r=(n=this._memoizedResolves.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([l,u])=>l.areEqual(this._itemStateStack.readSlot(l),u)))return i.result;let a;_chunk3QXCKMEJcjs.h.call(void 0, t)?a=$t(this,t):_chunk3JTP2ATRcjs.c.call(void 0, t)||_chunk3JTP2ATRcjs.b.call(void 0, t)?a=this.resolve(this.unwrap(t)):_chunk3JTP2ATRcjs.h.call(void 0, t)?a=t["~resolve"](this):a=this.resolveValue(t);let o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedResolves.set(t,r),a}catch(a){throw a instanceof _chunkQRLTUOBJcjs.e?a.appendToTrace(t):new (0, _chunkQRLTUOBJcjs.e)(a,[t])}finally{this._itemStateStack.popItem()}}resolve(t){if(_chunk3JTP2ATRcjs.d.call(void 0, t))return this.withSlots(t["~providing"].pairs,()=>this.resolve(t["~providing"].inner));if(t&&typeof t=="object"||typeof t=="function"){if(this._itemStateStack.itemDepth===0)try{_chunkQRLTUOBJcjs.n.call(void 0, _chunkQRLTUOBJcjs.k.GPU);let r=_chunkQRLTUOBJcjs.l.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
16
+ ${i}`}if("l"in t||"c"in t){let[r,n]="l"in t?t.l:t.c,a=n?F(e,n):void 0;if(!a||!n)throw new Error("Cannot create variable without an initial value.");Xn(e,r,a.dataType);let o=w(e,Et(e,r));if(typeof n=="object"&&"o"in n&&_chunkM4VUFFPZcjs.U.call(void 0, e.callStack[e.callStack.length-1])){let i=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}var ${o} = ${i}(${w(e,a)});`}return`${e.pre}var ${o} = ${w(e,a)};`}if("b"in t){e.pushBlockScope();try{return en(e,t)}finally{e.popBlockScope()}}if("j"in t){let[r,n,a,o]=t.j,i=r?se(e,r):void 0,s=i?i.slice(0,-1):"",l=n?F(e,n):void 0,u=l?w(e,l):"",d=a?se(e,a):void 0,m=d?d.slice(0,-1):"";e.indent();let g=se(e,o);return e.dedent(),`${e.pre}for (${s}; ${u}; ${m})
17
+ ${g}`}if("w"in t){let[r,n]=t.w,a=w(e,F(e,r));e.indent();let o=se(e,n);return e.dedent(),`${e.pre}while (${a})
18
+ ${o}`}return"k"in t?`${e.pre}continue;`:"d"in t?`${e.pre}break;`:`${e.pre}${w(e,F(e,t))};`}function Vt(e,t){return en(e,t)}var _typedbinary = require('typed-binary');function Zn(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var h=Zn;var tn=new WeakMap;function Ze(e){let t=tn.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let i=e.propTypes[o];if(i===void 0)throw new Error(`Property ${o} is undefined in struct`);let s=r.size;h(r,_chunkUPPJES6Wcjs.e.call(void 0, e)?_chunkUPPJES6Wcjs.aa.call(void 0, i):_chunkUPPJES6Wcjs.$.call(void 0, i)),a&&(a.padding=r.size-s);let l=_chunkUPPJES6Wcjs.ca.call(void 0, i);n[o]={offset:r.size,size:l},a=n[o],r.add(l)}return a&&(a.padding=_chunkUPPJES6Wcjs.j.call(void 0, _chunkUPPJES6Wcjs.ca.call(void 0, e),_chunkUPPJES6Wcjs.$.call(void 0, e))-r.size),tn.set(e,n),n}var tt=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),Gt=new WeakMap,$t={u32:"u32",vec2u:"u32",vec3u:"u32",vec4u:"u32",i32:"i32",vec2i:"i32",vec3i:"i32",vec4i:"i32",f32:"f32",vec2f:"f32",vec3f:"f32",vec4f:"f32",vec2h:"f32",vec3h:"f32",vec4h:"f32",mat2x2f:"f32",mat3x3f:"f32",mat4x4f:"f32"},kt={u32:"setUint32",i32:"setInt32",f32:"setFloat32"};function et(e,t,r){if(_chunkM4VUFFPZcjs.W.call(void 0, e)||_chunkM4VUFFPZcjs.aa.call(void 0, e))return et(e.inner,t,r);if(_chunkM4VUFFPZcjs.U.call(void 0, e)||_chunkUPPJES6Wcjs.e.call(void 0, e)){let a=Ze(e),o=Object.entries(a).sort((s,l)=>s[1].offset-l[1].offset),i="";for(let[s,l]of o){let u=e.propTypes[s];u&&(i+=et(u,`(${t} + ${l.offset})`,`${r}.${s}`))}return i}if(_chunkM4VUFFPZcjs.T.call(void 0, e)||_chunkUPPJES6Wcjs.d.call(void 0, e)){let a=e,o=_chunkUPPJES6Wcjs.j.call(void 0, _chunkUPPJES6Wcjs.ca.call(void 0, a.elementType),_chunkUPPJES6Wcjs.$.call(void 0, a.elementType)),i="";return i+=`for (let i = 0; i < ${a.elementCount}; i++) {
19
+ `,i+=et(a.elementType,`(${t} + i * ${o})`,`${r}[i]`),i+=`}
20
+ `,i}if(_chunkM4VUFFPZcjs.O.call(void 0, e)){let a=$t[e.type],o="",i=kt[a],s=["x","y","z","w"],l=_chunkM4VUFFPZcjs.M.call(void 0, e)?2:_chunkM4VUFFPZcjs.N.call(void 0, e)?3:4;for(let u=0;u<l;u++)o+=`output.${i}((${t} + ${u*4}), ${r}.${s[u]}, littleEndian);
21
+ `;return o}if(_chunkM4VUFFPZcjs.R.call(void 0, e)){let a=$t[e.type],o=kt[a],i=_chunkM4VUFFPZcjs.P.call(void 0, e)?2:_chunkM4VUFFPZcjs.Q.call(void 0, e)?3:4,s=i*i,l=_chunkUPPJES6Wcjs.j.call(void 0, i*4,8),u="";for(let d=0;d<s;d++){let m=Math.floor(d/i),g=d%i,T=m*l+g*4;u+=`output.${o}((${t} + ${T}), ${r}.columns[${m}].${["x","y","z","w"][g]}, littleEndian);
22
+ `}return u}let n=$t[e.type];return`output.${kt[n]}(${t}, ${r}, littleEndian);
23
+ `}function rt(e){if(Gt.has(e))return Gt.get(e);let t=et(e,"offset","value"),r=new Function("output","offset","value","littleEndian=true",t);return Gt.set(e,r),r}var he={bool(e,t,r){e.writeBool(r)},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkUPPJES6Wcjs.$.call(void 0, t);h(e,n);for(let[a,o]of Object.entries(t.propTypes))h(e,_chunkUPPJES6Wcjs.$.call(void 0, o)),Z(e,o,r[a]);h(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkUPPJES6Wcjs.$.call(void 0, t);h(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)h(e,n),Z(e,t.elementType,r[o]);e.seekTo(a+_chunkUPPJES6Wcjs.ca.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){_optionalChain([he, 'access', _14 => _14[t.inner.type], 'optionalCall', _15 => _15(e,t,r)])},decorated(e,t,r){let n=_chunkUPPJES6Wcjs.aa.call(void 0, t);h(e,n);let a=e.currentByteOffset;_optionalChain([he, 'access', _16 => _16[_optionalChain([t, 'access', _17 => _17.inner, 'optionalAccess', _18 => _18.type])], 'optionalCall', _19 => _19(e,t.inner,r)]),e.seekTo(a+_chunkUPPJES6Wcjs.ca.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(r*255)},unorm8x2(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255)},unorm8x4(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255),e.writeUint8(r.z*255),e.writeUint8(r.w*255)},snorm8(e,t,r){e.writeUint8(r*127+128)},snorm8x2(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128)},snorm8x4(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128),e.writeUint8(r.z*127+128),e.writeUint8(r.w*127+128)},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeUint16(r*32767+32768)},snorm16x2(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768)},snorm16x4(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768),e.writeUint16(r.z*32767+32768),e.writeUint16(r.w*32767+32768)},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.x*1023&1023)<<12,n|=(r.y*1023&1023)<<2,n|=r.z*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){let n=_chunkUPPJES6Wcjs.$.call(void 0, t);h(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)h(e,n),_optionalChain([he, 'access', _20 => _20[_optionalChain([t, 'access', _21 => _21.elementType, 'optionalAccess', _22 => _22.type])], 'optionalCall', _23 => _23(e,t.elementType,r[o])]);e.seekTo(a+_chunkUPPJES6Wcjs.ca.call(void 0, t))},unstruct(e,t,r){for(let[n,a]of Object.entries(t.propTypes))_optionalChain([he, 'access', _24 => _24[a.type], 'optionalCall', _25 => _25(e,a,r[n])])},"loose-decorated"(e,t,r){let n=_chunkUPPJES6Wcjs.aa.call(void 0, t);h(e,n);let a=e.currentByteOffset,o=he[_optionalChain([t, 'access', _26 => _26.inner, 'optionalAccess', _27 => _27.type])];return _optionalChain([o, 'optionalCall', _28 => _28(e,t.inner,r)]),e.seekTo(a+_chunkUPPJES6Wcjs.ca.call(void 0, t)),r}};function Z(e,t,r){let n=he[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var ue={bool(e){return e.readBool()},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunkM4VUFFPZcjs.p.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkM4VUFFPZcjs.t.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkM4VUFFPZcjs.x.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunkM4VUFFPZcjs.q.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunkM4VUFFPZcjs.u.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunkM4VUFFPZcjs.y.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunkM4VUFFPZcjs.r.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkM4VUFFPZcjs.v.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkM4VUFFPZcjs.z.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkM4VUFFPZcjs.s.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkM4VUFFPZcjs.w.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkM4VUFFPZcjs.A.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},mat2x2f(e){return _chunkM4VUFFPZcjs.B.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkM4VUFFPZcjs.C.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkM4VUFFPZcjs.D.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunkUPPJES6Wcjs.$.call(void 0, t);h(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))h(e,_chunkUPPJES6Wcjs.$.call(void 0, o)),n[a]=C(e,o);return h(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkUPPJES6Wcjs.$.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){h(e,r);let o=t.elementType,i=C(e,o);n.push(i)}return h(e,r),n},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return C(e,t.inner)},decorated(e,t){let r=_chunkUPPJES6Wcjs.aa.call(void 0, t);h(e,r);let n=e.currentByteOffset,a=C(e,t.inner);return e.seekTo(n+_chunkUPPJES6Wcjs.ca.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunkM4VUFFPZcjs.s.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunkM4VUFFPZcjs.A.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunkM4VUFFPZcjs.r.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunkM4VUFFPZcjs.z.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunkM4VUFFPZcjs.p.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunkM4VUFFPZcjs.x.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunkM4VUFFPZcjs.p.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunkM4VUFFPZcjs.x.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunkM4VUFFPZcjs.s.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunkM4VUFFPZcjs.A.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunkM4VUFFPZcjs.r.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunkM4VUFFPZcjs.z.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunkM4VUFFPZcjs.p.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunkM4VUFFPZcjs.x.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunkM4VUFFPZcjs.p.call(void 0, ue.snorm16(e),ue.snorm16(e)),snorm16x4:e=>_chunkM4VUFFPZcjs.x.call(void 0, ue.snorm16(e),ue.snorm16(e),ue.snorm16(e),ue.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunkM4VUFFPZcjs.p.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkM4VUFFPZcjs.x.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkM4VUFFPZcjs.p.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkM4VUFFPZcjs.t.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkM4VUFFPZcjs.x.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkM4VUFFPZcjs.s.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkM4VUFFPZcjs.w.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkM4VUFFPZcjs.A.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkM4VUFFPZcjs.r.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkM4VUFFPZcjs.v.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkM4VUFFPZcjs.z.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunkM4VUFFPZcjs.x.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunkM4VUFFPZcjs.x.call(void 0, n,r,t,a)},unstruct(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=C(e,a);return r},disarray(e,t){let r=_chunkUPPJES6Wcjs.$.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)h(e,r),n.push(C(e,t.elementType));return h(e,r),n},"loose-decorated"(e,t){h(e,_chunkUPPJES6Wcjs.aa.call(void 0, t));let r=e.currentByteOffset,n=C(e,t.inner);return e.seekTo(r+_chunkUPPJES6Wcjs.ca.call(void 0, t)),n}};function C(e,t){let r=ue[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function rn(e,t){let r=_chunkUPPJES6Wcjs.ca.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function i(u,d,m,g){if(d!=null){if(_chunkM4VUFFPZcjs.U.call(void 0, u)||_chunkUPPJES6Wcjs.e.call(void 0, u)){let T=Ze(u);for(let[f,S]of Object.entries(T)){let b=u.propTypes[f];if(!b)continue;let U=d[f];U!==void 0&&i(b,U,m+S.offset,_nullishCoalesce(S.padding, () => (g)))}return}if(_chunkM4VUFFPZcjs.T.call(void 0, u)||_chunkUPPJES6Wcjs.d.call(void 0, u)){let T=u,f=_chunkUPPJES6Wcjs.j.call(void 0, _chunkUPPJES6Wcjs.ca.call(void 0, T.elementType),_chunkUPPJES6Wcjs.$.call(void 0, T.elementType));if(!Array.isArray(d))throw new Error("Partial value for array must be an array");let S=d;S.sort((b,U)=>b.idx-U.idx);for(let{idx:b,value:U}of S)i(T.elementType,U,m+b*f,f-_chunkUPPJES6Wcjs.ca.call(void 0, T.elementType))}else{let T=_chunkUPPJES6Wcjs.ca.call(void 0, u);a.seekTo(m),Z(a,u,d),o.push({start:m,end:m+T,padding:g})}}}if(i(e,t,0),o.length===0)return[];let s=[],l=o[0];for(let u=1;u<o.length;u++){let d=o[u];if(!d||!l)throw new Error("Internal error: missing segment");d.start===l.end+(_nullishCoalesce(l.padding, () => (0)))?(l.end=d.end,l.padding=d.padding):(s.push({data:new Uint8Array(n,l.start,l.end-l.start)}),l=d)}if(!l)throw new Error("Internal error: missing segment");return s.push({data:new Uint8Array(n,l.start,l.end-l.start)}),s}function pe(e){return!!_optionalChain([e, 'optionalAccess', _29 => _29.usableAsStorage])}var Le=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(t.label, () => ("<unnamed>"))}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function nt(e){return!!e.usableAsUniform}var sn={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Ce= (_class4 =class{constructor(t,r){;_class4.prototype.__init4.call(this);this.usage=t;this.buffer=r;this[_chunkFM3TKZFZcjs.a]={dataType:r.dataType}}__init4() {this.resourceType="buffer-usage"}get label(){return this.buffer.label}$name(t){return this.buffer.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:this.buffer.dataType}:{storage:this.buffer.dataType,access:this.usage},this.buffer),o=sn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${a}) var<${o}> ${r}: ${t.resolve(this.buffer.dataType)};`),r}write(t){this.buffer.write(t)}toString(){return`${this.usage}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){if(!_chunkM4VUFFPZcjs.m.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkFM3TKZFZcjs.a]:{dataType:this.buffer.dataType}},G)}}, _class4),Ee= (_class5 =class{constructor(t,r,n){;_class5.prototype.__init5.call(this);this.usage=t;this.dataType=r;this._membership=n;this[_chunkFM3TKZFZcjs.a]={dataType:r}}__init5() {this.resourceType="buffer-usage"}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=sn[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){return`${this.usage}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){if(!_chunkM4VUFFPZcjs.m.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkFM3TKZFZcjs.a]:{dataType:this.dataType}},G)}}, _class5),nn=new WeakMap;function Ot(e){if(!pe(e))throw new Error(`Cannot pass ${e} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=nn.get(e);return t||(t=new Ce("mutable",e),nn.set(e,t)),t}var an=new WeakMap;function Wt(e){if(!pe(e))throw new Error(`Cannot pass ${e} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=an.get(e);return t||(t=new Ce("readonly",e),an.set(e,t)),t}var on=new WeakMap;function Mt(e){if(!nt(e))throw new Error(`Cannot pass ${e} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);let t=on.get(e);return t||(t=new Ce("uniform",e),on.set(e,t)),t}var na={uniform:Mt,mutable:Ot,readonly:Wt};function pn(e,t,r){return _chunkM4VUFFPZcjs.S.call(void 0, t)?new at(e,t,r):new at(e,t,r,["storage","uniform"])}function ee(e){return e.resourceType==="buffer"}function aa(e){return!!e.usableAsVertex}var un=_typedbinary.getSystemEndianness.call(void 0, ),at= (_class6 =class{constructor(t,r,n,a){;_class6.prototype.__init6.call(this);_class6.prototype.__init7.call(this);_class6.prototype.__init8.call(this);_class6.prototype.__init9.call(this);_class6.prototype.__init10.call(this);_class6.prototype.__init11.call(this);_class6.prototype.__init12.call(this);this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;_chunkFM3TKZFZcjs.j.call(void 0, n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init6() {this.resourceType="buffer"}__init7() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}__init8() {this._buffer=null}__init9() {this._destroyed=!1}__init10() {this.usableAsUniform=!1}__init11() {this.usableAsStorage=!1}__init12() {this.usableAsVertex=!1}get label(){return this._label}get buffer(){let t=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=t.createBuffer({size:_chunkUPPJES6Wcjs.ca.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:_nullishCoalesce(this.label, () => ("<unnamed>"))}),this.initial)){let r=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());Z(r,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get destroyed(){return this._destroyed}$name(t){return this._label=t,this._buffer&&(this._buffer.label=t),this}$usage(...t){for(let r of t){if(_optionalChain([this, 'access', _30 => _30._disallowedUsages, 'optionalAccess', _31 => _31.includes, 'call', _32 => _32(r)]))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${r}`);this.flags|=r==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=r==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=r==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||r==="uniform",this.usableAsStorage=this.usableAsStorage||r==="storage",this.usableAsVertex=this.usableAsVertex||r==="vertex"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}compileWriter(){if(tt)rt(this.dataType);else throw new Error("This environment does not allow eval")}write(t){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let o=r.getMappedRange();if(tt){rt(this.dataType)(new DataView(o),0,t,un==="little");return}Z(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunkUPPJES6Wcjs.ca.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),tt?rt(this.dataType)(new DataView(this._hostBuffer),0,t,un==="little"):Z(new (0, _typedbinary.BufferWriter)(this._hostBuffer),this.dataType,t),n.queue.writeBuffer(r,0,this._hostBuffer,0,a)}writePartial(t){let r=this.buffer,n=this._group.device,a=rn(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),i=new Uint8Array(o);for(let s of a)i.set(s.data,s.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunkUPPJES6Wcjs.ca.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(t.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let t=this.buffer,r=this._group.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return C(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),s=C(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),s}let n=r.createBuffer({size:_chunkUPPJES6Wcjs.ca.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkUPPJES6Wcjs.ca.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkUPPJES6Wcjs.ca.call(void 0, this.dataType));let o=C(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){return _optionalChain([na, 'access', _33 => _33[t], 'optionalCall', _34 => _34(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _35 => _35._buffer, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]))}toString(){return`buffer:${_nullishCoalesce(this._label, () => ("<unnamed>"))}`}}, _class6);function ln(e){return new jt(e)}function dn(e){return new Kt(e)}function Ve(e){return _optionalChain([e, 'optionalAccess', _38 => _38.resourceType])==="sampler"}function Ge(e){return _optionalChain([e, 'optionalAccess', _39 => _39.resourceType])==="sampler-comparison"}var ot= (_class7 =class{constructor(t){;_class7.prototype.__init13.call(this);this._membership=t}__init13() {this.resourceType="sampler"}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class7),it= (_class8 =class{constructor(t){;_class8.prototype.__init14.call(this);this._membership=t}__init14() {this.resourceType="sampler-comparison"}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class8),jt= (_class9 =class{constructor(t){;_class9.prototype.__init15.call(this);_class9.prototype.__init16.call(this);this._props=t;this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}__init15() {this.resourceType="sampler"}__init16() {this._sampler=null}unwrap(t){return this._sampler||(this._sampler=t.device.createSampler({...this._props,label:_nullishCoalesce(this._label, () => ("<unnamed>"))})),this._sampler}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),{group:n,binding:a}=t.allocateFixedEntry({sampler:this._filtering?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class9),Kt= (_class10 =class{constructor(t){;_class10.prototype.__init17.call(this);_class10.prototype.__init18.call(this);this._props=t}__init17() {this.resourceType="sampler-comparison"}__init18() {this._sampler=null}unwrap(t){return this._sampler||(this._sampler=t.device.createSampler({...this._props,label:_nullishCoalesce(this._label, () => ("<unnamed>"))})),this._sampler}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({sampler:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class10);var st= (_class11 =class{constructor(t){;_class11.prototype.__init19.call(this);this._membership=t}__init19() {this.resourceType="external-texture"}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class11);var mn={r8unorm:_chunkM4VUFFPZcjs.K,r8snorm:_chunkM4VUFFPZcjs.K,r8uint:_chunkM4VUFFPZcjs.I,r8sint:_chunkM4VUFFPZcjs.J,r16uint:_chunkM4VUFFPZcjs.I,r16sint:_chunkM4VUFFPZcjs.J,r16float:_chunkM4VUFFPZcjs.K,rg8unorm:_chunkM4VUFFPZcjs.K,rg8snorm:_chunkM4VUFFPZcjs.K,rg8uint:_chunkM4VUFFPZcjs.I,rg8sint:_chunkM4VUFFPZcjs.J,r32uint:_chunkM4VUFFPZcjs.I,r32sint:_chunkM4VUFFPZcjs.J,r32float:_chunkM4VUFFPZcjs.K,rg16uint:_chunkM4VUFFPZcjs.I,rg16sint:_chunkM4VUFFPZcjs.J,rg16float:_chunkM4VUFFPZcjs.K,rgba8unorm:_chunkM4VUFFPZcjs.K,"rgba8unorm-srgb":_chunkM4VUFFPZcjs.K,rgba8snorm:_chunkM4VUFFPZcjs.K,rgba8uint:_chunkM4VUFFPZcjs.I,rgba8sint:_chunkM4VUFFPZcjs.J,bgra8unorm:_chunkM4VUFFPZcjs.K,"bgra8unorm-srgb":_chunkM4VUFFPZcjs.K,rgb9e5ufloat:_chunkM4VUFFPZcjs.K,rgb10a2uint:_chunkM4VUFFPZcjs.I,rgb10a2unorm:_chunkM4VUFFPZcjs.K,rg11b10ufloat:_chunkM4VUFFPZcjs.K,rg32uint:_chunkM4VUFFPZcjs.I,rg32sint:_chunkM4VUFFPZcjs.J,rg32float:_chunkM4VUFFPZcjs.K,rgba16uint:_chunkM4VUFFPZcjs.I,rgba16sint:_chunkM4VUFFPZcjs.J,rgba16float:_chunkM4VUFFPZcjs.K,rgba32uint:_chunkM4VUFFPZcjs.I,rgba32sint:_chunkM4VUFFPZcjs.J,rgba32float:_chunkM4VUFFPZcjs.K,stencil8:_chunkM4VUFFPZcjs.K,depth16unorm:_chunkM4VUFFPZcjs.K,depth24plus:_chunkM4VUFFPZcjs.K,"depth24plus-stencil8":_chunkM4VUFFPZcjs.K,depth32float:_chunkM4VUFFPZcjs.K,"depth32float-stencil8":_chunkM4VUFFPZcjs.K,"bc1-rgba-unorm":_chunkM4VUFFPZcjs.K,"bc1-rgba-unorm-srgb":_chunkM4VUFFPZcjs.K,"bc2-rgba-unorm":_chunkM4VUFFPZcjs.K,"bc2-rgba-unorm-srgb":_chunkM4VUFFPZcjs.K,"bc3-rgba-unorm":_chunkM4VUFFPZcjs.K,"bc3-rgba-unorm-srgb":_chunkM4VUFFPZcjs.K,"bc4-r-unorm":_chunkM4VUFFPZcjs.K,"bc4-r-snorm":_chunkM4VUFFPZcjs.K,"bc5-rg-unorm":_chunkM4VUFFPZcjs.K,"bc5-rg-snorm":_chunkM4VUFFPZcjs.K,"bc6h-rgb-ufloat":_chunkM4VUFFPZcjs.K,"bc6h-rgb-float":_chunkM4VUFFPZcjs.K,"bc7-rgba-unorm":_chunkM4VUFFPZcjs.K,"bc7-rgba-unorm-srgb":_chunkM4VUFFPZcjs.K,"etc2-rgb8unorm":_chunkM4VUFFPZcjs.K,"etc2-rgb8unorm-srgb":_chunkM4VUFFPZcjs.K,"etc2-rgb8a1unorm":_chunkM4VUFFPZcjs.K,"etc2-rgb8a1unorm-srgb":_chunkM4VUFFPZcjs.K,"etc2-rgba8unorm":_chunkM4VUFFPZcjs.K,"etc2-rgba8unorm-srgb":_chunkM4VUFFPZcjs.K,"eac-r11unorm":_chunkM4VUFFPZcjs.K,"eac-r11snorm":_chunkM4VUFFPZcjs.K,"eac-rg11unorm":_chunkM4VUFFPZcjs.K,"eac-rg11snorm":_chunkM4VUFFPZcjs.K,"astc-4x4-unorm":_chunkM4VUFFPZcjs.K,"astc-4x4-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-5x4-unorm":_chunkM4VUFFPZcjs.K,"astc-5x4-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-5x5-unorm":_chunkM4VUFFPZcjs.K,"astc-5x5-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-6x5-unorm":_chunkM4VUFFPZcjs.K,"astc-6x5-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-6x6-unorm":_chunkM4VUFFPZcjs.K,"astc-6x6-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-8x5-unorm":_chunkM4VUFFPZcjs.K,"astc-8x5-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-8x6-unorm":_chunkM4VUFFPZcjs.K,"astc-8x6-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-8x8-unorm":_chunkM4VUFFPZcjs.K,"astc-8x8-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-10x5-unorm":_chunkM4VUFFPZcjs.K,"astc-10x5-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-10x6-unorm":_chunkM4VUFFPZcjs.K,"astc-10x6-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-10x8-unorm":_chunkM4VUFFPZcjs.K,"astc-10x8-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-10x10-unorm":_chunkM4VUFFPZcjs.K,"astc-10x10-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-12x10-unorm":_chunkM4VUFFPZcjs.K,"astc-12x10-unorm-srgb":_chunkM4VUFFPZcjs.K,"astc-12x12-unorm":_chunkM4VUFFPZcjs.K,"astc-12x12-unorm-srgb":_chunkM4VUFFPZcjs.K},$e={rgba8unorm:_chunkM4VUFFPZcjs.x,rgba8snorm:_chunkM4VUFFPZcjs.x,rgba8uint:_chunkM4VUFFPZcjs.A,rgba8sint:_chunkM4VUFFPZcjs.z,rgba16uint:_chunkM4VUFFPZcjs.A,rgba16sint:_chunkM4VUFFPZcjs.z,rgba16float:_chunkM4VUFFPZcjs.x,r32uint:_chunkM4VUFFPZcjs.A,r32sint:_chunkM4VUFFPZcjs.z,r32float:_chunkM4VUFFPZcjs.x,rg32uint:_chunkM4VUFFPZcjs.A,rg32sint:_chunkM4VUFFPZcjs.z,rg32float:_chunkM4VUFFPZcjs.x,rgba32uint:_chunkM4VUFFPZcjs.A,rgba32sint:_chunkM4VUFFPZcjs.z,rgba32float:_chunkM4VUFFPZcjs.x,bgra8unorm:_chunkM4VUFFPZcjs.x},fn={f32:"float",u32:"uint",i32:"sint"},gn={float:_chunkM4VUFFPZcjs.K,"unfilterable-float":_chunkM4VUFFPZcjs.K,uint:_chunkM4VUFFPZcjs.I,sint:_chunkM4VUFFPZcjs.J,depth:_chunkM4VUFFPZcjs.K};function Tn(e,t){return new qt(e,t)}function N(e){return _optionalChain([e, 'optionalAccess', _40 => _40.resourceType])==="texture"}function ke(e){return _optionalChain([e, 'optionalAccess', _41 => _41.resourceType])==="texture-storage-view"}function Oe(e){return _optionalChain([e, 'optionalAccess', _42 => _42.resourceType])==="texture-sampled-view"}var cn={mutable:"read_write",readonly:"read",writeonly:"write"},qt= (_class12 =class{constructor(t,r){;_class12.prototype.__init20.call(this);_class12.prototype.__init21.call(this);_class12.prototype.__init22.call(this);_class12.prototype.__init23.call(this);_class12.prototype.__init24.call(this);_class12.prototype.__init25.call(this);_class12.prototype.__init26.call(this);this.props=t;this._branch=r}__init20() {this.resourceType="texture"}__init21() {this.usableAsSampled=!1}__init22() {this.usableAsStorage=!1}__init23() {this.usableAsRender=!1}__init24() {this._destroyed=!1}__init25() {this._flags=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}__init26() {this._texture=null}get label(){return this._label}$name(t){return this._label=t,this}unwrap(){if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:_nullishCoalesce(this._label, () => ("<unnamed>")),format:this.props.format,size:this.props.size,usage:this._flags,dimension:_nullishCoalesce(this.props.dimension, () => ("2d")),viewFormats:_nullishCoalesce(this.props.viewFormats, () => ([])),mipLevelCount:_nullishCoalesce(this.props.mipLevelCount, () => (1)),sampleCount:_nullishCoalesce(this.props.sampleCount, () => (1))})),this._texture}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||=r,this.usableAsSampled||=n,this.usableAsRender||=a,this}createView(t,r){if(t==="sampled")return this._asSampled(r);let n=r;switch(t){case"mutable":return this._asMutable(n);case"readonly":return this._asReadonly(n);case"writeonly":return this._asWriteonly(n)}}_asStorage(t,r){if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _43 => _43.format]), () => (this.props.format)),a=$e[n];return _chunkM4VUFFPZcjs.a.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new Jt(_nullishCoalesce(t, () => ({})),r,this)}_asReadonly(t){return this._asStorage(t,"readonly")}_asWriteonly(t){return this._asStorage(t,"writeonly")}_asMutable(t){return this._asStorage(t,"mutable")}_asSampled(t){if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _44 => _44.format]), () => (this.props.format));if(!$e[r])throw new Error(`Unsupported storage texture format: ${r}`);return new Ht(t,this)}destroy(){this._destroyed||(this._destroyed=!0,_optionalChain([this, 'access', _45 => _45._texture, 'optionalAccess', _46 => _46.destroy, 'call', _47 => _47()]))}}, _class12),lt={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},Jt= (_class13 =class{constructor(t,r,n){;_class13.prototype.__init27.call(this);this.access=r;this._texture=n;this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _48 => _48.dimension]), () => (n.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _49 => _49.format]), () => (n.props.format)),this.texelDataType=$e[this._format]}__init27() {this.resourceType="texture-storage-view"}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){return this._view||(this._view=this._texture.unwrap().createView({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - View`,format:this._format,dimension:this.dimension})),this._view}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${lt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${cn[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class13),ut= (_class14 =class{constructor(t,r,n,a){;_class14.prototype.__init28.call(this);this._format=t;this.dimension=r;this.access=n;this._membership=a;this.texelDataType=$e[this._format]}__init28() {this.resourceType="texture-storage-view"}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${lt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${cn[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class14),Ht= (_class15 =class{constructor(t,r){;_class15.prototype.__init29.call(this);this._props=t;this._texture=r;this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _50 => _50.dimension]), () => (r.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _51 => _51.format]), () => (r.props.format)),this.channelDataType=mn[this._format]}__init29() {this.resourceType="texture-sampled-view"}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){return this._view||(this._view=this._texture.unwrap().createView({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - View`,...this._props})),this._view}"~resolve"(t){let r=t.names.makeUnique(this.label),n=(_nullishCoalesce(this._texture.props.sampleCount, () => (1)))>1,{group:a,binding:o}=t.allocateFixedEntry({texture:fn[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${lt[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class15),pt= (_class16 =class{constructor(t,r,n,a){;_class16.prototype.__init30.call(this);this.dimension=r;this._multisampled=n;this._membership=a;this.channelDataType=gn[t]}__init30() {this.resourceType="texture-sampled-view"}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${lt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class16);function Yt(e){return!!_optionalChain([e, 'optionalAccess', _52 => _52.usableAsSampled])}function oa(e){return!!_optionalChain([e, 'optionalAccess', _53 => _53.usableAsRender])}var dt=class e extends Error{constructor(t){super(`Resource '${_nullishCoalesce(t.label, () => ("<unnamed>"))}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function mt(e){return new Xt(e)}function ft(e){return!!e&&e.resourceType==="bind-group-layout"}function Zt(e){return!!e&&e.resourceType==="bind-group"}var Qt=class e extends Error{constructor(t,r){super(`Bind group '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},yn=["compute"],be=["compute","vertex","fragment"],Xt= (_class17 =class{constructor(t){;_class17.prototype.__init31.call(this);_class17.prototype.__init32.call(this);this.entries=t;let r=0;for(let[n,a]of Object.entries(t)){if(a===null){r++;continue}let o={idx:r,key:n,layout:this};if("uniform"in a&&(this.bound[n]=new Ee("uniform",a.uniform,o)),"storage"in a){let i="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new Ee(_nullishCoalesce(a.access, () => ("readonly")),i,o)}"texture"in a&&(this.bound[n]=new pt(a.texture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.multisampled, () => (!1)),o)),"storageTexture"in a&&(this.bound[n]=new ut(a.storageTexture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.access, () => ("writeonly")),o)),"externalTexture"in a&&(this.bound[n]=new st(o)),"sampler"in a&&(a.sampler==="comparison"?this.bound[n]=new it(o):this.bound[n]=new ot(o)),r++}}__init31() {this.resourceType="bind-group-layout"}__init32() {this.bound={}}get label(){return this._label}get index(){return this._index}$name(t){return this._label=t,this}$idx(t){return this._index=t,this}unwrap(t){return t.device.createBindGroupLayout({label:_nullishCoalesce(this.label, () => ("<unnamed>")),entries:Object.values(this.entries).map((n,a)=>{if(n===null)return null;let o=n.visibility,i={binding:a,visibility:0};if("uniform"in n)o=_nullishCoalesce(o, () => (be)),i.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?yn:be))),i.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (be)),i.sampler={type:n.sampler};else if("texture"in n)o=_nullishCoalesce(o, () => (be)),i.texture={sampleType:n.texture,viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d")),multisampled:_nullishCoalesce(n.multisampled, () => (!1))};else if("storageTexture"in n){let s=_nullishCoalesce(n.access, () => ("writeonly"));o=_nullishCoalesce(o, () => ((s==="readonly"?be:yn))),i.storageTexture={format:n.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[s],viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d"))}}else"externalTexture"in n&&(o=_nullishCoalesce(o, () => (be)),i.externalTexture={});return _optionalChain([o, 'optionalAccess', _54 => _54.includes, 'call', _55 => _55("compute")])&&(i.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _56 => _56.includes, 'call', _57 => _57("vertex")])&&(i.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _58 => _58.includes, 'call', _59 => _59("fragment")])&&(i.visibility|=GPUShaderStage.FRAGMENT),i}).filter(n=>n!==null)})}populate(t){return new le(this,t)}}, _class17),le= (_class18 =class{constructor(t,r){;_class18.prototype.__init33.call(this);this.layout=t;this.entries=r;for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new Qt(t.label,n)}__init33() {this.resourceType="bind-group"}unwrap(t){return t.device.createBindGroup({label:_nullishCoalesce(this.layout.label, () => ("<unnamed>")),layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([n,a],o)=>{if(a===null)return null;let i=this.entries[n];if(i===void 0)throw new Error(`'${n}' is a resource required to populate bind group layout '${_nullishCoalesce(this.layout.label, () => ("<unnamed>"))}'.`);if("uniform"in a){let s;if(ee(i)){if(!nt(i))throw new (0, _chunkM4VUFFPZcjs.d)(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("storage"in a){let s;if(ee(i)){if(!pe(i))throw new Le(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("texture"in a){let s;if(N(i)){if(!Yt(i))throw new dt(i);s=t.unwrap(i.createView("sampled"))}else Oe(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("storageTexture"in a){let s;if(N(i)){if(!pe(i))throw new Le(i);a.access==="readonly"?s=t.unwrap(i.createView("readonly")):a.access==="mutable"?s=t.unwrap(i.createView("mutable")):s=t.unwrap(i.createView("writeonly"))}else ke(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("sampler"in a)return Ve(i)||Ge(i)?{binding:o,resource:t.unwrap(i)}:{binding:o,resource:i};if("externalTexture"in a)return{binding:o,resource:i};throw new Error(`Malformed bind group entry: ${i} (${JSON.stringify(i)})`)}).filter(n=>n!==null)})}}, _class18);var xn="#CATCHALL#",tr= (_class19 =class{constructor() { _class19.prototype.__init34.call(this);_class19.prototype.__init35.call(this); }__init34() {this._stack=[]}__init35() {this._itemDepth=0}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}popItem(){this.pop("item")}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}popSlotBindings(){this.pop("slotBinding")}pushFunctionScope(t,r,n){this._stack.push({type:"functionScope",args:t,returnType:r,externalMap:n})}popFunctionScope(){this.pop("functionScope")}pushBlockScope(){this._stack.push({type:"blockScope",declarations:new Map})}popBlockScope(){this.pop("blockScope")}pop(t){let r=this._stack[this._stack.length-1];if(!r||t&&r.type!==t)throw new Error(`Internal error, expected a ${t} layer to be on top.`);this._stack.pop(),t==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _60 => _60.type])==="item")n.usedSlots.add(t);else if(_optionalChain([n, 'optionalAccess', _61 => _61.type])==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _62 => _62.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _63 => _63.type])==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getResourceById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _64 => _64.type])==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:_chunkFM3TKZFZcjs.i.call(void 0, o)?ce(o):_chunkFM3TKZFZcjs.f}:void 0}if(_optionalChain([n, 'optionalAccess', _65 => _65.type])==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return{value:t,dataType:a}}}}defineBlockVariable(t,r){for(let n=this._stack.length-1;n>=0;--n){let a=this._stack[n];if(_optionalChain([a, 'optionalAccess', _66 => _66.type])==="blockScope")return a.declarations.set(t,r),{value:t,dataType:r}}throw new Error("No block scope found to define a variable in.")}}, _class19),gt=[""," "," "," "," "," "," "," "," "],er=gt.length-1,rr= (_class20 =class{constructor() { _class20.prototype.__init36.call(this); }__init36() {this.identLevel=0}get pre(){return _nullishCoalesce(gt[this.identLevel], () => (gt[er].repeat(this.identLevel/er)+gt[this.identLevel%er]))}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}}, _class20),nr= (_class21 =class{__init37() {this._memoizedResolves=new WeakMap}__init38() {this._memoizedDerived=new WeakMap}__init39() {this._indentController=new rr}__init40() {this._itemStateStack=new tr}__init41() {this._declarations=[]}__init42() {this[_chunkFM3TKZFZcjs.a]={itemStateStack:this._itemStateStack}}__init43() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init44() {this._nextFreeLayoutPlaceholderIdx=0}__init45() {this.fixedBindings=[]}__init46() {this.callStack=[]}constructor(t){;_class21.prototype.__init37.call(this);_class21.prototype.__init38.call(this);_class21.prototype.__init39.call(this);_class21.prototype.__init40.call(this);_class21.prototype.__init41.call(this);_class21.prototype.__init42.call(this);_class21.prototype.__init43.call(this);_class21.prototype.__init44.call(this);_class21.prototype.__init45.call(this);_class21.prototype.__init46.call(this);this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){let r=this._itemStateStack.getResourceById(t);return r===void 0?null:r}defineVariable(t,r){return this._itemStateStack.defineBlockVariable(t,r)}pushBlockScope(){this._itemStateStack.pushBlockScope()}popBlockScope(){this._itemStateStack.popBlockScope()}transpileFn(t){if(!this._jitTranspiler)throw new Error("Tried to execute a tgpu.fn function without providing a JIT transpiler, or transpiling at build time.");return this._jitTranspiler.transpileFn(t)}fnToWgsl(t){this._itemStateStack.pushFunctionScope(t.args,t.returnType,t.externalMap);try{let r=Vt(this,t.body),n=t.args.map(a=>`${a.value}: ${this.resolve(a.dataType)}`).join(", ");return{head:t.returnType!==void 0?`(${n}) -> ${_chunkUPPJES6Wcjs.ua.call(void 0, t.returnType)} ${this.resolve(t.returnType)}`:`(${n})`,body:r}}finally{this._itemStateStack.popFunctionScope()}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:xn,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunkM4VUFFPZcjs.c)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}unwrap(t){if(_chunkFM3TKZFZcjs.d.call(void 0, t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if(_chunkFM3TKZFZcjs.b.call(void 0, r))r=this.readSlot(r);else if(_chunkFM3TKZFZcjs.c.call(void 0, r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){let r=_nullishCoalesce(this._memoizedDerived.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([s,l])=>s.areEqual(this._itemStateStack.readSlot(s),l)))return o.result;_chunkM4VUFFPZcjs.k.call(void 0, _chunkM4VUFFPZcjs.h.CPU);let n;try{n=t["~compute"]()}finally{_chunkM4VUFFPZcjs.l.call(void 0, _chunkM4VUFFPZcjs.h.CPU)}let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this._memoizedDerived.set(t,r),n}catch(n){throw n instanceof _chunkM4VUFFPZcjs.b?n.appendToTrace(t):new (0, _chunkM4VUFFPZcjs.b)(n,[t])}finally{this._itemStateStack.popItem()}}_getOrInstantiate(t){let r=_nullishCoalesce(this._memoizedResolves.get(t), () => ([]));this._itemStateStack.pushItem();try{for(let o of r)if([...o.slotToValueMap.entries()].every(([s,l])=>s.areEqual(this._itemStateStack.readSlot(s),l)))return o.result;let n;_chunkUPPJES6Wcjs.h.call(void 0, t)?n=Ct(this,t):_chunkFM3TKZFZcjs.c.call(void 0, t)||_chunkFM3TKZFZcjs.b.call(void 0, t)?n=this.resolve(this.unwrap(t)):_chunkFM3TKZFZcjs.h.call(void 0, t)?n=t["~resolve"](this):n=this.resolveValue(t);let a=new Map;for(let o of this._itemStateStack.topItem.usedSlots)a.set(o,this._itemStateStack.readSlot(o));return r.push({slotToValueMap:a,result:n}),this._memoizedResolves.set(t,r),n}catch(n){throw n instanceof _chunkM4VUFFPZcjs.b?n.appendToTrace(t):new (0, _chunkM4VUFFPZcjs.b)(n,[t])}finally{this._itemStateStack.popItem()}}resolve(t){if(_chunkFM3TKZFZcjs.d.call(void 0, t))return this.withSlots(t["~providing"].pairs,()=>this.resolve(t["~providing"].inner));if(t&&typeof t=="object"||typeof t=="function"){if(this._itemStateStack.itemDepth===0)try{_chunkM4VUFFPZcjs.k.call(void 0, _chunkM4VUFFPZcjs.h.GPU);let r=_chunkM4VUFFPZcjs.i.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
24
24
 
25
- `)}${r}`}finally{_chunkQRLTUOBJcjs.o.call(void 0, _chunkQRLTUOBJcjs.k.GPU)}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(_chunk3JTP2ATRcjs.i.call(void 0, t))return this.resolve(t);if(r&&_chunkQRLTUOBJcjs.W.call(void 0, r))return`array(${t.map(n=>this.resolveValue(n,r.elementType))})`;if(Array.isArray(t))return`array(${t.map(n=>this.resolveValue(n))})`;if(r&&_chunkQRLTUOBJcjs.X.call(void 0, r))return`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>this.resolveValue(t[n],a))})`;throw new Error(`Value ${t} (as json: ${JSON.stringify(t)}) of schema ${r} is not resolvable to WGSL`)}};function Ue(e,t){var f;let r=new pr(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(g=>g.index).filter(g=>g!==void 0)),s=_chunkQRLTUOBJcjs.q.call(void 0, i),l=r.fixedBindings.map((g,w)=>[String(w),g.layoutEntry]),u=()=>{let g=s.next().value,w=ct(Object.fromEntries(l));return o[g]=w,n=n.replaceAll(In,String(g)),[g,new Te(w,Object.fromEntries(r.fixedBindings.map((c,T)=>[String(T),c.resource])))]},d=l.length>0?u():null;for(let[g,w]of a.entries()){let c=(f=g.index)!=null?f:s.next().value;o[c]=g,n=n.replaceAll(w,String(c))}return{code:n,bindGroupLayouts:o,catchall:d}}function Rn(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};le(o,t!=null?t:{});let i={"~resolve"(l){return de(l,o,r!=null?r:"")},toString:()=>"<root>"},{code:s}=Ue(i,{names:n==="strict"?new ne:new re,jitTranspiler:a});return s}var Ke=class{constructor(t){this._make=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"_map",new WeakMap)}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}};function Bn(e,t,r){return new lr(new dr(e,t,r),{})}function _n(e){return(e==null?void 0:e.resourceType)==="compute-pipeline"}var lr=class e{constructor(t,r){this._core=t;this._priors=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","compute-pipeline")}get label(){return this._core.label}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){var n;return new e(this._core,{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])})}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o,label:i}=this._core,s=o.commandEncoder.beginComputePass({label:i!=null?i:"<unnamed>"});s.setPipeline(a.pipeline);let l=new Set(a.bindGroupLayouts);if(a.bindGroupLayouts.forEach((u,d)=>{var f;if(a.catchall&&d===a.catchall[0])s.setBindGroup(d,o.unwrap(a.catchall[1])),l.delete(u);else{let g=(f=this._priors.bindGroupLayoutMap)==null?void 0:f.get(u);g!==void 0&&(l.delete(u),s.setBindGroup(d,o.unwrap(g)))}}),l.size>0)throw new (0, _chunkQRLTUOBJcjs.i)(l);s.dispatchWorkgroups(t,r,n),s.end()}$name(t){return this._core.label=t,this}},dr=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n;_chunkQRLTUOBJcjs.c.call(void 0, this,"label");_chunkQRLTUOBJcjs.c.call(void 0, this,"_memo")}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let i=this.branch.device,{code:s,bindGroupLayouts:l,catchall:u}=Ue({"~resolve":d=>(d.withSlots(this._slotBindings,()=>{d.resolve(this._entryFn)}),""),toString:()=>{var d;return`computePipeline:${(d=this.label)!=null?d:"<unnamed>"}`}},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});u!==null&&((r=l[u[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`)),this._memo={pipeline:i.createComputePipeline({label:(n=this.label)!=null?n:"<unnamed>",layout:i.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:l.map(d=>this.branch.unwrap(d))}),compute:{module:i.createShaderModule({label:`${(o=this.label)!=null?o:"<unnamed>"} - Shader`,code:s})}}),bindGroupLayouts:l,catchall:u}}return this._memo}};function gr(e,t="vertex"){return new fr(e,t)}function bt(e){return(e==null?void 0:e.resourceType)==="vertex-layout"}var mr=Symbol("defaultAttribEntry");function ht(e,t,r,n,a){if(_chunkQRLTUOBJcjs.da.call(void 0, t)||_chunk3QXCKMEJcjs.f.call(void 0, t)){let o=_chunk3QXCKMEJcjs.g.call(void 0, t);return o!==void 0&&(n[a!=null?a:mr]=o),ht(e,t.inner,_chunk3QXCKMEJcjs.j.call(void 0, r,_chunk3QXCKMEJcjs.aa.call(void 0, t)),n)}if(_chunkQRLTUOBJcjs.X.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunk3QXCKMEJcjs.j.call(void 0, o,_chunk3QXCKMEJcjs.$.call(void 0, s));let l=[i,ht(e,s,o,n,i)];return o+=_chunk3QXCKMEJcjs.ca.call(void 0, s),l}))}if(_chunk3QXCKMEJcjs.e.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunk3QXCKMEJcjs.j.call(void 0, o,_chunk3QXCKMEJcjs.aa.call(void 0, s));let l=[i,ht(e,s,o,n,i)];return o+=_chunk3QXCKMEJcjs.ca.call(void 0, s),l}))}if("type"in t&&typeof t.type=="string"){if(_chunk3QXCKMEJcjs.a.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunk3QXCKMEJcjs.b[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var fr=class{constructor(t,r){this.schemaForCount=t;this.stepMode=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","vertex-layout");_chunkQRLTUOBJcjs.c.call(void 0, this,"stride");_chunkQRLTUOBJcjs.c.call(void 0, this,"attrib");_chunkQRLTUOBJcjs.c.call(void 0, this,"_customLocationMap",{});_chunkQRLTUOBJcjs.c.call(void 0, this,"_label");let n=t(0);this.stride=_chunk3QXCKMEJcjs.j.call(void 0, _chunk3QXCKMEJcjs.ca.call(void 0, n.elementType),_chunk3QXCKMEJcjs.$.call(void 0, n)),this.attrib=ht(this,n.elementType,0,this._customLocationMap)}get label(){return this._label}get vertexLayout(){if(this._customLocationMap[mr]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[mr]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return this._label=t,this}};function Ta(e){return typeof(e==null?void 0:e.loadOp)=="string"}function Pn(e,t){if(_chunk3QXCKMEJcjs.h.call(void 0, e)){if(!Ta(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function ca(e){return typeof(e==null?void 0:e.format)=="string"}function Ln(e,t){if(_chunk3QXCKMEJcjs.h.call(void 0, e)){if(!ca(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Cn(e){return new Tr(new cr(e),{})}function En(e){return(e==null?void 0:e.resourceType)==="render-pipeline"}var Tr=class e{constructor(t,r){this.core=t;this.priors=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","render-pipeline")}get label(){return this.core.label}$name(t){return this.core.label=t,this}with(t,r){var n,a;if(yt(t))return new e(this.core,_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this.priors),{bindGroupLayoutMap:new Map([...(n=this.priors.bindGroupLayoutMap)!=null?n:[],[t,r]])}));if(bt(t))return new e(this.core,_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this.priors),{vertexLayoutMap:new Map([...(a=this.priors.vertexLayoutMap)!=null?a:[],[t,r]])}));throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){return new e(this.core,_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this.priors),{colorAttachment:t}))}withDepthStencilAttachment(t){return new e(this.core,_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this.priors),{depthStencilAttachment:t}))}draw(t,r,n,a){var c;let o=this.core.unwrap(),{branch:i,fragmentFn:s}=this.core.options,u={colorAttachments:Pn(s.shell.targets,(c=this.priors.colorAttachment)!=null?c:{}).map(T=>J(T.view)?_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},T),{view:i.unwrap(T.view).createView()}):T)};if(this.core.label!==void 0&&(u.label=this.core.label),this.priors.depthStencilAttachment!==void 0){let T=this.priors.depthStencilAttachment;J(T.view)?u.depthStencilAttachment=_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},T),{view:i.unwrap(T.view).createView()}):u.depthStencilAttachment=T}let d=i.commandEncoder.beginRenderPass(u);d.setPipeline(o.pipeline);let f=new Set(o.bindGroupLayouts);o.bindGroupLayouts.forEach((T,F)=>{var y;if(o.catchall&&F===o.catchall[0])d.setBindGroup(F,i.unwrap(o.catchall[1])),f.delete(T);else{let x=(y=this.priors.bindGroupLayoutMap)==null?void 0:y.get(T);x!==void 0&&(f.delete(T),d.setBindGroup(F,i.unwrap(x)))}});let g=new Set(this.core.usedVertexLayouts);if(this.core.usedVertexLayouts.forEach((T,F)=>{var x;let y=(x=this.priors.vertexLayoutMap)==null?void 0:x.get(T);y&&(g.delete(T),d.setVertexBuffer(F,i.unwrap(y)))}),f.size>0)throw new (0, _chunkQRLTUOBJcjs.i)(f);if(g.size>0)throw new (0, _chunkQRLTUOBJcjs.j)(g);d.draw(t,r,n,a),d.end(),i.flush()}},cr=class{constructor(t){this.options=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"label");_chunkQRLTUOBJcjs.c.call(void 0, this,"usedVertexLayouts");_chunkQRLTUOBJcjs.c.call(void 0, this,"_memo");_chunkQRLTUOBJcjs.c.call(void 0, this,"_vertexBufferLayouts");_chunkQRLTUOBJcjs.c.call(void 0, this,"_targets");let r=an(t.vertexFn.shell.attributes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=Ln(t.fragmentFn.shell.targets,t.targets)}unwrap(){var t,r,n,a;if(this._memo===void 0){let{branch:o,vertexFn:i,fragmentFn:s,slotBindings:l,primitiveState:u,depthStencilState:d,multisampleState:f}=this.options,{code:g,bindGroupLayouts:w,catchall:c}=Ue({"~resolve":x=>(x.withSlots(l,()=>{x.resolve(i),x.resolve(s)}),""),toString:()=>{var x;return`renderPipeline:${(x=this.label)!=null?x:"<unnamed>"}`}},{names:o.nameRegistry,jitTranspiler:o.jitTranspiler});c!==null&&((r=w[c[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`));let T=o.device,F=T.createShaderModule({label:`${(n=this.label)!=null?n:"<unnamed>"} - Shader`,code:g}),y={layout:T.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:w.map(x=>o.unwrap(x))}),vertex:{module:F,buffers:this._vertexBufferLayouts},fragment:{module:F,targets:this._targets}};this.label!==void 0&&(y.label=this.label),u&&(y.primitive=u),d&&(y.depthStencil=d),f&&(y.multisample=f),this._memo={pipeline:T.createRenderPipeline(y),bindGroupLayouts:w,catchall:c}}return this._memo}};var yr=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[_chunk3JTP2ATRcjs.e.call(void 0, t)?t.slot:t,r]])}withCompute(t){return new xr(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new hr({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}},xr=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return Bn(this._root,this._slotBindings,this._entryFn)}},hr=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunkQRLTUOBJcjs.d.call(void 0, typeof t!="string","Just type mismatch validation"),_chunkQRLTUOBJcjs.d.call(void 0, typeof r!="string","Just type mismatch validation"),new br(_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this._options),{fragmentFn:t,targets:r}))}},br=class e{constructor(t){this._options=t}withPrimitive(t){return new e(_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this._options),{primitiveState:t}))}withDepthStencil(t){return new e(_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this._options),{depthStencilState:t}))}withMultisample(t){return new e(_chunkQRLTUOBJcjs.b.call(void 0, _chunkQRLTUOBJcjs.a.call(void 0, {},this._options),{multisampleState:t}))}createPipeline(){return Cn(this._options)}},wt=class extends yr{constructor(r,n,a,o){super(()=>this,[]);this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;_chunkQRLTUOBJcjs.c.call(void 0, this,"~unstable");_chunkQRLTUOBJcjs.c.call(void 0, this,"_disposables",[]);_chunkQRLTUOBJcjs.c.call(void 0, this,"_unwrappedBindGroupLayouts",new Ke(r=>r.unwrap(this)));_chunkQRLTUOBJcjs.c.call(void 0, this,"_unwrappedBindGroups",new Ke(r=>r.unwrap(this)));_chunkQRLTUOBJcjs.c.call(void 0, this,"_commandEncoder",null);this["~unstable"]=this}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=xn(this,r,n);return this._disposables.push(a),a}createUniform(r,n){return this.createBuffer(r,n).$usage("uniform").as("uniform")}createMutable(r,n){return this.createBuffer(r,n).$usage("storage").as("mutable")}createReadonly(r,n){return this.createBuffer(r,n).$usage("storage").as("readonly")}createBindGroup(r,n){return new Te(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=Fn(r,this);return this._disposables.push(n),n}unwrap(r){if(_n(r))return r.rawPipeline;if(En(r))return r.core.unwrap().pipeline;if(yt(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(or(r))return this._unwrappedBindGroups.getOrMake(r);if(oe(r))return r.buffer;if(J(r)||ze(r)||je(r))return r.unwrap();if(bt(r))return r.vertexLayout;if(We(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out sampler.")}if(Me(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out comparison sampler.")}throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,i=new Map,s,l=()=>{if(!s)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:u,priors:d}=s,f=u.unwrap();a.setPipeline(f.pipeline);let g=new Set(f.bindGroupLayouts);f.bindGroupLayouts.forEach((c,T)=>{var F,y;if(f.catchall&&T===f.catchall[0])a.setBindGroup(T,this.unwrap(f.catchall[1])),g.delete(c);else{let x=(y=(F=d.bindGroupLayoutMap)==null?void 0:F.get(c))!=null?y:o.get(c);x!==void 0&&(g.delete(c),or(x)?a.setBindGroup(T,this.unwrap(x)):a.setBindGroup(T,x))}});let w=new Set;if(u.usedVertexLayouts.forEach((c,T)=>{var x;let F=(x=d.vertexLayoutMap)==null?void 0:x.get(c),y=F?{buffer:F,offset:void 0,size:void 0}:i.get(c);!y||!y.buffer?w.add(c):oe(y.buffer)?a.setVertexBuffer(T,this.unwrap(y.buffer),y.offset,y.size):a.setVertexBuffer(T,y.buffer,y.offset,y.size)}),g.size>0)throw new (0, _chunkQRLTUOBJcjs.i)(g);if(w.size>0)throw new (0, _chunkQRLTUOBJcjs.j)(w)};n({setViewport(...u){a.setViewport(...u)},setScissorRect(...u){a.setScissorRect(...u)},setBlendConstant(...u){a.setBlendConstant(...u)},setStencilReference(...u){a.setStencilReference(...u)},beginOcclusionQuery(...u){a.beginOcclusionQuery(...u)},endOcclusionQuery(...u){a.endOcclusionQuery(...u)},executeBundles(...u){a.executeBundles(...u)},setPipeline(u){s=u},setIndexBuffer:(u,d,f,g)=>{oe(u)?a.setIndexBuffer(this.unwrap(u),d,f,g):a.setIndexBuffer(u,d,f,g)},setVertexBuffer(u,d,f,g){i.set(u,{buffer:d,offset:f,size:g})},setBindGroup(u,d){o.set(u,d)},draw(u,d,f,g){l(),a.draw(u,d,f,g)},drawIndexed(...u){l(),a.drawIndexed(...u)},drawIndirect(...u){l(),a.drawIndirect(...u)},drawIndexedIndirect(...u){l(),a.drawIndexedIndirect(...u)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}};async function Vn(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=e!=null?e:{};if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new wt(await o.requestDevice(r),n==="random"?new re:new ne,a,!0)}function Gn(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=e!=null?e:{};return new wt(t,r==="random"?new re:new ne,n,!1)}function St(e){return new wr(e)}var wr=class{constructor(t=void 0){this.defaultValue=t;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","slot");_chunkQRLTUOBJcjs.c.call(void 0, this,"label");_chunkQRLTUOBJcjs.c.call(void 0, this,"~repr")}$name(t){return this.label=t,this}areEqual(t,r){return Object.is(t,r)}toString(){var t;return`slot:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){let t=_chunkQRLTUOBJcjs.m.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return Ve(t.unwrap(this))}};function $n(e,t){return new Sr(e,t)}var Sr=class{constructor(t,r=void 0){this.schema=t;this.defaultValue=r;_chunkQRLTUOBJcjs.c.call(void 0, this,"resourceType","accessor");_chunkQRLTUOBJcjs.c.call(void 0, this,"~repr");_chunkQRLTUOBJcjs.c.call(void 0, this,"label");_chunkQRLTUOBJcjs.c.call(void 0, this,"slot");this.slot=St(r)}$name(t){return this.label=t,this.slot.$name(t),this}toString(){var t;return`accessor:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunkQRLTUOBJcjs.m.call(void 0, ))throw new Error("Cannot access tgpu.accessor's value outside of resolution.");return new Proxy({"~resolve":r=>r.resolve(this),toString:()=>{var r;return`.value:${(r=this.label)!=null?r:"<unnamed>"}`},[_chunk3JTP2ATRcjs.a]:{dataType:this.schema}},M)}"~resolve"(t){let r=t.unwrap(this.slot);return _chunk3JTP2ATRcjs.k.call(void 0, r)?t.resolve(r):Vt(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}};function On(e){return xa(e)}function ya([e,t]){var r;return`${(r=e.label)!=null?r:"<unnamed>"}=${t}`}function xa(e){return{resourceType:"derived","~compute":e,"~repr":void 0,get value(){let r=_chunkQRLTUOBJcjs.m.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Ve(r.unwrap(this))},with(r,n){return kn(this,[[r,n]])},toString(){return"derived"}}}function kn(e,t){return{resourceType:"derived","~repr":void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},get value(){let n=_chunkQRLTUOBJcjs.m.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Ve(n.unwrap(this))},with(n,a){return kn(e,[...t,[n,a]])},toString(){return`derived[${t.map(ya).join(", ")}]`}}}function Wn(e,t){return new Dt("private",e,t)}function Mn(e){return new Dt("workgroup",e)}var Dt=class{constructor(t,r,n){this.scope=t;this._dataType=r;this._initialValue=n;_chunkQRLTUOBJcjs.c.call(void 0, this,"_label")}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label);return this._initialValue?t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)} = ${t.resolveValue(this._initialValue,this._dataType)};`):t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)};`),r}get label(){return this._label}toString(){var t;return`var:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunkQRLTUOBJcjs.p.call(void 0, ))throw new Error("Cannot access tgpu.var's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`},[_chunk3JTP2ATRcjs.a]:{dataType:this._dataType}},M)}};var Nn={bindGroupLayout:ct,vertexLayout:gr,init:Vn,initFromDevice:Gn,resolve:Rn,"~unstable":{fn:Zr,fragmentFn:tn,vertexFn:rn,computeFn:Xr,vertexLayout:gr,derived:On,slot:St,accessor:$n,privateVar:Wn,workgroupVar:Mn,const:jr,declare:qr,sampler:hn,comparisonSampler:bn}},ju= exports.default =Nn;Object.assign(Nn,{__assignAst:Yr});exports.MissingBindGroupsError = _chunkQRLTUOBJcjs.i; exports.MissingLinksError = _chunkQRLTUOBJcjs.h; exports.MissingSlotValueError = _chunkQRLTUOBJcjs.f; exports.MissingVertexBuffersError = _chunkQRLTUOBJcjs.j; exports.NotUniformError = _chunkQRLTUOBJcjs.g; exports.RandomNameRegistry = re; exports.ResolutionError = _chunkQRLTUOBJcjs.e; exports.StrictNameRegistry = ne; exports.default = ju; exports.isBuffer = oe; exports.isComparisonSampler = Me; exports.isDerived = _chunk3JTP2ATRcjs.c; exports.isSampledTextureView = je; exports.isSampler = We; exports.isSlot = _chunk3JTP2ATRcjs.b; exports.isStorageTextureView = ze; exports.isTexture = J; exports.isTgpuFn = Vt; exports.isUsableAsRender = ga; exports.isUsableAsSampled = rr; exports.isUsableAsStorage = ge; exports.isUsableAsUniform = st; exports.isUsableAsVertex = fa; exports.tgpu = Nn; exports.unstable_asMutable = jt; exports.unstable_asReadonly = Kt; exports.unstable_asUniform = qt;
25
+ `)}${r}`}finally{_chunkM4VUFFPZcjs.l.call(void 0, _chunkM4VUFFPZcjs.h.GPU)}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(_chunkFM3TKZFZcjs.i.call(void 0, t))return this.resolve(t);if(r&&_chunkM4VUFFPZcjs.T.call(void 0, r))return`array(${t.map(n=>this.resolveValue(n,r.elementType))})`;if(Array.isArray(t))return`array(${t.map(n=>this.resolveValue(n))})`;if(r&&_chunkM4VUFFPZcjs.U.call(void 0, r))return`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>this.resolveValue(t[n],a))})`;throw new Error(`Value ${t} (as json: ${JSON.stringify(t)}) of schema ${r} is not resolvable to WGSL`)}}, _class21);function we(e,t){let r=new nr(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(m=>m.index).filter(m=>m!==void 0)),s=_chunkM4VUFFPZcjs.n.call(void 0, i),l=r.fixedBindings.map((m,g)=>[String(g),m.layoutEntry]),u=()=>{let m=s.next().value,g=mt(Object.fromEntries(l));return o[m]=g,n=n.replaceAll(xn,String(m)),[m,new le(g,Object.fromEntries(r.fixedBindings.map((T,f)=>[String(f),T.resource])))]},d=l.length>0?u():null;for(let[m,g]of a.entries()){let T=_nullishCoalesce(m.index, () => (s.next().value));o[T]=m,n=n.replaceAll(g,String(T))}return{code:n,bindGroupLayouts:o,catchall:d}}function hn(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};oe(o,_nullishCoalesce(t, () => ({})));let i={"~resolve"(l){return ie(l,o,_nullishCoalesce(r, () => ("")))},toString:()=>"<root>"},{code:s}=we(i,{names:n==="strict"?new X:new Q,jitTranspiler:a});return s}var We= (_class22 =class{constructor(t){;_class22.prototype.__init47.call(this);this._make=t}__init47() {this._map=new WeakMap}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}}, _class22);function bn(e,t,r){return new ar(new or(e,t,r),{})}function wn(e){return _optionalChain([e, 'optionalAccess', _67 => _67.resourceType])==="compute-pipeline"}var ar= (_class23 =class e{constructor(t,r){;_class23.prototype.__init48.call(this);this._core=t;this._priors=r}__init48() {this.resourceType="compute-pipeline"}get label(){return this._core.label}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){return new e(this._core,{bindGroupLayoutMap:new Map([..._nullishCoalesce(this._priors.bindGroupLayoutMap, () => ([])),[t,r]])})}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o,label:i}=this._core,s=o.commandEncoder.beginComputePass({label:_nullishCoalesce(i, () => ("<unnamed>"))});s.setPipeline(a.pipeline);let l=new Set(a.bindGroupLayouts);if(a.bindGroupLayouts.forEach((u,d)=>{if(a.catchall&&d===a.catchall[0])s.setBindGroup(d,o.unwrap(a.catchall[1])),l.delete(u);else{let m=_optionalChain([this, 'access', _68 => _68._priors, 'access', _69 => _69.bindGroupLayoutMap, 'optionalAccess', _70 => _70.get, 'call', _71 => _71(u)]);m!==void 0&&(l.delete(u),s.setBindGroup(d,o.unwrap(m)))}}),l.size>0)throw new (0, _chunkM4VUFFPZcjs.f)(l);s.dispatchWorkgroups(t,r,n),s.end()}$name(t){return this._core.label=t,this}}, _class23),or=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n}unwrap(){if(this._memo===void 0){let t=this.branch.device,{code:r,bindGroupLayouts:n,catchall:a}=we({"~resolve":o=>(o.withSlots(this._slotBindings,()=>{o.resolve(this._entryFn)}),""),toString:()=>`computePipeline:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});a!==null&&_optionalChain([n, 'access', _72 => _72[a[0]], 'optionalAccess', _73 => _73.$name, 'call', _74 => _74(`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]),this._memo={pipeline:t.createComputePipeline({label:_nullishCoalesce(this.label, () => ("<unnamed>")),layout:t.createPipelineLayout({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:n.map(o=>this.branch.unwrap(o))}),compute:{module:t.createShaderModule({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Shader`,code:r})}}),bindGroupLayouts:n,catchall:a}}return this._memo}};function ur(e,t="vertex"){return new sr(e,t)}function ct(e){return _optionalChain([e, 'optionalAccess', _75 => _75.resourceType])==="vertex-layout"}var ir=Symbol("defaultAttribEntry");function Tt(e,t,r,n,a){if(_chunkM4VUFFPZcjs.aa.call(void 0, t)||_chunkUPPJES6Wcjs.f.call(void 0, t)){let o=_chunkUPPJES6Wcjs.g.call(void 0, t);return o!==void 0&&(n[_nullishCoalesce(a, () => (ir))]=o),Tt(e,t.inner,_chunkUPPJES6Wcjs.j.call(void 0, r,_chunkUPPJES6Wcjs.aa.call(void 0, t)),n)}if(_chunkM4VUFFPZcjs.U.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunkUPPJES6Wcjs.j.call(void 0, o,_chunkUPPJES6Wcjs.$.call(void 0, s));let l=[i,Tt(e,s,o,n,i)];return o+=_chunkUPPJES6Wcjs.ca.call(void 0, s),l}))}if(_chunkUPPJES6Wcjs.e.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunkUPPJES6Wcjs.j.call(void 0, o,_chunkUPPJES6Wcjs.aa.call(void 0, s));let l=[i,Tt(e,s,o,n,i)];return o+=_chunkUPPJES6Wcjs.ca.call(void 0, s),l}))}if("type"in t&&typeof t.type=="string"){if(_chunkUPPJES6Wcjs.a.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkUPPJES6Wcjs.b[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var sr= (_class24 =class{constructor(t,r){;_class24.prototype.__init49.call(this);_class24.prototype.__init50.call(this);this.schemaForCount=t;this.stepMode=r;let n=t(0);this.stride=_chunkUPPJES6Wcjs.j.call(void 0, _chunkUPPJES6Wcjs.ca.call(void 0, n.elementType),_chunkUPPJES6Wcjs.$.call(void 0, n)),this.attrib=Tt(this,n.elementType,0,this._customLocationMap)}__init49() {this.resourceType="vertex-layout"}__init50() {this._customLocationMap={}}get label(){return this._label}get vertexLayout(){if(this._customLocationMap[ir]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[ir]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return this._label=t,this}}, _class24);function ia(e){return typeof _optionalChain([e, 'optionalAccess', _76 => _76.loadOp])=="string"}function Sn(e,t){if(_chunkUPPJES6Wcjs.h.call(void 0, e)){if(!ia(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function sa(e){return typeof _optionalChain([e, 'optionalAccess', _77 => _77.format])=="string"}function vn(e,t){if(_chunkUPPJES6Wcjs.h.call(void 0, e)){if(!sa(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Dn(e){return new pr(new lr(e),{})}function Fn(e){return _optionalChain([e, 'optionalAccess', _78 => _78.resourceType])==="render-pipeline"}var pr= (_class25 =class e{constructor(t,r){;_class25.prototype.__init51.call(this);this.core=t;this.priors=r}__init51() {this.resourceType="render-pipeline"}get label(){return this.core.label}$name(t){return this.core.label=t,this}with(t,r){if(ft(t))return new e(this.core,{...this.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this.priors.bindGroupLayoutMap, () => ([])),[t,r]])});if(ct(t))return new e(this.core,{...this.priors,vertexLayoutMap:new Map([..._nullishCoalesce(this.priors.vertexLayoutMap, () => ([])),[t,r]])});throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){return new e(this.core,{...this.priors,colorAttachment:t})}withDepthStencilAttachment(t){return new e(this.core,{...this.priors,depthStencilAttachment:t})}draw(t,r,n,a){let o=this.core.unwrap(),{branch:i,fragmentFn:s}=this.core.options,u={colorAttachments:Sn(s.shell.targets,_nullishCoalesce(this.priors.colorAttachment, () => ({}))).map(f=>N(f.view)?{...f,view:i.unwrap(f.view).createView()}:f)};if(this.core.label!==void 0&&(u.label=this.core.label),this.priors.depthStencilAttachment!==void 0){let f=this.priors.depthStencilAttachment;N(f.view)?u.depthStencilAttachment={...f,view:i.unwrap(f.view).createView()}:u.depthStencilAttachment=f}let d=i.commandEncoder.beginRenderPass(u);d.setPipeline(o.pipeline);let m=new Set(o.bindGroupLayouts);o.bindGroupLayouts.forEach((f,S)=>{if(o.catchall&&S===o.catchall[0])d.setBindGroup(S,i.unwrap(o.catchall[1])),m.delete(f);else{let b=_optionalChain([this, 'access', _79 => _79.priors, 'access', _80 => _80.bindGroupLayoutMap, 'optionalAccess', _81 => _81.get, 'call', _82 => _82(f)]);b!==void 0&&(m.delete(f),d.setBindGroup(S,i.unwrap(b)))}});let g=new Set(this.core.usedVertexLayouts);if(this.core.usedVertexLayouts.forEach((f,S)=>{let b=_optionalChain([this, 'access', _83 => _83.priors, 'access', _84 => _84.vertexLayoutMap, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(f)]);b&&(g.delete(f),d.setVertexBuffer(S,i.unwrap(b)))}),m.size>0)throw new (0, _chunkM4VUFFPZcjs.f)(m);if(g.size>0)throw new (0, _chunkM4VUFFPZcjs.g)(g);d.draw(t,r,n,a),d.end(),i.flush()}}, _class25),lr=class{constructor(t){this.options=t;let r=Qr(t.vertexFn.shell.attributes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=vn(t.fragmentFn.shell.targets,t.targets)}unwrap(){if(this._memo===void 0){let{branch:t,vertexFn:r,fragmentFn:n,slotBindings:a,primitiveState:o,depthStencilState:i,multisampleState:s}=this.options,{code:l,bindGroupLayouts:u,catchall:d}=we({"~resolve":f=>(f.withSlots(a,()=>{f.resolve(r),f.resolve(n)}),""),toString:()=>`renderPipeline:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`},{names:t.nameRegistry,jitTranspiler:t.jitTranspiler});d!==null&&_optionalChain([u, 'access', _87 => _87[d[0]], 'optionalAccess', _88 => _88.$name, 'call', _89 => _89(`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let m=t.device,g=m.createShaderModule({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Shader`,code:l}),T={layout:m.createPipelineLayout({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:u.map(f=>t.unwrap(f))}),vertex:{module:g,buffers:this._vertexBufferLayouts},fragment:{module:g,targets:this._targets}};this.label!==void 0&&(T.label=this.label),o&&(T.primitive=o),i&&(T.depthStencil=i),s&&(T.multisample=s),this._memo={pipeline:m.createRenderPipeline(T),bindGroupLayouts:u,catchall:d}}return this._memo}};var dr=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[_chunkFM3TKZFZcjs.e.call(void 0, t)?t.slot:t,r]])}withCompute(t){return new mr(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new fr({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}},mr=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return bn(this._root,this._slotBindings,this._entryFn)}},fr=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunkM4VUFFPZcjs.a.call(void 0, typeof t!="string","Just type mismatch validation"),_chunkM4VUFFPZcjs.a.call(void 0, typeof r!="string","Just type mismatch validation"),new gr({...this._options,fragmentFn:t,targets:r})}},gr=class e{constructor(t){this._options=t}withPrimitive(t){return new e({...this._options,primitiveState:t})}withDepthStencil(t){return new e({...this._options,depthStencilState:t})}withMultisample(t){return new e({...this._options,multisampleState:t})}createPipeline(){return Dn(this._options)}},yt= (_class26 =class extends dr{constructor(r,n,a,o){super(()=>this,[]);_class26.prototype.__init52.call(this);_class26.prototype.__init53.call(this);_class26.prototype.__init54.call(this);_class26.prototype.__init55.call(this);;this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;this["~unstable"]=this}__init52() {this._disposables=[]}__init53() {this._unwrappedBindGroupLayouts=new We(r=>r.unwrap(this))}__init54() {this._unwrappedBindGroups=new We(r=>r.unwrap(this))}__init55() {this._commandEncoder=null}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=pn(this,r,n);return this._disposables.push(a),a}createUniform(r,n){return this.createBuffer(r,n).$usage("uniform").as("uniform")}createMutable(r,n){return this.createBuffer(r,n).$usage("storage").as("mutable")}createReadonly(r,n){return this.createBuffer(r,n).$usage("storage").as("readonly")}createBindGroup(r,n){return new le(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=Tn(r,this);return this._disposables.push(n),n}unwrap(r){if(wn(r))return r.rawPipeline;if(Fn(r))return r.core.unwrap().pipeline;if(ft(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(Zt(r))return this._unwrappedBindGroups.getOrMake(r);if(ee(r))return r.buffer;if(N(r)||ke(r)||Oe(r))return r.unwrap();if(ct(r))return r.vertexLayout;if(Ve(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out sampler.")}if(Ge(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out comparison sampler.")}throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,i=new Map,s,l=()=>{if(!s)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:u,priors:d}=s,m=u.unwrap();a.setPipeline(m.pipeline);let g=new Set(m.bindGroupLayouts);m.bindGroupLayouts.forEach((f,S)=>{if(m.catchall&&S===m.catchall[0])a.setBindGroup(S,this.unwrap(m.catchall[1])),g.delete(f);else{let b=_nullishCoalesce(_optionalChain([d, 'access', _90 => _90.bindGroupLayoutMap, 'optionalAccess', _91 => _91.get, 'call', _92 => _92(f)]), () => (o.get(f)));b!==void 0&&(g.delete(f),Zt(b)?a.setBindGroup(S,this.unwrap(b)):a.setBindGroup(S,b))}});let T=new Set;if(u.usedVertexLayouts.forEach((f,S)=>{let b=_optionalChain([d, 'access', _93 => _93.vertexLayoutMap, 'optionalAccess', _94 => _94.get, 'call', _95 => _95(f)]),U=b?{buffer:b,offset:void 0,size:void 0}:i.get(f);!U||!U.buffer?T.add(f):ee(U.buffer)?a.setVertexBuffer(S,this.unwrap(U.buffer),U.offset,U.size):a.setVertexBuffer(S,U.buffer,U.offset,U.size)}),g.size>0)throw new (0, _chunkM4VUFFPZcjs.f)(g);if(T.size>0)throw new (0, _chunkM4VUFFPZcjs.g)(T)};n({setViewport(...u){a.setViewport(...u)},setScissorRect(...u){a.setScissorRect(...u)},setBlendConstant(...u){a.setBlendConstant(...u)},setStencilReference(...u){a.setStencilReference(...u)},beginOcclusionQuery(...u){a.beginOcclusionQuery(...u)},endOcclusionQuery(...u){a.endOcclusionQuery(...u)},executeBundles(...u){a.executeBundles(...u)},setPipeline(u){s=u},setIndexBuffer:(u,d,m,g)=>{ee(u)?a.setIndexBuffer(this.unwrap(u),d,m,g):a.setIndexBuffer(u,d,m,g)},setVertexBuffer(u,d,m,g){i.set(u,{buffer:d,offset:m,size:g})},setBindGroup(u,d){o.set(u,d)},draw(u,d,m,g){l(),a.draw(u,d,m,g)},drawIndexed(...u){l(),a.drawIndexed(...u)},drawIndirect(...u){l(),a.drawIndirect(...u)},drawIndexedIndirect(...u){l(),a.drawIndexedIndirect(...u)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class26);async function Un(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=_nullishCoalesce(e, () => ({}));if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new yt(await o.requestDevice(r),n==="random"?new Q:new X,a,!0)}function An(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=_nullishCoalesce(e, () => ({}));return new yt(t,r==="random"?new Q:new X,n,!1)}function xt(e){return new Tr(e)}var Tr= (_class27 =class{constructor(t=void 0){;_class27.prototype.__init56.call(this);_class27.prototype.__init57.call(this);this.defaultValue=t}__init56() {this.resourceType="slot"}__init57() {this["~repr"]=void 0}$name(t){return this.label=t,this}areEqual(t,r){return Object.is(t,r)}toString(){return`slot:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){let t=_chunkM4VUFFPZcjs.j.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return _e(t.unwrap(this))}}, _class27);function In(e,t){return new cr(e,t)}var cr= (_class28 =class{constructor(t,r=void 0){;_class28.prototype.__init58.call(this);_class28.prototype.__init59.call(this);this.schema=t;this.defaultValue=r;this.slot=xt(r)}__init58() {this.resourceType="accessor"}__init59() {this["~repr"]=void 0}$name(t){return this.label=t,this.slot.$name(t),this}toString(){return`accessor:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){if(!_chunkM4VUFFPZcjs.j.call(void 0, ))throw new Error("Cannot access tgpu.accessor's value outside of resolution.");return new Proxy({"~resolve":r=>r.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkFM3TKZFZcjs.a]:{dataType:this.schema}},G)}"~resolve"(t){let r=t.unwrap(this.slot);return _chunkFM3TKZFZcjs.k.call(void 0, r)?t.resolve(r):Pt(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}}, _class28);function Rn(e){return pa(e)}function ua([e,t]){return`${_nullishCoalesce(e.label, () => ("<unnamed>"))}=${t}`}function pa(e){return{resourceType:"derived","~compute":e,"~repr":void 0,get value(){let r=_chunkM4VUFFPZcjs.j.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return _e(r.unwrap(this))},with(r,n){return Bn(this,[[r,n]])},toString(){return"derived"}}}function Bn(e,t){return{resourceType:"derived","~repr":void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},get value(){let n=_chunkM4VUFFPZcjs.j.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return _e(n.unwrap(this))},with(n,a){return Bn(e,[...t,[n,a]])},toString(){return`derived[${t.map(ua).join(", ")}]`}}}function _n(e,t){return new ht("private",e,t)}function Pn(e){return new ht("workgroup",e)}var ht=class{constructor(t,r,n){this.scope=t;this._dataType=r;this._initialValue=n}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label);return this._initialValue?t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)} = ${t.resolveValue(this._initialValue,this._dataType)};`):t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)};`),r}get label(){return this._label}toString(){return`var:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){if(!_chunkM4VUFFPZcjs.m.call(void 0, ))throw new Error("Cannot access tgpu.var's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkFM3TKZFZcjs.a]:{dataType:this._dataType}},G)}};var Ln={bindGroupLayout:mt,vertexLayout:ur,init:Un,initFromDevice:An,resolve:hn,"~unstable":{fn:Kr,fragmentFn:Jr,vertexFn:Hr,computeFn:jr,vertexLayout:ur,derived:Rn,slot:xt,accessor:In,privateVar:_n,workgroupVar:Pn,const:$r,declare:Or,sampler:ln,comparisonSampler:dn}},xu= exports.default =Ln;Object.assign(Ln,{__assignAst:Nr});exports.MissingBindGroupsError = _chunkM4VUFFPZcjs.f; exports.MissingLinksError = _chunkM4VUFFPZcjs.e; exports.MissingSlotValueError = _chunkM4VUFFPZcjs.c; exports.MissingVertexBuffersError = _chunkM4VUFFPZcjs.g; exports.NotUniformError = _chunkM4VUFFPZcjs.d; exports.RandomNameRegistry = Q; exports.ResolutionError = _chunkM4VUFFPZcjs.b; exports.StrictNameRegistry = X; exports.default = xu; exports.isBuffer = ee; exports.isComparisonSampler = Ge; exports.isDerived = _chunkFM3TKZFZcjs.c; exports.isSampledTextureView = Oe; exports.isSampler = Ve; exports.isSlot = _chunkFM3TKZFZcjs.b; exports.isStorageTextureView = ke; exports.isTexture = N; exports.isTgpuFn = Pt; exports.isUsableAsRender = oa; exports.isUsableAsSampled = Yt; exports.isUsableAsStorage = pe; exports.isUsableAsUniform = nt; exports.isUsableAsVertex = aa; exports.tgpu = Ln; exports.unstable_asMutable = Ot; exports.unstable_asReadonly = Wt; exports.unstable_asUniform = Mt;
26
26
  //# sourceMappingURL=index.cjs.map