typegpu 0.3.0-alpha.3 → 0.3.0-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
package/index.cjs CHANGED
@@ -2,18 +2,18 @@
2
2
  `}function Vt(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
3
3
  struct ${r} {
4
4
  ${Object.entries(t.propTypes).map(n=>Ct(e,n)).join("")}}
5
- `),r}function kt(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function De(e,t){if(It(t))return t.type;if(t.type==="struct")return Vt(e,t);if(t.type==="array")return kt(e,t);if(t.type==="atomic")return`atomic<${De(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);ot(t,"resolveData")}var Se="Invariant failed";function Z(e,t){if(e)return;throw new Error(Se)}var O=class e extends Error{constructor(r,n){let a=n.map(o=>`- ${o}`);a.length>20&&(a=[...a.slice(0,11),"...",...a.slice(-10)]);super(`Resolution of the following tree failed:
5
+ `),r}function kt(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function Se(e,t){if(It(t))return t.type;if(t.type==="struct")return Vt(e,t);if(t.type==="array")return kt(e,t);if(t.type==="atomic")return`atomic<${Se(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);ot(t,"resolveData")}var Ue="Invariant failed";function Z(e,t){if(e)return;throw new Error(Ue)}var O=class e extends Error{constructor(r,n){let a=n.map(o=>`- ${o}`);a.length>20&&(a=[...a.slice(0,11),"...",...a.slice(-10)]);super(`Resolution of the following tree failed:
6
6
  ${a.join(`
7
- `)}`);this.cause=r;this.trace=n;Object.setPrototypeOf(this,e.prototype)}appendToTrace(r){let n=[r,...this.trace];return new e(this.cause,n)}},ne=class e extends Error{constructor(r){super(`Missing value for '${r}'`);this.slot=r;Object.setPrototypeOf(this,e.prototype)}},W= exports.NotUniformError =class e extends Error{constructor(t){var r;super(`Buffer '${(r=t.label)!=null?r:"<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};var N=class e extends Error{constructor(t){super(`Bind group was not provided for '${t!=null?t:"<unnamed>"}' layout.`),Object.setPrototypeOf(this,e.prototype)}};function*it(e){let t=0;for(;;)e.has(t)||(yield t),t++}var S=Symbol("Unknown data type");function j(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"resolve"in e}function st(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||j(e)}function ut(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function pt(e){return e.__brand==="TgpuSlot"}function x(e,t){return st(t.value)||_chunkW7MD3ZVBcjs.d.call(void 0, t.value)?e.resolve(t.value):String(t.value)}function Mt(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function lt(e,t){return t?{value:"true",dataType:_chunkW7MD3ZVBcjs.u}:{value:"false",dataType:_chunkW7MD3ZVBcjs.u}}function dt(e,t){return`${e.indent()}{
8
- ${t.block.map(r=>ve(e,r)).join(`
7
+ `)}`);this.cause=r;this.trace=n;Object.setPrototypeOf(this,e.prototype)}appendToTrace(r){let n=[r,...this.trace];return new e(this.cause,n)}},ae=class e extends Error{constructor(r){super(`Missing value for '${r}'`);this.slot=r;Object.setPrototypeOf(this,e.prototype)}},W= exports.NotUniformError =class e extends Error{constructor(t){var r;super(`Buffer '${(r=t.label)!=null?r:"<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};var N=class e extends Error{constructor(t){super(`Bind group was not provided for '${t!=null?t:"<unnamed>"}' layout.`),Object.setPrototypeOf(this,e.prototype)}};function*it(e){let t=0;for(;;)e.has(t)||(yield t),t++}var S=Symbol("Unknown data type");function j(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"resolve"in e}function st(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||j(e)}function ut(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function pt(e){return e.__brand==="TgpuSlot"}function x(e,t){return st(t.value)||_chunkW7MD3ZVBcjs.d.call(void 0, t.value)?e.resolve(t.value):String(t.value)}function Mt(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function lt(e,t){return t?{value:"true",dataType:_chunkW7MD3ZVBcjs.u}:{value:"false",dataType:_chunkW7MD3ZVBcjs.u}}function dt(e,t){return`${e.indent()}{
8
+ ${t.block.map(r=>Be(e,r)).join(`
9
9
  `)}
10
- ${e.dedent()}}`}function Ue(e,t){return e.getById(t)}function U(e,t){if(typeof t=="string")return Ue(e,t);if(typeof t=="boolean")return lt(e,t);if("x2"in t){let[r,n,a]=t.x2,o=x(e,U(e,r)),i=x(e,U(e,a));return{value:`${o} ${n} ${i}`,dataType:S}}if("."in t){let[r,n]=t["."],a=U(e,r),o=x(e,U(e,n));return j(a.value)||typeof a.value=="object"?o==="value"?{value:x(e,a),dataType:S}:{value:a.value[o],dataType:S}:{value:`${x(e,a)}.${o}`,dataType:S}}if("[]"in t){let[r,n]=t["[]"],a=x(e,U(e,r)),o=x(e,U(e,n));return{value:`${a}[${o}]`,dataType:S}}if("num"in t)return{value:t.num,dataType:S};if("call"in t){let n=U(e,t.call).value,o=t.args.map(i=>U(e,i)).map(i=>x(e,i));return j(n)||typeof n=="function"?{value:n(...o),dataType:S}:{value:`${String(n)}(${o.join(", ")})`,dataType:S}}Mt(t)}function ve(e,t){if(typeof t=="string")return`${e.pre}${x(e,Ue(e,t))};`;if(typeof t=="boolean")return`${e.pre}${x(e,lt(e,t))};`;if("return"in t)return t.return===null?`${e.pre}return;`:`${e.pre}return ${x(e,U(e,t.return))};`;if("if"in t){let r=x(e,U(e,t.if));e.indent();let n=ve(e,t.do);e.dedent(),e.indent();let a=t.else?ve(e,t.else):void 0;return e.dedent(),a?`${e.pre}if (${r})
10
+ ${e.dedent()}}`}function ve(e,t){return e.getById(t)}function U(e,t){if(typeof t=="string")return ve(e,t);if(typeof t=="boolean")return lt(e,t);if("x2"in t){let[r,n,a]=t.x2,o=x(e,U(e,r)),i=x(e,U(e,a));return{value:`${o} ${n} ${i}`,dataType:S}}if("."in t){let[r,n]=t["."],a=U(e,r),o=x(e,U(e,n));return j(a.value)||typeof a.value=="object"?o==="value"?{value:x(e,a),dataType:S}:{value:a.value[o],dataType:S}:{value:`${x(e,a)}.${o}`,dataType:S}}if("[]"in t){let[r,n]=t["[]"],a=x(e,U(e,r)),o=x(e,U(e,n));return{value:`${a}[${o}]`,dataType:S}}if("num"in t)return{value:t.num,dataType:S};if("call"in t){let n=U(e,t.call).value,o=t.args.map(i=>U(e,i)).map(i=>x(e,i));return j(n)||typeof n=="function"?{value:n(...o),dataType:S}:{value:`${String(n)}(${o.join(", ")})`,dataType:S}}Mt(t)}function Be(e,t){if(typeof t=="string")return`${e.pre}${x(e,ve(e,t))};`;if(typeof t=="boolean")return`${e.pre}${x(e,lt(e,t))};`;if("return"in t)return t.return===null?`${e.pre}return;`:`${e.pre}return ${x(e,U(e,t.return))};`;if("if"in t){let r=x(e,U(e,t.if));e.indent();let n=Be(e,t.do);e.dedent(),e.indent();let a=t.else?Be(e,t.else):void 0;return e.dedent(),a?`${e.pre}if (${r})
11
11
  ${n}
12
12
  ${e.pre}else
13
13
  ${a}`:`${e.pre}if (${r})
14
- ${n}`}if("let"in t||"const"in t){let r=x(e,Ue(e,"let"in t?t.let:t.const)),n=t.eq?U(e,t.eq):void 0;if(!n)throw new Error("Cannot create variable without an initial value.");return`${e.pre}var ${r} = ${x(e,n)};`}return"block"in t?dt(e,t):`${e.pre}${x(e,U(e,t))};`}function Be(e,t){return dt(e,t)}var _typedbinary = require('typed-binary');function $t(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 T=$t;function z(e,t){t>=0?e.writeByte(t&127):e.writeByte(t&127|128)}function q(e){let t=e.readByte();return t&128?(t&127)-128:t&127}var h={bool(e,t,r){e.writeBool(r)},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,n);for(let[a,o]of Object.entries(t.propTypes))T(e,_chunkW7MD3ZVBcjs.ma.call(void 0, o)),K(e,o,r[a]);T(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)T(e,n),K(e,t.elementType,r[o]);e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t))},atomic(e,t,r){var n;(n=h[t.inner.type])==null||n.call(h,e,t,r)},decorated(e,t,r){var o,i;let n=_chunkW7MD3ZVBcjs.na.call(void 0, t);T(e,n);let a=e.currentByteOffset;(i=h[(o=t.inner)==null?void 0:o.type])==null||i.call(h,e,t.inner,r),e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t))},uint8x2(e,t,r){e.writeByte(r.x),e.writeByte(r.y)},uint8x4(e,t,r){e.writeByte(r.x),e.writeByte(r.y),e.writeByte(r.z),e.writeByte(r.w)},sint8x2(e,t,r){z(e,r.x),z(e,r.y)},sint8x4(e,t,r){z(e,r.x),z(e,r.y),z(e,r.z),z(e,r.w)},unorm8x2(e,t,r){e.writeByte(Math.floor(r.x*255)),e.writeByte(Math.floor(r.y*255))},unorm8x4(e,t,r){e.writeByte(Math.floor(r.x*255)),e.writeByte(Math.floor(r.y*255)),e.writeByte(Math.floor(r.z*255)),e.writeByte(Math.floor(r.w*255))},snorm8x2(e,t,r){e.writeByte(Math.floor(r.x*127+128)),e.writeByte(Math.floor(r.y*127+128))},snorm8x4(e,t,r){e.writeByte(Math.floor(r.x*127+128)),e.writeByte(Math.floor(r.y*127+128)),e.writeByte(Math.floor(r.z*127+128)),e.writeByte(Math.floor(r.w*127+128))},uint16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,r.x,o),a.setUint16(2,r.y,o),e.writeSlice(new Uint8Array(n))},uint16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,r.x,o),a.setUint16(2,r.y,o),a.setUint16(4,r.z,o),a.setUint16(6,r.w,o),e.writeSlice(new Uint8Array(n))},sint16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setInt16(0,r.x,o),a.setInt16(2,r.y,o),e.writeSlice(new Uint8Array(n))},sint16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setInt16(0,r.x,o),a.setInt16(2,r.y,o),a.setInt16(4,r.z,o),a.setInt16(6,r.w,o),e.writeSlice(new Uint8Array(n))},unorm16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*65535),o),a.setUint16(2,Math.floor(r.y*65535),o),e.writeSlice(new Uint8Array(n))},unorm16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*65535),o),a.setUint16(2,Math.floor(r.y*65535),o),a.setUint16(4,Math.floor(r.z*65535),o),a.setUint16(6,Math.floor(r.w*65535),o),e.writeSlice(new Uint8Array(n))},snorm16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*32767+32768),o),a.setUint16(2,Math.floor(r.y*32767+32768),o),e.writeSlice(new Uint8Array(n))},snorm16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*32767+32768),o),a.setUint16(2,Math.floor(r.y*32767+32768),o),a.setUint16(4,Math.floor(r.z*32767+32768),o),a.setUint16(6,Math.floor(r.w*32767+32768),o),e.writeSlice(new Uint8Array(n))},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)},"loose-array"(e,t,r){var o,i;let n=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,n);let a=e.currentByteOffset;for(let p=0;p<Math.min(t.elementCount,r.length);p++)T(e,n),(i=h[(o=t.elementType)==null?void 0:o.type])==null||i.call(h,e,t.elementType,r[p]);e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t))},"loose-struct"(e,t,r){var n;for(let[a,o]of Object.entries(t.propTypes))(n=h[o.type])==null||n.call(h,e,o,r[a])},"loose-decorated"(e,t,r){var i;let n=_chunkW7MD3ZVBcjs.na.call(void 0, t);T(e,n);let a=e.currentByteOffset,o=h[(i=t.inner)==null?void 0:i.type];return o==null||o(e,t.inner,r),e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t)),r}};function K(e,t,r){let n=h[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var Ot={bool(e){return e.readBool()},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunkW7MD3ZVBcjs.z.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkW7MD3ZVBcjs.C.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkW7MD3ZVBcjs.F.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2i(e){return _chunkW7MD3ZVBcjs.A.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkW7MD3ZVBcjs.D.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkW7MD3ZVBcjs.G.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkW7MD3ZVBcjs.B.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkW7MD3ZVBcjs.E.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkW7MD3ZVBcjs.H.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},mat2x2f(e){return _chunkW7MD3ZVBcjs.Aa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkW7MD3ZVBcjs.Ba.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkW7MD3ZVBcjs.Ca.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=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))T(e,_chunkW7MD3ZVBcjs.ma.call(void 0, o)),n[a]=_(e,o);return T(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkW7MD3ZVBcjs.ma.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){T(e,r);let o=t.elementType,i=_(e,o);n.push(i)}return T(e,r),n},atomic(e,t){return _(e,t.inner)},decorated(e,t){let r=_chunkW7MD3ZVBcjs.na.call(void 0, t);T(e,r);let n=e.currentByteOffset,a=_(e,t.inner);return e.seekTo(n+_chunkW7MD3ZVBcjs.pa.call(void 0, t)),a},uint8x2:e=>_chunkW7MD3ZVBcjs.B.call(void 0, e.readByte(),e.readByte()),uint8x4:e=>_chunkW7MD3ZVBcjs.H.call(void 0, e.readByte(),e.readByte(),e.readByte(),e.readByte()),sint8x2:e=>_chunkW7MD3ZVBcjs.A.call(void 0, q(e),q(e)),sint8x4:e=>_chunkW7MD3ZVBcjs.G.call(void 0, q(e),q(e),q(e),q(e)),unorm8x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, e.readByte()/255,e.readByte()/255),unorm8x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, e.readByte()/255,e.readByte()/255,e.readByte()/255,e.readByte()/255),snorm8x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, (e.readByte()-128)/127,(e.readByte()-128)/127),snorm8x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, (e.readByte()-128)/127,(e.readByte()-128)/127,(e.readByte()-128)/127,(e.readByte()-128)/127),uint16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.B.call(void 0, r.getUint16(0,n),r.getUint16(2,n))},uint16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.H.call(void 0, r.getUint16(0,n),r.getUint16(2,n),r.getUint16(4,n),r.getUint16(6,n))},sint16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.A.call(void 0, r.getInt16(0,n),r.getInt16(2,n))},sint16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.G.call(void 0, r.getInt16(0,n),r.getInt16(2,n),r.getInt16(4,n),r.getInt16(6,n))},unorm16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.z.call(void 0, r.getUint16(0,n)/65535,r.getUint16(2,n)/65535)},unorm16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.F.call(void 0, r.getUint16(0,n)/65535,r.getUint16(2,n)/65535,r.getUint16(4,n)/65535,r.getUint16(6,n)/65535)},snorm16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.z.call(void 0, (r.getUint16(0,n)-32768)/32767,(r.getUint16(2,n)-32768)/32767)},snorm16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.F.call(void 0, (r.getUint16(0,n)-32768)/32767,(r.getUint16(2,n)-32768)/32767,(r.getUint16(4,n)-32768)/32767,(r.getUint16(6,n)-32768)/32767)},float16x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkW7MD3ZVBcjs.C.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkW7MD3ZVBcjs.B.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkW7MD3ZVBcjs.E.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkW7MD3ZVBcjs.H.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkW7MD3ZVBcjs.A.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkW7MD3ZVBcjs.D.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkW7MD3ZVBcjs.G.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 _chunkW7MD3ZVBcjs.F.call(void 0, r,n,a,o)},"loose-struct"(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=_(e,a);return r},"loose-array"(e,t){let r=_chunkW7MD3ZVBcjs.ma.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)T(e,r),n.push(_(e,t.elementType));return T(e,r),n},"loose-decorated"(e,t){T(e,_chunkW7MD3ZVBcjs.na.call(void 0, t));let r=e.currentByteOffset,n=_(e,t.inner);return e.seekTo(r+_chunkW7MD3ZVBcjs.pa.call(void 0, t)),n}};function _(e,t){let r=Ot[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function mt(e,t,r){return new Ae(e,t,r)}function G(e){return e.resourceType==="buffer"}function Ee(e){return!!e.usableAsUniform}function Wt(e){return!!e.usableAsVertex}var Ae=class{constructor(t,r,n){this._group=t;this.dataType=r;this.initialOrBuffer=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","buffer");_chunkW7MD3ZVBcjs.c.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_device",null);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_buffer",null);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_destroyed",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"initial");_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsUniform",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsStorage",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsVertex",!1);ut(n)?this._buffer=n:this.initial=n}get label(){return this._label}get buffer(){var t;if(!this._device)throw new Error("Create this buffer using `root.createBuffer` instead of `tgpu.createBuffer`.");if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=this._device.createBuffer({size:_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:(t=this.label)!=null?t:"<unnamed>"}),this.initial)){let r=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());K(r,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get device(){if(!this._device)throw new Error("This buffer has not been assigned a device. Use .$device(device) to assign a device");return this._device}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)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){return this.flags|=t,this}$device(t){return this._device=t,this}write(t){let r=this.buffer,n=this.device;if(r.mapState==="mapped"){let o=r.getMappedRange();if(G(t))throw new Error("Cannot copy to a mapped buffer.");K(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType);if(G(t)){let o=t.buffer;if(this._group)this._group.commandEncoder.copyBufferToBuffer(o,0,r,0,a);else{let i=n.createCommandEncoder();i.copyBufferToBuffer(o,0,r,0,a),n.queue.submit([i.finish()])}}else{this._group&&this._group.flush();let o=new ArrayBuffer(a);K(new (0, _typedbinary.BufferWriter)(o),this.dataType,t),n.queue.writeBuffer(r,0,o,0,a)}}async read(){this._group&&this._group.flush();let t=this.buffer,r=this.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return _(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),p=_(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),p}let n=r.createBuffer({size:_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType));let o=_(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._buffer)==null||t.destroy())}toString(){var t;return`buffer:${(t=this._label)!=null?t:"<unnamed>"}`}};function oe(e){return!!(e!=null&&e.usableAsStorage)}var ae=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};var Nt={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"};var ee=class{constructor(t,r,n){this.usage=t;this.dataType=r;this._membership=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"~repr");_chunkW7MD3ZVBcjs.c.call(void 0, 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=Nt[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunkW7MD3ZVBcjs.t.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return this}};function jt(e){return(e==null?void 0:e.resourceType)==="sampler"}function zt(e){return(e==null?void 0:e.resourceType)==="sampler-comparison"}var ie=class{constructor(t){this._membership=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","sampler")}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}},se=class{constructor(t){this._membership=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","sampler-comparison")}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}};var ue=class{constructor(t){this._membership=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","external-texture")}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}};var gt={r8unorm:_chunkW7MD3ZVBcjs.x,r8snorm:_chunkW7MD3ZVBcjs.x,r8uint:_chunkW7MD3ZVBcjs.v,r8sint:_chunkW7MD3ZVBcjs.w,r16uint:_chunkW7MD3ZVBcjs.v,r16sint:_chunkW7MD3ZVBcjs.w,r16float:_chunkW7MD3ZVBcjs.x,rg8unorm:_chunkW7MD3ZVBcjs.x,rg8snorm:_chunkW7MD3ZVBcjs.x,rg8uint:_chunkW7MD3ZVBcjs.v,rg8sint:_chunkW7MD3ZVBcjs.w,r32uint:_chunkW7MD3ZVBcjs.v,r32sint:_chunkW7MD3ZVBcjs.w,r32float:_chunkW7MD3ZVBcjs.x,rg16uint:_chunkW7MD3ZVBcjs.v,rg16sint:_chunkW7MD3ZVBcjs.w,rg16float:_chunkW7MD3ZVBcjs.x,rgba8unorm:_chunkW7MD3ZVBcjs.x,"rgba8unorm-srgb":_chunkW7MD3ZVBcjs.x,rgba8snorm:_chunkW7MD3ZVBcjs.x,rgba8uint:_chunkW7MD3ZVBcjs.v,rgba8sint:_chunkW7MD3ZVBcjs.w,bgra8unorm:_chunkW7MD3ZVBcjs.x,"bgra8unorm-srgb":_chunkW7MD3ZVBcjs.x,rgb9e5ufloat:_chunkW7MD3ZVBcjs.x,rgb10a2uint:_chunkW7MD3ZVBcjs.v,rgb10a2unorm:_chunkW7MD3ZVBcjs.x,rg11b10ufloat:_chunkW7MD3ZVBcjs.x,rg32uint:_chunkW7MD3ZVBcjs.v,rg32sint:_chunkW7MD3ZVBcjs.w,rg32float:_chunkW7MD3ZVBcjs.x,rgba16uint:_chunkW7MD3ZVBcjs.v,rgba16sint:_chunkW7MD3ZVBcjs.w,rgba16float:_chunkW7MD3ZVBcjs.x,rgba32uint:_chunkW7MD3ZVBcjs.v,rgba32sint:_chunkW7MD3ZVBcjs.w,rgba32float:_chunkW7MD3ZVBcjs.x,stencil8:_chunkW7MD3ZVBcjs.x,depth16unorm:_chunkW7MD3ZVBcjs.x,depth24plus:_chunkW7MD3ZVBcjs.x,"depth24plus-stencil8":_chunkW7MD3ZVBcjs.x,depth32float:_chunkW7MD3ZVBcjs.x,"depth32float-stencil8":_chunkW7MD3ZVBcjs.x,"bc1-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc1-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"bc2-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc2-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"bc3-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc3-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"bc4-r-unorm":_chunkW7MD3ZVBcjs.x,"bc4-r-snorm":_chunkW7MD3ZVBcjs.x,"bc5-rg-unorm":_chunkW7MD3ZVBcjs.x,"bc5-rg-snorm":_chunkW7MD3ZVBcjs.x,"bc6h-rgb-ufloat":_chunkW7MD3ZVBcjs.x,"bc6h-rgb-float":_chunkW7MD3ZVBcjs.x,"bc7-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc7-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"etc2-rgb8unorm":_chunkW7MD3ZVBcjs.x,"etc2-rgb8unorm-srgb":_chunkW7MD3ZVBcjs.x,"etc2-rgb8a1unorm":_chunkW7MD3ZVBcjs.x,"etc2-rgb8a1unorm-srgb":_chunkW7MD3ZVBcjs.x,"etc2-rgba8unorm":_chunkW7MD3ZVBcjs.x,"etc2-rgba8unorm-srgb":_chunkW7MD3ZVBcjs.x,"eac-r11unorm":_chunkW7MD3ZVBcjs.x,"eac-r11snorm":_chunkW7MD3ZVBcjs.x,"eac-rg11unorm":_chunkW7MD3ZVBcjs.x,"eac-rg11snorm":_chunkW7MD3ZVBcjs.x,"astc-4x4-unorm":_chunkW7MD3ZVBcjs.x,"astc-4x4-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-5x4-unorm":_chunkW7MD3ZVBcjs.x,"astc-5x4-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-5x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-5x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-6x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-6x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-6x6-unorm":_chunkW7MD3ZVBcjs.x,"astc-6x6-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-8x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-8x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-8x6-unorm":_chunkW7MD3ZVBcjs.x,"astc-8x6-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-8x8-unorm":_chunkW7MD3ZVBcjs.x,"astc-8x8-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x6-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x6-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x8-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x8-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x10-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x10-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-12x10-unorm":_chunkW7MD3ZVBcjs.x,"astc-12x10-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-12x12-unorm":_chunkW7MD3ZVBcjs.x,"astc-12x12-unorm-srgb":_chunkW7MD3ZVBcjs.x},te={rgba8unorm:_chunkW7MD3ZVBcjs.F,rgba8snorm:_chunkW7MD3ZVBcjs.F,rgba8uint:_chunkW7MD3ZVBcjs.H,rgba8sint:_chunkW7MD3ZVBcjs.G,rgba16uint:_chunkW7MD3ZVBcjs.H,rgba16sint:_chunkW7MD3ZVBcjs.G,rgba16float:_chunkW7MD3ZVBcjs.F,r32uint:_chunkW7MD3ZVBcjs.H,r32sint:_chunkW7MD3ZVBcjs.G,r32float:_chunkW7MD3ZVBcjs.F,rg32uint:_chunkW7MD3ZVBcjs.H,rg32sint:_chunkW7MD3ZVBcjs.G,rg32float:_chunkW7MD3ZVBcjs.F,rgba32uint:_chunkW7MD3ZVBcjs.H,rgba32sint:_chunkW7MD3ZVBcjs.G,rgba32float:_chunkW7MD3ZVBcjs.F,bgra8unorm:_chunkW7MD3ZVBcjs.F},ft={f32:"float",u32:"uint",i32:"sint"},Tt={float:_chunkW7MD3ZVBcjs.x,"unfilterable-float":_chunkW7MD3ZVBcjs.x,uint:_chunkW7MD3ZVBcjs.v,sint:_chunkW7MD3ZVBcjs.w,depth:_chunkW7MD3ZVBcjs.x};function yt(e,t){return new Pe(e,t)}function I(e){return(e==null?void 0:e.resourceType)==="texture"}function Ge(e){return(e==null?void 0:e.resourceType)==="texture-storage-view"}function Ie(e){return(e==null?void 0:e.resourceType)==="texture-sampled-view"}var ct={mutable:"read_write",readonly:"read",writeonly:"write"},Pe=class{constructor(t,r){this.props=t;this._branch=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture");_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsSampled",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsStorage",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsRender",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_destroyed",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_flags",GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_texture",null)}get label(){return this._label}$name(t){return this._label=t,this}unwrap(){var t,r,n,a,o;if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:(t=this._label)!=null?t:"<unnamed>",format:this.props.format,size:this.props.size,usage:this._flags,dimension:(r=this.props.dimension)!=null?r:"2d",viewFormats:(n=this.props.viewFormats)!=null?n:[],mipLevelCount:(a=this.props.mipLevelCount)!=null?a:1,sampleCount:(o=this.props.sampleCount)!=null?o:1})),this._texture}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||(this.usableAsStorage=r),this.usableAsSampled||(this.usableAsSampled=n),this.usableAsRender||(this.usableAsRender=a),this}_asStorage(t,r){var o;if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=(o=t==null?void 0:t.format)!=null?o:this.props.format,a=te[n];return Z(!!a,`Unsupported storage texture format: ${n}`),new Re(t!=null?t:{},r,this)}asReadonly(t){return this._asStorage(t,"readonly")}asWriteonly(t){return this._asStorage(t,"writeonly")}asMutable(t){return this._asStorage(t,"mutable")}asSampled(t){var a;if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=(a=t==null?void 0:t.format)!=null?a:this.props.format;if(!te[r])throw new Error(`Unsupported storage texture format: ${r}`);return new Le(t,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._texture)==null||t.destroy())}},de={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},Re=class{constructor(t,r,n){this.access=r;this._texture=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"texelDataType");_chunkW7MD3ZVBcjs.c.call(void 0, this,"dimension");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_format");var a,o,i;this.dimension=(o=(a=t==null?void 0:t.dimension)!=null?a:n.props.dimension)!=null?o:"2d",this._format=(i=t==null?void 0:t.format)!=null?i:n.props.format,this.texelDataType=te[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView({label:`${(t=this.label)!=null?t:"<unnamed>"} - View`,format:this._format,dimension:this.dimension})),this._view}resolve(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${de[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${ct[this.access]}>;`),r}},pe=class{constructor(t,r,n,a){this._format=t;this.dimension=r;this.access=n;this._membership=a;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"texelDataType");this.texelDataType=te[this._format]}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${de[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${ct[this.access]}>;`),r}},Le=class{constructor(t,r){this._props=t;this._texture=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"channelDataType");_chunkW7MD3ZVBcjs.c.call(void 0, this,"dimension");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_format");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_view");var n,a,o;this.dimension=(a=(n=t==null?void 0:t.dimension)!=null?n:r.props.dimension)!=null?a:"2d",this._format=(o=t==null?void 0:t.format)!=null?o:r.props.format,this.channelDataType=gt[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView(_chunkW7MD3ZVBcjs.a.call(void 0, {label:`${(t=this.label)!=null?t:"<unnamed>"} - View`},this._props))),this._view}resolve(t){var p;let r=t.names.makeUnique(this.label),n=((p=this._texture.props.sampleCount)!=null?p:1)>1,{group:a,binding:o}=t.allocateFixedEntry({texture:ft[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${de[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}},le=class{constructor(t,r,n,a){this.dimension=r;this._multisampled=n;this._membership=a;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"channelDataType");this.channelDataType=Tt[t]}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${de[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}};function Ce(e){return!!(e!=null&&e.usableAsSampled)}function qt(e){return!!(e!=null&&e.usableAsRender)}var me=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function ge(e){return new ke(e)}function fe(e){return!!e&&e.resourceType==="bind-group-layout"}function bt(e){return!!e&&e.resourceType==="bind-group"}var Ve=class e extends Error{constructor(t,r){super(`Bind group '${t!=null?t:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},xt=["compute"],J=["compute","vertex","fragment"],ke=class{constructor(t){this.entries=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"_label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_index");_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","bind-group-layout");_chunkW7MD3ZVBcjs.c.call(void 0, this,"bound",{});var n,a,o,i,p;let r=0;for(let[g,l]of Object.entries(t)){if(l===null){r++;continue}let d={idx:r,key:g,layout:this};if("uniform"in l&&(this.bound[g]=new ee("uniform",l.uniform,d)),"storage"in l){let f="type"in l.storage?l.storage:l.storage(0);this.bound[g]=new ee((n=l.access)!=null?n:"readonly",f,d)}"texture"in l&&(this.bound[g]=new le(l.texture,(a=l.viewDimension)!=null?a:"2d",(o=l.multisampled)!=null?o:!1,d)),"storageTexture"in l&&(this.bound[g]=new pe(l.storageTexture,(i=l.viewDimension)!=null?i:"2d",(p=l.access)!=null?p:"writeonly",d)),"externalTexture"in l&&(this.bound[g]=new ue(d)),"sampler"in l&&(l.sampler==="comparison"?this.bound[g]=new se(d):this.bound[g]=new ie(d)),r++}}get label(){return this._label}get index(){return this._index}$name(t){return this._label=t,this}$idx(t){return this._index=t,this}unwrap(t){var n;return t.device.createBindGroupLayout({label:(n=this.label)!=null?n:"<unnamed>",entries:Object.values(this.entries).map((a,o)=>{var g,l,d,f;if(a===null)return null;let i=a.visibility,p={binding:o,visibility:0};if("uniform"in a)i=i!=null?i:J,p.buffer={type:"uniform"};else if("storage"in a)i=i!=null?i:a.access==="mutable"?xt:J,p.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)i=i!=null?i:J,p.sampler={type:a.sampler};else if("texture"in a)i=i!=null?i:J,p.texture={sampleType:a.texture,viewDimension:(g=a.viewDimension)!=null?g:"2d",multisampled:(l=a.multisampled)!=null?l:!1};else if("storageTexture"in a){let m=(d=a.access)!=null?d:"writeonly";i=i!=null?i:m==="readonly"?J:xt,p.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[m],viewDimension:(f=a.viewDimension)!=null?f:"2d"}}else"externalTexture"in a&&(i=i!=null?i:J,p.externalTexture={});return i!=null&&i.includes("compute")&&(p.visibility|=GPUShaderStage.COMPUTE),i!=null&&i.includes("vertex")&&(p.visibility|=GPUShaderStage.VERTEX),i!=null&&i.includes("fragment")&&(p.visibility|=GPUShaderStage.FRAGMENT),p}).filter(a=>a!==null)})}populate(t){return new Me(this,t)}},Me=class{constructor(t,r){this.layout=t;this.entries=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new Ve(t.label,n)}unwrap(t){var n;return t.device.createBindGroup({label:(n=this.layout.label)!=null?n:"<unnamed>",layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,o],i)=>{var g;if(o===null)return null;let p=this.entries[a];if(p===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(g=this.layout.label)!=null?g:"<unnamed>"}'.`);if("uniform"in o){let l;if(G(p)){if(!Ee(p))throw new W(p);l={buffer:t.unwrap(p)}}else l={buffer:p};return{binding:i,resource:l}}if("storage"in o){let l;if(G(p)){if(!oe(p))throw new W(p);l={buffer:t.unwrap(p)}}else l={buffer:p};return{binding:i,resource:l}}if("texture"in o){let l;if(I(p)){if(!Ce(p))throw new me(p);l=t.unwrap(p.asSampled())}else l=p;return{binding:i,resource:l}}if("storageTexture"in o){let l;if(I(p)){if(!oe(p))throw new ae(p);o.access==="readonly"?l=t.unwrap(p.asReadonly()):o.access==="mutable"?l=t.unwrap(p.asMutable()):l=t.unwrap(p.asReadonly())}else l=p;return{binding:i,resource:l}}if("externalTexture"in o||"sampler"in o)return{binding:i,resource:p};throw new Error(`Malformed bind group entry: ${p} (${JSON.stringify(p)})`)}).filter(a=>a!==null)})}};var ht="#CATCHALL#",Oe=class{constructor(){_chunkW7MD3ZVBcjs.c.call(void 0, this,"_stack",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_itemDepth",0)}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}pushFunctionScope(t,r,n){this._stack.push({type:"functionScope",args:t,returnType:r,externalMap:n})}pop(){let t=this._stack.pop();(t==null?void 0:t.type)==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="item")n.usedSlots.add(t);else if((n==null?void 0:n.type)==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!((n==null?void 0:n.type)==="functionScope"||(n==null?void 0:n.type)==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getResourceById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:S}:void 0}if((n==null?void 0:n.type)==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return{value:t,dataType:a}}}}},Te=[""," "," "," "," "," "," "," "," "],$e=Te.length-1,We=class{constructor(){_chunkW7MD3ZVBcjs.c.call(void 0, this,"identLevel",0)}get pre(){var t;return(t=Te[this.identLevel])!=null?t:Te[$e].repeat(this.identLevel/$e)+Te[this.identLevel%$e]}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}},Ne=class{constructor(t){_chunkW7MD3ZVBcjs.c.call(void 0, this,"_memoizedResolves",new WeakMap);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_indentController",new We);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_jitTranspiler");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_itemStateStack",new Oe);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_declarations",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"bindGroupLayoutsToPlaceholderMap",new Map);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_nextFreeLayoutPlaceholderIdx",0);_chunkW7MD3ZVBcjs.c.call(void 0, this,"fixedBindings",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"names");this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){var r;return(r=this._itemStateStack.getResourceById(t))!=null?r:{value:t,dataType:S}}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);let r=Be(this,t.body);this._itemStateStack.pop();let n=t.args.map(a=>`${a.value}: ${this.resolve(a.dataType)}`).join(", ");return{head:t.returnType!==void 0?`(${n}) -> ${this.resolve(t.returnType)}`:`(${n})`,body:r}}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:ht,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new ne(t);return r}unwrap(t){let r=t;for(;pt(r);)r=this.readSlot(r);return r}_getOrInstantiate(t){var n;let r=(n=this._memoizedResolves.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([g,l])=>this._itemStateStack.readSlot(g)===l))return i.result;let a=_chunkW7MD3ZVBcjs.d.call(void 0, t)?De(this,t):t.resolve(this),o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedResolves.set(t,r),a}catch(a){throw a instanceof O?a.appendToTrace(t):new O(a,[t])}finally{this._itemStateStack.pop()}}resolve(t,r=[]){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return String(t);let n=!1;r.length>0&&(n=!0,this._itemStateStack.pushSlotBindings(r));try{if(this._itemStateStack.itemDepth===0){let a=_chunkW7MD3ZVBcjs.s.call(void 0, ()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
14
+ ${n}`}if("let"in t||"const"in t){let r=x(e,ve(e,"let"in t?t.let:t.const)),n=t.eq?U(e,t.eq):void 0;if(!n)throw new Error("Cannot create variable without an initial value.");return`${e.pre}var ${r} = ${x(e,n)};`}return"block"in t?dt(e,t):`${e.pre}${x(e,U(e,t))};`}function Fe(e,t){return dt(e,t)}var _typedbinary = require('typed-binary');function $t(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 T=$t;function z(e,t){t>=0?e.writeByte(t&127):e.writeByte(t&127|128)}function K(e){let t=e.readByte();return t&128?(t&127)-128:t&127}var h={bool(e,t,r){e.writeBool(r)},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,n);for(let[a,o]of Object.entries(t.propTypes))T(e,_chunkW7MD3ZVBcjs.ma.call(void 0, o)),q(e,o,r[a]);T(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)T(e,n),q(e,t.elementType,r[o]);e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t))},atomic(e,t,r){var n;(n=h[t.inner.type])==null||n.call(h,e,t,r)},decorated(e,t,r){var o,i;let n=_chunkW7MD3ZVBcjs.na.call(void 0, t);T(e,n);let a=e.currentByteOffset;(i=h[(o=t.inner)==null?void 0:o.type])==null||i.call(h,e,t.inner,r),e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t))},uint8x2(e,t,r){e.writeByte(r.x),e.writeByte(r.y)},uint8x4(e,t,r){e.writeByte(r.x),e.writeByte(r.y),e.writeByte(r.z),e.writeByte(r.w)},sint8x2(e,t,r){z(e,r.x),z(e,r.y)},sint8x4(e,t,r){z(e,r.x),z(e,r.y),z(e,r.z),z(e,r.w)},unorm8x2(e,t,r){e.writeByte(Math.floor(r.x*255)),e.writeByte(Math.floor(r.y*255))},unorm8x4(e,t,r){e.writeByte(Math.floor(r.x*255)),e.writeByte(Math.floor(r.y*255)),e.writeByte(Math.floor(r.z*255)),e.writeByte(Math.floor(r.w*255))},snorm8x2(e,t,r){e.writeByte(Math.floor(r.x*127+128)),e.writeByte(Math.floor(r.y*127+128))},snorm8x4(e,t,r){e.writeByte(Math.floor(r.x*127+128)),e.writeByte(Math.floor(r.y*127+128)),e.writeByte(Math.floor(r.z*127+128)),e.writeByte(Math.floor(r.w*127+128))},uint16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,r.x,o),a.setUint16(2,r.y,o),e.writeSlice(new Uint8Array(n))},uint16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,r.x,o),a.setUint16(2,r.y,o),a.setUint16(4,r.z,o),a.setUint16(6,r.w,o),e.writeSlice(new Uint8Array(n))},sint16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setInt16(0,r.x,o),a.setInt16(2,r.y,o),e.writeSlice(new Uint8Array(n))},sint16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setInt16(0,r.x,o),a.setInt16(2,r.y,o),a.setInt16(4,r.z,o),a.setInt16(6,r.w,o),e.writeSlice(new Uint8Array(n))},unorm16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*65535),o),a.setUint16(2,Math.floor(r.y*65535),o),e.writeSlice(new Uint8Array(n))},unorm16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*65535),o),a.setUint16(2,Math.floor(r.y*65535),o),a.setUint16(4,Math.floor(r.z*65535),o),a.setUint16(6,Math.floor(r.w*65535),o),e.writeSlice(new Uint8Array(n))},snorm16x2(e,t,r){let n=new ArrayBuffer(4),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*32767+32768),o),a.setUint16(2,Math.floor(r.y*32767+32768),o),e.writeSlice(new Uint8Array(n))},snorm16x4(e,t,r){let n=new ArrayBuffer(8),a=new DataView(n),o=e.endianness==="little";a.setUint16(0,Math.floor(r.x*32767+32768),o),a.setUint16(2,Math.floor(r.y*32767+32768),o),a.setUint16(4,Math.floor(r.z*32767+32768),o),a.setUint16(6,Math.floor(r.w*32767+32768),o),e.writeSlice(new Uint8Array(n))},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)},"loose-array"(e,t,r){var o,i;let n=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,n);let a=e.currentByteOffset;for(let p=0;p<Math.min(t.elementCount,r.length);p++)T(e,n),(i=h[(o=t.elementType)==null?void 0:o.type])==null||i.call(h,e,t.elementType,r[p]);e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t))},"loose-struct"(e,t,r){var n;for(let[a,o]of Object.entries(t.propTypes))(n=h[o.type])==null||n.call(h,e,o,r[a])},"loose-decorated"(e,t,r){var i;let n=_chunkW7MD3ZVBcjs.na.call(void 0, t);T(e,n);let a=e.currentByteOffset,o=h[(i=t.inner)==null?void 0:i.type];return o==null||o(e,t.inner,r),e.seekTo(a+_chunkW7MD3ZVBcjs.pa.call(void 0, t)),r}};function q(e,t,r){let n=h[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var Ot={bool(e){return e.readBool()},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunkW7MD3ZVBcjs.z.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunkW7MD3ZVBcjs.C.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunkW7MD3ZVBcjs.F.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2i(e){return _chunkW7MD3ZVBcjs.A.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunkW7MD3ZVBcjs.D.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunkW7MD3ZVBcjs.G.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunkW7MD3ZVBcjs.B.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunkW7MD3ZVBcjs.E.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunkW7MD3ZVBcjs.H.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},mat2x2f(e){return _chunkW7MD3ZVBcjs.Aa.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunkW7MD3ZVBcjs.Ba.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunkW7MD3ZVBcjs.Ca.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=_chunkW7MD3ZVBcjs.ma.call(void 0, t);T(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))T(e,_chunkW7MD3ZVBcjs.ma.call(void 0, o)),n[a]=_(e,o);return T(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkW7MD3ZVBcjs.ma.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){T(e,r);let o=t.elementType,i=_(e,o);n.push(i)}return T(e,r),n},atomic(e,t){return _(e,t.inner)},decorated(e,t){let r=_chunkW7MD3ZVBcjs.na.call(void 0, t);T(e,r);let n=e.currentByteOffset,a=_(e,t.inner);return e.seekTo(n+_chunkW7MD3ZVBcjs.pa.call(void 0, t)),a},uint8x2:e=>_chunkW7MD3ZVBcjs.B.call(void 0, e.readByte(),e.readByte()),uint8x4:e=>_chunkW7MD3ZVBcjs.H.call(void 0, e.readByte(),e.readByte(),e.readByte(),e.readByte()),sint8x2:e=>_chunkW7MD3ZVBcjs.A.call(void 0, K(e),K(e)),sint8x4:e=>_chunkW7MD3ZVBcjs.G.call(void 0, K(e),K(e),K(e),K(e)),unorm8x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, e.readByte()/255,e.readByte()/255),unorm8x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, e.readByte()/255,e.readByte()/255,e.readByte()/255,e.readByte()/255),snorm8x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, (e.readByte()-128)/127,(e.readByte()-128)/127),snorm8x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, (e.readByte()-128)/127,(e.readByte()-128)/127,(e.readByte()-128)/127,(e.readByte()-128)/127),uint16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.B.call(void 0, r.getUint16(0,n),r.getUint16(2,n))},uint16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.H.call(void 0, r.getUint16(0,n),r.getUint16(2,n),r.getUint16(4,n),r.getUint16(6,n))},sint16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.A.call(void 0, r.getInt16(0,n),r.getInt16(2,n))},sint16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.G.call(void 0, r.getInt16(0,n),r.getInt16(2,n),r.getInt16(4,n),r.getInt16(6,n))},unorm16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.z.call(void 0, r.getUint16(0,n)/65535,r.getUint16(2,n)/65535)},unorm16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.F.call(void 0, r.getUint16(0,n)/65535,r.getUint16(2,n)/65535,r.getUint16(4,n)/65535,r.getUint16(6,n)/65535)},snorm16x2(e){let t=new ArrayBuffer(4);e.readSlice(new Uint8Array(t),0,4);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.z.call(void 0, (r.getUint16(0,n)-32768)/32767,(r.getUint16(2,n)-32768)/32767)},snorm16x4(e){let t=new ArrayBuffer(8);e.readSlice(new Uint8Array(t),0,8);let r=new DataView(t),n=e.endianness==="little";return _chunkW7MD3ZVBcjs.F.call(void 0, (r.getUint16(0,n)-32768)/32767,(r.getUint16(2,n)-32768)/32767,(r.getUint16(4,n)-32768)/32767,(r.getUint16(6,n)-32768)/32767)},float16x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunkW7MD3ZVBcjs.z.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunkW7MD3ZVBcjs.C.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunkW7MD3ZVBcjs.F.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunkW7MD3ZVBcjs.B.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunkW7MD3ZVBcjs.E.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunkW7MD3ZVBcjs.H.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunkW7MD3ZVBcjs.A.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunkW7MD3ZVBcjs.D.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunkW7MD3ZVBcjs.G.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 _chunkW7MD3ZVBcjs.F.call(void 0, r,n,a,o)},"loose-struct"(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=_(e,a);return r},"loose-array"(e,t){let r=_chunkW7MD3ZVBcjs.ma.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)T(e,r),n.push(_(e,t.elementType));return T(e,r),n},"loose-decorated"(e,t){T(e,_chunkW7MD3ZVBcjs.na.call(void 0, t));let r=e.currentByteOffset,n=_(e,t.inner);return e.seekTo(r+_chunkW7MD3ZVBcjs.pa.call(void 0, t)),n}};function _(e,t){let r=Ot[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}function mt(e,t,r){return new Ee(e,t,r)}function G(e){return e.resourceType==="buffer"}function Pe(e){return!!e.usableAsUniform}function Wt(e){return!!e.usableAsVertex}var Ee=class{constructor(t,r,n){this._group=t;this.dataType=r;this.initialOrBuffer=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","buffer");_chunkW7MD3ZVBcjs.c.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_device",null);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_buffer",null);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_destroyed",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"initial");_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsUniform",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsStorage",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsVertex",!1);ut(n)?this._buffer=n:this.initial=n}get label(){return this._label}get buffer(){var t;if(!this._device)throw new Error("Create this buffer using `root.createBuffer` instead of `tgpu.createBuffer`.");if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=this._device.createBuffer({size:_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:(t=this.label)!=null?t:"<unnamed>"}),this.initial)){let r=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());q(r,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get device(){if(!this._device)throw new Error("This buffer has not been assigned a device. Use .$device(device) to assign a device");return this._device}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)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){return this.flags|=t,this}$device(t){return this._device=t,this}write(t){let r=this.buffer,n=this.device;if(r.mapState==="mapped"){let o=r.getMappedRange();if(G(t))throw new Error("Cannot copy to a mapped buffer.");q(new (0, _typedbinary.BufferWriter)(o),this.dataType,t);return}let a=_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType);if(G(t)){let o=t.buffer;if(this._group)this._group.commandEncoder.copyBufferToBuffer(o,0,r,0,a);else{let i=n.createCommandEncoder();i.copyBufferToBuffer(o,0,r,0,a),n.queue.submit([i.finish()])}}else{this._group&&this._group.flush();let o=new ArrayBuffer(a);q(new (0, _typedbinary.BufferWriter)(o),this.dataType,t),n.queue.writeBuffer(r,0,o,0,a)}}async read(){this._group&&this._group.flush();let t=this.buffer,r=this.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return _(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),p=_(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),p}let n=r.createBuffer({size:_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkW7MD3ZVBcjs.pa.call(void 0, this.dataType));let o=_(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._buffer)==null||t.destroy())}toString(){var t;return`buffer:${(t=this._label)!=null?t:"<unnamed>"}`}};function ie(e){return!!(e!=null&&e.usableAsStorage)}var oe=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};var Nt={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"};var ee=class{constructor(t,r,n){this.usage=t;this.dataType=r;this._membership=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"~repr");_chunkW7MD3ZVBcjs.c.call(void 0, 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=Nt[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunkW7MD3ZVBcjs.t.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return this}};function jt(e){return(e==null?void 0:e.resourceType)==="sampler"}function zt(e){return(e==null?void 0:e.resourceType)==="sampler-comparison"}var se=class{constructor(t){this._membership=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","sampler")}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}},ue=class{constructor(t){this._membership=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","sampler-comparison")}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}};var pe=class{constructor(t){this._membership=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","external-texture")}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}};var gt={r8unorm:_chunkW7MD3ZVBcjs.x,r8snorm:_chunkW7MD3ZVBcjs.x,r8uint:_chunkW7MD3ZVBcjs.v,r8sint:_chunkW7MD3ZVBcjs.w,r16uint:_chunkW7MD3ZVBcjs.v,r16sint:_chunkW7MD3ZVBcjs.w,r16float:_chunkW7MD3ZVBcjs.x,rg8unorm:_chunkW7MD3ZVBcjs.x,rg8snorm:_chunkW7MD3ZVBcjs.x,rg8uint:_chunkW7MD3ZVBcjs.v,rg8sint:_chunkW7MD3ZVBcjs.w,r32uint:_chunkW7MD3ZVBcjs.v,r32sint:_chunkW7MD3ZVBcjs.w,r32float:_chunkW7MD3ZVBcjs.x,rg16uint:_chunkW7MD3ZVBcjs.v,rg16sint:_chunkW7MD3ZVBcjs.w,rg16float:_chunkW7MD3ZVBcjs.x,rgba8unorm:_chunkW7MD3ZVBcjs.x,"rgba8unorm-srgb":_chunkW7MD3ZVBcjs.x,rgba8snorm:_chunkW7MD3ZVBcjs.x,rgba8uint:_chunkW7MD3ZVBcjs.v,rgba8sint:_chunkW7MD3ZVBcjs.w,bgra8unorm:_chunkW7MD3ZVBcjs.x,"bgra8unorm-srgb":_chunkW7MD3ZVBcjs.x,rgb9e5ufloat:_chunkW7MD3ZVBcjs.x,rgb10a2uint:_chunkW7MD3ZVBcjs.v,rgb10a2unorm:_chunkW7MD3ZVBcjs.x,rg11b10ufloat:_chunkW7MD3ZVBcjs.x,rg32uint:_chunkW7MD3ZVBcjs.v,rg32sint:_chunkW7MD3ZVBcjs.w,rg32float:_chunkW7MD3ZVBcjs.x,rgba16uint:_chunkW7MD3ZVBcjs.v,rgba16sint:_chunkW7MD3ZVBcjs.w,rgba16float:_chunkW7MD3ZVBcjs.x,rgba32uint:_chunkW7MD3ZVBcjs.v,rgba32sint:_chunkW7MD3ZVBcjs.w,rgba32float:_chunkW7MD3ZVBcjs.x,stencil8:_chunkW7MD3ZVBcjs.x,depth16unorm:_chunkW7MD3ZVBcjs.x,depth24plus:_chunkW7MD3ZVBcjs.x,"depth24plus-stencil8":_chunkW7MD3ZVBcjs.x,depth32float:_chunkW7MD3ZVBcjs.x,"depth32float-stencil8":_chunkW7MD3ZVBcjs.x,"bc1-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc1-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"bc2-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc2-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"bc3-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc3-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"bc4-r-unorm":_chunkW7MD3ZVBcjs.x,"bc4-r-snorm":_chunkW7MD3ZVBcjs.x,"bc5-rg-unorm":_chunkW7MD3ZVBcjs.x,"bc5-rg-snorm":_chunkW7MD3ZVBcjs.x,"bc6h-rgb-ufloat":_chunkW7MD3ZVBcjs.x,"bc6h-rgb-float":_chunkW7MD3ZVBcjs.x,"bc7-rgba-unorm":_chunkW7MD3ZVBcjs.x,"bc7-rgba-unorm-srgb":_chunkW7MD3ZVBcjs.x,"etc2-rgb8unorm":_chunkW7MD3ZVBcjs.x,"etc2-rgb8unorm-srgb":_chunkW7MD3ZVBcjs.x,"etc2-rgb8a1unorm":_chunkW7MD3ZVBcjs.x,"etc2-rgb8a1unorm-srgb":_chunkW7MD3ZVBcjs.x,"etc2-rgba8unorm":_chunkW7MD3ZVBcjs.x,"etc2-rgba8unorm-srgb":_chunkW7MD3ZVBcjs.x,"eac-r11unorm":_chunkW7MD3ZVBcjs.x,"eac-r11snorm":_chunkW7MD3ZVBcjs.x,"eac-rg11unorm":_chunkW7MD3ZVBcjs.x,"eac-rg11snorm":_chunkW7MD3ZVBcjs.x,"astc-4x4-unorm":_chunkW7MD3ZVBcjs.x,"astc-4x4-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-5x4-unorm":_chunkW7MD3ZVBcjs.x,"astc-5x4-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-5x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-5x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-6x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-6x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-6x6-unorm":_chunkW7MD3ZVBcjs.x,"astc-6x6-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-8x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-8x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-8x6-unorm":_chunkW7MD3ZVBcjs.x,"astc-8x6-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-8x8-unorm":_chunkW7MD3ZVBcjs.x,"astc-8x8-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x5-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x5-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x6-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x6-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x8-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x8-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-10x10-unorm":_chunkW7MD3ZVBcjs.x,"astc-10x10-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-12x10-unorm":_chunkW7MD3ZVBcjs.x,"astc-12x10-unorm-srgb":_chunkW7MD3ZVBcjs.x,"astc-12x12-unorm":_chunkW7MD3ZVBcjs.x,"astc-12x12-unorm-srgb":_chunkW7MD3ZVBcjs.x},te={rgba8unorm:_chunkW7MD3ZVBcjs.F,rgba8snorm:_chunkW7MD3ZVBcjs.F,rgba8uint:_chunkW7MD3ZVBcjs.H,rgba8sint:_chunkW7MD3ZVBcjs.G,rgba16uint:_chunkW7MD3ZVBcjs.H,rgba16sint:_chunkW7MD3ZVBcjs.G,rgba16float:_chunkW7MD3ZVBcjs.F,r32uint:_chunkW7MD3ZVBcjs.H,r32sint:_chunkW7MD3ZVBcjs.G,r32float:_chunkW7MD3ZVBcjs.F,rg32uint:_chunkW7MD3ZVBcjs.H,rg32sint:_chunkW7MD3ZVBcjs.G,rg32float:_chunkW7MD3ZVBcjs.F,rgba32uint:_chunkW7MD3ZVBcjs.H,rgba32sint:_chunkW7MD3ZVBcjs.G,rgba32float:_chunkW7MD3ZVBcjs.F,bgra8unorm:_chunkW7MD3ZVBcjs.F},ft={f32:"float",u32:"uint",i32:"sint"},Tt={float:_chunkW7MD3ZVBcjs.x,"unfilterable-float":_chunkW7MD3ZVBcjs.x,uint:_chunkW7MD3ZVBcjs.v,sint:_chunkW7MD3ZVBcjs.w,depth:_chunkW7MD3ZVBcjs.x};function yt(e,t){return new Re(e,t)}function I(e){return(e==null?void 0:e.resourceType)==="texture"}function Ie(e){return(e==null?void 0:e.resourceType)==="texture-storage-view"}function Ce(e){return(e==null?void 0:e.resourceType)==="texture-sampled-view"}var ct={mutable:"read_write",readonly:"read",writeonly:"write"},Re=class{constructor(t,r){this.props=t;this._branch=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture");_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsSampled",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsStorage",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"usableAsRender",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_destroyed",!1);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_flags",GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_texture",null)}get label(){return this._label}$name(t){return this._label=t,this}unwrap(){var t,r,n,a,o;if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:(t=this._label)!=null?t:"<unnamed>",format:this.props.format,size:this.props.size,usage:this._flags,dimension:(r=this.props.dimension)!=null?r:"2d",viewFormats:(n=this.props.viewFormats)!=null?n:[],mipLevelCount:(a=this.props.mipLevelCount)!=null?a:1,sampleCount:(o=this.props.sampleCount)!=null?o:1})),this._texture}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||(this.usableAsStorage=r),this.usableAsSampled||(this.usableAsSampled=n),this.usableAsRender||(this.usableAsRender=a),this}_asStorage(t,r){var o;if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=(o=t==null?void 0:t.format)!=null?o:this.props.format,a=te[n];return Z(!!a,`Unsupported storage texture format: ${n}`),new Le(t!=null?t:{},r,this)}asReadonly(t){return this._asStorage(t,"readonly")}asWriteonly(t){return this._asStorage(t,"writeonly")}asMutable(t){return this._asStorage(t,"mutable")}asSampled(t){var a;if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=(a=t==null?void 0:t.format)!=null?a:this.props.format;if(!te[r])throw new Error(`Unsupported storage texture format: ${r}`);return new Ge(t,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._texture)==null||t.destroy())}},me={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},Le=class{constructor(t,r,n){this.access=r;this._texture=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"texelDataType");_chunkW7MD3ZVBcjs.c.call(void 0, this,"dimension");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_format");var a,o,i;this.dimension=(o=(a=t==null?void 0:t.dimension)!=null?a:n.props.dimension)!=null?o:"2d",this._format=(i=t==null?void 0:t.format)!=null?i:n.props.format,this.texelDataType=te[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView({label:`${(t=this.label)!=null?t:"<unnamed>"} - View`,format:this._format,dimension:this.dimension})),this._view}resolve(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${me[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${ct[this.access]}>;`),r}},le=class{constructor(t,r,n,a){this._format=t;this.dimension=r;this.access=n;this._membership=a;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"texelDataType");this.texelDataType=te[this._format]}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${me[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${ct[this.access]}>;`),r}},Ge=class{constructor(t,r){this._props=t;this._texture=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"channelDataType");_chunkW7MD3ZVBcjs.c.call(void 0, this,"dimension");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_format");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_view");var n,a,o;this.dimension=(a=(n=t==null?void 0:t.dimension)!=null?n:r.props.dimension)!=null?a:"2d",this._format=(o=t==null?void 0:t.format)!=null?o:r.props.format,this.channelDataType=gt[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView(_chunkW7MD3ZVBcjs.a.call(void 0, {label:`${(t=this.label)!=null?t:"<unnamed>"} - View`},this._props))),this._view}resolve(t){var p;let r=t.names.makeUnique(this.label),n=((p=this._texture.props.sampleCount)!=null?p:1)>1,{group:a,binding:o}=t.allocateFixedEntry({texture:ft[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${me[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}},de=class{constructor(t,r,n,a){this.dimension=r;this._multisampled=n;this._membership=a;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunkW7MD3ZVBcjs.c.call(void 0, this,"channelDataType");this.channelDataType=Tt[t]}get label(){return this._membership.key}resolve(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${me[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}};function Ve(e){return!!(e!=null&&e.usableAsSampled)}function Kt(e){return!!(e!=null&&e.usableAsRender)}var ge=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function fe(e){return new Me(e)}function Te(e){return!!e&&e.resourceType==="bind-group-layout"}function bt(e){return!!e&&e.resourceType==="bind-group"}var ke=class e extends Error{constructor(t,r){super(`Bind group '${t!=null?t:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},xt=["compute"],J=["compute","vertex","fragment"],Me=class{constructor(t){this.entries=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"_label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_index");_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","bind-group-layout");_chunkW7MD3ZVBcjs.c.call(void 0, this,"bound",{});var n,a,o,i,p;let r=0;for(let[g,l]of Object.entries(t)){if(l===null){r++;continue}let d={idx:r,key:g,layout:this};if("uniform"in l&&(this.bound[g]=new ee("uniform",l.uniform,d)),"storage"in l){let f="type"in l.storage?l.storage:l.storage(0);this.bound[g]=new ee((n=l.access)!=null?n:"readonly",f,d)}"texture"in l&&(this.bound[g]=new de(l.texture,(a=l.viewDimension)!=null?a:"2d",(o=l.multisampled)!=null?o:!1,d)),"storageTexture"in l&&(this.bound[g]=new le(l.storageTexture,(i=l.viewDimension)!=null?i:"2d",(p=l.access)!=null?p:"writeonly",d)),"externalTexture"in l&&(this.bound[g]=new pe(d)),"sampler"in l&&(l.sampler==="comparison"?this.bound[g]=new ue(d):this.bound[g]=new se(d)),r++}}get label(){return this._label}get index(){return this._index}$name(t){return this._label=t,this}$idx(t){return this._index=t,this}unwrap(t){var n;return t.device.createBindGroupLayout({label:(n=this.label)!=null?n:"<unnamed>",entries:Object.values(this.entries).map((a,o)=>{var g,l,d,f;if(a===null)return null;let i=a.visibility,p={binding:o,visibility:0};if("uniform"in a)i=i!=null?i:J,p.buffer={type:"uniform"};else if("storage"in a)i=i!=null?i:a.access==="mutable"?xt:J,p.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)i=i!=null?i:J,p.sampler={type:a.sampler};else if("texture"in a)i=i!=null?i:J,p.texture={sampleType:a.texture,viewDimension:(g=a.viewDimension)!=null?g:"2d",multisampled:(l=a.multisampled)!=null?l:!1};else if("storageTexture"in a){let m=(d=a.access)!=null?d:"writeonly";i=i!=null?i:m==="readonly"?J:xt,p.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[m],viewDimension:(f=a.viewDimension)!=null?f:"2d"}}else"externalTexture"in a&&(i=i!=null?i:J,p.externalTexture={});return i!=null&&i.includes("compute")&&(p.visibility|=GPUShaderStage.COMPUTE),i!=null&&i.includes("vertex")&&(p.visibility|=GPUShaderStage.VERTEX),i!=null&&i.includes("fragment")&&(p.visibility|=GPUShaderStage.FRAGMENT),p}).filter(a=>a!==null)})}populate(t){return new re(this,t)}},re=class{constructor(t,r){this.layout=t;this.entries=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new ke(t.label,n)}unwrap(t){var n;return t.device.createBindGroup({label:(n=this.layout.label)!=null?n:"<unnamed>",layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,o],i)=>{var g;if(o===null)return null;let p=this.entries[a];if(p===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(g=this.layout.label)!=null?g:"<unnamed>"}'.`);if("uniform"in o){let l;if(G(p)){if(!Pe(p))throw new W(p);l={buffer:t.unwrap(p)}}else l={buffer:p};return{binding:i,resource:l}}if("storage"in o){let l;if(G(p)){if(!ie(p))throw new W(p);l={buffer:t.unwrap(p)}}else l={buffer:p};return{binding:i,resource:l}}if("texture"in o){let l;if(I(p)){if(!Ve(p))throw new ge(p);l=t.unwrap(p.asSampled())}else l=p;return{binding:i,resource:l}}if("storageTexture"in o){let l;if(I(p)){if(!ie(p))throw new oe(p);o.access==="readonly"?l=t.unwrap(p.asReadonly()):o.access==="mutable"?l=t.unwrap(p.asMutable()):l=t.unwrap(p.asReadonly())}else l=p;return{binding:i,resource:l}}if("externalTexture"in o||"sampler"in o)return{binding:i,resource:p};throw new Error(`Malformed bind group entry: ${p} (${JSON.stringify(p)})`)}).filter(a=>a!==null)})}};var ht="#CATCHALL#",Oe=class{constructor(){_chunkW7MD3ZVBcjs.c.call(void 0, this,"_stack",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_itemDepth",0)}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}pushFunctionScope(t,r,n){this._stack.push({type:"functionScope",args:t,returnType:r,externalMap:n})}pop(){let t=this._stack.pop();(t==null?void 0:t.type)==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="item")n.usedSlots.add(t);else if((n==null?void 0:n.type)==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!((n==null?void 0:n.type)==="functionScope"||(n==null?void 0:n.type)==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getResourceById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:S}:void 0}if((n==null?void 0:n.type)==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return{value:t,dataType:a}}}}},ye=[""," "," "," "," "," "," "," "," "],$e=ye.length-1,We=class{constructor(){_chunkW7MD3ZVBcjs.c.call(void 0, this,"identLevel",0)}get pre(){var t;return(t=ye[this.identLevel])!=null?t:ye[$e].repeat(this.identLevel/$e)+ye[this.identLevel%$e]}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}},Ne=class{constructor(t){_chunkW7MD3ZVBcjs.c.call(void 0, this,"_memoizedResolves",new WeakMap);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_indentController",new We);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_jitTranspiler");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_itemStateStack",new Oe);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_declarations",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"bindGroupLayoutsToPlaceholderMap",new Map);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_nextFreeLayoutPlaceholderIdx",0);_chunkW7MD3ZVBcjs.c.call(void 0, this,"fixedBindings",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"names");this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){var r;return(r=this._itemStateStack.getResourceById(t))!=null?r:{value:t,dataType:S}}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);let r=Fe(this,t.body);this._itemStateStack.pop();let n=t.args.map(a=>`${a.value}: ${this.resolve(a.dataType)}`).join(", ");return{head:t.returnType!==void 0?`(${n}) -> ${this.resolve(t.returnType)}`:`(${n})`,body:r}}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:ht,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new ae(t);return r}unwrap(t){let r=t;for(;pt(r);)r=this.readSlot(r);return r}_getOrInstantiate(t){var n;let r=(n=this._memoizedResolves.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([g,l])=>this._itemStateStack.readSlot(g)===l))return i.result;let a=_chunkW7MD3ZVBcjs.d.call(void 0, t)?Se(this,t):t.resolve(this),o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedResolves.set(t,r),a}catch(a){throw a instanceof O?a.appendToTrace(t):new O(a,[t])}finally{this._itemStateStack.pop()}}resolve(t,r=[]){if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")return String(t);let n=!1;r.length>0&&(n=!0,this._itemStateStack.pushSlotBindings(r));try{if(this._itemStateStack.itemDepth===0){let a=_chunkW7MD3ZVBcjs.s.call(void 0, ()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
15
15
 
16
- `)}${a}`}return this._getOrInstantiate(t)}finally{n&&this._itemStateStack.pop()}}};function Y(e,t){var f;let r=new Ne(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(m=>m.index).filter(m=>m!==void 0)),p=it(i),g=r.fixedBindings.map((m,c)=>[String(c),m.layoutEntry]),l=()=>{let m=p.next().value,c=ge(Object.fromEntries(g));return o[m]=c,n=n.replaceAll(ht,String(m)),[m,c.populate(Object.fromEntries(r.fixedBindings.map((b,A)=>[String(A),b.resource])))]},d=g.length>0?l():null;for(let[m,c]of a.entries()){let b=(f=m.index)!=null?f:p.next().value;o[b]=m,n=n.replaceAll(c,String(b))}return{code:n,bindGroupLayouts:o,catchall:d}}function wt(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function Dt(e,t){for(let[r,n]of Object.entries(t))e[r]=n,wt(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function St(e,t,r){return Object.entries(t).reduce((n,[a,o])=>{let i=j(o)||_chunkW7MD3ZVBcjs.d.call(void 0, o)?e.resolve(o):String(o);return n.replaceAll(new RegExp(`(?<![\\w_])${a}(?![\\w_])`,"g"),i)},r)}function Ut(e){let{input:t,extraDependencies:r,names:n,jitTranspiler:a}=e,o={};Dt(o,r!=null?r:{});let i=(Array.isArray(t)?t:[t]).filter(d=>typeof d=="string"),p=(Array.isArray(t)?t:[t]).filter(d=>typeof d!="string"),g={resolve(d){let f=i.join(`
16
+ `)}${a}`}return this._getOrInstantiate(t)}finally{n&&this._itemStateStack.pop()}}};function Y(e,t){var f;let r=new Ne(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(m=>m.index).filter(m=>m!==void 0)),p=it(i),g=r.fixedBindings.map((m,c)=>[String(c),m.layoutEntry]),l=()=>{let m=p.next().value,c=fe(Object.fromEntries(g));return o[m]=c,n=n.replaceAll(ht,String(m)),[m,c.populate(Object.fromEntries(r.fixedBindings.map((b,A)=>[String(A),b.resource])))]},d=g.length>0?l():null;for(let[m,c]of a.entries()){let b=(f=m.index)!=null?f:p.next().value;o[b]=m,n=n.replaceAll(c,String(b))}return{code:n,bindGroupLayouts:o,catchall:d}}function wt(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function Dt(e,t){for(let[r,n]of Object.entries(t))e[r]=n,wt(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function St(e,t,r){return Object.entries(t).reduce((n,[a,o])=>{let i=j(o)||_chunkW7MD3ZVBcjs.d.call(void 0, o)?e.resolve(o):String(o);return n.replaceAll(new RegExp(`(?<![\\w_])${a}(?![\\w_])`,"g"),i)},r)}function Ut(e){let{input:t,extraDependencies:r,names:n,jitTranspiler:a}=e,o={};Dt(o,r!=null?r:{});let i=(Array.isArray(t)?t:[t]).filter(d=>typeof d=="string"),p=(Array.isArray(t)?t:[t]).filter(d=>typeof d!="string"),g={resolve(d){let f=i.join(`
17
17
 
18
- `);for(let m of p)d.resolve(m);return St(d,o,f)}},{code:l}=Y(g,{names:n==="strict"?new k:new V,jitTranspiler:a});return l}var re=class{constructor(t){this._make=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"_map",new WeakMap)}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}};function vt(e,t,r){return new je(new ze(e,t,r),{})}function Bt(e){return(e==null?void 0:e.resourceType)==="compute-pipeline"}var je=class e{constructor(t,r){this._core=t;this._priors=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","compute-pipeline")}get label(){return this._core.label}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){var n;return new e(this._core,{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])})}dispatchWorkgroups(t,r,n){var i;let a=this._core.unwrap(),o=this._core.branch.commandEncoder.beginComputePass({label:(i=this._core.label)!=null?i:"<unnamed>"});o.setPipeline(a.pipeline),a.bindGroupLayouts.forEach((p,g)=>{var l;if(a.catchall&&g===a.catchall[0])o.setBindGroup(g,this._core.branch.unwrap(a.catchall[1]));else{let d=(l=this._priors.bindGroupLayoutMap)==null?void 0:l.get(p);if(d===void 0)throw new N(p.label);o.setBindGroup(g,this._core.branch.unwrap(d))}}),o.dispatchWorkgroups(t,r,n),o.end()}$name(t){return this._core.label=t,this}},ze=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_memo")}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let i=this.branch.device,{code:p,bindGroupLayouts:g,catchall:l}=Y({resolve:d=>(d.resolve(this._entryFn,this._slotBindings),"")},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});l!==null&&((r=g[l[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`)),this._memo={pipeline:i.createComputePipeline({label:(n=this.label)!=null?n:"<unnamed>",layout:i.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:g.map(d=>this.branch.unwrap(d))}),compute:{module:i.createShaderModule({label:`${(o=this.label)!=null?o:"<unnamed>"} - Shader`,code:p})}}),bindGroupLayouts:g,catchall:l}}return this._memo}};function Kt(e){return typeof(e==null?void 0:e.format)=="string"}function Ft(e,t){var i,p;let r=[];if(_chunkW7MD3ZVBcjs.r.call(void 0, e)){if(!Kt(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:(i=_chunkW7MD3ZVBcjs.q.call(void 0, e))!=null?i:0}]}]}}let n=[],a=new WeakMap,o=0;for(let[g,l]of Object.entries(e)){if(_chunkW7MD3ZVBcjs.ua.call(void 0, l))continue;let d=t[g];if(!d)throw new Error(`An attribute by the name of '${g}' was not provided to the shader.`);let f=d._layout,m=a.get(f);m||(r.push(f),m=[],n.push({arrayStride:f.stride,stepMode:f.stepMode,attributes:m}),a.set(f,m)),o=(p=_chunkW7MD3ZVBcjs.q.call(void 0, l))!=null?p:o,m.push({format:d.format,offset:d.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}function _t(e){return(e==null?void 0:e.resourceType)==="vertex-layout"}function Jt(e){return typeof(e==null?void 0:e.loadOp)=="string"}function At(e,t){if(_chunkW7MD3ZVBcjs.r.call(void 0, e)){if(!Jt(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 Yt(e){return typeof(e==null?void 0:e.format)=="string"}function Et(e,t){if(_chunkW7MD3ZVBcjs.r.call(void 0, e)){if(!Yt(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 Pt(e){return new qe(new Ke(e),{})}var qe=class e{constructor(t,r){this._core=t;this._priors=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","render-pipeline")}get label(){return this._core.label}$name(t){return this._core.label=t,this}with(t,r){var n,a;if(fe(t))return new e(this._core,_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._priors),{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])}));if(_t(t))return new e(this._core,_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._priors),{vertexLayoutMap:new Map([...(a=this._priors.vertexLayoutMap)!=null?a:[],[t,r]])}));throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){return new e(this._core,_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._priors),{colorAttachment:t}))}draw(t,r,n,a){var d,f;let o=this._core.unwrap(),{branch:i,fragmentFn:p}=this._core.options,g=At(p.shell.returnType,(d=this._priors.colorAttachment)!=null?d:{}).map(m=>I(m.view)?_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},m),{view:i.unwrap(m.view).createView()}):m),l=i.commandEncoder.beginRenderPass({label:(f=this._core.label)!=null?f:"<unnamed>",colorAttachments:g});l.setPipeline(o.pipeline),o.bindGroupLayouts.forEach((m,c)=>{var b;if(o.catchall&&c===o.catchall[0])l.setBindGroup(c,i.unwrap(o.catchall[1]));else{let A=(b=this._priors.bindGroupLayoutMap)==null?void 0:b.get(m);if(A===void 0)throw new N(m.label);l.setBindGroup(c,i.unwrap(A))}}),this._core.usedVertexLayouts.forEach((m,c)=>{var A,C;let b=(A=this._priors.vertexLayoutMap)==null?void 0:A.get(m);if(!b)throw new Error(`Missing vertex buffer for layout '${(C=m.label)!=null?C:"<unnamed>"}'. Please provide it using pipeline.with(layout, buffer).(...)`);l.setVertexBuffer(c,i.unwrap(b))}),l.draw(t,r,n,a),l.end()}},Ke=class{constructor(t){this.options=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"usedVertexLayouts");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_memo");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_vertexBufferLayouts");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_targets");let r=Ft(t.vertexFn.shell.argTypes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=Et(t.fragmentFn.shell.returnType,t.targets)}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let{branch:i,vertexFn:p,fragmentFn:g,slotBindings:l,primitiveState:d}=this.options,{code:f,bindGroupLayouts:m,catchall:c}=Y({resolve:C=>(C.resolve(p,l),C.resolve(g,l),"")},{names:i.nameRegistry,jitTranspiler:i.jitTranspiler});c!==null&&((r=m[c[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`));let b=i.device,A=b.createShaderModule({label:`${(n=this.label)!=null?n:"<unnamed>"} - Shader`,code:f});this._memo={pipeline:b.createRenderPipeline({label:(a=this.label)!=null?a:"<unnamed>",layout:b.createPipelineLayout({label:`${(o=this.label)!=null?o:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:m.map(C=>i.unwrap(C))}),vertex:{module:A,buffers:this._vertexBufferLayouts},fragment:{module:A,targets:this._targets},primitive:d!=null?d:{}}),bindGroupLayouts:m,catchall:c}}return this._memo}};var Je=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[t,r]])}withCompute(t){return new Ye(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new He({branch:this._getRoot(),primitiveState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r})}},Ye=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return vt(this._root,this._slotBindings,this._entryFn)}},He=class{constructor(t){this._options=t}withFragment(t,r,n){return Z(typeof t!="string","Just type mismatch validation"),Z(typeof r!="string","Just type mismatch validation"),new Xe(_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._options),{fragmentFn:t,targets:r}))}},Xe=class e{constructor(t){this._options=t}withPrimitive(t){return new e(_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._options),{primitiveState:t}))}createPipeline(){return Pt(this._options)}},ye=class extends Je{constructor(r,n,a,o){super(()=>this,[]);this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;_chunkW7MD3ZVBcjs.c.call(void 0, this,"_disposables",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_unwrappedBindGroupLayouts",new re(r=>r.unwrap(this)));_chunkW7MD3ZVBcjs.c.call(void 0, this,"_unwrappedBindGroups",new re(r=>r.unwrap(this)));_chunkW7MD3ZVBcjs.c.call(void 0, this,"_commandEncoder",null)}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=mt(this,r,n).$device(this.device);return this._disposables.push(a),a}createTexture(r){let n=yt(r,this);return this._disposables.push(n),n}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}unwrap(r){if(Bt(r))return r.rawPipeline;if(fe(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(bt(r))return this._unwrappedBindGroups.getOrMake(r);if(G(r))return r.buffer;if(I(r)||Ge(r)||Ie(r))return r.unwrap();throw new Error(`Unknown resource type: ${r}`)}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}};async function Rt(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=e!=null?e:{};if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new ye(await o.requestDevice(r),n==="random"?new V:new k,a,!0)}function Lt(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=e!=null?e:{};return new ye(t,r==="random"?new V:new k,n,!1)}var Ht={Uniform:"uniform",Storage:"storage",Vertex:"vertex",bindGroupLayout:ge,init:Rt,initFromDevice:Lt,resolve:Ut},ra= exports.default =Ht;exports.NotUniformError = W; exports.ResolutionError = O; exports.default = ra; exports.isBuffer = G; exports.isComparisonSampler = zt; exports.isSampledTextureView = Ie; exports.isSampler = jt; exports.isStorageTextureView = Ge; exports.isTexture = I; exports.isUsableAsRender = qt; exports.isUsableAsSampled = Ce; exports.isUsableAsStorage = oe; exports.isUsableAsUniform = Ee; exports.isUsableAsVertex = Wt; exports.tgpu = Ht;
18
+ `);for(let m of p)d.resolve(m);return St(d,o,f)}},{code:l}=Y(g,{names:n==="strict"?new k:new V,jitTranspiler:a});return l}var ne=class{constructor(t){this._make=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"_map",new WeakMap)}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}};function vt(e,t,r){return new je(new ze(e,t,r),{})}function Bt(e){return(e==null?void 0:e.resourceType)==="compute-pipeline"}var je=class e{constructor(t,r){this._core=t;this._priors=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","compute-pipeline")}get label(){return this._core.label}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){var n;return new e(this._core,{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])})}dispatchWorkgroups(t,r,n){var i;let a=this._core.unwrap(),o=this._core.branch.commandEncoder.beginComputePass({label:(i=this._core.label)!=null?i:"<unnamed>"});o.setPipeline(a.pipeline),a.bindGroupLayouts.forEach((p,g)=>{var l;if(a.catchall&&g===a.catchall[0])o.setBindGroup(g,this._core.branch.unwrap(a.catchall[1]));else{let d=(l=this._priors.bindGroupLayoutMap)==null?void 0:l.get(p);if(d===void 0)throw new N(p.label);o.setBindGroup(g,this._core.branch.unwrap(d))}}),o.dispatchWorkgroups(t,r,n),o.end()}$name(t){return this._core.label=t,this}},ze=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n;_chunkW7MD3ZVBcjs.c.call(void 0, this,"label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_memo")}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let i=this.branch.device,{code:p,bindGroupLayouts:g,catchall:l}=Y({resolve:d=>(d.resolve(this._entryFn,this._slotBindings),"")},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});l!==null&&((r=g[l[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`)),this._memo={pipeline:i.createComputePipeline({label:(n=this.label)!=null?n:"<unnamed>",layout:i.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:g.map(d=>this.branch.unwrap(d))}),compute:{module:i.createShaderModule({label:`${(o=this.label)!=null?o:"<unnamed>"} - Shader`,code:p})}}),bindGroupLayouts:g,catchall:l}}return this._memo}};function qt(e){return typeof(e==null?void 0:e.format)=="string"}function Ft(e,t){var i,p;let r=[];if(_chunkW7MD3ZVBcjs.r.call(void 0, e)){if(!qt(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:(i=_chunkW7MD3ZVBcjs.q.call(void 0, e))!=null?i:0}]}]}}let n=[],a=new WeakMap,o=0;for(let[g,l]of Object.entries(e)){if(_chunkW7MD3ZVBcjs.ua.call(void 0, l))continue;let d=t[g];if(!d)throw new Error(`An attribute by the name of '${g}' was not provided to the shader.`);let f=d._layout,m=a.get(f);m||(r.push(f),m=[],n.push({arrayStride:f.stride,stepMode:f.stepMode,attributes:m}),a.set(f,m)),o=(p=_chunkW7MD3ZVBcjs.q.call(void 0, l))!=null?p:o,m.push({format:d.format,offset:d.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}function _t(e){return(e==null?void 0:e.resourceType)==="vertex-layout"}function Jt(e){return typeof(e==null?void 0:e.loadOp)=="string"}function At(e,t){if(_chunkW7MD3ZVBcjs.r.call(void 0, e)){if(!Jt(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 Yt(e){return typeof(e==null?void 0:e.format)=="string"}function Et(e,t){if(_chunkW7MD3ZVBcjs.r.call(void 0, e)){if(!Yt(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 Pt(e){return new Ke(new qe(e),{})}var Ke=class e{constructor(t,r){this._core=t;this._priors=r;_chunkW7MD3ZVBcjs.c.call(void 0, this,"resourceType","render-pipeline")}get label(){return this._core.label}$name(t){return this._core.label=t,this}with(t,r){var n,a;if(Te(t))return new e(this._core,_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._priors),{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])}));if(_t(t))return new e(this._core,_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._priors),{vertexLayoutMap:new Map([...(a=this._priors.vertexLayoutMap)!=null?a:[],[t,r]])}));throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){return new e(this._core,_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._priors),{colorAttachment:t}))}draw(t,r,n,a){var d,f;let o=this._core.unwrap(),{branch:i,fragmentFn:p}=this._core.options,g=At(p.shell.returnType,(d=this._priors.colorAttachment)!=null?d:{}).map(m=>I(m.view)?_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},m),{view:i.unwrap(m.view).createView()}):m),l=i.commandEncoder.beginRenderPass({label:(f=this._core.label)!=null?f:"<unnamed>",colorAttachments:g});l.setPipeline(o.pipeline),o.bindGroupLayouts.forEach((m,c)=>{var b;if(o.catchall&&c===o.catchall[0])l.setBindGroup(c,i.unwrap(o.catchall[1]));else{let A=(b=this._priors.bindGroupLayoutMap)==null?void 0:b.get(m);if(A===void 0)throw new N(m.label);l.setBindGroup(c,i.unwrap(A))}}),this._core.usedVertexLayouts.forEach((m,c)=>{var A,C;let b=(A=this._priors.vertexLayoutMap)==null?void 0:A.get(m);if(!b)throw new Error(`Missing vertex buffer for layout '${(C=m.label)!=null?C:"<unnamed>"}'. Please provide it using pipeline.with(layout, buffer).(...)`);l.setVertexBuffer(c,i.unwrap(b))}),l.draw(t,r,n,a),l.end()}},qe=class{constructor(t){this.options=t;_chunkW7MD3ZVBcjs.c.call(void 0, this,"label");_chunkW7MD3ZVBcjs.c.call(void 0, this,"usedVertexLayouts");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_memo");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_vertexBufferLayouts");_chunkW7MD3ZVBcjs.c.call(void 0, this,"_targets");let r=Ft(t.vertexFn.shell.argTypes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=Et(t.fragmentFn.shell.returnType,t.targets)}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let{branch:i,vertexFn:p,fragmentFn:g,slotBindings:l,primitiveState:d}=this.options,{code:f,bindGroupLayouts:m,catchall:c}=Y({resolve:C=>(C.resolve(p,l),C.resolve(g,l),"")},{names:i.nameRegistry,jitTranspiler:i.jitTranspiler});c!==null&&((r=m[c[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`));let b=i.device,A=b.createShaderModule({label:`${(n=this.label)!=null?n:"<unnamed>"} - Shader`,code:f});this._memo={pipeline:b.createRenderPipeline({label:(a=this.label)!=null?a:"<unnamed>",layout:b.createPipelineLayout({label:`${(o=this.label)!=null?o:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:m.map(C=>i.unwrap(C))}),vertex:{module:A,buffers:this._vertexBufferLayouts},fragment:{module:A,targets:this._targets},primitive:d!=null?d:{}}),bindGroupLayouts:m,catchall:c}}return this._memo}};var Je=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[t,r]])}withCompute(t){return new Ye(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new He({branch:this._getRoot(),primitiveState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r})}},Ye=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return vt(this._root,this._slotBindings,this._entryFn)}},He=class{constructor(t){this._options=t}withFragment(t,r,n){return Z(typeof t!="string","Just type mismatch validation"),Z(typeof r!="string","Just type mismatch validation"),new Xe(_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._options),{fragmentFn:t,targets:r}))}},Xe=class e{constructor(t){this._options=t}withPrimitive(t){return new e(_chunkW7MD3ZVBcjs.b.call(void 0, _chunkW7MD3ZVBcjs.a.call(void 0, {},this._options),{primitiveState:t}))}createPipeline(){return Pt(this._options)}},ce=class extends Je{constructor(r,n,a,o){super(()=>this,[]);this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;_chunkW7MD3ZVBcjs.c.call(void 0, this,"_disposables",[]);_chunkW7MD3ZVBcjs.c.call(void 0, this,"_unwrappedBindGroupLayouts",new ne(r=>r.unwrap(this)));_chunkW7MD3ZVBcjs.c.call(void 0, this,"_unwrappedBindGroups",new ne(r=>r.unwrap(this)));_chunkW7MD3ZVBcjs.c.call(void 0, this,"_commandEncoder",null)}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=mt(this,r,n).$device(this.device);return this._disposables.push(a),a}createTexture(r){let n=yt(r,this);return this._disposables.push(n),n}createBindGroup(r,n){return new re(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}unwrap(r){if(Bt(r))return r.rawPipeline;if(Te(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(bt(r))return this._unwrappedBindGroups.getOrMake(r);if(G(r))return r.buffer;if(I(r)||Ie(r)||Ce(r))return r.unwrap();throw new Error(`Unknown resource type: ${r}`)}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}};async function Rt(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=e!=null?e:{};if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new ce(await o.requestDevice(r),n==="random"?new V:new k,a,!0)}function Lt(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=e!=null?e:{};return new ce(t,r==="random"?new V:new k,n,!1)}var Ht={Uniform:"uniform",Storage:"storage",Vertex:"vertex",bindGroupLayout:fe,init:Rt,initFromDevice:Lt,resolve:Ut},ra= exports.default =Ht;exports.NotUniformError = W; exports.ResolutionError = O; exports.default = ra; exports.isBuffer = G; exports.isComparisonSampler = zt; exports.isSampledTextureView = Ce; exports.isSampler = jt; exports.isStorageTextureView = Ie; exports.isTexture = I; exports.isUsableAsRender = Kt; exports.isUsableAsSampled = Ve; exports.isUsableAsStorage = ie; exports.isUsableAsUniform = Pe; exports.isUsableAsVertex = Wt; exports.tgpu = Ht;
19
19
  //# sourceMappingURL=index.cjs.map