typegpu 0.5.4 → 0.5.6

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}); 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 _chunkURJCMUTTcjs = require('./chunk-URJCMUTT.cjs');var _chunk7UUBX6MCcjs = require('./chunk-7UUBX6MC.cjs');var kn=["vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","struct"],Wn={f:{1:_chunk7UUBX6MCcjs.O,2:_chunk7UUBX6MCcjs.q,3:_chunk7UUBX6MCcjs.v,4:_chunk7UUBX6MCcjs.A},h:{1:_chunk7UUBX6MCcjs.P,2:_chunk7UUBX6MCcjs.r,3:_chunk7UUBX6MCcjs.w,4:_chunk7UUBX6MCcjs.B},i:{1:_chunk7UUBX6MCcjs.N,2:_chunk7UUBX6MCcjs.s,3:_chunk7UUBX6MCcjs.x,4:_chunk7UUBX6MCcjs.C},u:{1:_chunk7UUBX6MCcjs.M,2:_chunk7UUBX6MCcjs.t,3:_chunk7UUBX6MCcjs.y,4:_chunk7UUBX6MCcjs.D},b:{1:_chunk7UUBX6MCcjs.L,2:_chunk7UUBX6MCcjs.u,3:_chunk7UUBX6MCcjs.z,4:_chunk7UUBX6MCcjs.E}},kr={vec2f:_chunk7UUBX6MCcjs.q,vec2h:_chunk7UUBX6MCcjs.r,vec2i:_chunk7UUBX6MCcjs.s,vec2u:_chunk7UUBX6MCcjs.t,"vec2<bool>":_chunk7UUBX6MCcjs.u,vec3f:_chunk7UUBX6MCcjs.v,vec3h:_chunk7UUBX6MCcjs.w,vec3i:_chunk7UUBX6MCcjs.x,vec3u:_chunk7UUBX6MCcjs.y,"vec3<bool>":_chunk7UUBX6MCcjs.z,vec4f:_chunk7UUBX6MCcjs.A,vec4h:_chunk7UUBX6MCcjs.B,vec4i:_chunk7UUBX6MCcjs.C,vec4u:_chunk7UUBX6MCcjs.D,"vec4<bool>":_chunk7UUBX6MCcjs.E,mat2x2f:_chunk7UUBX6MCcjs.F,mat3x3f:_chunk7UUBX6MCcjs.G,mat4x4f:_chunk7UUBX6MCcjs.H},Wr={vec2f:_chunk7UUBX6MCcjs.O,vec2h:_chunk7UUBX6MCcjs.P,vec2i:_chunk7UUBX6MCcjs.N,vec2u:_chunk7UUBX6MCcjs.M,"vec2<bool>":_chunk7UUBX6MCcjs.L,vec3f:_chunk7UUBX6MCcjs.O,vec3h:_chunk7UUBX6MCcjs.P,vec3i:_chunk7UUBX6MCcjs.N,vec3u:_chunk7UUBX6MCcjs.M,"vec3<bool>":_chunk7UUBX6MCcjs.L,vec4f:_chunk7UUBX6MCcjs.O,vec4h:_chunk7UUBX6MCcjs.P,vec4i:_chunk7UUBX6MCcjs.N,vec4u:_chunk7UUBX6MCcjs.M,"vec4<bool>":_chunk7UUBX6MCcjs.L,mat2x2f:_chunk7UUBX6MCcjs.q,mat3x3f:_chunk7UUBX6MCcjs.v,mat4x4f:_chunk7UUBX6MCcjs.A};function Pe(e,t){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return _chunkURJCMUTTcjs.f;if(_chunkURJCMUTTcjs.c.call(void 0, e)||_chunkURJCMUTTcjs.b.call(void 0, e)){let o=_chunk7UUBX6MCcjs.j.call(void 0, );if(!o)throw new Error("Resolution context not found when unwrapping slot or derived");let i=o.unwrap(e);return xe(i)}let r=e;for(_chunkURJCMUTTcjs.l.call(void 0, r)&&(r=r[_chunkURJCMUTTcjs.a].dataType);_chunk7UUBX6MCcjs.ea.call(void 0, r);)r=r.inner;let n="kind"in r?r.kind:r.type;if(n==="struct")return _nullishCoalesce(r.propTypes[t], () => (_chunkURJCMUTTcjs.f));let a=t.length;if(kn.includes(n)&&a>=1&&a<=4){let o=n.includes("bool")?"b":n[4],i=Wn[o][a];if(i)return i}return _chunk7UUBX6MCcjs.W.call(void 0, r)?r:_chunkURJCMUTTcjs.f}function Mr(e){if(_chunk7UUBX6MCcjs.W.call(void 0, e)){if(_chunk7UUBX6MCcjs.X.call(void 0, e))return e.elementType;if(e.type in Wr)return Wr[e.type]}return _chunkURJCMUTTcjs.f}function xe(e){if(_chunkURJCMUTTcjs.c.call(void 0, e)||_chunkURJCMUTTcjs.b.call(void 0, e))return xe(e.value);if(typeof e=="string")return _chunkURJCMUTTcjs.f;if(typeof e=="number")return _nullishCoalesce(_optionalChain([Lt, 'call', _2 => _2(String(e)), 'optionalAccess', _3 => _3.dataType]), () => (_chunkURJCMUTTcjs.f));if(typeof e=="boolean")return _chunk7UUBX6MCcjs.L;if("kind"in e){let t=e.kind;if(t in kr)return kr[t]}return _chunk7UUBX6MCcjs.W.call(void 0, e)?e:_chunkURJCMUTTcjs.f}function Lt(e){if(/^0x[0-9a-f]+$/i.test(e))return{value:e,dataType:_chunk7UUBX6MCcjs.J};if(/^0b[01]+$/i.test(e))return{value:`${Number.parseInt(e.slice(2),2)}`,dataType:_chunk7UUBX6MCcjs.J};if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return{value:e,dataType:_chunk7UUBX6MCcjs.K};if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return{value:e,dataType:_chunk7UUBX6MCcjs.K};if(/^-?\d+$/i.test(e))return{value:e,dataType:_chunk7UUBX6MCcjs.J}}var k={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>"))}`,[_chunkURJCMUTTcjs.a]:{dataType:Pe(e[_chunkURJCMUTTcjs.a].dataType,String(t))}},k)}};function Le(e){let t=e;for(;_chunkURJCMUTTcjs.b.call(void 0, t)||_chunkURJCMUTTcjs.c.call(void 0, t)||_chunkURJCMUTTcjs.e.call(void 0, t)||_chunkURJCMUTTcjs.k.call(void 0, t);)t=t.value;return t}function Nr(e,t){return new Ct(e,t)}var Ct=class{constructor(t,r){this.dataType=t;this._value=r;this[_chunkURJCMUTTcjs.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 _chunk7UUBX6MCcjs.m.call(void 0, )?new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkURJCMUTTcjs.a]:{dataType:this.dataType}},k):this._value}};function W(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function K(e,t){for(let[r,n]of Object.entries(t))e[r]=n,W(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function jr(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 _chunk7UUBX6MCcjs.Y.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function he(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;_chunk7UUBX6MCcjs.Y.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function Mn(e){return new RegExp(`(?<![\\w\\$_.])${e.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function se(e,t,r){return Object.entries(t).reduce((n,[a,o])=>_chunkURJCMUTTcjs.i.call(void 0, o)||_chunk7UUBX6MCcjs.ha.call(void 0, o)?n.replaceAll(Mn(a),e.resolve(o)):o!==null&&typeof o=="object"?(_nullishCoalesce([...r.matchAll(new RegExp(`${a.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(s=>s[1]), () => ([]))).reduce((s,p)=>p&&p in o?se(e,{[`${a}.${p}`]:o[p]},s):s,n):n,r)}function zr(e){return new Et(e)}var Et= (_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)K(r,a);let n=se(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}}, _class);var Kr=new WeakMap;function qr(e){return Kr.get(e)}function Hr(e,t,r){return Kr.set(e,{ast:t,externals:r}),e}function Jr(e){return()=>{throw new Error(`The function "${_nullishCoalesce(e, () => ("<unnamed>"))}" is invokable only on the GPU. If you want to use it on the CPU, mark it with the "kernel & js" directive.`)}}function Yr(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}function Ce(e){return typeof _optionalChain([e, 'optionalAccess', _7 => _7.format])=="string"}function Qr(e,t){let r=[];if(_chunk7UUBX6MCcjs.ma.call(void 0, e)){if(!Ce(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(_chunk7UUBX6MCcjs.la.call(void 0, e), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[i,s]of Object.entries(e)){if(_chunk7UUBX6MCcjs.nb.call(void 0, s))continue;let p=t[i];if(!p)throw new Error(`An attribute by the name of '${i}' was not provided to the shader.`);let u=p._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(_chunk7UUBX6MCcjs.la.call(void 0, s), () => (o)),d.push({format:p.format,offset:p.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Nn=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2<bool>","vec3<bool>","vec4<bool>","mat2x2f","mat3x3f","mat4x4f"];function jn(e){return Nn.includes(e.type)}function Vt(e,[t,r]){return` ${_chunk7UUBX6MCcjs.ob.call(void 0, r)}${t}: ${e.resolve(r)},
2
- `}function zn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkLB4TSIPNcjs = require('./chunk-LB4TSIPN.cjs');var _chunkVTUUXD6Hcjs = require('./chunk-VTUUXD6H.cjs');function $(e){return _optionalChain([e, 'optionalAccess', _2 => _2.resourceType])==="slot"}function k(e){return _optionalChain([e, 'optionalAccess', _3 => _3.resourceType])==="derived"}function Ve(e){return _optionalChain([e, 'optionalAccess', _4 => _4["~providing"]])!==void 0}function ue(e){return _optionalChain([e, 'optionalAccess', _5 => _5.resourceType])==="accessor"}var U={type:"unknown"};function $t(e){return typeof _optionalChain([e, 'optionalAccess', _6 => _6["~resolve"]])=="function"}function K(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||$t(e)||_chunkVTUUXD6Hcjs.Y.call(void 0, e)||$(e)||k(e)||Ve(e)}function kr(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function et(e){return _optionalChain([e, 'optionalAccess', _7 => _7.resourceType])==="buffer-usage"}function Or(e){return!!e&&typeof e=="object"&&!!_optionalChain([e, 'optionalAccess', _8 => _8[_chunkVTUUXD6Hcjs.n], 'optionalAccess', _9 => _9.dataType])}function Gr(e){return!!_optionalChain([e, 'optionalAccess', _10 => _10[_chunkVTUUXD6Hcjs.n]])}var Mn=["vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","struct"],Nn={f:{1:_chunkVTUUXD6Hcjs.P,2:_chunkVTUUXD6Hcjs.r,3:_chunkVTUUXD6Hcjs.w,4:_chunkVTUUXD6Hcjs.B},h:{1:_chunkVTUUXD6Hcjs.Q,2:_chunkVTUUXD6Hcjs.s,3:_chunkVTUUXD6Hcjs.x,4:_chunkVTUUXD6Hcjs.C},i:{1:_chunkVTUUXD6Hcjs.O,2:_chunkVTUUXD6Hcjs.t,3:_chunkVTUUXD6Hcjs.y,4:_chunkVTUUXD6Hcjs.D},u:{1:_chunkVTUUXD6Hcjs.N,2:_chunkVTUUXD6Hcjs.u,3:_chunkVTUUXD6Hcjs.z,4:_chunkVTUUXD6Hcjs.E},b:{1:_chunkVTUUXD6Hcjs.M,2:_chunkVTUUXD6Hcjs.v,3:_chunkVTUUXD6Hcjs.A,4:_chunkVTUUXD6Hcjs.F}},Wr={vec2f:_chunkVTUUXD6Hcjs.r,vec2h:_chunkVTUUXD6Hcjs.s,vec2i:_chunkVTUUXD6Hcjs.t,vec2u:_chunkVTUUXD6Hcjs.u,"vec2<bool>":_chunkVTUUXD6Hcjs.v,vec3f:_chunkVTUUXD6Hcjs.w,vec3h:_chunkVTUUXD6Hcjs.x,vec3i:_chunkVTUUXD6Hcjs.y,vec3u:_chunkVTUUXD6Hcjs.z,"vec3<bool>":_chunkVTUUXD6Hcjs.A,vec4f:_chunkVTUUXD6Hcjs.B,vec4h:_chunkVTUUXD6Hcjs.C,vec4i:_chunkVTUUXD6Hcjs.D,vec4u:_chunkVTUUXD6Hcjs.E,"vec4<bool>":_chunkVTUUXD6Hcjs.F,mat2x2f:_chunkVTUUXD6Hcjs.G,mat3x3f:_chunkVTUUXD6Hcjs.H,mat4x4f:_chunkVTUUXD6Hcjs.I},Mr={vec2f:_chunkVTUUXD6Hcjs.P,vec2h:_chunkVTUUXD6Hcjs.Q,vec2i:_chunkVTUUXD6Hcjs.O,vec2u:_chunkVTUUXD6Hcjs.N,"vec2<bool>":_chunkVTUUXD6Hcjs.M,vec3f:_chunkVTUUXD6Hcjs.P,vec3h:_chunkVTUUXD6Hcjs.Q,vec3i:_chunkVTUUXD6Hcjs.O,vec3u:_chunkVTUUXD6Hcjs.N,"vec3<bool>":_chunkVTUUXD6Hcjs.M,vec4f:_chunkVTUUXD6Hcjs.P,vec4h:_chunkVTUUXD6Hcjs.Q,vec4i:_chunkVTUUXD6Hcjs.O,vec4u:_chunkVTUUXD6Hcjs.N,"vec4<bool>":_chunkVTUUXD6Hcjs.M,mat2x2f:_chunkVTUUXD6Hcjs.r,mat3x3f:_chunkVTUUXD6Hcjs.w,mat4x4f:_chunkVTUUXD6Hcjs.B};function he(e,t){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return U;if(k(e)||$(e)){let o=_chunkVTUUXD6Hcjs.j.call(void 0, );if(!o)throw new Error("Resolution context not found when unwrapping slot or derived");let s=o.unwrap(e);return we(s)}let r=e;for(Or(r)&&(r=r[_chunkVTUUXD6Hcjs.n].dataType);_chunkVTUUXD6Hcjs.ga.call(void 0, r);)r=r.inner;let n="kind"in r?r.kind:r.type;if(n==="struct")return _nullishCoalesce(r.propTypes[t], () => (U));let a=t.length;if(Mn.includes(n)&&a>=1&&a<=4){let o=n.includes("bool")?"b":n[4],s=Nn[o][a];if(s)return s}return _chunkVTUUXD6Hcjs.Y.call(void 0, r)?r:U}function Nr(e){if(_chunkVTUUXD6Hcjs.Y.call(void 0, e)){if(_chunkVTUUXD6Hcjs.Z.call(void 0, e))return e.elementType;if(e.type in Mr)return Mr[e.type]}return U}function we(e){if(k(e)||$(e))return we(e.value);if(typeof e=="string")return U;if(typeof e=="number")return _nullishCoalesce(_optionalChain([kt, 'call', _11 => _11(String(e)), 'optionalAccess', _12 => _12.dataType]), () => (U));if(typeof e=="boolean")return _chunkVTUUXD6Hcjs.M;if("kind"in e){let t=e.kind;if(t in Wr)return Wr[t]}return _chunkVTUUXD6Hcjs.Y.call(void 0, e)?e:U}function kt(e){if(/^0x[0-9a-f]+$/i.test(e))return{value:e,dataType:_chunkVTUUXD6Hcjs.K};if(/^0b[01]+$/i.test(e))return{value:`${Number.parseInt(e.slice(2),2)}`,dataType:_chunkVTUUXD6Hcjs.K};if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return{value:e,dataType:_chunkVTUUXD6Hcjs.L};if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return{value:e,dataType:_chunkVTUUXD6Hcjs.L};if(/^-?\d+$/i.test(e))return{value:e,dataType:_chunkVTUUXD6Hcjs.K}}var N={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>"))}`,[_chunkVTUUXD6Hcjs.n]:{dataType:he(e[_chunkVTUUXD6Hcjs.n].dataType,String(t))}},N)}};function $e(e){let t=e;for(;$(t)||k(t)||ue(t)||et(t);)t=t.value;return t}function jr(e,t){return new Ot(e,t)}var Ot=class{constructor(t,r){this.dataType=t;this._value=r;this[_chunkVTUUXD6Hcjs.n]={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 _chunkVTUUXD6Hcjs.m.call(void 0, )?new Proxy({"~resolve":t=>t.resolve(this),toString:()=>`.value:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`,[_chunkVTUUXD6Hcjs.n]:{dataType:this.dataType}},N):this._value}};function j(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function q(e,t){for(let[r,n]of Object.entries(t))e[r]=n,j(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function zr(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 s=n?n[o]:void 0;return _chunkVTUUXD6Hcjs._.call(void 0, a)&&s!==void 0?[[s,a]]:[]})))}function Se(e,t,r){let n=e.match(/->\s(?<output>[\w\d_]+)\s{/),a=n?_optionalChain([n, 'access', _13 => _13[1], 'optionalAccess', _14 => _14.trim, 'call', _15 => _15()]):void 0;_chunkVTUUXD6Hcjs._.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function jn(e){return new RegExp(`(?<![\\w\\$_.])${e.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function pe(e,t,r){return Object.entries(t).reduce((n,[a,o])=>K(o)||_chunkLB4TSIPNcjs.c.call(void 0, o)?n.replaceAll(jn(a),e.resolve(o)):o!==null&&typeof o=="object"?(_nullishCoalesce([...r.matchAll(new RegExp(`${a.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(i=>i[1]), () => ([]))).reduce((i,p)=>p&&p in o?pe(e,{[`${a}.${p}`]:o[p]},i):i,n):n,r)}function Kr(e){return new Gt(e)}var Gt= (_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)q(r,a);let n=pe(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}}, _class);var qr=new WeakMap;function Hr(e){return qr.get(e)}function Jr(e,t,r){return qr.set(e,{ast:t,externals:r}),e}function Yr(e){return()=>{throw new Error(`The function "${_nullishCoalesce(e, () => ("<unnamed>"))}" is invokable only on the GPU. If you want to use it on the CPU, mark it with the "kernel & js" directive.`)}}function Qr(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}function ke(e){return typeof _optionalChain([e, 'optionalAccess', _16 => _16.format])=="string"}function Xr(e,t){let r=[];if(_chunkLB4TSIPNcjs.h.call(void 0, e)){if(!ke(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(_chunkLB4TSIPNcjs.g.call(void 0, e), () => (0))}]}]}}let n=[],a=new WeakMap,o=0;for(let[s,i]of Object.entries(e)){if(_chunkLB4TSIPNcjs.ha.call(void 0, i))continue;let p=t[s];if(!p)throw new Error(`An attribute by the name of '${s}' was not provided to the shader.`);let u=p._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(_chunkLB4TSIPNcjs.g.call(void 0, i), () => (o)),d.push({format:p.format,offset:p.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var zn=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2<bool>","vec3<bool>","vec4<bool>","mat2x2f","mat3x3f","mat4x4f"];function Kn(e){return zn.includes(e.type)}function Wt(e,[t,r]){return` ${_chunkLB4TSIPNcjs.ia.call(void 0, r)}${t}: ${e.resolve(r)},
2
+ `}function qn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
3
3
  struct ${r} {
4
- ${Object.entries(t.propTypes).map(n=>Vt(e,n)).join("")}}
5
- `),r}function Kn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
4
+ ${Object.entries(t.propTypes).map(n=>Wt(e,n)).join("")}}
5
+ `),r}function Hn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
6
6
  struct ${r} {
7
- ${Object.entries(t.propTypes).map(n=>Ce(n[1])?Vt(e,[n[0],_chunk7UUBX6MCcjs.na[n[1].format]]):Vt(e,n)).join("")}
7
+ ${Object.entries(t.propTypes).map(n=>ke(n[1])?Wt(e,[n[0],_chunkLB4TSIPNcjs.i[n[1].format]]):Wt(e,n)).join("")}
8
8
  }
9
- `),r}function qn(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Hn(e,t){let r=e.resolve(Ce(t.elementType)?_chunk7UUBX6MCcjs.na[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Ot(e,t){if(_chunk7UUBX6MCcjs.ha.call(void 0, t))return t.type==="unstruct"?Kn(e,t):t.type==="disarray"?Hn(e,t):t.type==="loose-decorated"?e.resolve(Ce(t.inner)?_chunk7UUBX6MCcjs.na[t.inner.format]:t.inner):e.resolve(_chunk7UUBX6MCcjs.na[t.type]);if(jn(t))return t.type;if(t.type==="struct")return zn(e,t);if(t.type==="array")return qn(e,t);if(t.type==="atomic")return`atomic<${Ot(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 Yn=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],Qn=["&&","||","==","!=","<","<=",">",">="];function Xr(e,t,r){return r?Qn.includes(t)?_chunk7UUBX6MCcjs.L:t==="="?r:e:t==="!"||t==="~"?_chunk7UUBX6MCcjs.L:e}function v(e,t){return _chunkURJCMUTTcjs.i.call(void 0, t.value)?e.resolve(t.value):String(t.value)}function Xn(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function Zr(e,t){return{value:t?"true":"false",dataType:_chunk7UUBX6MCcjs.L}}function en(e,t){e.pushBlockScope();try{return`${e.indent()}{
10
- ${t.b.map(r=>ue(e,r)).join(`
9
+ `),r}function Jn(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Yn(e,t){let r=e.resolve(ke(t.elementType)?_chunkLB4TSIPNcjs.i[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Mt(e,t){if(_chunkLB4TSIPNcjs.c.call(void 0, t))return t.type==="unstruct"?Hn(e,t):t.type==="disarray"?Yn(e,t):t.type==="loose-decorated"?e.resolve(ke(t.inner)?_chunkLB4TSIPNcjs.i[t.inner.format]:t.inner):e.resolve(_chunkLB4TSIPNcjs.i[t.type]);if(Kn(t))return t.type;if(t.type==="struct")return qn(e,t);if(t.type==="array")return Jn(e,t);if(t.type==="atomic")return`atomic<${Mt(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");if(t.type==="void")throw new Error("Void has no representation in WGSL");Qr(t,"resolveData")}var _typedbinary = require('typed-binary');function Qn(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 w=Qn;var Zr=new WeakMap;function tt(e){let t=Zr.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let s=e.propTypes[o];if(s===void 0)throw new Error(`Property ${o} is undefined in struct`);let i=r.size;w(r,_chunkLB4TSIPNcjs.e.call(void 0, e)?_chunkLB4TSIPNcjs._.call(void 0, s):_chunkLB4TSIPNcjs.Z.call(void 0, s)),a&&(a.padding=r.size-i);let p=_chunkLB4TSIPNcjs.ba.call(void 0, s);n[o]={offset:r.size,size:p},a=n[o],r.add(p)}return a&&(a.padding=_chunkLB4TSIPNcjs.aa.call(void 0, _chunkLB4TSIPNcjs.ba.call(void 0, e),_chunkLB4TSIPNcjs.Z.call(void 0, e))-r.size),Zr.set(e,n),n}var nt=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),Nt=new WeakMap,jt={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"},zt={u32:"setUint32",i32:"setInt32",f32:"setFloat32"};function rt(e,t,r){if(_chunkVTUUXD6Hcjs.aa.call(void 0, e)||_chunkVTUUXD6Hcjs.ga.call(void 0, e))return rt(e.inner,t,r);if(_chunkVTUUXD6Hcjs._.call(void 0, e)||_chunkLB4TSIPNcjs.e.call(void 0, e)){let a=tt(e),o=Object.entries(a).sort((i,p)=>i[1].offset-p[1].offset),s="";for(let[i,p]of o){let u=e.propTypes[i];u&&(s+=rt(u,`(${t} + ${p.offset})`,`${r}.${i}`))}return s}if(_chunkVTUUXD6Hcjs.Z.call(void 0, e)||_chunkLB4TSIPNcjs.d.call(void 0, e)){let a=e,o=_chunkLB4TSIPNcjs.aa.call(void 0, _chunkLB4TSIPNcjs.ba.call(void 0, a.elementType),_chunkLB4TSIPNcjs.Z.call(void 0, a.elementType)),s="";return s+=`for (let i = 0; i < ${a.elementCount}; i++) {
10
+ `,s+=rt(a.elementType,`(${t} + i * ${o})`,`${r}[i]`),s+=`}
11
+ `,s}if(_chunkVTUUXD6Hcjs.U.call(void 0, e)){let a=jt[e.type],o="",s=zt[a],i=["x","y","z","w"],p=_chunkVTUUXD6Hcjs.S.call(void 0, e)?2:_chunkVTUUXD6Hcjs.T.call(void 0, e)?3:4;for(let u=0;u<p;u++)o+=`output.${s}((${t} + ${u*4}), ${r}.${i[u]}, littleEndian);
12
+ `;return o}if(_chunkVTUUXD6Hcjs.X.call(void 0, e)){let a=jt[e.type],o=zt[a],s=_chunkVTUUXD6Hcjs.V.call(void 0, e)?2:_chunkVTUUXD6Hcjs.W.call(void 0, e)?3:4,i=s*s,p=_chunkLB4TSIPNcjs.aa.call(void 0, s*4,8),u="";for(let d=0;d<i;d++){let m=Math.floor(d/s),T=d%s,f=m*p+T*4;u+=`output.${o}((${t} + ${f}), ${r}.columns[${m}].${["x","y","z","w"][T]}, littleEndian);
13
+ `}return u}let n=jt[e.type];return`output.${zt[n]}(${t}, ${r}, littleEndian);
14
+ `}function at(e){if(Nt.has(e))return Nt.get(e);let t=rt(e,"offset","value"),r=new Function("output","offset","value","littleEndian=true",t);return Nt.set(e,r),r}var ve={bool(){throw new Error("Booleans are not host-shareable")},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)},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},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)},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},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)},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},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=_chunkLB4TSIPNcjs.Z.call(void 0, t);w(e,n);for(let[a,o]of Object.entries(t.propTypes))w(e,_chunkLB4TSIPNcjs.Z.call(void 0, o)),Z(e,o,r[a]);w(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkLB4TSIPNcjs.Z.call(void 0, t);w(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)w(e,n),Z(e,t.elementType,r[o]);e.seekTo(a+_chunkLB4TSIPNcjs.ba.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){_optionalChain([ve, 'access', _17 => _17[t.inner.type], 'optionalCall', _18 => _18(e,t,r)])},decorated(e,t,r){let n=_chunkLB4TSIPNcjs._.call(void 0, t);w(e,n);let a=e.currentByteOffset;_optionalChain([ve, 'access', _19 => _19[_optionalChain([t, 'access', _20 => _20.inner, 'optionalAccess', _21 => _21.type])], 'optionalCall', _22 => _22(e,t.inner,r)]),e.seekTo(a+_chunkLB4TSIPNcjs.ba.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=_chunkLB4TSIPNcjs.Z.call(void 0, t);w(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)w(e,n),_optionalChain([ve, 'access', _23 => _23[_optionalChain([t, 'access', _24 => _24.elementType, 'optionalAccess', _25 => _25.type])], 'optionalCall', _26 => _26(e,t.elementType,r[o])]);e.seekTo(a+_chunkLB4TSIPNcjs.ba.call(void 0, t))},unstruct(e,t,r){for(let[n,a]of Object.entries(t.propTypes))_optionalChain([ve, 'access', _27 => _27[a.type], 'optionalCall', _28 => _28(e,a,r[n])])},"loose-decorated"(e,t,r){let n=_chunkLB4TSIPNcjs._.call(void 0, t);w(e,n);let a=e.currentByteOffset,o=ve[_optionalChain([t, 'access', _29 => _29.inner, 'optionalAccess', _30 => _30.type])];return _optionalChain([o, 'optionalCall', _31 => _31(e,t.inner,r)]),e.seekTo(a+_chunkLB4TSIPNcjs.ba.call(void 0, t)),r}};function Z(e,t,r){let n=ve[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var le={bool(){throw new Error("Booleans are not host-shareable")},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunkVTUUXD6Hcjs.r.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkVTUUXD6Hcjs.w.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkVTUUXD6Hcjs.B.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunkVTUUXD6Hcjs.s.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunkVTUUXD6Hcjs.x.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunkVTUUXD6Hcjs.C.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunkVTUUXD6Hcjs.t.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkVTUUXD6Hcjs.y.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkVTUUXD6Hcjs.D.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkVTUUXD6Hcjs.u.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkVTUUXD6Hcjs.z.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkVTUUXD6Hcjs.E.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e){return _chunkVTUUXD6Hcjs.G.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkVTUUXD6Hcjs.H.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkVTUUXD6Hcjs.I.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=_chunkLB4TSIPNcjs.Z.call(void 0, t);w(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))w(e,_chunkLB4TSIPNcjs.Z.call(void 0, o)),n[a]=O(e,o);return w(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkLB4TSIPNcjs.Z.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){w(e,r);let o=t.elementType,s=O(e,o);n.push(s)}return w(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=_chunkLB4TSIPNcjs._.call(void 0, t);w(e,r);let n=e.currentByteOffset,a=O(e,t.inner);return e.seekTo(n+_chunkLB4TSIPNcjs.ba.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunkVTUUXD6Hcjs.u.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunkVTUUXD6Hcjs.E.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunkVTUUXD6Hcjs.t.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunkVTUUXD6Hcjs.D.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunkVTUUXD6Hcjs.r.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunkVTUUXD6Hcjs.B.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunkVTUUXD6Hcjs.r.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunkVTUUXD6Hcjs.B.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=>_chunkVTUUXD6Hcjs.u.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunkVTUUXD6Hcjs.E.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunkVTUUXD6Hcjs.t.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunkVTUUXD6Hcjs.D.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunkVTUUXD6Hcjs.r.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunkVTUUXD6Hcjs.B.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunkVTUUXD6Hcjs.r.call(void 0, le.snorm16(e),le.snorm16(e)),snorm16x4:e=>_chunkVTUUXD6Hcjs.B.call(void 0, le.snorm16(e),le.snorm16(e),le.snorm16(e),le.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunkVTUUXD6Hcjs.r.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkVTUUXD6Hcjs.B.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkVTUUXD6Hcjs.r.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkVTUUXD6Hcjs.w.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkVTUUXD6Hcjs.B.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkVTUUXD6Hcjs.u.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkVTUUXD6Hcjs.z.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkVTUUXD6Hcjs.E.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkVTUUXD6Hcjs.t.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkVTUUXD6Hcjs.y.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkVTUUXD6Hcjs.D.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 _chunkVTUUXD6Hcjs.B.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 _chunkVTUUXD6Hcjs.B.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=_chunkLB4TSIPNcjs.Z.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)w(e,r),n.push(O(e,t.elementType));return w(e,r),n},"loose-decorated"(e,t){w(e,_chunkLB4TSIPNcjs._.call(void 0, t));let r=e.currentByteOffset,n=O(e,t.inner);return e.seekTo(r+_chunkLB4TSIPNcjs.ba.call(void 0, t)),n}};function O(e,t){let r=le[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function en(e,t){let r=_chunkLB4TSIPNcjs.ba.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 s(u,d,m,T){if(d!=null){if(_chunkVTUUXD6Hcjs._.call(void 0, u)||_chunkLB4TSIPNcjs.e.call(void 0, u)){let f=tt(u);for(let[g,F]of Object.entries(f)){let S=u.propTypes[g];if(!S)continue;let B=d[g];B!==void 0&&s(S,B,m+F.offset,_nullishCoalesce(F.padding, () => (T)))}return}if(_chunkVTUUXD6Hcjs.Z.call(void 0, u)||_chunkLB4TSIPNcjs.d.call(void 0, u)){let f=u,g=_chunkLB4TSIPNcjs.aa.call(void 0, _chunkLB4TSIPNcjs.ba.call(void 0, f.elementType),_chunkLB4TSIPNcjs.Z.call(void 0, f.elementType));if(!Array.isArray(d))throw new Error("Partial value for array must be an array");let F=d;F.sort((S,B)=>S.idx-B.idx);for(let{idx:S,value:B}of F)s(f.elementType,B,m+S*g,g-_chunkLB4TSIPNcjs.ba.call(void 0, f.elementType))}else{let f=_chunkLB4TSIPNcjs.ba.call(void 0, u);a.seekTo(m),Z(a,u,d),o.push({start:m,end:m+f,padding:T})}}}if(s(e,t,0),o.length===0)return[];let i=[],p=o[0];for(let u=1;u<o.length;u++){let d=o[u];if(!d||!p)throw new Error("Internal error: missing segment");d.start===p.end+(_nullishCoalesce(p.padding, () => (0)))?(p.end=d.end,p.padding=d.padding):(i.push({data:new Uint8Array(n,p.start,p.end-p.start)}),p=d)}if(!p)throw new Error("Internal error: missing segment");return i.push({data:new Uint8Array(n,p.start,p.end-p.start)}),i}function de(e){return!!_optionalChain([e, 'optionalAccess', _32 => _32.usableAsStorage])}var Oe=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 ot(e){return!!e.usableAsUniform}var an={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Ge= (_class2 =class{constructor(t,r){;_class2.prototype.__init2.call(this);this.usage=t;this.buffer=r;this[_chunkVTUUXD6Hcjs.n]={dataType:r.dataType}}__init2() {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=an[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(!_chunkVTUUXD6Hcjs.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>"))}`,[_chunkVTUUXD6Hcjs.n]:{dataType:this.buffer.dataType}},N)}}, _class2),We= (_class3 =class{constructor(t,r,n){;_class3.prototype.__init3.call(this);this.usage=t;this.dataType=r;this._membership=n;this[_chunkVTUUXD6Hcjs.n]={dataType:r}}__init3() {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=an[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(!_chunkVTUUXD6Hcjs.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>"))}`,[_chunkVTUUXD6Hcjs.n]:{dataType:this.dataType}},N)}}, _class3),tn=new WeakMap;function Kt(e){if(!de(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=tn.get(e);return t||(t=new Ge("mutable",e),tn.set(e,t)),t}var rn=new WeakMap;function qt(e){if(!de(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=rn.get(e);return t||(t=new Ge("readonly",e),rn.set(e,t)),t}var nn=new WeakMap;function Ht(e){if(!ot(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=nn.get(e);return t||(t=new Ge("uniform",e),nn.set(e,t)),t}var ra={uniform:Ht,mutable:Kt,readonly:qt};function sn(e,t,r){return _chunkVTUUXD6Hcjs.Y.call(void 0, t)?new st(e,t,r):new st(e,t,r,["storage","uniform"])}function ee(e){return e.resourceType==="buffer"}function na(e){return!!e.usableAsVertex}var on=_typedbinary.getSystemEndianness.call(void 0, ),st= (_class4 =class{constructor(t,r,n,a){;_class4.prototype.__init4.call(this);_class4.prototype.__init5.call(this);_class4.prototype.__init6.call(this);_class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this);this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;kr(n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init4() {this.resourceType="buffer"}__init5() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}__init6() {this._buffer=null}__init7() {this._destroyed=!1}__init8() {this.usableAsUniform=!1}__init9() {this.usableAsStorage=!1}__init10() {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:_chunkLB4TSIPNcjs.ba.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', _33 => _33._disallowedUsages, 'optionalAccess', _34 => _34.includes, 'call', _35 => _35(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(nt)at(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(nt){at(this.dataType)(new DataView(o),0,t,on==="little");return}Z(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunkLB4TSIPNcjs.ba.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),nt?at(this.dataType)(new DataView(this._hostBuffer),0,t,on==="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=en(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),s=new Uint8Array(o);for(let i of a)s.set(i.data,i.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=_chunkLB4TSIPNcjs.ba.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 s=t.getMappedRange();return O(new (0, _typedbinary.BufferReader)(s),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let s=t.getMappedRange(),i=O(new (0, _typedbinary.BufferReader)(s),this.dataType);return t.unmap(),i}let n=r.createBuffer({size:_chunkLB4TSIPNcjs.ba.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkLB4TSIPNcjs.ba.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkLB4TSIPNcjs.ba.call(void 0, this.dataType));let o=O(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){return _optionalChain([ra, 'access', _36 => _36[t], 'optionalCall', _37 => _37(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _38 => _38._buffer, 'optionalAccess', _39 => _39.destroy, 'call', _40 => _40()]))}toString(){return`buffer:${_nullishCoalesce(this._label, () => ("<unnamed>"))}`}}, _class4);function un(e){return new Qt(e)}function pn(e){return new Xt(e)}function Me(e){return _optionalChain([e, 'optionalAccess', _41 => _41.resourceType])==="sampler"}function Ne(e){return _optionalChain([e, 'optionalAccess', _42 => _42.resourceType])==="sampler-comparison"}var it= (_class5 =class{constructor(t){;_class5.prototype.__init11.call(this);this._membership=t}__init11() {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>"))}`}}, _class5),ut= (_class6 =class{constructor(t){;_class6.prototype.__init12.call(this);this._membership=t}__init12() {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>"))}`}}, _class6),Qt= (_class7 =class{constructor(t){;_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);this._props=t;this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}__init13() {this.resourceType="sampler"}__init14() {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>"))}`}}, _class7),Xt= (_class8 =class{constructor(t){;_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this);this._props=t}__init15() {this.resourceType="sampler-comparison"}__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:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class8);var pt= (_class9 =class{constructor(t){;_class9.prototype.__init17.call(this);this._membership=t}__init17() {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>"))}`}}, _class9);var ln={r8unorm:_chunkVTUUXD6Hcjs.P,r8snorm:_chunkVTUUXD6Hcjs.P,r8uint:_chunkVTUUXD6Hcjs.N,r8sint:_chunkVTUUXD6Hcjs.O,r16uint:_chunkVTUUXD6Hcjs.N,r16sint:_chunkVTUUXD6Hcjs.O,r16float:_chunkVTUUXD6Hcjs.P,rg8unorm:_chunkVTUUXD6Hcjs.P,rg8snorm:_chunkVTUUXD6Hcjs.P,rg8uint:_chunkVTUUXD6Hcjs.N,rg8sint:_chunkVTUUXD6Hcjs.O,r32uint:_chunkVTUUXD6Hcjs.N,r32sint:_chunkVTUUXD6Hcjs.O,r32float:_chunkVTUUXD6Hcjs.P,rg16uint:_chunkVTUUXD6Hcjs.N,rg16sint:_chunkVTUUXD6Hcjs.O,rg16float:_chunkVTUUXD6Hcjs.P,rgba8unorm:_chunkVTUUXD6Hcjs.P,"rgba8unorm-srgb":_chunkVTUUXD6Hcjs.P,rgba8snorm:_chunkVTUUXD6Hcjs.P,rgba8uint:_chunkVTUUXD6Hcjs.N,rgba8sint:_chunkVTUUXD6Hcjs.O,bgra8unorm:_chunkVTUUXD6Hcjs.P,"bgra8unorm-srgb":_chunkVTUUXD6Hcjs.P,rgb9e5ufloat:_chunkVTUUXD6Hcjs.P,rgb10a2uint:_chunkVTUUXD6Hcjs.N,rgb10a2unorm:_chunkVTUUXD6Hcjs.P,rg11b10ufloat:_chunkVTUUXD6Hcjs.P,rg32uint:_chunkVTUUXD6Hcjs.N,rg32sint:_chunkVTUUXD6Hcjs.O,rg32float:_chunkVTUUXD6Hcjs.P,rgba16uint:_chunkVTUUXD6Hcjs.N,rgba16sint:_chunkVTUUXD6Hcjs.O,rgba16float:_chunkVTUUXD6Hcjs.P,rgba32uint:_chunkVTUUXD6Hcjs.N,rgba32sint:_chunkVTUUXD6Hcjs.O,rgba32float:_chunkVTUUXD6Hcjs.P,stencil8:_chunkVTUUXD6Hcjs.P,depth16unorm:_chunkVTUUXD6Hcjs.P,depth24plus:_chunkVTUUXD6Hcjs.P,"depth24plus-stencil8":_chunkVTUUXD6Hcjs.P,depth32float:_chunkVTUUXD6Hcjs.P,"depth32float-stencil8":_chunkVTUUXD6Hcjs.P,"bc1-rgba-unorm":_chunkVTUUXD6Hcjs.P,"bc1-rgba-unorm-srgb":_chunkVTUUXD6Hcjs.P,"bc2-rgba-unorm":_chunkVTUUXD6Hcjs.P,"bc2-rgba-unorm-srgb":_chunkVTUUXD6Hcjs.P,"bc3-rgba-unorm":_chunkVTUUXD6Hcjs.P,"bc3-rgba-unorm-srgb":_chunkVTUUXD6Hcjs.P,"bc4-r-unorm":_chunkVTUUXD6Hcjs.P,"bc4-r-snorm":_chunkVTUUXD6Hcjs.P,"bc5-rg-unorm":_chunkVTUUXD6Hcjs.P,"bc5-rg-snorm":_chunkVTUUXD6Hcjs.P,"bc6h-rgb-ufloat":_chunkVTUUXD6Hcjs.P,"bc6h-rgb-float":_chunkVTUUXD6Hcjs.P,"bc7-rgba-unorm":_chunkVTUUXD6Hcjs.P,"bc7-rgba-unorm-srgb":_chunkVTUUXD6Hcjs.P,"etc2-rgb8unorm":_chunkVTUUXD6Hcjs.P,"etc2-rgb8unorm-srgb":_chunkVTUUXD6Hcjs.P,"etc2-rgb8a1unorm":_chunkVTUUXD6Hcjs.P,"etc2-rgb8a1unorm-srgb":_chunkVTUUXD6Hcjs.P,"etc2-rgba8unorm":_chunkVTUUXD6Hcjs.P,"etc2-rgba8unorm-srgb":_chunkVTUUXD6Hcjs.P,"eac-r11unorm":_chunkVTUUXD6Hcjs.P,"eac-r11snorm":_chunkVTUUXD6Hcjs.P,"eac-rg11unorm":_chunkVTUUXD6Hcjs.P,"eac-rg11snorm":_chunkVTUUXD6Hcjs.P,"astc-4x4-unorm":_chunkVTUUXD6Hcjs.P,"astc-4x4-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-5x4-unorm":_chunkVTUUXD6Hcjs.P,"astc-5x4-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-5x5-unorm":_chunkVTUUXD6Hcjs.P,"astc-5x5-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-6x5-unorm":_chunkVTUUXD6Hcjs.P,"astc-6x5-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-6x6-unorm":_chunkVTUUXD6Hcjs.P,"astc-6x6-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-8x5-unorm":_chunkVTUUXD6Hcjs.P,"astc-8x5-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-8x6-unorm":_chunkVTUUXD6Hcjs.P,"astc-8x6-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-8x8-unorm":_chunkVTUUXD6Hcjs.P,"astc-8x8-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-10x5-unorm":_chunkVTUUXD6Hcjs.P,"astc-10x5-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-10x6-unorm":_chunkVTUUXD6Hcjs.P,"astc-10x6-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-10x8-unorm":_chunkVTUUXD6Hcjs.P,"astc-10x8-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-10x10-unorm":_chunkVTUUXD6Hcjs.P,"astc-10x10-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-12x10-unorm":_chunkVTUUXD6Hcjs.P,"astc-12x10-unorm-srgb":_chunkVTUUXD6Hcjs.P,"astc-12x12-unorm":_chunkVTUUXD6Hcjs.P,"astc-12x12-unorm-srgb":_chunkVTUUXD6Hcjs.P},je={rgba8unorm:_chunkVTUUXD6Hcjs.B,rgba8snorm:_chunkVTUUXD6Hcjs.B,rgba8uint:_chunkVTUUXD6Hcjs.E,rgba8sint:_chunkVTUUXD6Hcjs.D,rgba16uint:_chunkVTUUXD6Hcjs.E,rgba16sint:_chunkVTUUXD6Hcjs.D,rgba16float:_chunkVTUUXD6Hcjs.B,r32uint:_chunkVTUUXD6Hcjs.E,r32sint:_chunkVTUUXD6Hcjs.D,r32float:_chunkVTUUXD6Hcjs.B,rg32uint:_chunkVTUUXD6Hcjs.E,rg32sint:_chunkVTUUXD6Hcjs.D,rg32float:_chunkVTUUXD6Hcjs.B,rgba32uint:_chunkVTUUXD6Hcjs.E,rgba32sint:_chunkVTUUXD6Hcjs.D,rgba32float:_chunkVTUUXD6Hcjs.B,bgra8unorm:_chunkVTUUXD6Hcjs.B},dn={f32:"float",u32:"uint",i32:"sint"},mn={float:_chunkVTUUXD6Hcjs.P,"unfilterable-float":_chunkVTUUXD6Hcjs.P,uint:_chunkVTUUXD6Hcjs.N,sint:_chunkVTUUXD6Hcjs.O,depth:_chunkVTUUXD6Hcjs.P};function gn(e,t){return new Zt(e,t)}function H(e){return _optionalChain([e, 'optionalAccess', _43 => _43.resourceType])==="texture"}function ze(e){return _optionalChain([e, 'optionalAccess', _44 => _44.resourceType])==="texture-storage-view"}function Ke(e){return _optionalChain([e, 'optionalAccess', _45 => _45.resourceType])==="texture-sampled-view"}var fn={mutable:"read_write",readonly:"read",writeonly:"write"},Zt= (_class10 =class{constructor(t,r){;_class10.prototype.__init18.call(this);_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this);_class10.prototype.__init21.call(this);_class10.prototype.__init22.call(this);_class10.prototype.__init23.call(this);_class10.prototype.__init24.call(this);this.props=t;this._branch=r}__init18() {this.resourceType="texture"}__init19() {this.usableAsSampled=!1}__init20() {this.usableAsStorage=!1}__init21() {this.usableAsRender=!1}__init22() {this._destroyed=!1}__init23() {this._flags=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}__init24() {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', _46 => _46.format]), () => (this.props.format)),a=je[n];return _chunkVTUUXD6Hcjs.a.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new er(_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', _47 => _47.format]), () => (this.props.format));if(!je[r])throw new Error(`Unsupported storage texture format: ${r}`);return new tr(t,this)}destroy(){this._destroyed||(this._destroyed=!0,_optionalChain([this, 'access', _48 => _48._texture, 'optionalAccess', _49 => _49.destroy, 'call', _50 => _50()]))}}, _class10),mt={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},er= (_class11 =class{constructor(t,r,n){;_class11.prototype.__init25.call(this);this.access=r;this._texture=n;this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _51 => _51.dimension]), () => (n.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _52 => _52.format]), () => (n.props.format)),this.texelDataType=je[this._format]}__init25() {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_${mt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${fn[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class11),lt= (_class12 =class{constructor(t,r,n,a){;_class12.prototype.__init26.call(this);this._format=t;this.dimension=r;this.access=n;this._membership=a;this.texelDataType=je[this._format]}__init26() {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_${mt[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${fn[this.access]}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class12),tr= (_class13 =class{constructor(t,r){;_class13.prototype.__init27.call(this);this._props=t;this._texture=r;this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _53 => _53.dimension]), () => (r.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _54 => _54.format]), () => (r.props.format)),this.channelDataType=ln[this._format]}__init27() {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:dn[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),s=n?"texture_multisampled_2d":`texture_${mt[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${s}<${t.resolve(this.channelDataType)}>;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class13),dt= (_class14 =class{constructor(t,r,n,a){;_class14.prototype.__init28.call(this);this.dimension=r;this._multisampled=n;this._membership=a;this.channelDataType=mn[t]}__init28() {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_${mt[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>"))}`}}, _class14);function rr(e){return!!_optionalChain([e, 'optionalAccess', _55 => _55.usableAsSampled])}function aa(e){return!!_optionalChain([e, 'optionalAccess', _56 => _56.usableAsRender])}var gt=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 ft(e){return new ar(e)}function Tt(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 '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},Tn=["compute"],De=["compute","vertex","fragment"],ar= (_class15 =class{constructor(t){;_class15.prototype.__init29.call(this);_class15.prototype.__init30.call(this);_class15.prototype.__init31.call(this);_class15.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 We("uniform",a.uniform,o)),"storage"in a){let s="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new We(_nullishCoalesce(a.access, () => ("readonly")),s,o)}"texture"in a&&(this.bound[n]=new dt(a.texture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.multisampled, () => (!1)),o)),"storageTexture"in a&&(this.bound[n]=new lt(a.storageTexture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.access, () => ("writeonly")),o)),"externalTexture"in a&&(this.bound[n]=new pt(o)),"sampler"in a&&(a.sampler==="comparison"?this.bound[n]=new ut(o):this.bound[n]=new it(o)),"texture"in a||"storageTexture"in a||"externalTexture"in a||"sampler"in a?this.value[n]=this.bound[n]:Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init29() {this.resourceType="bind-group-layout"}__init30() {this.bound={}}__init31() {this.value={}}__init32() {this.$= exports.isSlot =this.value}toString(){return`bindGroupLayout:${_nullishCoalesce(this._label, () => ("<unnamed>"))}`}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,s={binding:a,visibility:0};if("uniform"in n)o=_nullishCoalesce(o, () => (De)),s.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?Tn:De))),s.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (De)),s.sampler={type:n.sampler};else if("texture"in n)o=_nullishCoalesce(o, () => (De)),s.texture={sampleType:n.texture,viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d")),multisampled:_nullishCoalesce(n.multisampled, () => (!1))};else if("storageTexture"in n){let i=_nullishCoalesce(n.access, () => ("writeonly"));o=_nullishCoalesce(o, () => ((i==="readonly"?De:Tn))),s.storageTexture={format:n.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[i],viewDimension:_nullishCoalesce(n.viewDimension, () => ("2d"))}}else"externalTexture"in n&&(o=_nullishCoalesce(o, () => (De)),s.externalTexture={});return _optionalChain([o, 'optionalAccess', _57 => _57.includes, 'call', _58 => _58("compute")])&&(s.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _59 => _59.includes, 'call', _60 => _60("vertex")])&&(s.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _61 => _61.includes, 'call', _62 => _62("fragment")])&&(s.visibility|=GPUShaderStage.FRAGMENT),s}).filter(n=>n!==null)})}}, _class15),Fe= (_class16 =class{constructor(t,r){;_class16.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 nr(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 s=this.entries[n];if(s===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 i;if(ee(s)){if(!ot(s))throw new (0, _chunkVTUUXD6Hcjs.d)(s);i={buffer:t.unwrap(s)}}else i={buffer:s};return{binding:o,resource:i}}if("storage"in a){let i;if(ee(s)){if(!de(s))throw new Oe(s);i={buffer:t.unwrap(s)}}else i={buffer:s};return{binding:o,resource:i}}if("texture"in a){let i;if(H(s)){if(!rr(s))throw new gt(s);i=t.unwrap(s.createView("sampled"))}else Ke(s)?i=t.unwrap(s):i=s;return{binding:o,resource:i}}if("storageTexture"in a){let i;if(H(s)){if(!de(s))throw new Oe(s);a.access==="readonly"?i=t.unwrap(s.createView("readonly")):a.access==="mutable"?i=t.unwrap(s.createView("mutable")):i=t.unwrap(s.createView("writeonly"))}else ze(s)?i=t.unwrap(s):i=s;return{binding:o,resource:i}}if("sampler"in a)return Me(s)||Ne(s)?{binding:o,resource:t.unwrap(s)}:{binding:o,resource:s};if("externalTexture"in a)return{binding:o,resource:s};throw new Error(`Malformed bind group entry: ${s} (${JSON.stringify(s)})`)}).filter(n=>n!==null)})}}, _class16);var _tinyest = require('tinyest'); var oa = _interopRequireWildcard(_tinyest);var{NodeTypeCatalog:x}=oa,sa=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],ia=["&&","||","==","!=","<","<=",">",">="];function yn(e,t,r){return r?ia.includes(t)?_chunkVTUUXD6Hcjs.M:t==="="?r:e:t==="!"||t==="~"?_chunkVTUUXD6Hcjs.M:e}function D(e,t){return K(t.value)?e.resolve(t.value):String(t.value)}function ua(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function cn(e,t){return{value:t?"true":"false",dataType:_chunkVTUUXD6Hcjs.M}}function xn(e,[t,r]){e.pushBlockScope();try{return`${e.indent()}{
15
+ ${r.map(n=>me(e,n)).join(`
11
16
  `)}
12
- ${e.dedent()}}`}finally{e.popBlockScope()}}function Zn(e,t,r){return e.defineVariable(t,r)}function $t(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function U(e,t){if(typeof t=="string")return $t(e,t);if(typeof t=="boolean")return Zr(e,t);if("x"in t){let[r,n,a]=t.x,o=U(e,r),i=U(e,a),s=v(e,o),p=v(e,i),u=Xr(o.dataType,n,i.dataType);return{value:Yn.includes(n)?`(${s} ${n} ${p})`:`${s} ${n} ${p}`,dataType:u}}if("p"in t){let[r,n]=t.p,a=U(e,n);return{value:`${v(e,a)}${r}`,dataType:a.dataType}}if("u"in t){let[r,n]=t.u,a=U(e,n),o=v(e,a),i=Xr(a.dataType,r);return{value:`${r}${o}`,dataType:i}}if("a"in t){let[r,n]=t.a,a=U(e,r);if(typeof a.value=="string")return{value:`${a.value}.${n}`,dataType:Pe(a.dataType,n)};if(_chunk7UUBX6MCcjs.X.call(void 0, a.dataType)&&n==="length")return a.dataType.elementCount===0?{value:`arrayLength(&${e.resolve(a.value)})`,dataType:_chunk7UUBX6MCcjs.M}:{value:String(a.dataType.elementCount),dataType:_chunk7UUBX6MCcjs.J};let o=a.value[n];if(_chunkURJCMUTTcjs.i.call(void 0, a.value))return{value:o,dataType:Pe(a.value,n)};if(typeof a.value=="object"){let i=_chunkURJCMUTTcjs.i.call(void 0, o)?xe(o):_chunkURJCMUTTcjs.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=U(e,r),o=U(e,n),i=v(e,a),s=v(e,o);return{value:`${i}[${s}]`,dataType:Mr(a.dataType)}}if("n"in t){let r=Lt(t.n);if(!r)throw new Error(`Invalid numeric literal ${t.n}`);return r}if("f"in t){let[r,n]=t.f,a=U(e,r),o=a.value;e.callStack.push(o);let s=n.map(u=>U(e,u)).map(u=>({value:v(e,u),dataType:u.dataType})),p=s.map(u=>u.value);return e.callStack.pop(),typeof o=="string"?{value:`${o}(${p.join(", ")})`,dataType:a.dataType}:_chunk7UUBX6MCcjs.Y.call(void 0, o)?{value:`${e.resolve(o)}(${p.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=U(e,i);return v(e,s)}).join(", ");if(_chunk7UUBX6MCcjs.Y.call(void 0, n)){let i=Object.keys(n.propTypes).map(s=>{let p=r[s];if(p===void 0)throw new Error(`Missing property ${s} in object literal for struct ${n}`);return p});return{value:a(i),dataType:n}}return{value:a(Object.values(r)),dataType:_chunkURJCMUTTcjs.f}}if("y"in t){let r=t.y.map(p=>U(e,p));if(r.length===0)throw new Error("Cannot create empty array literal.");let n=_optionalChain([r, 'access', _8 => _8[0], 'optionalAccess', _9 => _9.dataType]),a=r.find(p=>p.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', _10 => _10.type])}.`);if(!_chunk7UUBX6MCcjs.W.call(void 0, n))throw new Error("Cannot use non-WGSL data types in array literals.");n=n.type==="abstractInt"?_chunk7UUBX6MCcjs.M:n.type==="abstractFloat"?_chunk7UUBX6MCcjs.O:n;let i=`array<${e.resolve(n)}, ${r.length}>`,s=r.map(p=>v(e,p));return{value:`${i}( ${s.join(", ")} )`,dataType:_chunk7UUBX6MCcjs.qb.call(void 0, n,r.length)}}if("s"in t)throw new Error("Cannot use string literals in TGSL.");Xn(t)}function ue(e,t){if(typeof t=="string")return`${e.pre}${v(e,$t(e,t))};`;if(typeof t=="boolean")return`${e.pre}${v(e,Zr(e,t))};`;if("r"in t){if(_chunk7UUBX6MCcjs.Y.call(void 0, e.callStack[e.callStack.length-1])&&t.r!==null&&typeof t.r=="object"&&"o"in t.r){let r=v(e,U(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,U(e,t.r))};`}if("q"in t){let[r,n,a]=t.q,o=v(e,U(e,r));e.indent();let i=ue(e,n);e.dedent(),e.indent();let s=a?ue(e,a):void 0;return e.dedent(),s?`${e.pre}if (${o})
17
+ ${e.dedent()}}`}finally{e.popBlockScope()}}function pa(e,t,r){return e.defineVariable(t,r)}function sr(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function I(e,t){if(typeof t=="string")return sr(e,t);if(typeof t=="boolean")return cn(e,t);if(t[0]===x.logicalExpr||t[0]===x.binaryExpr||t[0]===x.assignmentExpr){let[r,n,a,o]=t,s=I(e,n),i=I(e,o),p=D(e,s),u=D(e,i),d=yn(s.dataType,a,i.dataType);return{value:sa.includes(a)?`(${p} ${a} ${u})`:`${p} ${a} ${u}`,dataType:d}}if(t[0]===x.postUpdate){let[r,n,a]=t,o=I(e,a);return{value:`${D(e,o)}${n}`,dataType:o.dataType}}if(t[0]===x.unaryExpr){let[r,n,a]=t,o=I(e,a),s=D(e,o),i=yn(o.dataType,n);return{value:`${n}${s}`,dataType:i}}if(t[0]===x.memberAccess){let[r,n,a]=t,o=I(e,n);if(typeof o.value=="string")return{value:`${o.value}.${a}`,dataType:_chunkLB4TSIPNcjs.h.call(void 0, o.dataType)?he(o.dataType,a):U};if(_chunkVTUUXD6Hcjs.Z.call(void 0, o.dataType)&&a==="length")return o.dataType.elementCount===0?{value:`arrayLength(&${e.resolve(o.value)})`,dataType:_chunkVTUUXD6Hcjs.N}:{value:String(o.dataType.elementCount),dataType:_chunkVTUUXD6Hcjs.K};let s=o.value[a];if(o.dataType.type!=="unknown")return _chunkVTUUXD6Hcjs.X.call(void 0, o.dataType)&&a==="columns"?{value:o.value,dataType:o.dataType}:{value:s,dataType:he(o.dataType,a)};if(K(o.value))return{value:s,dataType:he(o.value,a)};if(typeof o.value=="object"){let i=K(s)?we(s):U;return{value:s,dataType:i}}throw new Error(`Cannot access member ${a} of ${o.value}`)}if(t[0]===x.indexAccess){let[r,n,a]=t,o=I(e,n),s=I(e,a),i=D(e,o),p=D(e,s);return{value:`${i}[${p}]`,dataType:_chunkLB4TSIPNcjs.h.call(void 0, o.dataType)?Nr(o.dataType):U}}if(t[0]===x.numericLiteral){let r=kt(t[1]);if(!r)throw new Error(`Invalid numeric literal ${t[1]}`);return r}if(t[0]===x.call){let[r,n,a]=t,o=I(e,n),s=o.value;e.callStack.push(s);let p=a.map(m=>I(e,m)).map(m=>({value:D(e,m),dataType:m.dataType})),u=p.map(m=>m.value);if(e.callStack.pop(),typeof s=="string")return{value:`${s}(${u.join(", ")})`,dataType:o.dataType};if(_chunkVTUUXD6Hcjs._.call(void 0, s))return{value:`${e.resolve(s)}(${u.join(", ")})`,dataType:o.dataType};if(!Gr(s))throw new Error(`Function ${String(s)} has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`);let d=s(...p);return{value:D(e,d),dataType:d.dataType}}if(t[0]===x.objectExpr){let r=t[1],n=e.callStack[e.callStack.length-1],a=o=>o.map(s=>{let i=I(e,s);return D(e,i)}).join(", ");if(_chunkVTUUXD6Hcjs._.call(void 0, n)){let s=Object.keys(n.propTypes).map(i=>{let p=r[i];if(p===void 0)throw new Error(`Missing property ${i} in object literal for struct ${n}`);return p});return{value:a(s),dataType:n}}return{value:a(Object.values(r)),dataType:U}}if(t[0]===x.arrayExpr){let[r,n]=t,a=n.map(d=>I(e,d));if(a.length===0)throw new Error("Cannot create empty array literal.");let o=_optionalChain([a, 'access', _63 => _63[0], 'optionalAccess', _64 => _64.dataType]),s=a.find(d=>d.dataType!==o);if(s)throw new Error(`Cannot mix types in array literal. Type ${s.dataType.type} does not match expected type ${_optionalChain([o, 'optionalAccess', _65 => _65.type])}.`);if(!_chunkVTUUXD6Hcjs.Y.call(void 0, o))throw new Error("Cannot use non-WGSL data types in array literals.");o=o.type==="abstractInt"?_chunkVTUUXD6Hcjs.N:o.type==="abstractFloat"?_chunkVTUUXD6Hcjs.P:o;let p=`array<${e.resolve(o)}, ${a.length}>`,u=a.map(d=>D(e,d));return{value:`${p}( ${u.join(", ")} )`,dataType:_chunkLB4TSIPNcjs.ka.call(void 0, o,a.length)}}if(t[0]===x.stringLiteral)throw new Error("Cannot use string literals in TGSL.");if(t[0]===x.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");ua(t)}function me(e,t){if(typeof t=="string")return`${e.pre}${D(e,sr(e,t))};`;if(typeof t=="boolean")return`${e.pre}${D(e,cn(e,t))};`;if(t[0]===x.return){let r=t[1],n=r!==void 0?D(e,I(e,r)):void 0;if(_chunkVTUUXD6Hcjs._.call(void 0, e.callStack[e.callStack.length-1])&&typeof r=="object"&&r[0]===x.objectExpr){let a=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}return ${a}(${n});`}return n?`${e.pre}return ${n};`:`${e.pre}return;`}if(t[0]===x.if){let[r,n,a,o]=t,s=D(e,I(e,n));e.indent();let i=me(e,a);e.dedent(),e.indent();let p=o?me(e,o):void 0;return e.dedent(),p?`${e.pre}if (${s})
13
18
  ${i}
14
19
  ${e.pre}else
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?U(e,n):void 0;if(!a||!n)throw new Error("Cannot create variable without an initial value.");Zn(e,r,a.dataType);let o=v(e,$t(e,r));if(typeof n=="object"&&"o"in n&&_chunk7UUBX6MCcjs.Y.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 en(e,t)}finally{e.popBlockScope()}}if("j"in t){let[r,n,a,o]=t.j,i=r?ue(e,r):void 0,s=i?i.slice(0,-1):"",p=n?U(e,n):void 0,u=p?v(e,p):"",d=a?ue(e,a):void 0,m=d?d.slice(0,-1):"";e.indent();let T=ue(e,o);return e.dedent(),`${e.pre}for (${s}; ${u}; ${m})
17
- ${T}`}if("w"in t){let[r,n]=t.w,a=v(e,U(e,r));e.indent();let o=ue(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,U(e,t))};`}function Gt(e,t){return en(e,t)}var _typedbinary = require('typed-binary');function ea(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 b=ea;var tn=new WeakMap;function Qe(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;b(r,_chunk7UUBX6MCcjs.ja.call(void 0, e)?_chunk7UUBX6MCcjs.db.call(void 0, i):_chunk7UUBX6MCcjs.cb.call(void 0, i)),a&&(a.padding=r.size-s);let p=_chunk7UUBX6MCcjs.gb.call(void 0, i);n[o]={offset:r.size,size:p},a=n[o],r.add(p)}return a&&(a.padding=_chunk7UUBX6MCcjs.fb.call(void 0, _chunk7UUBX6MCcjs.gb.call(void 0, e),_chunk7UUBX6MCcjs.cb.call(void 0, e))-r.size),tn.set(e,n),n}var Ze=(()=>{try{return new Function("return true"),!0}catch (e2){return!1}})(),kt=new WeakMap,Wt={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"},Mt={u32:"setUint32",i32:"setInt32",f32:"setFloat32"};function Xe(e,t,r){if(_chunk7UUBX6MCcjs._.call(void 0, e)||_chunk7UUBX6MCcjs.ea.call(void 0, e))return Xe(e.inner,t,r);if(_chunk7UUBX6MCcjs.Y.call(void 0, e)||_chunk7UUBX6MCcjs.ja.call(void 0, e)){let a=Qe(e),o=Object.entries(a).sort((s,p)=>s[1].offset-p[1].offset),i="";for(let[s,p]of o){let u=e.propTypes[s];u&&(i+=Xe(u,`(${t} + ${p.offset})`,`${r}.${s}`))}return i}if(_chunk7UUBX6MCcjs.X.call(void 0, e)||_chunk7UUBX6MCcjs.ia.call(void 0, e)){let a=e,o=_chunk7UUBX6MCcjs.fb.call(void 0, _chunk7UUBX6MCcjs.gb.call(void 0, a.elementType),_chunk7UUBX6MCcjs.cb.call(void 0, a.elementType)),i="";return i+=`for (let i = 0; i < ${a.elementCount}; i++) {
19
- `,i+=Xe(a.elementType,`(${t} + i * ${o})`,`${r}[i]`),i+=`}
20
- `,i}if(_chunk7UUBX6MCcjs.S.call(void 0, e)){let a=Wt[e.type],o="",i=Mt[a],s=["x","y","z","w"],p=_chunk7UUBX6MCcjs.Q.call(void 0, e)?2:_chunk7UUBX6MCcjs.R.call(void 0, e)?3:4;for(let u=0;u<p;u++)o+=`output.${i}((${t} + ${u*4}), ${r}.${s[u]}, littleEndian);
21
- `;return o}if(_chunk7UUBX6MCcjs.V.call(void 0, e)){let a=Wt[e.type],o=Mt[a],i=_chunk7UUBX6MCcjs.T.call(void 0, e)?2:_chunk7UUBX6MCcjs.U.call(void 0, e)?3:4,s=i*i,p=_chunk7UUBX6MCcjs.fb.call(void 0, i*4,8),u="";for(let d=0;d<s;d++){let m=Math.floor(d/i),T=d%i,f=m*p+T*4;u+=`output.${o}((${t} + ${f}), ${r}.columns[${m}].${["x","y","z","w"][T]}, littleEndian);
22
- `}return u}let n=Wt[e.type];return`output.${Mt[n]}(${t}, ${r}, littleEndian);
23
- `}function et(e){if(kt.has(e))return kt.get(e);let t=Xe(e,"offset","value"),r=new Function("output","offset","value","littleEndian=true",t);return kt.set(e,r),r}var be={bool(){throw new Error("Booleans are not host-shareable")},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)},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},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)},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},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)},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},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=_chunk7UUBX6MCcjs.cb.call(void 0, t);b(e,n);for(let[a,o]of Object.entries(t.propTypes))b(e,_chunk7UUBX6MCcjs.cb.call(void 0, o)),X(e,o,r[a]);b(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunk7UUBX6MCcjs.cb.call(void 0, t);b(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)b(e,n),X(e,t.elementType,r[o]);e.seekTo(a+_chunk7UUBX6MCcjs.gb.call(void 0, t))},ptr(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){_optionalChain([be, 'access', _11 => _11[t.inner.type], 'optionalCall', _12 => _12(e,t,r)])},decorated(e,t,r){let n=_chunk7UUBX6MCcjs.db.call(void 0, t);b(e,n);let a=e.currentByteOffset;_optionalChain([be, 'access', _13 => _13[_optionalChain([t, 'access', _14 => _14.inner, 'optionalAccess', _15 => _15.type])], 'optionalCall', _16 => _16(e,t.inner,r)]),e.seekTo(a+_chunk7UUBX6MCcjs.gb.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=_chunk7UUBX6MCcjs.cb.call(void 0, t);b(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)b(e,n),_optionalChain([be, 'access', _17 => _17[_optionalChain([t, 'access', _18 => _18.elementType, 'optionalAccess', _19 => _19.type])], 'optionalCall', _20 => _20(e,t.elementType,r[o])]);e.seekTo(a+_chunk7UUBX6MCcjs.gb.call(void 0, t))},unstruct(e,t,r){for(let[n,a]of Object.entries(t.propTypes))_optionalChain([be, 'access', _21 => _21[a.type], 'optionalCall', _22 => _22(e,a,r[n])])},"loose-decorated"(e,t,r){let n=_chunk7UUBX6MCcjs.db.call(void 0, t);b(e,n);let a=e.currentByteOffset,o=be[_optionalChain([t, 'access', _23 => _23.inner, 'optionalAccess', _24 => _24.type])];return _optionalChain([o, 'optionalCall', _25 => _25(e,t.inner,r)]),e.seekTo(a+_chunk7UUBX6MCcjs.gb.call(void 0, t)),r}};function X(e,t,r){let n=be[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var pe={bool(){throw new Error("Booleans are not host-shareable")},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunk7UUBX6MCcjs.q.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunk7UUBX6MCcjs.v.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunk7UUBX6MCcjs.A.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunk7UUBX6MCcjs.r.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunk7UUBX6MCcjs.w.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunk7UUBX6MCcjs.B.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunk7UUBX6MCcjs.s.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunk7UUBX6MCcjs.x.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunk7UUBX6MCcjs.C.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunk7UUBX6MCcjs.t.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunk7UUBX6MCcjs.y.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunk7UUBX6MCcjs.D.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},"vec2<bool>"(){throw new Error("Booleans are not host-shareable")},"vec3<bool>"(){throw new Error("Booleans are not host-shareable")},"vec4<bool>"(){throw new Error("Booleans are not host-shareable")},mat2x2f(e){return _chunk7UUBX6MCcjs.F.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunk7UUBX6MCcjs.G.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunk7UUBX6MCcjs.H.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=_chunk7UUBX6MCcjs.cb.call(void 0, t);b(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))b(e,_chunk7UUBX6MCcjs.cb.call(void 0, o)),n[a]=C(e,o);return b(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunk7UUBX6MCcjs.cb.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){b(e,r);let o=t.elementType,i=C(e,o);n.push(i)}return b(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=_chunk7UUBX6MCcjs.db.call(void 0, t);b(e,r);let n=e.currentByteOffset,a=C(e,t.inner);return e.seekTo(n+_chunk7UUBX6MCcjs.gb.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunk7UUBX6MCcjs.t.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunk7UUBX6MCcjs.D.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunk7UUBX6MCcjs.s.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunk7UUBX6MCcjs.C.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunk7UUBX6MCcjs.q.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunk7UUBX6MCcjs.A.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunk7UUBX6MCcjs.q.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunk7UUBX6MCcjs.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=>_chunk7UUBX6MCcjs.t.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunk7UUBX6MCcjs.D.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunk7UUBX6MCcjs.s.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunk7UUBX6MCcjs.C.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunk7UUBX6MCcjs.q.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunk7UUBX6MCcjs.A.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunk7UUBX6MCcjs.q.call(void 0, pe.snorm16(e),pe.snorm16(e)),snorm16x4:e=>_chunk7UUBX6MCcjs.A.call(void 0, pe.snorm16(e),pe.snorm16(e),pe.snorm16(e),pe.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunk7UUBX6MCcjs.q.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunk7UUBX6MCcjs.A.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunk7UUBX6MCcjs.q.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunk7UUBX6MCcjs.v.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunk7UUBX6MCcjs.A.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunk7UUBX6MCcjs.t.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunk7UUBX6MCcjs.y.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunk7UUBX6MCcjs.D.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunk7UUBX6MCcjs.s.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunk7UUBX6MCcjs.x.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunk7UUBX6MCcjs.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 _chunk7UUBX6MCcjs.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 _chunk7UUBX6MCcjs.A.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=_chunk7UUBX6MCcjs.cb.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)b(e,r),n.push(C(e,t.elementType));return b(e,r),n},"loose-decorated"(e,t){b(e,_chunk7UUBX6MCcjs.db.call(void 0, t));let r=e.currentByteOffset,n=C(e,t.inner);return e.seekTo(r+_chunk7UUBX6MCcjs.gb.call(void 0, t)),n}};function C(e,t){let r=pe[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function rn(e,t){let r=_chunk7UUBX6MCcjs.gb.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,T){if(d!=null){if(_chunk7UUBX6MCcjs.Y.call(void 0, u)||_chunk7UUBX6MCcjs.ja.call(void 0, u)){let f=Qe(u);for(let[g,F]of Object.entries(f)){let w=u.propTypes[g];if(!w)continue;let A=d[g];A!==void 0&&i(w,A,m+F.offset,_nullishCoalesce(F.padding, () => (T)))}return}if(_chunk7UUBX6MCcjs.X.call(void 0, u)||_chunk7UUBX6MCcjs.ia.call(void 0, u)){let f=u,g=_chunk7UUBX6MCcjs.fb.call(void 0, _chunk7UUBX6MCcjs.gb.call(void 0, f.elementType),_chunk7UUBX6MCcjs.cb.call(void 0, f.elementType));if(!Array.isArray(d))throw new Error("Partial value for array must be an array");let F=d;F.sort((w,A)=>w.idx-A.idx);for(let{idx:w,value:A}of F)i(f.elementType,A,m+w*g,g-_chunk7UUBX6MCcjs.gb.call(void 0, f.elementType))}else{let f=_chunk7UUBX6MCcjs.gb.call(void 0, u);a.seekTo(m),X(a,u,d),o.push({start:m,end:m+f,padding:T})}}}if(i(e,t,0),o.length===0)return[];let s=[],p=o[0];for(let u=1;u<o.length;u++){let d=o[u];if(!d||!p)throw new Error("Internal error: missing segment");d.start===p.end+(_nullishCoalesce(p.padding, () => (0)))?(p.end=d.end,p.padding=d.padding):(s.push({data:new Uint8Array(n,p.start,p.end-p.start)}),p=d)}if(!p)throw new Error("Internal error: missing segment");return s.push({data:new Uint8Array(n,p.start,p.end-p.start)}),s}function le(e){return!!_optionalChain([e, 'optionalAccess', _26 => _26.usableAsStorage])}var Ee=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 tt(e){return!!e.usableAsUniform}var sn={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},Ve= (_class2 =class{constructor(t,r){;_class2.prototype.__init2.call(this);this.usage=t;this.buffer=r;this[_chunkURJCMUTTcjs.a]={dataType:r.dataType}}__init2() {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(!_chunk7UUBX6MCcjs.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>"))}`,[_chunkURJCMUTTcjs.a]:{dataType:this.buffer.dataType}},k)}}, _class2),Oe= (_class3 =class{constructor(t,r,n){;_class3.prototype.__init3.call(this);this.usage=t;this.dataType=r;this._membership=n;this[_chunkURJCMUTTcjs.a]={dataType:r}}__init3() {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(!_chunk7UUBX6MCcjs.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>"))}`,[_chunkURJCMUTTcjs.a]:{dataType:this.dataType}},k)}}, _class3),nn=new WeakMap;function Nt(e){if(!le(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 Ve("mutable",e),nn.set(e,t)),t}var an=new WeakMap;function jt(e){if(!le(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 Ve("readonly",e),an.set(e,t)),t}var on=new WeakMap;function zt(e){if(!tt(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 Ve("uniform",e),on.set(e,t)),t}var aa={uniform:zt,mutable:Nt,readonly:jt};function pn(e,t,r){return _chunk7UUBX6MCcjs.W.call(void 0, t)?new rt(e,t,r):new rt(e,t,r,["storage","uniform"])}function Z(e){return e.resourceType==="buffer"}function oa(e){return!!e.usableAsVertex}var un=_typedbinary.getSystemEndianness.call(void 0, ),rt= (_class4 =class{constructor(t,r,n,a){;_class4.prototype.__init4.call(this);_class4.prototype.__init5.call(this);_class4.prototype.__init6.call(this);_class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this);this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;_chunkURJCMUTTcjs.j.call(void 0, n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}__init4() {this.resourceType="buffer"}__init5() {this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}__init6() {this._buffer=null}__init7() {this._destroyed=!1}__init8() {this.usableAsUniform=!1}__init9() {this.usableAsStorage=!1}__init10() {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:_chunk7UUBX6MCcjs.gb.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());X(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', _27 => _27._disallowedUsages, 'optionalAccess', _28 => _28.includes, 'call', _29 => _29(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(Ze)et(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(Ze){et(this.dataType)(new DataView(o),0,t,un==="little");return}X(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunk7UUBX6MCcjs.gb.call(void 0, this.dataType);this._hostBuffer||(this._hostBuffer=new ArrayBuffer(a)),this._group.flush(),Ze?et(this.dataType)(new DataView(this._hostBuffer),0,t,un==="little"):X(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=_chunk7UUBX6MCcjs.gb.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:_chunk7UUBX6MCcjs.gb.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunk7UUBX6MCcjs.gb.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunk7UUBX6MCcjs.gb.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([aa, 'access', _30 => _30[t], 'optionalCall', _31 => _31(this)])}destroy(){this._destroyed||(this._destroyed=!0,this._ownBuffer&&_optionalChain([this, 'access', _32 => _32._buffer, 'optionalAccess', _33 => _33.destroy, 'call', _34 => _34()]))}toString(){return`buffer:${_nullishCoalesce(this._label, () => ("<unnamed>"))}`}}, _class4);function ln(e){return new Ht(e)}function dn(e){return new Jt(e)}function $e(e){return _optionalChain([e, 'optionalAccess', _35 => _35.resourceType])==="sampler"}function Ge(e){return _optionalChain([e, 'optionalAccess', _36 => _36.resourceType])==="sampler-comparison"}var nt= (_class5 =class{constructor(t){;_class5.prototype.__init11.call(this);this._membership=t}__init11() {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>"))}`}}, _class5),at= (_class6 =class{constructor(t){;_class6.prototype.__init12.call(this);this._membership=t}__init12() {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>"))}`}}, _class6),Ht= (_class7 =class{constructor(t){;_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);this._props=t;this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}__init13() {this.resourceType="sampler"}__init14() {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>"))}`}}, _class7),Jt= (_class8 =class{constructor(t){;_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this);this._props=t}__init15() {this.resourceType="sampler-comparison"}__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:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){return`${this.resourceType}:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}, _class8);var ot= (_class9 =class{constructor(t){;_class9.prototype.__init17.call(this);this._membership=t}__init17() {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>"))}`}}, _class9);var mn={r8unorm:_chunk7UUBX6MCcjs.O,r8snorm:_chunk7UUBX6MCcjs.O,r8uint:_chunk7UUBX6MCcjs.M,r8sint:_chunk7UUBX6MCcjs.N,r16uint:_chunk7UUBX6MCcjs.M,r16sint:_chunk7UUBX6MCcjs.N,r16float:_chunk7UUBX6MCcjs.O,rg8unorm:_chunk7UUBX6MCcjs.O,rg8snorm:_chunk7UUBX6MCcjs.O,rg8uint:_chunk7UUBX6MCcjs.M,rg8sint:_chunk7UUBX6MCcjs.N,r32uint:_chunk7UUBX6MCcjs.M,r32sint:_chunk7UUBX6MCcjs.N,r32float:_chunk7UUBX6MCcjs.O,rg16uint:_chunk7UUBX6MCcjs.M,rg16sint:_chunk7UUBX6MCcjs.N,rg16float:_chunk7UUBX6MCcjs.O,rgba8unorm:_chunk7UUBX6MCcjs.O,"rgba8unorm-srgb":_chunk7UUBX6MCcjs.O,rgba8snorm:_chunk7UUBX6MCcjs.O,rgba8uint:_chunk7UUBX6MCcjs.M,rgba8sint:_chunk7UUBX6MCcjs.N,bgra8unorm:_chunk7UUBX6MCcjs.O,"bgra8unorm-srgb":_chunk7UUBX6MCcjs.O,rgb9e5ufloat:_chunk7UUBX6MCcjs.O,rgb10a2uint:_chunk7UUBX6MCcjs.M,rgb10a2unorm:_chunk7UUBX6MCcjs.O,rg11b10ufloat:_chunk7UUBX6MCcjs.O,rg32uint:_chunk7UUBX6MCcjs.M,rg32sint:_chunk7UUBX6MCcjs.N,rg32float:_chunk7UUBX6MCcjs.O,rgba16uint:_chunk7UUBX6MCcjs.M,rgba16sint:_chunk7UUBX6MCcjs.N,rgba16float:_chunk7UUBX6MCcjs.O,rgba32uint:_chunk7UUBX6MCcjs.M,rgba32sint:_chunk7UUBX6MCcjs.N,rgba32float:_chunk7UUBX6MCcjs.O,stencil8:_chunk7UUBX6MCcjs.O,depth16unorm:_chunk7UUBX6MCcjs.O,depth24plus:_chunk7UUBX6MCcjs.O,"depth24plus-stencil8":_chunk7UUBX6MCcjs.O,depth32float:_chunk7UUBX6MCcjs.O,"depth32float-stencil8":_chunk7UUBX6MCcjs.O,"bc1-rgba-unorm":_chunk7UUBX6MCcjs.O,"bc1-rgba-unorm-srgb":_chunk7UUBX6MCcjs.O,"bc2-rgba-unorm":_chunk7UUBX6MCcjs.O,"bc2-rgba-unorm-srgb":_chunk7UUBX6MCcjs.O,"bc3-rgba-unorm":_chunk7UUBX6MCcjs.O,"bc3-rgba-unorm-srgb":_chunk7UUBX6MCcjs.O,"bc4-r-unorm":_chunk7UUBX6MCcjs.O,"bc4-r-snorm":_chunk7UUBX6MCcjs.O,"bc5-rg-unorm":_chunk7UUBX6MCcjs.O,"bc5-rg-snorm":_chunk7UUBX6MCcjs.O,"bc6h-rgb-ufloat":_chunk7UUBX6MCcjs.O,"bc6h-rgb-float":_chunk7UUBX6MCcjs.O,"bc7-rgba-unorm":_chunk7UUBX6MCcjs.O,"bc7-rgba-unorm-srgb":_chunk7UUBX6MCcjs.O,"etc2-rgb8unorm":_chunk7UUBX6MCcjs.O,"etc2-rgb8unorm-srgb":_chunk7UUBX6MCcjs.O,"etc2-rgb8a1unorm":_chunk7UUBX6MCcjs.O,"etc2-rgb8a1unorm-srgb":_chunk7UUBX6MCcjs.O,"etc2-rgba8unorm":_chunk7UUBX6MCcjs.O,"etc2-rgba8unorm-srgb":_chunk7UUBX6MCcjs.O,"eac-r11unorm":_chunk7UUBX6MCcjs.O,"eac-r11snorm":_chunk7UUBX6MCcjs.O,"eac-rg11unorm":_chunk7UUBX6MCcjs.O,"eac-rg11snorm":_chunk7UUBX6MCcjs.O,"astc-4x4-unorm":_chunk7UUBX6MCcjs.O,"astc-4x4-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-5x4-unorm":_chunk7UUBX6MCcjs.O,"astc-5x4-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-5x5-unorm":_chunk7UUBX6MCcjs.O,"astc-5x5-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-6x5-unorm":_chunk7UUBX6MCcjs.O,"astc-6x5-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-6x6-unorm":_chunk7UUBX6MCcjs.O,"astc-6x6-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-8x5-unorm":_chunk7UUBX6MCcjs.O,"astc-8x5-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-8x6-unorm":_chunk7UUBX6MCcjs.O,"astc-8x6-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-8x8-unorm":_chunk7UUBX6MCcjs.O,"astc-8x8-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-10x5-unorm":_chunk7UUBX6MCcjs.O,"astc-10x5-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-10x6-unorm":_chunk7UUBX6MCcjs.O,"astc-10x6-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-10x8-unorm":_chunk7UUBX6MCcjs.O,"astc-10x8-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-10x10-unorm":_chunk7UUBX6MCcjs.O,"astc-10x10-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-12x10-unorm":_chunk7UUBX6MCcjs.O,"astc-12x10-unorm-srgb":_chunk7UUBX6MCcjs.O,"astc-12x12-unorm":_chunk7UUBX6MCcjs.O,"astc-12x12-unorm-srgb":_chunk7UUBX6MCcjs.O},ke={rgba8unorm:_chunk7UUBX6MCcjs.A,rgba8snorm:_chunk7UUBX6MCcjs.A,rgba8uint:_chunk7UUBX6MCcjs.D,rgba8sint:_chunk7UUBX6MCcjs.C,rgba16uint:_chunk7UUBX6MCcjs.D,rgba16sint:_chunk7UUBX6MCcjs.C,rgba16float:_chunk7UUBX6MCcjs.A,r32uint:_chunk7UUBX6MCcjs.D,r32sint:_chunk7UUBX6MCcjs.C,r32float:_chunk7UUBX6MCcjs.A,rg32uint:_chunk7UUBX6MCcjs.D,rg32sint:_chunk7UUBX6MCcjs.C,rg32float:_chunk7UUBX6MCcjs.A,rgba32uint:_chunk7UUBX6MCcjs.D,rgba32sint:_chunk7UUBX6MCcjs.C,rgba32float:_chunk7UUBX6MCcjs.A,bgra8unorm:_chunk7UUBX6MCcjs.A},gn={f32:"float",u32:"uint",i32:"sint"},fn={float:_chunk7UUBX6MCcjs.O,"unfilterable-float":_chunk7UUBX6MCcjs.O,uint:_chunk7UUBX6MCcjs.M,sint:_chunk7UUBX6MCcjs.N,depth:_chunk7UUBX6MCcjs.O};function Tn(e,t){return new Yt(e,t)}function q(e){return _optionalChain([e, 'optionalAccess', _37 => _37.resourceType])==="texture"}function We(e){return _optionalChain([e, 'optionalAccess', _38 => _38.resourceType])==="texture-storage-view"}function Me(e){return _optionalChain([e, 'optionalAccess', _39 => _39.resourceType])==="texture-sampled-view"}var cn={mutable:"read_write",readonly:"read",writeonly:"write"},Yt= (_class10 =class{constructor(t,r){;_class10.prototype.__init18.call(this);_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this);_class10.prototype.__init21.call(this);_class10.prototype.__init22.call(this);_class10.prototype.__init23.call(this);_class10.prototype.__init24.call(this);this.props=t;this._branch=r}__init18() {this.resourceType="texture"}__init19() {this.usableAsSampled=!1}__init20() {this.usableAsStorage=!1}__init21() {this.usableAsRender=!1}__init22() {this._destroyed=!1}__init23() {this._flags=GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}__init24() {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', _40 => _40.format]), () => (this.props.format)),a=ke[n];return _chunk7UUBX6MCcjs.a.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new Qt(_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', _41 => _41.format]), () => (this.props.format));if(!ke[r])throw new Error(`Unsupported storage texture format: ${r}`);return new Xt(t,this)}destroy(){this._destroyed||(this._destroyed=!0,_optionalChain([this, 'access', _42 => _42._texture, 'optionalAccess', _43 => _43.destroy, 'call', _44 => _44()]))}}, _class10),ut={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},Qt= (_class11 =class{constructor(t,r,n){;_class11.prototype.__init25.call(this);this.access=r;this._texture=n;this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _45 => _45.dimension]), () => (n.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _46 => _46.format]), () => (n.props.format)),this.texelDataType=ke[this._format]}__init25() {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_${ut[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>"))}`}}, _class11),it= (_class12 =class{constructor(t,r,n,a){;_class12.prototype.__init26.call(this);this._format=t;this.dimension=r;this.access=n;this._membership=a;this.texelDataType=ke[this._format]}__init26() {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_${ut[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>"))}`}}, _class12),Xt= (_class13 =class{constructor(t,r){;_class13.prototype.__init27.call(this);this._props=t;this._texture=r;this.dimension=_nullishCoalesce(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _47 => _47.dimension]), () => (r.props.dimension)), () => ("2d")),this._format=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _48 => _48.format]), () => (r.props.format)),this.channelDataType=mn[this._format]}__init27() {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:gn[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${ut[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>"))}`}}, _class13),st= (_class14 =class{constructor(t,r,n,a){;_class14.prototype.__init28.call(this);this.dimension=r;this._multisampled=n;this._membership=a;this.channelDataType=fn[t]}__init28() {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_${ut[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>"))}`}}, _class14);function Zt(e){return!!_optionalChain([e, 'optionalAccess', _49 => _49.usableAsSampled])}function ia(e){return!!_optionalChain([e, 'optionalAccess', _50 => _50.usableAsRender])}var pt=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 lt(e){return new tr(e)}function dt(e){return!!e&&e.resourceType==="bind-group-layout"}function rr(e){return!!e&&e.resourceType==="bind-group"}var er=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"],we=["compute","vertex","fragment"],tr= (_class15 =class{constructor(t){;_class15.prototype.__init29.call(this);_class15.prototype.__init30.call(this);_class15.prototype.__init31.call(this);_class15.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 Oe("uniform",a.uniform,o)),"storage"in a){let i="type"in a.storage?a.storage:a.storage(0);this.bound[n]=new Oe(_nullishCoalesce(a.access, () => ("readonly")),i,o)}"texture"in a&&(this.bound[n]=new st(a.texture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.multisampled, () => (!1)),o)),"storageTexture"in a&&(this.bound[n]=new it(a.storageTexture,_nullishCoalesce(a.viewDimension, () => ("2d")),_nullishCoalesce(a.access, () => ("writeonly")),o)),"externalTexture"in a&&(this.bound[n]=new ot(o)),"sampler"in a&&(a.sampler==="comparison"?this.bound[n]=new at(o):this.bound[n]=new nt(o)),"texture"in a||"storageTexture"in a||"externalTexture"in a||"sampler"in a?this.value[n]=this.bound[n]:Object.defineProperty(this.value,n,{get:()=>this.bound[n].value}),r++}}__init29() {this.resourceType="bind-group-layout"}__init30() {this.bound={}}__init31() {this.value={}}__init32() {this.$=this.value}toString(){return`bindGroupLayout:${_nullishCoalesce(this._label, () => ("<unnamed>"))}`}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, () => (we)),i.buffer={type:"uniform"};else if("storage"in n)o=_nullishCoalesce(o, () => ((n.access==="mutable"?yn:we))),i.buffer={type:n.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in n)o=_nullishCoalesce(o, () => (we)),i.sampler={type:n.sampler};else if("texture"in n)o=_nullishCoalesce(o, () => (we)),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"?we: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, () => (we)),i.externalTexture={});return _optionalChain([o, 'optionalAccess', _51 => _51.includes, 'call', _52 => _52("compute")])&&(i.visibility|=GPUShaderStage.COMPUTE),_optionalChain([o, 'optionalAccess', _53 => _53.includes, 'call', _54 => _54("vertex")])&&(i.visibility|=GPUShaderStage.VERTEX),_optionalChain([o, 'optionalAccess', _55 => _55.includes, 'call', _56 => _56("fragment")])&&(i.visibility|=GPUShaderStage.FRAGMENT),i}).filter(n=>n!==null)})}populate(t){return new de(this,t)}}, _class15),de= (_class16 =class{constructor(t,r){;_class16.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 er(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(Z(i)){if(!tt(i))throw new (0, _chunk7UUBX6MCcjs.d)(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("storage"in a){let s;if(Z(i)){if(!le(i))throw new Ee(i);s={buffer:t.unwrap(i)}}else s={buffer:i};return{binding:o,resource:s}}if("texture"in a){let s;if(q(i)){if(!Zt(i))throw new pt(i);s=t.unwrap(i.createView("sampled"))}else Me(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("storageTexture"in a){let s;if(q(i)){if(!le(i))throw new Ee(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 We(i)?s=t.unwrap(i):s=i;return{binding:o,resource:s}}if("sampler"in a)return $e(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)})}}, _class16);var xn="#CATCHALL#",ar= (_class17 =class{constructor() { _class17.prototype.__init34.call(this);_class17.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', _57 => _57.type])==="item")n.usedSlots.add(t);else if(_optionalChain([n, 'optionalAccess', _58 => _58.type])==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _59 => _59.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _60 => _60.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', _61 => _61.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:_chunkURJCMUTTcjs.i.call(void 0, o)?xe(o):_chunkURJCMUTTcjs.f}:void 0}if(_optionalChain([n, 'optionalAccess', _62 => _62.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', _63 => _63.type])==="blockScope")return a.declarations.set(t,r),{value:t,dataType:r}}throw new Error("No block scope found to define a variable in.")}}, _class17),mt=[""," "," "," "," "," "," "," "," "],nr=mt.length-1,or= (_class18 =class{constructor() { _class18.prototype.__init36.call(this); }__init36() {this.identLevel=0}get pre(){return _nullishCoalesce(mt[this.identLevel], () => (mt[nr].repeat(this.identLevel/nr)+mt[this.identLevel%nr]))}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}}, _class18),ir= (_class19 =class{__init37() {this._memoizedResolves=new WeakMap}__init38() {this._memoizedDerived=new WeakMap}__init39() {this._indentController=new or}__init40() {this._itemStateStack=new ar}__init41() {this._declarations=[]}__init42() {this[_chunkURJCMUTTcjs.a]={itemStateStack:this._itemStateStack}}__init43() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init44() {this._nextFreeLayoutPlaceholderIdx=0}__init45() {this.fixedBindings=[]}__init46() {this.callStack=[]}constructor(t){;_class19.prototype.__init37.call(this);_class19.prototype.__init38.call(this);_class19.prototype.__init39.call(this);_class19.prototype.__init40.call(this);_class19.prototype.__init41.call(this);_class19.prototype.__init42.call(this);_class19.prototype.__init43.call(this);_class19.prototype.__init44.call(this);_class19.prototype.__init45.call(this);_class19.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{return{head:sr(this,t.args,t.returnType),body:Gt(this,t.body)}}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, _chunk7UUBX6MCcjs.c)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}unwrap(t){if(_chunkURJCMUTTcjs.d.call(void 0, t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if(_chunkURJCMUTTcjs.b.call(void 0, r))r=this.readSlot(r);else if(_chunkURJCMUTTcjs.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,p])=>s.areEqual(this._itemStateStack.readSlot(s),p)))return o.result;_chunk7UUBX6MCcjs.k.call(void 0, _chunk7UUBX6MCcjs.h.CPU);let n;try{n=t["~compute"]()}finally{_chunk7UUBX6MCcjs.l.call(void 0, _chunk7UUBX6MCcjs.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 _chunk7UUBX6MCcjs.b?n.appendToTrace(t):new (0, _chunk7UUBX6MCcjs.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,p])=>s.areEqual(this._itemStateStack.readSlot(s),p)))return o.result;let n;_chunk7UUBX6MCcjs.ma.call(void 0, t)?n=Ot(this,t):_chunkURJCMUTTcjs.c.call(void 0, t)||_chunkURJCMUTTcjs.b.call(void 0, t)?n=this.resolve(this.unwrap(t)):_chunkURJCMUTTcjs.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 _chunk7UUBX6MCcjs.b?n.appendToTrace(t):new (0, _chunk7UUBX6MCcjs.b)(n,[t])}finally{this._itemStateStack.popItem()}}resolve(t){if(_chunkURJCMUTTcjs.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{_chunk7UUBX6MCcjs.k.call(void 0, _chunk7UUBX6MCcjs.h.GPU);let r=_chunk7UUBX6MCcjs.i.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
20
+ ${p}`:`${e.pre}if (${s})
21
+ ${i}`}if(t[0]===x.let||t[0]===x.const){let[r,n,a]=t,o=a?I(e,a):void 0;if(!o||!a)throw new Error("Cannot create variable without an initial value.");if(_chunkLB4TSIPNcjs.c.call(void 0, o.dataType))throw new Error("Cannot create variable with loose data type.");pa(e,n,o.dataType);let s=D(e,sr(e,n));if(typeof a=="object"&&a[0]===x.objectExpr&&_chunkVTUUXD6Hcjs._.call(void 0, e.callStack[e.callStack.length-1])){let i=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}var ${s} = ${i}(${D(e,o)});`}return`${e.pre}var ${s} = ${D(e,o)};`}if(t[0]===x.block)return xn(e,t);if(t[0]===x.for){let[r,n,a,o,s]=t,i=n?me(e,n):void 0,p=i?i.slice(0,-1):"",u=a?I(e,a):void 0,d=u?D(e,u):"",m=o?me(e,o):void 0,T=m?m.slice(0,-1):"";e.indent();let f=me(e,s);return e.dedent(),`${e.pre}for (${p}; ${d}; ${T})
22
+ ${f}`}if(t[0]===x.while){let[r,n,a]=t,o=D(e,I(e,n));e.indent();let s=me(e,a);return e.dedent(),`${e.pre}while (${o})
23
+ ${s}`}return t[0]===x.continue?`${e.pre}continue;`:t[0]===x.break?`${e.pre}break;`:`${e.pre}${D(e,I(e,t))};`}function bn(e,t){return xn(e,t)}var hn="#CATCHALL#",ur= (_class17 =class{constructor() { _class17.prototype.__init34.call(this);_class17.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', _66 => _66.type])==="item")n.usedSlots.add(t);else if(_optionalChain([n, 'optionalAccess', _67 => _67.type])==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!(_optionalChain([n, 'optionalAccess', _68 => _68.type])==="functionScope"||_optionalChain([n, 'optionalAccess', _69 => _69.type])==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getSnippetById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if(_optionalChain([n, 'optionalAccess', _70 => _70.type])==="functionScope"){let a=n.args.find(s=>s.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:K(o)?we(o):U}:void 0}if(_optionalChain([n, 'optionalAccess', _71 => _71.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', _72 => _72.type])==="blockScope")return a.declarations.set(t,r),{value:t,dataType:r}}throw new Error("No block scope found to define a variable in.")}}, _class17),yt=[""," "," "," "," "," "," "," "," "],ir=yt.length-1,pr= (_class18 =class{constructor() { _class18.prototype.__init36.call(this); }__init36() {this.identLevel=0}get pre(){return _nullishCoalesce(yt[this.identLevel], () => (yt[ir].repeat(this.identLevel/ir)+yt[this.identLevel%ir]))}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}}, _class18),lr= (_class19 =class{__init37() {this._memoizedResolves=new WeakMap}__init38() {this._memoizedDerived=new WeakMap}__init39() {this._indentController=new pr}__init40() {this._itemStateStack=new ur}__init41() {this._declarations=[]}__init42() {this[_chunkVTUUXD6Hcjs.n]={itemStateStack:this._itemStateStack}}__init43() {this.bindGroupLayoutsToPlaceholderMap=new Map}__init44() {this._nextFreeLayoutPlaceholderIdx=0}__init45() {this.fixedBindings=[]}__init46() {this.callStack=[]}constructor(t){;_class19.prototype.__init37.call(this);_class19.prototype.__init38.call(this);_class19.prototype.__init39.call(this);_class19.prototype.__init40.call(this);_class19.prototype.__init41.call(this);_class19.prototype.__init42.call(this);_class19.prototype.__init43.call(this);_class19.prototype.__init44.call(this);_class19.prototype.__init45.call(this);_class19.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.getSnippetById(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{return{head:dr(this,t.args,t.returnType),body:bn(this,t.body)}}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:hn,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunkVTUUXD6Hcjs.c)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.popSlotBindings()}}unwrap(t){if(Ve(t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if($(r))r=this.readSlot(r);else if(k(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(([i,p])=>i.areEqual(this._itemStateStack.readSlot(i),p)))return o.result;_chunkVTUUXD6Hcjs.k.call(void 0, _chunkVTUUXD6Hcjs.h.CPU);let n;try{n=t["~compute"]()}finally{_chunkVTUUXD6Hcjs.l.call(void 0, _chunkVTUUXD6Hcjs.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 _chunkVTUUXD6Hcjs.b?n.appendToTrace(t):new (0, _chunkVTUUXD6Hcjs.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(([i,p])=>i.areEqual(this._itemStateStack.readSlot(i),p)))return o.result;let n;_chunkLB4TSIPNcjs.h.call(void 0, t)?n=Mt(this,t):k(t)||$(t)?n=this.resolve(this.unwrap(t)):$t(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 _chunkVTUUXD6Hcjs.b?n.appendToTrace(t):new (0, _chunkVTUUXD6Hcjs.b)(n,[t])}finally{this._itemStateStack.popItem()}}resolve(t){if(Ve(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{_chunkVTUUXD6Hcjs.k.call(void 0, _chunkVTUUXD6Hcjs.h.GPU);let r=_chunkVTUUXD6Hcjs.i.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
24
24
 
25
- `)}${r}`}finally{_chunk7UUBX6MCcjs.l.call(void 0, _chunk7UUBX6MCcjs.h.GPU)}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(_chunkURJCMUTTcjs.i.call(void 0, t))return this.resolve(t);if(r&&_chunk7UUBX6MCcjs.X.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&&_chunk7UUBX6MCcjs.Y.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`)}}, _class19);function Se(e,t){let r=new ir(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(m=>m.index).filter(m=>m!==void 0)),s=_chunk7UUBX6MCcjs.n.call(void 0, i),p=r.fixedBindings.map((m,T)=>[String(T),m.layoutEntry]),u=()=>{let m=s.next().value,T=lt(Object.fromEntries(p));return o[m]=T,n=n.replaceAll(xn,String(m)),[m,new de(T,Object.fromEntries(r.fixedBindings.map((f,g)=>[String(g),f.resource])))]},d=p.length>0?u():null;for(let[m,T]of a.entries()){let f=_nullishCoalesce(m.index, () => (s.next().value));o[f]=m,n=n.replaceAll(T,String(f))}return{code:n,bindGroupLayouts:o,catchall:d}}function sr(e,t,r){let n=t.map(a=>`${a.value}: ${e.resolve(a.dataType)}`).join(", ");return r!==void 0?`(${n}) -> ${_chunk7UUBX6MCcjs.ob.call(void 0, r)} ${e.resolve(r)}`:`(${n})`}function ee(e,t){let r=[];return typeof t=="string"&&(jr(t,Array.isArray(e.argTypes)?e.argTypes:Object.values(e.argTypes),n=>r.push(n)),he(t,e.returnType,n=>r.push(n)),Array.isArray(e.argTypes)&&_chunk7UUBX6MCcjs.Y.call(void 0, e.argTypes[0])&&r.push({In:e.argTypes[0]}),_chunk7UUBX6MCcjs.Y.call(void 0, e.returnType)&&r.push({Out:e.returnType})),{label:void 0,applyExternals(n){r.push(n)},resolve(n,a=""){let o={};for(let s of r)K(o,s);let i=n.names.makeUnique(this.label);if(typeof t=="string"){let s="";if(a==="")s=Array.isArray(e.argTypes)?"":sr(n,Object.entries(e.argTypes).map(([u,d])=>({value:u,dataType:d})),e.returnType);else{let u=Array.isArray(e.argTypes)&&_chunk7UUBX6MCcjs.Y.call(void 0, e.argTypes[0])?"(in: In)":"()",d=_chunk7UUBX6MCcjs.W.call(void 0, e.returnType)?_chunk7UUBX6MCcjs.ob.call(void 0, e.returnType):"",m=e.returnType!==void 0?_chunk7UUBX6MCcjs.Y.call(void 0, e.returnType)?"-> Out":`-> ${d!==""?d:"@location(0)"} ${n.resolve(e.returnType)}`:"";s=`${u} ${m} `}let p=se(n,o,`${s}${t.trim()}`);n.addDeclaration(`${a}fn ${i}${p}`)}else{let s=qr(t);if(_optionalChain([s, 'optionalAccess', _64 => _64.externals])){let f=Object.fromEntries(Object.entries(s.externals).filter(([g])=>!(g in o)));K(o,f)}let p=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _65 => _65.ast]), () => (n.transpileFn(String(t))));p.argNames.type==="destructured-object"&&K(o,Object.fromEntries(p.argNames.props.map(({prop:f,alias:g})=>[g,f]))),!Array.isArray(e.argTypes)&&p.argNames.type==="identifiers"&&p.argNames.names[0]!==void 0&&K(o,{[p.argNames.names[0]]:Object.fromEntries(Object.keys(e.argTypes).map(f=>[f,f]))});let u=p.externalNames.filter(f=>!(f in o));if(u.length>0)throw new (0, _chunk7UUBX6MCcjs.e)(this.label,u);let d=Array.isArray(e.argTypes)?p.argNames.type==="identifiers"?p.argNames.names.map((f,g)=>({value:f,dataType:e.argTypes[g]})):[]:Object.entries(e.argTypes).map(([f,g])=>({value:f,dataType:g})),{head:m,body:T}=n.fnToWgsl({args:d,returnType:e.returnType,body:p.body,externalMap:o});n.addDeclaration(`${a}fn ${i}${n.resolve(m)}${n.resolve(T)}`)}return i}}}function hn(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunk7UUBX6MCcjs.nb.call(void 0, n))return[r,n];let a=_chunk7UUBX6MCcjs.la.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunk7UUBX6MCcjs.ib.call(void 0, n,{type:"@location",value:t++})]}))}function gt(e){return _chunk7UUBX6MCcjs.ma.call(void 0, e)?_chunk7UUBX6MCcjs.la.call(void 0, e)!==void 0?e:_chunk7UUBX6MCcjs.lb.call(void 0, 0,e):_chunk7UUBX6MCcjs.pb.call(void 0, hn(e))}function ve(e){return _chunk7UUBX6MCcjs.pb.call(void 0, hn(e))}function bn(e){let t={argTypes:[ve(_nullishCoalesce(e.in, () => ({})))],returnType:void 0,workgroupSize:[_nullishCoalesce(e.workgroupSize[0], () => (1)),_nullishCoalesce(e.workgroupSize[1], () => (1)),_nullishCoalesce(e.workgroupSize[2], () => (1))]},r=n=>sa(t,e.workgroupSize,n);return Object.assign(Object.assign(r,t),{does:r})}function sa(e,t,r){let n=ee(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,W(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 wn(e,t){let r={argTypes:e,returnType:t},n=a=>pa(r,a);return Object.assign(Object.assign(n,r),{does:n})}function ur(e){return _optionalChain([e, 'optionalAccess', _66 => _66.resourceType])==="function"}function ua([e,t]){return`${_nullishCoalesce(e.label, () => ("<unnamed>"))}=${t}`}function pa(e,t){let r=ee(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 Sn(o,[[_chunkURJCMUTTcjs.e.call(void 0, i)?i.slot:i,s]])},"~resolve"(i){if(typeof t=="string")return r.resolve(i);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(e.returnType),r.resolve(i)}finally{s.callStack.pop()}}},a=_chunk7UUBX6MCcjs.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 ft(o,i.map(s=>s.value)),dataType:_nullishCoalesce(e.returnType, () => (_chunkURJCMUTTcjs.f))}));Object.defineProperty(a,_chunkURJCMUTTcjs.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 Sn(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 Sn(a,[...t,[_chunkURJCMUTTcjs.e.call(void 0, o)?o.slot:o,i]])}},n=_chunk7UUBX6MCcjs.o.call(void 0, (...o)=>e(...o),(...o)=>({value:new ft(a,o.map(i=>i.value)),dataType:_nullishCoalesce(e.shell.returnType, () => (_chunkURJCMUTTcjs.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(ua).join(", ")}]`}}),Object.defineProperty(a,_chunkURJCMUTTcjs.a,{value:{implementation:e[_chunkURJCMUTTcjs.a].implementation}}),a}var ft=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 vn(e){let t={argTypes:[ve(_nullishCoalesce(e.in, () => ({})))],targets:e.out,returnType:gt(e.out)},r=n=>la(t,n);return Object.assign(Object.assign(r,t),{does:r})}function la(e,t){let r=ee(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&he(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,W(n)&&n.$name(`${i}_Output`),W(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 Fn(e){let t={attributes:[_nullishCoalesce(e.in, () => ({}))],returnType:gt(e.out),argTypes:[ve(_nullishCoalesce(e.in, () => ({})))]},r=n=>da(t,n);return Object.assign(Object.assign(r,t),{does:r})}function da(e,t){let r=ee(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&he(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,W(n)&&n.$name(`${o}_Output`),W(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 te= (_class20 =class{constructor() { _class20.prototype.__init47.call(this); }__init47() {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++}`}}, _class20),re= exports.StrictNameRegistry = (_class21 =class{constructor() { _class21.prototype.__init48.call(this); }__init48() {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}}, _class21);function Dn(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};K(o,_nullishCoalesce(t, () => ({})));let i={"~resolve"(p){return se(p,o,_nullishCoalesce(r, () => ("")))},toString:()=>"<root>"},{code:s}=Se(i,{names:n==="strict"?new re:new te,jitTranspiler:a});return s}var Ne= (_class22 =class{constructor(t){;_class22.prototype.__init49.call(this);this._make=t}__init49() {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 Un(e,t,r){return new pr(new lr(e,t,r),{})}function An(e){return _optionalChain([e, 'optionalAccess', _67 => _67.resourceType])==="compute-pipeline"}var pr= (_class23 =class e{constructor(t,r){;_class23.prototype.__init50.call(this);this._core=t;this._priors=r}__init50() {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 p=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])),p.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&&(p.delete(u),s.setBindGroup(d,o.unwrap(m)))}}),p.size>0)throw new (0, _chunk7UUBX6MCcjs.f)(p);s.dispatchWorkgroups(t,r,n),s.end()}$name(t){return this._core.label=t,this}}, _class23),lr=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}=Se({"~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 gr(e,t="vertex"){return new mr(e,t)}function ct(e){return _optionalChain([e, 'optionalAccess', _75 => _75.resourceType])==="vertex-layout"}var dr=Symbol("defaultAttribEntry");function Tt(e,t,r,n,a){if(_chunk7UUBX6MCcjs.ea.call(void 0, t)||_chunk7UUBX6MCcjs.ka.call(void 0, t)){let o=_chunk7UUBX6MCcjs.la.call(void 0, t);return o!==void 0&&(n[_nullishCoalesce(a, () => (dr))]=o),Tt(e,t.inner,_chunk7UUBX6MCcjs.fb.call(void 0, r,_chunk7UUBX6MCcjs.db.call(void 0, t)),n)}if(_chunk7UUBX6MCcjs.Y.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunk7UUBX6MCcjs.fb.call(void 0, o,_chunk7UUBX6MCcjs.cb.call(void 0, s));let p=[i,Tt(e,s,o,n,i)];return o+=_chunk7UUBX6MCcjs.gb.call(void 0, s),p}))}if(_chunk7UUBX6MCcjs.ja.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,s])=>{o=_chunk7UUBX6MCcjs.fb.call(void 0, o,_chunk7UUBX6MCcjs.db.call(void 0, s));let p=[i,Tt(e,s,o,n,i)];return o+=_chunk7UUBX6MCcjs.gb.call(void 0, s),p}))}if("type"in t&&typeof t.type=="string"){if(_chunk7UUBX6MCcjs.fa.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunk7UUBX6MCcjs.ga[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var mr= (_class24 =class{constructor(t,r){;_class24.prototype.__init51.call(this);_class24.prototype.__init52.call(this);this.schemaForCount=t;this.stepMode=r;let n=t(0);this.stride=_chunk7UUBX6MCcjs.fb.call(void 0, _chunk7UUBX6MCcjs.gb.call(void 0, n.elementType),_chunk7UUBX6MCcjs.cb.call(void 0, n)),this.attrib=Tt(this,n.elementType,0,this._customLocationMap)}__init51() {this.resourceType="vertex-layout"}__init52() {this._customLocationMap={}}get label(){return this._label}get vertexLayout(){if(this._customLocationMap[dr]!==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[dr]}]}}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 ma(e){return typeof _optionalChain([e, 'optionalAccess', _76 => _76.loadOp])=="string"}function In(e,t){if(_chunk7UUBX6MCcjs.ma.call(void 0, e)){if(!ma(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 ga(e){return typeof _optionalChain([e, 'optionalAccess', _77 => _77.format])=="string"}function Rn(e,t){if(_chunk7UUBX6MCcjs.ma.call(void 0, e)){if(!ga(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 Bn(e){return new fr(new Tr(e),{})}function _n(e){return _optionalChain([e, 'optionalAccess', _78 => _78.resourceType])==="render-pipeline"}var fr= (_class25 =class e{constructor(t,r){;_class25.prototype.__init53.call(this);this.core=t;this.priors=r}__init53() {this.resourceType="render-pipeline"}get label(){return this.core.label}$name(t){return this.core.label=t,this}with(t,r){if(dt(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:In(s.shell.targets,_nullishCoalesce(this.priors.colorAttachment, () => ({}))).map(g=>q(g.view)?{...g,view:i.unwrap(g.view).createView()}:g)};if(this.core.label!==void 0&&(u.label=this.core.label),this.priors.depthStencilAttachment!==void 0){let g=this.priors.depthStencilAttachment;q(g.view)?u.depthStencilAttachment={...g,view:i.unwrap(g.view).createView()}:u.depthStencilAttachment=g}let d=i.commandEncoder.beginRenderPass(u);d.setPipeline(o.pipeline);let m=new Set(o.bindGroupLayouts);o.bindGroupLayouts.forEach((g,F)=>{if(o.catchall&&F===o.catchall[0])d.setBindGroup(F,i.unwrap(o.catchall[1])),m.delete(g);else{let w=_optionalChain([this, 'access', _79 => _79.priors, 'access', _80 => _80.bindGroupLayoutMap, 'optionalAccess', _81 => _81.get, 'call', _82 => _82(g)]);w!==void 0&&(m.delete(g),d.setBindGroup(F,i.unwrap(w)))}});let T=new Set(this.core.usedVertexLayouts);if(this.core.usedVertexLayouts.forEach((g,F)=>{let w=_optionalChain([this, 'access', _83 => _83.priors, 'access', _84 => _84.vertexLayoutMap, 'optionalAccess', _85 => _85.get, 'call', _86 => _86(g)]);w&&(T.delete(g),d.setVertexBuffer(F,i.unwrap(w)))}),m.size>0)throw new (0, _chunk7UUBX6MCcjs.f)(m);if(T.size>0)throw new (0, _chunk7UUBX6MCcjs.g)(T);d.draw(t,r,n,a),d.end(),i.flush()}}, _class25),Tr=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=Rn(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:p,bindGroupLayouts:u,catchall:d}=Se({"~resolve":g=>(g.withSlots(a,()=>{g.resolve(r),g.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,T=m.createShaderModule({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Shader`,code:p}),f={layout:m.createPipelineLayout({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:u.map(g=>t.unwrap(g))}),vertex:{module:T,buffers:this._vertexBufferLayouts},fragment:{module:T,targets:this._targets}};this.label!==void 0&&(f.label=this.label),o&&(f.primitive=o),i&&(f.depthStencil=i),s&&(f.multisample=s),this._memo={pipeline:m.createRenderPipeline(f),bindGroupLayouts:u,catchall:d}}return this._memo}};var cr=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[_chunkURJCMUTTcjs.e.call(void 0, t)?t.slot:t,r]])}withCompute(t){return new yr(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new xr({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}},yr=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return Un(this._root,this._slotBindings,this._entryFn)}},xr=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunk7UUBX6MCcjs.a.call(void 0, typeof t!="string","Just type mismatch validation"),_chunk7UUBX6MCcjs.a.call(void 0, typeof r!="string","Just type mismatch validation"),new hr({...this._options,fragmentFn:t,targets:r})}},hr=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 Bn(this._options)}},yt= (_class26 =class extends cr{constructor(r,n,a,o){super(()=>this,[]);_class26.prototype.__init54.call(this);_class26.prototype.__init55.call(this);_class26.prototype.__init56.call(this);_class26.prototype.__init57.call(this);;this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;this["~unstable"]=this}__init54() {this._disposables=[]}__init55() {this._unwrappedBindGroupLayouts=new Ne(r=>r.unwrap(this))}__init56() {this._unwrappedBindGroups=new Ne(r=>r.unwrap(this))}__init57() {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 de(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(An(r))return r.rawPipeline;if(_n(r))return r.core.unwrap().pipeline;if(dt(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(rr(r))return this._unwrappedBindGroups.getOrMake(r);if(Z(r))return r.buffer;if(q(r)||We(r)||Me(r))return r.unwrap();if(ct(r))return r.vertexLayout;if($e(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,p=()=>{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 T=new Set(m.bindGroupLayouts);m.bindGroupLayouts.forEach((g,F)=>{if(m.catchall&&F===m.catchall[0])a.setBindGroup(F,this.unwrap(m.catchall[1])),T.delete(g);else{let w=_nullishCoalesce(_optionalChain([d, 'access', _90 => _90.bindGroupLayoutMap, 'optionalAccess', _91 => _91.get, 'call', _92 => _92(g)]), () => (o.get(g)));w!==void 0&&(T.delete(g),rr(w)?a.setBindGroup(F,this.unwrap(w)):a.setBindGroup(F,w))}});let f=new Set;if(u.usedVertexLayouts.forEach((g,F)=>{let w=_optionalChain([d, 'access', _93 => _93.vertexLayoutMap, 'optionalAccess', _94 => _94.get, 'call', _95 => _95(g)]),A=w?{buffer:w,offset:void 0,size:void 0}:i.get(g);!A||!A.buffer?f.add(g):Z(A.buffer)?a.setVertexBuffer(F,this.unwrap(A.buffer),A.offset,A.size):a.setVertexBuffer(F,A.buffer,A.offset,A.size)}),T.size>0)throw new (0, _chunk7UUBX6MCcjs.f)(T);if(f.size>0)throw new (0, _chunk7UUBX6MCcjs.g)(f)};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,T)=>{Z(u)?a.setIndexBuffer(this.unwrap(u),d,m,T):a.setIndexBuffer(u,d,m,T)},setVertexBuffer(u,d,m,T){i.set(u,{buffer:d,offset:m,size:T})},setBindGroup(u,d){o.set(u,d)},draw(u,d,m,T){p(),a.draw(u,d,m,T)},drawIndexed(...u){p(),a.drawIndexed(...u)},drawIndirect(...u){p(),a.drawIndirect(...u)},drawIndexedIndirect(...u){p(),a.drawIndexedIndirect(...u)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class26);async function Pn(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 te:new re,a,!0)}function Ln(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=_nullishCoalesce(e, () => ({}));return new yt(t,r==="random"?new te:new re,n,!1)}function xt(e){return new br(e)}var br= (_class27 =class{constructor(t=void 0){;_class27.prototype.__init58.call(this);this.defaultValue=t}__init58() {this.resourceType="slot"}$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=_chunk7UUBX6MCcjs.j.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return Le(t.unwrap(this))}}, _class27);function Cn(e,t){return new wr(e,t)}var wr= (_class28 =class{constructor(t,r=void 0){;_class28.prototype.__init59.call(this);this.schema=t;this.defaultValue=r;this.slot=xt(r)}__init59() {this.resourceType="accessor"}$name(t){return this.label=t,this.slot.$name(t),this}toString(){return`accessor:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){if(!_chunk7UUBX6MCcjs.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>"))}`,[_chunkURJCMUTTcjs.a]:{dataType:this.schema}},k)}"~resolve"(t){let r=t.unwrap(this.slot);return _chunkURJCMUTTcjs.k.call(void 0, r)?t.resolve(r):ur(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}}, _class28);function En(e){return Ta(e)}function fa([e,t]){return`${_nullishCoalesce(e.label, () => ("<unnamed>"))}=${t}`}function Ta(e){return{resourceType:"derived","~compute":e,[_chunk7UUBX6MCcjs.p]:void 0,get value(){let r=_chunk7UUBX6MCcjs.j.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Le(r.unwrap(this))},with(r,n){return Vn(this,[[r,n]])},toString(){return"derived"}}}function Vn(e,t){return{resourceType:"derived",[_chunk7UUBX6MCcjs.p]:void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},get value(){let n=_chunk7UUBX6MCcjs.j.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Le(n.unwrap(this))},with(n,a){return Vn(e,[...t,[n,a]])},toString(){return`derived[${t.map(fa).join(", ")}]`}}}function On(e,t){return new ht("private",e,t)}function $n(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(!_chunk7UUBX6MCcjs.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>"))}`,[_chunkURJCMUTTcjs.a]:{dataType:this._dataType}},k)}};var Gn={bindGroupLayout:lt,vertexLayout:gr,init:Pn,initFromDevice:Ln,resolve:Dn,"~unstable":{fn:wn,fragmentFn:vn,vertexFn:Fn,computeFn:bn,vertexLayout:gr,derived:En,slot:xt,accessor:Cn,privateVar:On,workgroupVar:$n,const:Nr,declare:zr,sampler:ln,comparisonSampler:dn}},Bu= exports.default =Gn;Object.assign(Gn,{__assignAst:Hr,__removedJsImpl:Jr});exports.MissingBindGroupsError = _chunk7UUBX6MCcjs.f; exports.MissingLinksError = _chunk7UUBX6MCcjs.e; exports.MissingSlotValueError = _chunk7UUBX6MCcjs.c; exports.MissingVertexBuffersError = _chunk7UUBX6MCcjs.g; exports.NotUniformError = _chunk7UUBX6MCcjs.d; exports.RandomNameRegistry = te; exports.ResolutionError = _chunk7UUBX6MCcjs.b; exports.StrictNameRegistry = re; exports.default = Bu; exports.isBuffer = Z; exports.isComparisonSampler = Ge; exports.isDerived = _chunkURJCMUTTcjs.c; exports.isSampledTextureView = Me; exports.isSampler = $e; exports.isSlot = _chunkURJCMUTTcjs.b; exports.isStorageTextureView = We; exports.isTexture = q; exports.isTgpuFn = ur; exports.isUsableAsRender = ia; exports.isUsableAsSampled = Zt; exports.isUsableAsStorage = le; exports.isUsableAsUniform = tt; exports.isUsableAsVertex = oa; exports.tgpu = Gn; exports.unstable_asMutable = Nt; exports.unstable_asReadonly = jt; exports.unstable_asUniform = zt;
25
+ `)}${r}`}finally{_chunkVTUUXD6Hcjs.l.call(void 0, _chunkVTUUXD6Hcjs.h.GPU)}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(K(t))return this.resolve(t);if(r&&_chunkVTUUXD6Hcjs.Z.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&&_chunkVTUUXD6Hcjs._.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`)}}, _class19);function Ae(e,t){let r=new lr(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],s=new Set([...a.keys()].map(m=>m.index).filter(m=>m!==void 0)),i=_chunkVTUUXD6Hcjs.o.call(void 0, s),p=r.fixedBindings.map((m,T)=>[String(T),m.layoutEntry]),u=()=>{let m=i.next().value,T=ft(Object.fromEntries(p));return o[m]=T,n=n.replaceAll(hn,String(m)),[m,new Fe(T,Object.fromEntries(r.fixedBindings.map((f,g)=>[String(g),f.resource])))]},d=p.length>0?u():null;for(let[m,T]of a.entries()){let f=_nullishCoalesce(m.index, () => (i.next().value));o[f]=m,n=n.replaceAll(T,String(f))}return{code:n,bindGroupLayouts:o,catchall:d}}function dr(e,t,r){let n=t.map(a=>`${a.value}: ${e.resolve(a.dataType)}`).join(", ");return r!==void 0?`(${n}) -> ${_chunkLB4TSIPNcjs.ia.call(void 0, r)} ${e.resolve(r)}`:`(${n})`}function te(e,t){let r=[];return typeof t=="string"&&(e.isEntry?(Array.isArray(e.argTypes)&&_chunkVTUUXD6Hcjs._.call(void 0, e.argTypes[0])&&r.push({In:e.argTypes[0]}),_chunkVTUUXD6Hcjs._.call(void 0, e.returnType)&&r.push({Out:e.returnType})):Array.isArray(e.argTypes)&&(zr(t,Array.isArray(e.argTypes)?e.argTypes:Object.values(e.argTypes),n=>r.push(n)),Se(t,e.returnType,n=>r.push(n)))),{label:void 0,applyExternals(n){r.push(n)},resolve(n,a=""){let o={};for(let i of r)q(o,i);let s=n.names.makeUnique(this.label);if(typeof t=="string"){let i="";if(!e.isEntry)i=Array.isArray(e.argTypes)?"":dr(n,Object.entries(e.argTypes).map(([u,d])=>({value:u,dataType:d})),e.returnType);else{let u=Array.isArray(e.argTypes)&&_chunkVTUUXD6Hcjs._.call(void 0, e.argTypes[0])?"(in: In)":"()",d=_chunkVTUUXD6Hcjs.Y.call(void 0, e.returnType)?_chunkLB4TSIPNcjs.ia.call(void 0, e.returnType):"",m=e.returnType!==void 0?_chunkVTUUXD6Hcjs._.call(void 0, e.returnType)?"-> Out":`-> ${d!==""?d:"@location(0)"} ${n.resolve(e.returnType)}`:"";i=`${u} ${m} `}let p=pe(n,o,`${i}${t.trim()}`);n.addDeclaration(`${a}fn ${s}${p}`)}else{let i=Hr(t);if(_optionalChain([i, 'optionalAccess', _73 => _73.externals])){let f=Object.fromEntries(Object.entries(i.externals).filter(([g])=>!(g in o)));q(o,f)}let p=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _74 => _74.ast]), () => (n.transpileFn(String(t))));p.argNames.type==="destructured-object"&&q(o,Object.fromEntries(p.argNames.props.map(({prop:f,alias:g})=>[g,f]))),!Array.isArray(e.argTypes)&&p.argNames.type==="identifiers"&&p.argNames.names[0]!==void 0&&q(o,{[p.argNames.names[0]]:Object.fromEntries(Object.keys(e.argTypes).map(f=>[f,f]))});let u=p.externalNames.filter(f=>!(f in o));if(u.length>0)throw new (0, _chunkVTUUXD6Hcjs.e)(this.label,u);let d=Array.isArray(e.argTypes)?p.argNames.type==="identifiers"?e.argTypes.map((f,g)=>({value:_nullishCoalesce((p.argNames.type==="identifiers"?p.argNames.names[g]:void 0), () => (`arg_${g}`)),dataType:f})):[]:Object.entries(e.argTypes).map(([f,g])=>({value:f,dataType:g})),{head:m,body:T}=n.fnToWgsl({args:d,returnType:e.returnType,body:p.body,externalMap:o});n.addDeclaration(`${a}fn ${s}${n.resolve(m)}${n.resolve(T)}`)}return s}}}function wn(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunkLB4TSIPNcjs.ha.call(void 0, n))return[r,n];let a=_chunkLB4TSIPNcjs.g.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunkLB4TSIPNcjs.fa.call(void 0, t++,n)]}))}function ct(e){return _chunkLB4TSIPNcjs.h.call(void 0, e)?_chunkLB4TSIPNcjs.g.call(void 0, e)!==void 0?e:_chunkLB4TSIPNcjs.fa.call(void 0, 0,e):_chunkLB4TSIPNcjs.ja.call(void 0, wn(e))}function Ue(e){return _chunkLB4TSIPNcjs.ja.call(void 0, wn(e))}function re(e,...t){return la(e)?da(e,...t):e}function la(e){return Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw)&&e.raw.every(t=>typeof t=="string")}function da(e,...t){return e.slice(1).reduce((r,n,a)=>`${r}${t[a]}${n}`,e[0])}function Sn(e){let t={argTypes:e.in&&Object.keys(e.in).length!==0?[Ue(e.in)]:[],returnType:void 0,workgroupSize:[_nullishCoalesce(e.workgroupSize[0], () => (1)),_nullishCoalesce(e.workgroupSize[1], () => (1)),_nullishCoalesce(e.workgroupSize[2], () => (1))],isEntry:!0},r=(n,...a)=>ma(t,e.workgroupSize,re(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function ma(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,j(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 vn(e,t){let r={argTypes:e,returnType:t,isEntry:!1},n=(a,...o)=>fa(r,re(a,...o));return Object.assign(Object.assign(n,r),{does:n})}function mr(e){return _optionalChain([e, 'optionalAccess', _75 => _75.resourceType])==="function"}function ga([e,t]){return`${_nullishCoalesce(e.label, () => ("<unnamed>"))}=${t}`}function fa(e,t){let r=te(e,t),n={[_chunkVTUUXD6Hcjs.n]:{implementation:t},shell:e,resourceType:"function",$uses(s){return r.applyExternals(s),this},$name(s){return r.label=s,this},with(s,i){return Dn(o,[[ue(s)?s.slot:s,i]])},"~resolve"(s){if(typeof t=="string")return r.resolve(s);let i=s;if(i.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return i.callStack.push(e.returnType),r.resolve(s)}finally{i.callStack.pop()}}},a=_chunkVTUUXD6Hcjs.p.call(void 0, (...s)=>{if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");return t(...s)},(...s)=>({value:new xt(o,s.map(i=>i.value)),dataType:_nullishCoalesce(e.returnType, () => (U))})),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 Dn(e,t){let r={[_chunkVTUUXD6Hcjs.n]:{implementation:e[_chunkVTUUXD6Hcjs.n].implementation},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,s){return Dn(a,[...t,[ue(o)?o.slot:o,s]])}},n=_chunkVTUUXD6Hcjs.p.call(void 0, (...o)=>e(...o),(...o)=>({value:new xt(a,o.map(s=>s.value)),dataType:_nullishCoalesce(e.shell.returnType, () => (U))})),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(ga).join(", ")}]`}}),a[_chunkVTUUXD6Hcjs.n].implementation=e[_chunkVTUUXD6Hcjs.n].implementation,a}var xt=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 Fn(e){let t={argTypes:e.in&&Object.keys(e.in).length!==0?[Ue(e.in)]:[],targets:e.out,returnType:Object.keys(e.out).length!==0?ct(e.out):void 0,isEntry:!0},r=(n,...a)=>Ta(t,re(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function Ta(e,t){let r=te(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&Se(t,n,s=>r.applyExternals(s)),{shell:e,outputType:n,get label(){return r.label},$uses(s){return r.applyExternals(s),this},$name(s){return r.label=s,j(n)&&n.$name(`${s}_Output`),j(a)&&a.$name(`${s}_Input`),this},"~resolve"(s){if(typeof t=="string")return r.resolve(s,"@fragment ");let i=s;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(s,"@fragment ")}finally{i.callStack.pop()}},toString(){return`fragmentFn:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}}function An(e){let t={attributes:[_nullishCoalesce(e.in, () => ({}))],returnType:Object.keys(e.out).length!==0?ct(e.out):void 0,argTypes:e.in&&Object.keys(e.in).length!==0?[Ue(e.in)]:[],isEntry:!0},r=(n,...a)=>ya(t,re(n,...a));return Object.assign(Object.assign(r,t),{does:r})}function ya(e,t){let r=te(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&Se(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,j(n)&&n.$name(`${o}_Output`),j(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){if(typeof t=="string")return r.resolve(o,"@vertex ");let s=o;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(o,"@vertex ")}finally{s.callStack.pop()}},toString(){return`vertexFn:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}}}var ne= (_class20 =class{constructor() { _class20.prototype.__init47.call(this); }__init47() {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++}`}}, _class20),ae= exports.StrictNameRegistry = (_class21 =class{constructor() { _class21.prototype.__init48.call(this); }__init48() {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}}, _class21);function Un(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};q(o,_nullishCoalesce(t, () => ({})));let s={"~resolve"(p){return pe(p,o,_nullishCoalesce(r, () => ("")))},toString:()=>"<root>"},{code:i}=Ae(s,{names:n==="strict"?new ae:new ne,jitTranspiler:a});return i}var qe= (_class22 =class{constructor(t){;_class22.prototype.__init49.call(this);this._make=t}__init49() {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 In(e,t,r){return new gr(new fr(e,t,r),{})}function Bn(e){return _optionalChain([e, 'optionalAccess', _76 => _76.resourceType])==="compute-pipeline"}var gr= (_class23 =class e{constructor(t,r){;_class23.prototype.__init50.call(this);this._core=t;this._priors=r}__init50() {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:s}=this._core,i=o.commandEncoder.beginComputePass({label:_nullishCoalesce(s, () => ("<unnamed>"))});i.setPipeline(a.pipeline);let p=new Set(a.bindGroupLayouts);if(a.bindGroupLayouts.forEach((u,d)=>{if(a.catchall&&d===a.catchall[0])i.setBindGroup(d,o.unwrap(a.catchall[1])),p.delete(u);else{let m=_optionalChain([this, 'access', _77 => _77._priors, 'access', _78 => _78.bindGroupLayoutMap, 'optionalAccess', _79 => _79.get, 'call', _80 => _80(u)]);m!==void 0&&(p.delete(u),i.setBindGroup(d,o.unwrap(m)))}}),p.size>0)throw new (0, _chunkVTUUXD6Hcjs.f)(p);i.dispatchWorkgroups(t,r,n),i.end()}$name(t){return this._core.label=t,this}}, _class23),fr=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}=Ae({"~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', _81 => _81[a[0]], 'optionalAccess', _82 => _82.$name, 'call', _83 => _83(`${_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 cr(e,t="vertex"){return new yr(e,t)}function ht(e){return _optionalChain([e, 'optionalAccess', _84 => _84.resourceType])==="vertex-layout"}var Tr=Symbol("defaultAttribEntry");function bt(e,t,r,n,a){if(_chunkVTUUXD6Hcjs.ga.call(void 0, t)||_chunkLB4TSIPNcjs.f.call(void 0, t)){let o=_chunkLB4TSIPNcjs.g.call(void 0, t);return o!==void 0&&(n[_nullishCoalesce(a, () => (Tr))]=o),bt(e,t.inner,_chunkLB4TSIPNcjs.aa.call(void 0, r,_chunkLB4TSIPNcjs._.call(void 0, t)),n)}if(_chunkVTUUXD6Hcjs._.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([s,i])=>{o=_chunkLB4TSIPNcjs.aa.call(void 0, o,_chunkLB4TSIPNcjs.Z.call(void 0, i));let p=[s,bt(e,i,o,n,s)];return o+=_chunkLB4TSIPNcjs.ba.call(void 0, i),p}))}if(_chunkLB4TSIPNcjs.e.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([s,i])=>{o=_chunkLB4TSIPNcjs.aa.call(void 0, o,_chunkLB4TSIPNcjs._.call(void 0, i));let p=[s,bt(e,i,o,n,s)];return o+=_chunkLB4TSIPNcjs.ba.call(void 0, i),p}))}if("type"in t&&typeof t.type=="string"){if(_chunkLB4TSIPNcjs.a.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkLB4TSIPNcjs.b[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var yr= (_class24 =class{constructor(t,r){;_class24.prototype.__init51.call(this);_class24.prototype.__init52.call(this);this.schemaForCount=t;this.stepMode=r;let n=t(0);this.stride=_chunkLB4TSIPNcjs.aa.call(void 0, _chunkLB4TSIPNcjs.ba.call(void 0, n.elementType),_chunkLB4TSIPNcjs.Z.call(void 0, n)),this.attrib=bt(this,n.elementType,0,this._customLocationMap)}__init51() {this.resourceType="vertex-layout"}__init52() {this._customLocationMap={}}get label(){return this._label}get vertexLayout(){if(this._customLocationMap[Tr]!==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[Tr]}]}}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 ca(e){return typeof _optionalChain([e, 'optionalAccess', _85 => _85.loadOp])=="string"}function Rn(e,t){if(_chunkLB4TSIPNcjs.h.call(void 0, e)){if(!ca(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 xa(e){return typeof _optionalChain([e, 'optionalAccess', _86 => _86.format])=="string"}function _n(e,t){if(_chunkLB4TSIPNcjs.h.call(void 0, e)){if(!xa(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 Pn(e){return new xr(new br(e),{})}function Ln(e){return _optionalChain([e, 'optionalAccess', _87 => _87.resourceType])==="render-pipeline"}var xr= (_class25 =class e{constructor(t,r){;_class25.prototype.__init53.call(this);this.core=t;this.priors=r}__init53() {this.resourceType="render-pipeline"}get label(){return this.core.label}$name(t){return this.core.label=t,this}with(t,r){if(Tt(t))return new e(this.core,{...this.priors,bindGroupLayoutMap:new Map([..._nullishCoalesce(this.priors.bindGroupLayoutMap, () => ([])),[t,r]])});if(ht(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:s,fragmentFn:i}=this.core.options,u={colorAttachments:Rn(i.shell.targets,_nullishCoalesce(this.priors.colorAttachment, () => ({}))).map(g=>H(g.view)?{...g,view:s.unwrap(g.view).createView()}:g)};if(this.core.label!==void 0&&(u.label=this.core.label),this.priors.depthStencilAttachment!==void 0){let g=this.priors.depthStencilAttachment;H(g.view)?u.depthStencilAttachment={...g,view:s.unwrap(g.view).createView()}:u.depthStencilAttachment=g}let d=s.commandEncoder.beginRenderPass(u);d.setPipeline(o.pipeline);let m=new Set(o.bindGroupLayouts);o.bindGroupLayouts.forEach((g,F)=>{if(o.catchall&&F===o.catchall[0])d.setBindGroup(F,s.unwrap(o.catchall[1])),m.delete(g);else{let S=_optionalChain([this, 'access', _88 => _88.priors, 'access', _89 => _89.bindGroupLayoutMap, 'optionalAccess', _90 => _90.get, 'call', _91 => _91(g)]);S!==void 0&&(m.delete(g),d.setBindGroup(F,s.unwrap(S)))}});let T=new Set(this.core.usedVertexLayouts);if(this.core.usedVertexLayouts.forEach((g,F)=>{let S=_optionalChain([this, 'access', _92 => _92.priors, 'access', _93 => _93.vertexLayoutMap, 'optionalAccess', _94 => _94.get, 'call', _95 => _95(g)]);S&&(T.delete(g),d.setVertexBuffer(F,s.unwrap(S)))}),m.size>0)throw new (0, _chunkVTUUXD6Hcjs.f)(m);if(T.size>0)throw new (0, _chunkVTUUXD6Hcjs.g)(T);d.draw(t,r,n,a),d.end(),s.flush()}}, _class25),br=class{constructor(t){this.options=t;let r=Xr(t.vertexFn.shell.attributes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=_n(t.fragmentFn.shell.targets,t.targets)}unwrap(){if(this._memo===void 0){let{branch:t,vertexFn:r,fragmentFn:n,slotBindings:a,primitiveState:o,depthStencilState:s,multisampleState:i}=this.options,{code:p,bindGroupLayouts:u,catchall:d}=Ae({"~resolve":g=>(g.withSlots(a,()=>{g.resolve(r),g.resolve(n)}),""),toString:()=>`renderPipeline:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`},{names:t.nameRegistry,jitTranspiler:t.jitTranspiler});d!==null&&_optionalChain([u, 'access', _96 => _96[d[0]], 'optionalAccess', _97 => _97.$name, 'call', _98 => _98(`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Automatic Bind Group & Layout`)]);let m=t.device,T=m.createShaderModule({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Shader`,code:p}),f={layout:m.createPipelineLayout({label:`${_nullishCoalesce(this.label, () => ("<unnamed>"))} - Pipeline Layout`,bindGroupLayouts:u.map(g=>t.unwrap(g))}),vertex:{module:T,buffers:this._vertexBufferLayouts},fragment:{module:T,targets:this._targets}};this.label!==void 0&&(f.label=this.label),o&&(f.primitive=o),s&&(f.depthStencil=s),i&&(f.multisample=i),this._memo={pipeline:m.createRenderPipeline(f),bindGroupLayouts:u,catchall:d}}return this._memo}};var hr=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[ue(t)?t.slot:t,r]])}withCompute(t){return new wr(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new Sr({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r,multisampleState:void 0})}},wr=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return In(this._root,this._slotBindings,this._entryFn)}},Sr=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunkVTUUXD6Hcjs.a.call(void 0, typeof t!="string","Just type mismatch validation"),_chunkVTUUXD6Hcjs.a.call(void 0, typeof r!="string","Just type mismatch validation"),new vr({...this._options,fragmentFn:t,targets:r})}},vr=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 Pn(this._options)}},wt= (_class26 =class extends hr{constructor(r,n,a,o){super(()=>this,[]);_class26.prototype.__init54.call(this);_class26.prototype.__init55.call(this);_class26.prototype.__init56.call(this);_class26.prototype.__init57.call(this);;this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;this["~unstable"]=this}__init54() {this._disposables=[]}__init55() {this._unwrappedBindGroupLayouts=new qe(r=>r.unwrap(this))}__init56() {this._unwrappedBindGroups=new qe(r=>r.unwrap(this))}__init57() {this._commandEncoder=null}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=sn(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 Fe(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=gn(r,this);return this._disposables.push(n),n}unwrap(r){if(Bn(r))return r.rawPipeline;if(Ln(r))return r.core.unwrap().pipeline;if(Tt(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(or(r))return this._unwrappedBindGroups.getOrMake(r);if(ee(r))return r.buffer;if(H(r)||ze(r)||Ke(r))return r.unwrap();if(ht(r))return r.vertexLayout;if(Me(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out sampler.")}if(Ne(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,s=new Map,i,p=()=>{if(!i)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:u,priors:d}=i,m=u.unwrap();a.setPipeline(m.pipeline);let T=new Set(m.bindGroupLayouts);m.bindGroupLayouts.forEach((g,F)=>{if(m.catchall&&F===m.catchall[0])a.setBindGroup(F,this.unwrap(m.catchall[1])),T.delete(g);else{let S=_nullishCoalesce(_optionalChain([d, 'access', _99 => _99.bindGroupLayoutMap, 'optionalAccess', _100 => _100.get, 'call', _101 => _101(g)]), () => (o.get(g)));S!==void 0&&(T.delete(g),or(S)?a.setBindGroup(F,this.unwrap(S)):a.setBindGroup(F,S))}});let f=new Set;if(u.usedVertexLayouts.forEach((g,F)=>{let S=_optionalChain([d, 'access', _102 => _102.vertexLayoutMap, 'optionalAccess', _103 => _103.get, 'call', _104 => _104(g)]),B=S?{buffer:S,offset:void 0,size:void 0}:s.get(g);!B||!B.buffer?f.add(g):ee(B.buffer)?a.setVertexBuffer(F,this.unwrap(B.buffer),B.offset,B.size):a.setVertexBuffer(F,B.buffer,B.offset,B.size)}),T.size>0)throw new (0, _chunkVTUUXD6Hcjs.f)(T);if(f.size>0)throw new (0, _chunkVTUUXD6Hcjs.g)(f)};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){i=u},setIndexBuffer:(u,d,m,T)=>{ee(u)?a.setIndexBuffer(this.unwrap(u),d,m,T):a.setIndexBuffer(u,d,m,T)},setVertexBuffer(u,d,m,T){s.set(u,{buffer:d,offset:m,size:T})},setBindGroup(u,d){o.set(u,d)},draw(u,d,m,T){p(),a.draw(u,d,m,T)},drawIndexed(...u){p(),a.drawIndexed(...u)},drawIndirect(...u){p(),a.drawIndirect(...u)},drawIndexedIndirect(...u){p(),a.drawIndexedIndirect(...u)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}}, _class26);async function Cn(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 wt(await o.requestDevice(r),n==="random"?new ne:new ae,a,!0)}function En(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=_nullishCoalesce(e, () => ({}));return new wt(t,r==="random"?new ne:new ae,n,!1)}function St(e){return new Dr(e)}var Dr= (_class27 =class{constructor(t=void 0){;_class27.prototype.__init58.call(this);this.defaultValue=t}__init58() {this.resourceType="slot"}$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=_chunkVTUUXD6Hcjs.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 Vn(e,t){return new Fr(e,t)}var Fr= (_class28 =class{constructor(t,r=void 0){;_class28.prototype.__init59.call(this);this.schema=t;this.defaultValue=r;this.slot=St(r)}__init59() {this.resourceType="accessor"}$name(t){return this.label=t,this.slot.$name(t),this}toString(){return`accessor:${_nullishCoalesce(this.label, () => ("<unnamed>"))}`}get value(){if(!_chunkVTUUXD6Hcjs.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>"))}`,[_chunkVTUUXD6Hcjs.n]:{dataType:this.schema}},N)}"~resolve"(t){let r=t.unwrap(this.slot);return et(r)?t.resolve(r):mr(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}}, _class28);function $n(e){return ha(e)}function ba([e,t]){return`${_nullishCoalesce(e.label, () => ("<unnamed>"))}=${t}`}function ha(e){return{resourceType:"derived","~compute":e,[_chunkVTUUXD6Hcjs.q]:void 0,get value(){let r=_chunkVTUUXD6Hcjs.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 kn(this,[[r,n]])},toString(){return"derived"}}}function kn(e,t){return{resourceType:"derived",[_chunkVTUUXD6Hcjs.q]:void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},get value(){let n=_chunkVTUUXD6Hcjs.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 kn(e,[...t,[n,a]])},toString(){return`derived[${t.map(ba).join(", ")}]`}}}function On(e,t){return new vt("private",e,t)}function Gn(e){return new vt("workgroup",e)}var vt=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(!_chunkVTUUXD6Hcjs.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>"))}`,[_chunkVTUUXD6Hcjs.n]:{dataType:this._dataType}},N)}};var Wn={bindGroupLayout:ft,vertexLayout:cr,init:Cn,initFromDevice:En,resolve:Un,"~unstable":{fn:vn,fragmentFn:Fn,vertexFn:An,computeFn:Sn,vertexLayout:cr,derived:$n,slot:St,accessor:Vn,privateVar:On,workgroupVar:Gn,const:jr,declare:Kr,sampler:un,comparisonSampler:pn}},Nu= exports.default =Wn;Object.assign(Wn,{__assignAst:Jr,__removedJsImpl:Yr});exports.MissingBindGroupsError = _chunkVTUUXD6Hcjs.f; exports.MissingLinksError = _chunkVTUUXD6Hcjs.e; exports.MissingSlotValueError = _chunkVTUUXD6Hcjs.c; exports.MissingVertexBuffersError = _chunkVTUUXD6Hcjs.g; exports.NotUniformError = _chunkVTUUXD6Hcjs.d; exports.RandomNameRegistry = ne; exports.ResolutionError = _chunkVTUUXD6Hcjs.b; exports.StrictNameRegistry = ae; exports.default = Nu; exports.isBuffer = ee; exports.isComparisonSampler = Ne; exports.isDerived = k; exports.isSampledTextureView = Ke; exports.isSampler = Me; exports.isSlot = $; exports.isStorageTextureView = ze; exports.isTexture = H; exports.isTgpuFn = mr; exports.isUsableAsRender = aa; exports.isUsableAsSampled = rr; exports.isUsableAsStorage = de; exports.isUsableAsUniform = ot; exports.isUsableAsVertex = na; exports.tgpu = Wn; exports.unstable_asMutable = Kt; exports.unstable_asReadonly = qt; exports.unstable_asUniform = Ht;
26
26
  //# sourceMappingURL=index.cjs.map