typegpu 0.5.9 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/chunk-3K53YJSU.cjs +10 -0
  2. package/chunk-3K53YJSU.cjs.map +1 -0
  3. package/chunk-BF35NEOX.cjs +43 -0
  4. package/chunk-BF35NEOX.cjs.map +1 -0
  5. package/chunk-IH2QU6TV.js +43 -0
  6. package/chunk-IH2QU6TV.js.map +1 -0
  7. package/chunk-S27MYQ6U.js +10 -0
  8. package/chunk-S27MYQ6U.js.map +1 -0
  9. package/data/index.cjs +1 -1
  10. package/data/index.cjs.map +1 -1
  11. package/data/index.d.cts +30 -4
  12. package/data/index.d.ts +30 -4
  13. package/data/index.js +1 -1
  14. package/index.cjs +18 -29
  15. package/index.cjs.map +1 -1
  16. package/index.d.cts +95 -9
  17. package/index.d.ts +95 -9
  18. package/index.js +18 -29
  19. package/index.js.map +1 -1
  20. package/{matrix-BULDDGYa.d.ts → matrix-BXuR-7-A.d.ts} +1 -1
  21. package/{matrix-BnXitNJ7.d.cts → matrix-DzXuhOr3.d.cts} +1 -1
  22. package/package.json +1 -1
  23. package/std/index.cjs +1 -1
  24. package/std/index.cjs.map +1 -1
  25. package/std/index.d.cts +22 -9
  26. package/std/index.d.ts +22 -9
  27. package/std/index.js +1 -1
  28. package/std/index.js.map +1 -1
  29. package/{tgpuComputeFn-BxPDI5hQ.d.ts → tgpuConstant-BAmV6caN.d.cts} +3254 -2840
  30. package/{tgpuComputeFn-BxPDI5hQ.d.cts → tgpuConstant-BAmV6caN.d.ts} +3254 -2840
  31. package/chunk-734H4JWF.js +0 -2
  32. package/chunk-734H4JWF.js.map +0 -1
  33. package/chunk-BJSN5UVV.cjs +0 -41
  34. package/chunk-BJSN5UVV.cjs.map +0 -1
  35. package/chunk-BZVU4Q6A.cjs +0 -2
  36. package/chunk-BZVU4Q6A.cjs.map +0 -1
  37. package/chunk-CDUKTYES.cjs +0 -2
  38. package/chunk-CDUKTYES.cjs.map +0 -1
  39. package/chunk-CGVYLGBG.js +0 -2
  40. package/chunk-CGVYLGBG.js.map +0 -1
  41. package/chunk-SWJVYRFM.js +0 -41
  42. package/chunk-SWJVYRFM.js.map +0 -1
  43. /package/{LICENSE.md → LICENSE} +0 -0
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;var _chunkBF35NEOXcjs = require('./chunk-BF35NEOX.cjs');var _tinyest = require('tinyest'); var Ot = _interopRequireWildcard(_tinyest);var ee=(e,t)=>{let r=t-1,n=~r;return(e&r)===0?e:(e&n)+t};var ut=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],an= exports.c ={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};var It=["unstruct","disarray","loose-decorated",...ut];function te(e){return _optionalChain([e, 'optionalAccess', _2 => _2[_chunkBF35NEOXcjs.a]])&&It.includes(_optionalChain([e, 'optionalAccess', _3 => _3.type]))}function W(e){return _optionalChain([e, 'optionalAccess', _4 => _4[_chunkBF35NEOXcjs.a]])&&_optionalChain([e, 'optionalAccess', _5 => _5.type])==="disarray"}function O(e){return _optionalChain([e, 'optionalAccess', _6 => _6[_chunkBF35NEOXcjs.a]])&&_optionalChain([e, 'optionalAccess', _7 => _7.type])==="unstruct"}function V(e){return _optionalChain([e, 'optionalAccess', _8 => _8[_chunkBF35NEOXcjs.a]])&&_optionalChain([e, 'optionalAccess', _9 => _9.type])==="loose-decorated"}function ne(e){return _optionalChain([e, 'access', _10 => _10.attribs, 'optionalAccess', _11 => _11.find, 'call', _12 => _12(_chunkBF35NEOXcjs.S), 'optionalAccess', _13 => _13.params, 'access', _14 => _14[0]])}function lt(e){return _optionalChain([e, 'access', _15 => _15.attribs, 'optionalAccess', _16 => _16.find, 'call', _17 => _17(_chunkBF35NEOXcjs.T), 'optionalAccess', _18 => _18.params, 'access', _19 => _19[0]])}function ln(e){return _optionalChain([e, 'access', _20 => _20.attribs, 'optionalAccess', _21 => _21.find, 'call', _22 => _22(_chunkBF35NEOXcjs.U), 'optionalAccess', _23 => _23.params, 'access', _24 => _24[0]])}function Ue(e){return _chunkBF35NEOXcjs.N.call(void 0, e)||te(e)}var w={type:"unknown",toString(){return"unknown"}},le=class{constructor(t,r,n){this.name=t;this.lhs=r;this.operator=n}};var p= (_class =class{constructor(t){;_class.prototype.__init.call(this);this.type=t}__init() {this[_chunkBF35NEOXcjs.a]=!0}}, _class),ht= exports.k ={uint8:_chunkBF35NEOXcjs.ta,uint8x2:_chunkBF35NEOXcjs.Ca,uint8x4:_chunkBF35NEOXcjs.Ma,sint8:_chunkBF35NEOXcjs.va,sint8x2:_chunkBF35NEOXcjs.Ba,sint8x4:_chunkBF35NEOXcjs.La,unorm8:_chunkBF35NEOXcjs.wa,unorm8x2:_chunkBF35NEOXcjs.za,unorm8x4:_chunkBF35NEOXcjs.Ja,snorm8:_chunkBF35NEOXcjs.wa,snorm8x2:_chunkBF35NEOXcjs.za,snorm8x4:_chunkBF35NEOXcjs.Ja,uint16:_chunkBF35NEOXcjs.ta,uint16x2:_chunkBF35NEOXcjs.Ca,uint16x4:_chunkBF35NEOXcjs.Ma,sint16:_chunkBF35NEOXcjs.va,sint16x2:_chunkBF35NEOXcjs.Ba,sint16x4:_chunkBF35NEOXcjs.La,unorm16:_chunkBF35NEOXcjs.wa,unorm16x2:_chunkBF35NEOXcjs.za,unorm16x4:_chunkBF35NEOXcjs.Ja,snorm16:_chunkBF35NEOXcjs.wa,snorm16x2:_chunkBF35NEOXcjs.za,snorm16x4:_chunkBF35NEOXcjs.Ja,float16:_chunkBF35NEOXcjs.wa,float16x2:_chunkBF35NEOXcjs.za,float16x4:_chunkBF35NEOXcjs.Ja,float32:_chunkBF35NEOXcjs.wa,float32x2:_chunkBF35NEOXcjs.za,float32x3:_chunkBF35NEOXcjs.Ea,float32x4:_chunkBF35NEOXcjs.Ja,uint32:_chunkBF35NEOXcjs.ta,uint32x2:_chunkBF35NEOXcjs.Ca,uint32x3:_chunkBF35NEOXcjs.Ha,uint32x4:_chunkBF35NEOXcjs.Ma,sint32:_chunkBF35NEOXcjs.va,sint32x2:_chunkBF35NEOXcjs.Ba,sint32x3:_chunkBF35NEOXcjs.Ga,sint32x4:_chunkBF35NEOXcjs.La,"unorm10-10-10-2":_chunkBF35NEOXcjs.Ja,"unorm8x4-bgra":_chunkBF35NEOXcjs.Ja},We= exports.l =new Set(Object.keys(ht)),xn= exports.m =new p("uint8"),dn= exports.n =new p("uint8x2"),Tn= exports.o =new p("uint8x4"),gn= exports.p =new p("sint8"),vn= exports.q =new p("sint8x2"),bn= exports.r =new p("sint8x4"),Dn= exports.s =new p("unorm8"),wn= exports.t =new p("unorm8x2"),In= exports.u =new p("unorm8x4"),hn= exports.v =new p("snorm8"),An= exports.w =new p("snorm8x2"),Sn= exports.x =new p("snorm8x4"),$n= exports.y =new p("uint16"),Vn= exports.z =new p("uint16x2"),kn= exports.A =new p("uint16x4"),Bn= exports.B =new p("sint16"),Fn= exports.C =new p("sint16x2"),Cn= exports.D =new p("sint16x4"),Pn= exports.E =new p("unorm16"),Ln= exports.F =new p("unorm16x2"),_n= exports.G =new p("unorm16x4"),En= exports.H =new p("snorm16"),Rn= exports.I =new p("snorm16x2"),Un= exports.J =new p("snorm16x4"),Wn= exports.K =new p("float16"),On= exports.L =new p("float16x2"),Nn= exports.M =new p("float16x4"),zn= exports.N =new p("float32"),Mn= exports.O =new p("float32x2"),jn= exports.P =new p("float32x3"),Gn= exports.Q =new p("float32x4"),Kn= exports.R =new p("uint32"),Hn= exports.S =new p("uint32x2"),Yn= exports.T =new p("uint32x3"),qn= exports.U =new p("uint32x4"),Jn= exports.V =new p("sint32"),Qn= exports.W =new p("sint32x2"),Xn= exports.X =new p("sint32x3"),Zn= exports.Y =new p("sint32x4"),er= exports.Z =new p("unorm10-10-10-2"),tr= exports._ =new p("unorm8x4-bgra");function nr(e){return _optionalChain([e, 'optionalAccess', _25 => _25[_chunkBF35NEOXcjs.a]])&&We.has(_optionalChain([e, 'optionalAccess', _26 => _26.type]))}var At={f32:4,f16:2,i32:4,u32:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,mat2x2f:8,mat3x3f:16,mat4x4f:16,atomic:4};function St(e){let t=_optionalChain([e, 'optionalAccess', _27 => _27.type]),r=At[t];if(r!==void 0)return r;if(_chunkBF35NEOXcjs.P.call(void 0, e))return Object.values(e.propTypes).map(k).reduce((n,o)=>n>o?n:o);if(_chunkBF35NEOXcjs.O.call(void 0, e))return k(e.elementType);if(O(e)){let n=Object.values(e.propTypes)[0];return n?_nullishCoalesce(ne(n), () => (1)):1}if(W(e))return _nullishCoalesce(ne(e.elementType), () => (1));if(_chunkBF35NEOXcjs.X.call(void 0, e)||V(e))return _nullishCoalesce(ne(e), () => (k(e.inner)));if(We.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${JSON.stringify(e)}`)}function $t(e){if(O(e)){let t=Object.values(e.propTypes)[0];return t?re(t):1}return W(e)?re(e.elementType):V(e)?_nullishCoalesce(ne(e), () => (re(e.inner))):_nullishCoalesce(ne(e), () => (1))}var ct=new WeakMap,mt=new WeakMap;function k(e){let t=ct.get(e);return t===void 0&&(t=St(e),ct.set(e,t)),t}function re(e){let t=mt.get(e);return t===void 0&&(t=$t(e),mt.set(e,t)),t}function Vt(e){return k(e)}var kt={f32:4,f16:2,i32:4,u32:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,mat2x2f:16,mat3x3f:48,mat4x4f:64,uint8:1,uint8x2:2,uint8x4:4,sint8:1,sint8x2:2,sint8x4:4,unorm8:1,unorm8x2:2,unorm8x4:4,snorm8:1,snorm8x2:2,snorm8x4:4,uint16:2,uint16x2:4,uint16x4:8,sint16:2,sint16x2:4,sint16x4:8,unorm16:2,unorm16x2:4,unorm16x4:8,snorm16:2,snorm16x2:4,snorm16x4:8,float16:2,float16x2:4,float16x4:8,float32:4,float32x2:8,float32x3:12,float32x4:16,uint32:4,uint32x2:8,uint32x3:12,uint32x4:16,sint32:4,sint32x2:8,sint32x3:12,sint32x4:16,"unorm10-10-10-2":4,"unorm8x4-bgra":4,atomic:4};function Bt(e){let t=0,r=e.propTypes;for(let n of Object.values(r)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=ee(t,k(n)),t+=B(n),Number.isNaN(t)&&n.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return ee(t,k(e))}function Ft(e){let t=0,r=e.propTypes;for(let n of Object.values(r)){let o=re(n);t=ee(t,o),t+=B(n)}return t}function Ct(e){let t=kt[_optionalChain([e, 'optionalAccess', _28 => _28.type])];if(t!==void 0)return t;if(_chunkBF35NEOXcjs.P.call(void 0, e))return Bt(e);if(O(e))return Ft(e);if(_chunkBF35NEOXcjs.O.call(void 0, e)){if(e.elementCount===0)return Number.NaN;let r=k(e.elementType);return ee(B(e.elementType),r)*e.elementCount}if(W(e)){let r=re(e.elementType);return ee(B(e.elementType),r)*e.elementCount}if(_chunkBF35NEOXcjs.X.call(void 0, e)||V(e))return _nullishCoalesce(lt(e), () => (B(e.inner)));throw new Error(`Cannot determine size of data: ${e}`)}var yt=new WeakMap;function B(e){let t=yt.get(e);return t===void 0&&(t=Ct(e),yt.set(e,t)),t}function Pt(e){return B(e)}function he(e,t){try{return e(t)}catch (e2){let r=_optionalChain([e, 'optionalAccess', _29 => _29.type]);throw new Error(`Schema of type ${_nullishCoalesce(r, () => ("<unknown>"))} is not callable or was called with invalid arguments.`)}}function Ae(e){try{return e()}catch (e3){let t=_optionalChain([e, 'optionalAccess', _30 => _30.type]);throw new Error(`Schema of type ${_nullishCoalesce(t, () => ("<unknown>"))} is not callable.`)}}function H(e,t){let r=n=>{if(n&&n.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${n.length} arguments.`);return Array.from({length:t},(o,a)=>n?he(e,n[a]):Ae(e))};if(Object.setPrototypeOf(r,Lt),Number.isNaN(B(e)))throw new Error("Cannot nest runtime sized arrays.");if(r.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return r.elementCount=t,r}var Lt={[_chunkBF35NEOXcjs.a]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};function ft(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var _t={f:{1:_chunkBF35NEOXcjs.wa,2:_chunkBF35NEOXcjs.za,3:_chunkBF35NEOXcjs.Ea,4:_chunkBF35NEOXcjs.Ja},h:{1:_chunkBF35NEOXcjs.xa,2:_chunkBF35NEOXcjs.Aa,3:_chunkBF35NEOXcjs.Fa,4:_chunkBF35NEOXcjs.Ka},i:{1:_chunkBF35NEOXcjs.va,2:_chunkBF35NEOXcjs.Ba,3:_chunkBF35NEOXcjs.Ga,4:_chunkBF35NEOXcjs.La},u:{1:_chunkBF35NEOXcjs.ta,2:_chunkBF35NEOXcjs.Ca,3:_chunkBF35NEOXcjs.Ha,4:_chunkBF35NEOXcjs.Ma},b:{1:_chunkBF35NEOXcjs.sa,2:_chunkBF35NEOXcjs.Da,3:_chunkBF35NEOXcjs.Ia,4:_chunkBF35NEOXcjs.Na}},Et={vec2f:_chunkBF35NEOXcjs.za,vec2h:_chunkBF35NEOXcjs.Aa,vec2i:_chunkBF35NEOXcjs.Ba,vec2u:_chunkBF35NEOXcjs.Ca,"vec2<bool>":_chunkBF35NEOXcjs.Da,vec3f:_chunkBF35NEOXcjs.Ea,vec3h:_chunkBF35NEOXcjs.Fa,vec3i:_chunkBF35NEOXcjs.Ga,vec3u:_chunkBF35NEOXcjs.Ha,"vec3<bool>":_chunkBF35NEOXcjs.Ia,vec4f:_chunkBF35NEOXcjs.Ja,vec4h:_chunkBF35NEOXcjs.Ka,vec4i:_chunkBF35NEOXcjs.La,vec4u:_chunkBF35NEOXcjs.Ma,"vec4<bool>":_chunkBF35NEOXcjs.Na,mat2x2f:_chunkBF35NEOXcjs.Ya,mat3x3f:_chunkBF35NEOXcjs.Za,mat4x4f:_chunkBF35NEOXcjs._a},xt={vec2f:_chunkBF35NEOXcjs.wa,vec2h:_chunkBF35NEOXcjs.xa,vec2i:_chunkBF35NEOXcjs.va,vec2u:_chunkBF35NEOXcjs.ta,"vec2<bool>":_chunkBF35NEOXcjs.sa,vec3f:_chunkBF35NEOXcjs.wa,vec3h:_chunkBF35NEOXcjs.xa,vec3i:_chunkBF35NEOXcjs.va,vec3u:_chunkBF35NEOXcjs.ta,"vec3<bool>":_chunkBF35NEOXcjs.sa,vec4f:_chunkBF35NEOXcjs.wa,vec4h:_chunkBF35NEOXcjs.xa,vec4i:_chunkBF35NEOXcjs.va,vec4u:_chunkBF35NEOXcjs.ta,"vec4<bool>":_chunkBF35NEOXcjs.sa,mat2x2f:_chunkBF35NEOXcjs.za,mat3x3f:_chunkBF35NEOXcjs.Ea,mat4x4f:_chunkBF35NEOXcjs.Ja};function Oe(e,t){if(_chunkBF35NEOXcjs.P.call(void 0, e)||O(e))return _nullishCoalesce(e.propTypes[t], () => (w));if(e===_chunkBF35NEOXcjs.sa||_chunkBF35NEOXcjs.cb.call(void 0, e))return w;let r=t.length;if(_chunkBF35NEOXcjs.I.call(void 0, e)&&r>=1&&r<=4){let n=e.type.includes("bool")?"b":e.type[4],o=_t[n][r];if(o)return o}return w}function Ne(e){return _chunkBF35NEOXcjs.O.call(void 0, e)||W(e)?e.elementType:e.type in xt?xt[e.type]:w}function ze(e){if(/^0x[0-9a-f]+$/i.test(e))return _chunkBF35NEOXcjs.pa.call(void 0, e,_chunkBF35NEOXcjs.qa);if(/^0b[01]+$/i.test(e))return _chunkBF35NEOXcjs.pa.call(void 0, `${Number.parseInt(e.slice(2),2)}`,_chunkBF35NEOXcjs.qa);if(/^-?(?:\d+\.\d*|\d*\.\d+)$/i.test(e))return _chunkBF35NEOXcjs.pa.call(void 0, e,_chunkBF35NEOXcjs.ra);if(/^-?\d+(?:\.\d+)?e-?\d+$/i.test(e))return _chunkBF35NEOXcjs.pa.call(void 0, e,_chunkBF35NEOXcjs.ra);if(/^-?\d+$/i.test(e))return _chunkBF35NEOXcjs.pa.call(void 0, e,_chunkBF35NEOXcjs.qa)}var Me={rank:Number.POSITIVE_INFINITY,action:"none"};function dt(e){return _chunkBF35NEOXcjs.I.call(void 0, e)?_chunkBF35NEOXcjs.Oa[e.type]:void 0}function Se(e,t){let r=_chunkBF35NEOXcjs.na.call(void 0, e),n=_chunkBF35NEOXcjs.na.call(void 0, t);if(r.type===n.type)return{rank:0,action:"none"};if(r.type==="abstractFloat"){if(n.type==="f32")return{rank:1,action:"none"};if(n.type==="f16")return{rank:2,action:"none"}}if(r.type==="abstractInt"){if(n.type==="i32")return{rank:3,action:"none"};if(n.type==="u32")return{rank:4,action:"none"};if(n.type==="abstractFloat")return{rank:5,action:"none"};if(n.type==="f32")return{rank:6,action:"none"};if(n.type==="f16")return{rank:7,action:"none"}}if(_chunkBF35NEOXcjs.I.call(void 0, r)&&_chunkBF35NEOXcjs.I.call(void 0, n)){let o=dt(r),a=dt(n);if(o&&a)return Se(o,a)}return _chunkBF35NEOXcjs.M.call(void 0, r)&&_chunkBF35NEOXcjs.M.call(void 0, n)?{rank:0,action:"none"}:Me}function Rt(e,t){let r=_chunkBF35NEOXcjs.na.call(void 0, e),n=_chunkBF35NEOXcjs.na.call(void 0, t);if(r.type==="ptr"&&Se(r.inner,n).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(n.type==="ptr"&&Se(r,n.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let o={f32:0,f16:1,i32:2,u32:3,bool:4};if(r.type in o&&n.type in o){let a=r.type,i=n.type;if(a!==i){let s=o[a];return{rank:o[i]<s?10:20,action:"cast",targetType:n}}}return Me}function Ut(e,t,r){let n=Se(e,t);return n.rank<Number.POSITIVE_INFINITY?n:r?Rt(e,t):Me}function Tt(e,t,r){let n,o=Number.POSITIVE_INFINITY,a=new Map;for(let l of t){let y=0,T=[],z=!0;for(let Q of e){let M=Ut(Q,l,r);if(M.rank===Number.POSITIVE_INFINITY){z=!1;break}y+=M.rank,T.push(M)}z&&y<o&&(o=y,n=l,a.set(n,T))}if(!n)return;let s=a.get(n).map((l,y)=>({sourceIndex:y,action:l.action,...l.action==="cast"&&{targetType:l.targetType}})),f=s.some(l=>l.action==="cast");return{targetType:n,actions:s,hasImplicitConversions:f}}function ce(e){return e.type==="abstractFloat"?_chunkBF35NEOXcjs.wa:e.type==="abstractInt"?_chunkBF35NEOXcjs.va:e}function gt(e,t){if(e.length===0)return;let r=[...new Set(e.map(_chunkBF35NEOXcjs.na))],n=t?[...new Set(t.map(_chunkBF35NEOXcjs.na))]:r,o=Tt(e,n,!1);if(o)return o;let a=Tt(e,n,!0);if(a)return a.hasImplicitConversions=a.actions.some(i=>i.action==="cast"),a}function Wt(e,t,r,n){if(r.action==="none")return _chunkBF35NEOXcjs.pa.call(void 0, t.value,n);let o=e.resolve(t.value);switch(r.action){case"ref":return _chunkBF35NEOXcjs.pa.call(void 0, `&${o}`,n);case"deref":return _chunkBF35NEOXcjs.pa.call(void 0, `*${o}`,n);case"cast":return _chunkBF35NEOXcjs.pa.call(void 0, `${e.resolve(n)}(${o})`,n);default:ft(r.action,"applyActionToSnippet")}}function Y({ctx:e,values:t,restrictTo:r,concretizeTypes:n=!1,verbose:o=!0}){let a=t.map(s=>n?ce(s.dataType):s.dataType);if(a.some(s=>s===w))return;_chunkBF35NEOXcjs.h&&o&&Array.isArray(r)&&r.length===0&&console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");let i=gt(a,r);if(i)return _chunkBF35NEOXcjs.h&&o&&i.hasImplicitConversions&&console.warn(`Implicit conversions from [
2
+ ${t.map(s=>` ${s.value}: ${s.dataType.type}`).join(`,
3
+ `)}
4
+ ] to ${i.targetType.type} are supported, but not recommended.
5
+ Consider using explicit conversions instead.`),t.map((s,f)=>{let l=i.actions[f];return _chunkBF35NEOXcjs.n.call(void 0, l,"Action should not be undefined"),Wt(e,s,l,i.targetType)})}function je(e,t,r){if(r===t.dataType)return t;if(r.type==="void")throw new (0, _chunkBF35NEOXcjs.x)(`Cannot convert value of type '${t.dataType.type}' to type 'void'`);let n=Y({ctx:e,values:[t],restrictTo:[r]});if(!n)throw new (0, _chunkBF35NEOXcjs.x)(`Cannot convert value of type '${t.dataType.type}' to type '${r.type}'`);return n[0]}function vt(e,t,r){return Object.keys(t.propTypes).map(o=>{let a=r[o];if(!a)throw new Error(`Missing property ${o}`);let i=t.propTypes[o];return _nullishCoalesce(_optionalChain([Y, 'call', _31 => _31({ctx:e,values:[a],restrictTo:[i]}), 'optionalAccess', _32 => _32[0]]), () => (a))})}function me(e){if(_chunkBF35NEOXcjs.oa.call(void 0, e))return e;if(_chunkBF35NEOXcjs.C.call(void 0, e))return _chunkBF35NEOXcjs.pa.call(void 0, e,e[_chunkBF35NEOXcjs.b]);if(_chunkBF35NEOXcjs.E.call(void 0, e)||_chunkBF35NEOXcjs.J.call(void 0, e))return _chunkBF35NEOXcjs.pa.call(void 0, e,Et[e.kind]);if(Array.isArray(e)){let t=e.map(me).filter(Boolean),r=_chunkBF35NEOXcjs.ia.call(void 0, );if(!r)throw new Error("Tried to coerce array without a context");let n=Y({ctx:r,values:t}),o=_optionalChain([gt, 'call', _33 => _33(t.map(a=>a.dataType)), 'optionalAccess', _34 => _34.targetType]);return!n||!o?_chunkBF35NEOXcjs.pa.call(void 0, e,w):_chunkBF35NEOXcjs.pa.call(void 0, n.map(a=>a.value).join(", "),H(ce(o),e.length))}return typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?_chunkBF35NEOXcjs.pa.call(void 0, e,w):typeof e=="number"||typeof e=="bigint"?_chunkBF35NEOXcjs.pa.call(void 0, e,_nullishCoalesce(_optionalChain([ze, 'call', _35 => _35(String(e)), 'optionalAccess', _36 => _36.dataType]), () => (w))):typeof e=="boolean"?_chunkBF35NEOXcjs.pa.call(void 0, e,_chunkBF35NEOXcjs.sa):_chunkBF35NEOXcjs.pa.call(void 0, e,w)}var{NodeTypeCatalog:m}=Ot,Nt=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],zt=["&&","||","==","!=","<","<=",">",">="],Mt=["vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"],Ve={add:_chunkBF35NEOXcjs.db,sub:_chunkBF35NEOXcjs.eb,mul:_chunkBF35NEOXcjs.fb,div:_chunkBF35NEOXcjs.gb};function bt(e,t,r){return r?zt.includes(t)?_chunkBF35NEOXcjs.sa:t==="="?r:e:t==="!"||t==="~"?_chunkBF35NEOXcjs.sa:e}function jt(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function oe(e,[t,r]){e.pushBlockScope();try{e.indent();let n=r.map(o=>Ke(e,o)).join(`
6
+ `);return e.dedent(),`{
7
+ ${n}
8
+ ${e.pre}}`}finally{e.popBlockScope()}}function Gt(e,t,r){return e.defineVariable(t,r)}function Ge(e,t){let r=e.getById(t);if(!r)throw new Error(`Identifier ${t} not found`);return r}function N(e,t,r){let n=e.expectedType;e.expectedType=r;try{let o=b(e,t);return je(e,o,r)}finally{e.expectedType=n}}function b(e,t){if(typeof t=="string")return Ge(e,t);if(typeof t=="boolean")return _chunkBF35NEOXcjs.pa.call(void 0, t?"true":"false",_chunkBF35NEOXcjs.sa);if(t[0]===m.logicalExpr||t[0]===m.binaryExpr||t[0]===m.assignmentExpr){let[r,n,o,a]=t,i=b(e,n),s=b(e,a),f=t[0]===m.assignmentExpr?i.dataType.type==="ptr"?[i.dataType.inner]:[i.dataType]:void 0,l=Y({ctx:e,values:[i,s],restrictTo:o==="/"?[_chunkBF35NEOXcjs.wa,_chunkBF35NEOXcjs.xa]:f,concretizeTypes:o==="/",verbose:o!=="/"}),[y,T]=l||[i,s],z=e.resolve(y.value),Q=e.resolve(T.value),M=bt(y.dataType,o,T.dataType);return _chunkBF35NEOXcjs.pa.call(void 0, Nt.includes(o)?`(${z} ${o} ${Q})`:`${z} ${o} ${Q}`,M)}if(t[0]===m.postUpdate){let[r,n,o]=t,a=b(e,o),i=e.resolve(a.value);return _chunkBF35NEOXcjs.pa.call(void 0, `${i}${n}`,a.dataType)}if(t[0]===m.unaryExpr){let[r,n,o]=t,a=b(e,o),i=e.resolve(a.value),s=bt(a.dataType,n);return _chunkBF35NEOXcjs.pa.call(void 0, `${n}${i}`,s)}if(t[0]===m.memberAccess){let[r,n,o]=t,a=b(e,n);if(Mt.includes(a.dataType.type)&&o in Ve)return{value:new le(o,a,Ve[o][_chunkBF35NEOXcjs.a].gpuImpl),dataType:w};if(a.dataType.type==="unknown"){let i=a.value[o];return me(i)}return _chunkBF35NEOXcjs.Q.call(void 0, a.dataType)?_chunkBF35NEOXcjs.pa.call(void 0, `(*${e.resolve(a.value)}).${o}`,Oe(a.dataType.inner,o)):_chunkBF35NEOXcjs.O.call(void 0, a.dataType)&&o==="length"?a.dataType.elementCount===0?_chunkBF35NEOXcjs.pa.call(void 0, `arrayLength(&${e.resolve(a.value)})`,_chunkBF35NEOXcjs.ta):_chunkBF35NEOXcjs.pa.call(void 0, String(a.dataType.elementCount),_chunkBF35NEOXcjs.qa):_chunkBF35NEOXcjs.M.call(void 0, a.dataType)&&o==="columns"?_chunkBF35NEOXcjs.pa.call(void 0, a.value,a.dataType):_chunkBF35NEOXcjs.I.call(void 0, a.dataType)&&_chunkBF35NEOXcjs.E.call(void 0, a.value)?me(a.value[o]):_chunkBF35NEOXcjs.pa.call(void 0, `${e.resolve(a.value)}.${o}`,Oe(a.dataType,o))}if(t[0]===m.indexAccess){let[r,n,o]=t,a=b(e,n),i=b(e,o),s=e.resolve(a.value),f=e.resolve(i.value);if(a.dataType.type==="unknown"){if(Array.isArray(o)&&o[0]===m.numericLiteral)return me(a.value[o[1]]);throw new Error(`Cannot index value ${s} of unknown type with index ${f}`)}return _chunkBF35NEOXcjs.Q.call(void 0, a.dataType)?_chunkBF35NEOXcjs.pa.call(void 0, `(*${s})[${f}]`,Ne(a.dataType.inner)):_chunkBF35NEOXcjs.pa.call(void 0, `${s}[${f}]`,Ue(a.dataType)?Ne(a.dataType):w)}if(t[0]===m.numericLiteral){let r=ze(t[1]);if(!r)throw new Error(`Invalid numeric literal ${t[1]}`);return r}if(t[0]===m.call){let[r,n,o]=t,a=b(e,n);if(_chunkBF35NEOXcjs.P.call(void 0, a.value)||_chunkBF35NEOXcjs.O.call(void 0, a.value)){if(o.length>1)throw new (0, _chunkBF35NEOXcjs.x)("Array and struct schemas should always be called with at most 1 argument");if(!o[0])return _chunkBF35NEOXcjs.pa.call(void 0, `${e.resolve(a.value)}()`,a.value);let s=N(e,o[0],a.value);return _chunkBF35NEOXcjs.pa.call(void 0, e.resolve(s.value),a.value)}if(a.value instanceof le){if(!o[0])throw new (0, _chunkBF35NEOXcjs.x)(`An infix operator '${a.value.name}' was called without any arguments`);return a.value.operator(a.value.lhs,b(e,o[0]))}if(!_chunkBF35NEOXcjs.ea.call(void 0, a.value))throw new Error(`Function ${String(a.value)} ${_chunkBF35NEOXcjs.j.call(void 0, a.value)} has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`);let i=_nullishCoalesce(_optionalChain([a, 'access', _37 => _37.value, 'access', _38 => _38[_chunkBF35NEOXcjs.a], 'optionalAccess', _39 => _39.argConversionHint]), () => ("keep"));try{let s;if(Array.isArray(i))s=o.map((l,y)=>{let T=i[y];if(!T)throw new (0, _chunkBF35NEOXcjs.x)(`Function '${_chunkBF35NEOXcjs.j.call(void 0, a.value)}' was called with too many arguments`);return N(e,l,T)});else{let l=o.map(y=>b(e,y)).map(y=>_chunkBF35NEOXcjs.pa.call(void 0, e.resolve(y.value),y.dataType));i==="keep"?s=l:i==="unify"?s=_nullishCoalesce(Y({ctx:e,values:l}), () => (l)):s=i(...l).map((y,T)=>[y,l[T]]).map(([y,T])=>je(e,T,y))}let f=a.value(...s);return _chunkBF35NEOXcjs.pa.call(void 0, e.withResetIndentLevel(()=>e.resolve(f.value)),f.dataType)}catch(s){throw new (0, _chunkBF35NEOXcjs.o)(s,[{toString:()=>_chunkBF35NEOXcjs.j.call(void 0, a.value)}])}}if(t[0]===m.objectExpr){let r=t[1],n=e.expectedType;if(!n||!_chunkBF35NEOXcjs.P.call(void 0, n))throw new (0, _chunkBF35NEOXcjs.x)(`No target type could be inferred for object with keys [${Object.keys(r).join(", ")}], please wrap the object in the corresponding schema.`);let o=Object.fromEntries(Object.entries(n.propTypes).map(([i,s])=>{let f=r[i];if(f===void 0)throw new (0, _chunkBF35NEOXcjs.x)(`Missing property ${i} in object literal for struct ${n}`);let l=N(e,f,s);return[i,l]})),a=vt(e,n,o);return _chunkBF35NEOXcjs.pa.call(void 0, `${e.resolve(n)}(${a.map(i=>e.resolve(i.value)).join(", ")})`,n)}if(t[0]===m.arrayExpr){let[r,n]=t,o=e.expectedType,a,i;if(_chunkBF35NEOXcjs.O.call(void 0, o)){if(a=o.elementType,i=n.map(l=>N(e,l,a)),i.length!==o.elementCount)throw new (0, _chunkBF35NEOXcjs.x)(`Cannot create value of type '${o}' from an array of length: ${i.length}`)}else{let l=n.map(T=>b(e,T));if(l.length===0)throw new (0, _chunkBF35NEOXcjs.x)("Cannot infer the type of an empty array literal.");let y=Y({ctx:e,values:l});if(!y)throw new (0, _chunkBF35NEOXcjs.x)("The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema");i=y,a=ce(_optionalChain([i, 'access', _40 => _40[0], 'optionalAccess', _41 => _41.dataType]))}let s=`array<${e.resolve(a)}, ${i.length}>`,f=i.map(l=>e.resolve(l.value));return _chunkBF35NEOXcjs.pa.call(void 0, `${s}(${f.join(", ")})`,H(a,i.length))}if(t[0]===m.stringLiteral)throw new Error("Cannot use string literals in TGSL.");if(t[0]===m.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");jt(t)}function $e(e){return typeof e!="object"||e[0]!==m.block?[m.block,[e]]:e}function Ke(e,t){if(typeof t=="string")return`${e.pre}${e.resolve(Ge(e,t).value)};`;if(typeof t=="boolean")return`${e.pre}${t?"true":"false"};`;if(t[0]===m.return){let r=t[1],n=r!==void 0?e.resolve(N(e,r,e.topFunctionReturnType).value):void 0;return n?`${e.pre}return ${n};`:`${e.pre}return;`}if(t[0]===m.if){let[r,n,o,a]=t,i=e.resolve(N(e,n,_chunkBF35NEOXcjs.sa).value),s=oe(e,$e(o)),f=a?oe(e,$e(a)):void 0;return f?`${e.pre}if (${i}) ${s}
9
+ ${e.pre}else ${f}`:`${e.pre}if (${i}) ${s}`}if(t[0]===m.let||t[0]===m.const){let[r,n,o]=t,a=o!==void 0?b(e,o):void 0;if(!a)throw new Error(`Cannot create variable '${n}' without an initial value.`);if(te(a.dataType))throw new Error(`Cannot create variable '${n}' with loose data type.`);Gt(e,n,ce(a.dataType));let i=e.resolve(Ge(e,n).value);return`${e.pre}var ${i} = ${e.resolve(a.value)};`}if(t[0]===m.block)return oe(e,t);if(t[0]===m.for){let[r,n,o,a,i]=t,[s,f,l]=e.withResetIndentLevel(()=>[n?Ke(e,n):void 0,o?b(e,o):void 0,a?Ke(e,a):void 0]),y=s?s.slice(0,-1):"",T=o?N(e,o,_chunkBF35NEOXcjs.sa):void 0,z=T?e.resolve(T.value):"",Q=l?l.slice(0,-1):"",M=oe(e,$e(i));return`${e.pre}for (${y}; ${z}; ${Q}) ${M}`}if(t[0]===m.while){let[r,n,o]=t,a=N(e,n,_chunkBF35NEOXcjs.sa),i=e.resolve(a.value),s=oe(e,$e(o));return`${e.pre}while (${i}) ${s}`}return t[0]===m.continue?`${e.pre}continue;`:t[0]===m.break?`${e.pre}break;`:`${e.pre}${e.resolve(b(e,t).value)};`}function jr(e,t){return oe(e,t)}function Kt(e){let t=r=>Object.fromEntries(Object.entries(e).map(([n,o])=>[n,r?he(o,r[n]):Ae(o)]));return Object.setPrototypeOf(t,Ht),t.propTypes=e,t}var Ht={[_chunkBF35NEOXcjs.a]:!0,type:"struct",$name(e){return _chunkBF35NEOXcjs.k.call(void 0, this,e),this},toString(){return`struct:${_nullishCoalesce(_chunkBF35NEOXcjs.j.call(void 0, this), () => ("<unnamed>"))}`}};function Yt(e,t){return new He(e,t)}var He= (_class2 =class{constructor(t,r){;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);this.elementType=t;this.elementCount=r;if(!Number.isInteger(r)||r<0)throw new Error(`Cannot create disarray schema with invalid element count: ${r}.`)}__init2() {this[_chunkBF35NEOXcjs.a]=!0}__init3() {this.type="disarray"}}, _class2);function qt(e){let t=r=>r;return Object.setPrototypeOf(t,Jt),t.propTypes=e,t}var Jt={[_chunkBF35NEOXcjs.a]:!0,type:"unstruct",$name(e){return _chunkBF35NEOXcjs.k.call(void 0, this,e),this},toString(){return`unstruct:${_nullishCoalesce(_chunkBF35NEOXcjs.j.call(void 0, this), () => ("<unnamed>"))}`}};function Qt(e){return new Ye(e)}var Ye= (_class3 =class{constructor(t){;_class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this);this.inner=t}__init4() {this[_chunkBF35NEOXcjs.a]=!0}__init5() {this.type="atomic"}}, _class3);function q(e,t){return _chunkBF35NEOXcjs.X.call(void 0, e)?new Be(e.inner,[t,...e.attribs]):V(e)?new Fe(e.inner,[t,...e.attribs]):te(e)?new Fe(e,[t]):new Be(e,[t])}function Xt(e,t){return q(t,{[_chunkBF35NEOXcjs.a]:!0,type:"@align",params:[e]})}function Zt(e,t){return q(t,{[_chunkBF35NEOXcjs.a]:!0,type:"@size",params:[e]})}function en(e,t){return q(t,{[_chunkBF35NEOXcjs.a]:!0,type:"@location",params:[e]})}function tn(e,t){return q(t,{[_chunkBF35NEOXcjs.a]:!0,type:"@interpolate",params:[e]})}function nn(e){if(!Dt(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=_chunkBF35NEOXcjs.X.call(void 0, e)||V(e)?e.attribs.find(_chunkBF35NEOXcjs.W):void 0;if(!t||t.params[0]!=="position")throw new Error("The @invariant attribute must only be applied to the position built-in value.");return q(e,{[_chunkBF35NEOXcjs.a]:!0,type:"@invariant",params:[]})}function Dt(e){return(_chunkBF35NEOXcjs.X.call(void 0, e)||V(e))&&e.attribs.find(_chunkBF35NEOXcjs.W)!==void 0}function po(e){return!_chunkBF35NEOXcjs.X.call(void 0, e)&&!V(e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var ke= (_class4 =class{constructor(t,r){;_class4.prototype.__init6.call(this);this.inner=t;this.attribs=r;let n=_optionalChain([r, 'access', _42 => _42.find, 'call', _43 => _43(_chunkBF35NEOXcjs.S), 'optionalAccess', _44 => _44.params, 'access', _45 => _45[0]]),o=_optionalChain([r, 'access', _46 => _46.find, 'call', _47 => _47(_chunkBF35NEOXcjs.T), 'optionalAccess', _48 => _48.params, 'access', _49 => _49[0]]);if(n!==void 0){if(n<=0)throw new Error(`Custom data alignment must be a positive number, got: ${n}.`);if(Math.log2(n)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${n}.`);if(_chunkBF35NEOXcjs.N.call(void 0, this.inner)&&n%k(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${n}, expected multiple of: ${k(this.inner)}.`)}if(o!==void 0){if(o<B(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${o}, expected at least: ${B(this.inner)}.`);if(o<=0)throw new Error(`Custom data size must be a positive number. Got: ${o}.`)}}__init6() {this[_chunkBF35NEOXcjs.a]=!0}}, _class4),Be= (_class5 =class extends ke{constructor(...args) { super(...args); _class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this); }__init7() {this[_chunkBF35NEOXcjs.a]=!0}__init8() {this.type="decorated"}}, _class5),Fe= (_class6 =class extends ke{constructor(...args2) { super(...args2); _class6.prototype.__init9.call(this);_class6.prototype.__init10.call(this); }__init9() {this[_chunkBF35NEOXcjs.a]=!0}__init10() {this.type="loose-decorated"}}, _class6);function D(e,t){return q(e,{[_chunkBF35NEOXcjs.a]:!0,type:"@builtin",params:[t]})}var rn={vertexIndex:D(_chunkBF35NEOXcjs.ta,"vertex_index"),instanceIndex:D(_chunkBF35NEOXcjs.ta,"instance_index"),position:D(_chunkBF35NEOXcjs.Ja,"position"),clipDistances:D(H(_chunkBF35NEOXcjs.ta,8),"clip_distances"),frontFacing:D(_chunkBF35NEOXcjs.sa,"front_facing"),fragDepth:D(_chunkBF35NEOXcjs.wa,"frag_depth"),sampleIndex:D(_chunkBF35NEOXcjs.ta,"sample_index"),sampleMask:D(_chunkBF35NEOXcjs.ta,"sample_mask"),localInvocationId:D(_chunkBF35NEOXcjs.Ha,"local_invocation_id"),localInvocationIndex:D(_chunkBF35NEOXcjs.ta,"local_invocation_index"),globalInvocationId:D(_chunkBF35NEOXcjs.Ha,"global_invocation_id"),workgroupId:D(_chunkBF35NEOXcjs.Ha,"workgroup_id"),numWorkgroups:D(_chunkBF35NEOXcjs.Ha,"num_workgroups"),subgroupInvocationId:D(_chunkBF35NEOXcjs.ta,"subgroup_invocation_id"),subgroupSize:D(_chunkBF35NEOXcjs.ta,"subgroup_size")};function J(e,t){let r=e.prototype,n=Ve[t][_chunkBF35NEOXcjs.a].jsImpl;r[t]=function(o){return n(this,o)}}J(_chunkBF35NEOXcjs.ya,"add");J(_chunkBF35NEOXcjs.ya,"sub");J(_chunkBF35NEOXcjs.ya,"mul");J(_chunkBF35NEOXcjs.ya,"div");J(_chunkBF35NEOXcjs.Pa,"add");J(_chunkBF35NEOXcjs.Pa,"sub");J(_chunkBF35NEOXcjs.Pa,"mul");exports.a = ee; exports.b = ut; exports.c = an; exports.d = te; exports.e = W; exports.f = O; exports.g = V; exports.h = ln; exports.i = Ue; exports.j = w; exports.k = ht; exports.l = We; exports.m = xn; exports.n = dn; exports.o = Tn; exports.p = gn; exports.q = vn; exports.r = bn; exports.s = Dn; exports.t = wn; exports.u = In; exports.v = hn; exports.w = An; exports.x = Sn; exports.y = $n; exports.z = Vn; exports.A = kn; exports.B = Bn; exports.C = Fn; exports.D = Cn; exports.E = Pn; exports.F = Ln; exports.G = _n; exports.H = En; exports.I = Rn; exports.J = Un; exports.K = Wn; exports.L = On; exports.M = Nn; exports.N = zn; exports.O = Mn; exports.P = jn; exports.Q = Gn; exports.R = Kn; exports.S = Hn; exports.T = Yn; exports.U = qn; exports.V = Jn; exports.W = Qn; exports.X = Xn; exports.Y = Zn; exports.Z = er; exports._ = tr; exports.$ = nr; exports.aa = k; exports.ba = re; exports.ca = Vt; exports.da = B; exports.ea = Pt; exports.fa = he; exports.ga = Ae; exports.ha = H; exports.ia = ft; exports.ja = Oe; exports.ka = me; exports.la = Xt; exports.ma = Zt; exports.na = en; exports.oa = tn; exports.pa = nn; exports.qa = Dt; exports.ra = po; exports.sa = Kt; exports.ta = jr; exports.ua = Yt; exports.va = qt; exports.wa = Qt; exports.xa = rn;
10
+ //# sourceMappingURL=chunk-3K53YJSU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-3K53YJSU.cjs","../src/tgsl/wgslGenerator.ts","../src/mathUtils.ts","../src/shared/vertexFormat.ts","../src/data/dataTypes.ts","../src/data/vertexFormatData.ts","../src/data/alignmentOf.ts","../src/tgsl/generationHelpers.ts","../src/builtin.ts"],"names":["roundUp","value","modulo","bitMask","invBitMask","vertexFormats","kindToDefaultFormatMap","looseTypeLiterals","isLooseData","data","$internal","isDisarray","schema","isUnstruct","isLooseDecorated","getCustomAlignment","isAlignAttrib","getCustomSize","isSizeAttrib","getCustomLocation","isLocationAttrib","isData","isWgslData","UnknownData","InfixDispatch","name","lhs","operator","TgpuVertexFormatDataImpl","type","formatToWGSLType","u32","vec2u","vec4u","i32","vec2i","vec4i","f32","vec2f","vec4f","vec3f","vec3u","vec3i","packedFormats","uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10_10_10_2","unorm8x4_bgra","isPackedData","knownAlignmentMap","computeAlignment","dataType","knownAlignment","isWgslStruct","alignmentOf","a","b","isWgslArray","firstProp","isDecorated"],"mappings":"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","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-3K53YJSU.cjs","sourcesContent":[null,"import * as tinyest from 'tinyest';\nimport { arrayOf } from '../data/array.ts';\nimport {\n type AnyData,\n InfixDispatch,\n isData,\n isLooseData,\n UnknownData,\n} from '../data/dataTypes.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport { abstractInt, bool, f16, f32, u32 } from '../data/numeric.ts';\nimport * as wgsl from '../data/wgslTypes.ts';\nimport { ResolutionError, WgslTypeError } from '../errors.ts';\nimport { getName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { add, div, mul, sub } from '../std/numeric.ts';\nimport { type FnArgsConversionHint, isMarkedInternal } from '../types.ts';\nimport {\n coerceToSnippet,\n concretize,\n convertStructValues,\n convertToCommonType,\n type GenerationCtx,\n getTypeForIndexAccess,\n getTypeForPropAccess,\n numericLiteralToSnippet,\n tryConvertSnippet,\n} from './generationHelpers.ts';\n\nconst { NodeTypeCatalog: NODE } = tinyest;\n\nconst parenthesizedOps = [\n '==',\n '!=',\n '<',\n '<=',\n '>',\n '>=',\n '<<',\n '>>',\n '+',\n '-',\n '*',\n '/',\n '%',\n '|',\n '^',\n '&',\n '&&',\n '||',\n];\n\nconst binaryLogicalOps = ['&&', '||', '==', '!=', '<', '<=', '>', '>='];\n\nconst infixKinds = [\n 'vec2f',\n 'vec3f',\n 'vec4f',\n 'vec2h',\n 'vec3h',\n 'vec4h',\n 'vec2i',\n 'vec3i',\n 'vec4i',\n 'vec2u',\n 'vec3u',\n 'vec4u',\n 'mat2x2f',\n 'mat3x3f',\n 'mat4x4f',\n];\n\nexport const infixOperators = {\n add,\n sub,\n mul,\n div,\n} as const;\n\nexport type InfixOperator = keyof typeof infixOperators;\n\ntype Operator =\n | tinyest.BinaryOperator\n | tinyest.AssignmentOperator\n | tinyest.LogicalOperator\n | tinyest.UnaryOperator;\n\nfunction operatorToType<\n TL extends AnyData | UnknownData,\n TR extends AnyData | UnknownData,\n>(lhs: TL, op: Operator, rhs?: TR): TL | TR | wgsl.Bool {\n if (!rhs) {\n if (op === '!' || op === '~') {\n return bool;\n }\n\n return lhs;\n }\n\n if (binaryLogicalOps.includes(op)) {\n return bool;\n }\n\n if (op === '=') {\n return rhs;\n }\n\n return lhs;\n}\n\nfunction assertExhaustive(value: never): never {\n throw new Error(\n `'${JSON.stringify(value)}' was not handled by the WGSL generator.`,\n );\n}\n\nexport function generateBlock(\n ctx: GenerationCtx,\n [_, statements]: tinyest.Block,\n): string {\n ctx.pushBlockScope();\n try {\n ctx.indent();\n const body = statements.map((statement) =>\n generateStatement(ctx, statement)\n ).join('\\n');\n ctx.dedent();\n return `{\n${body}\n${ctx.pre}}`;\n } finally {\n ctx.popBlockScope();\n }\n}\n\nexport function registerBlockVariable(\n ctx: GenerationCtx,\n id: string,\n dataType: wgsl.AnyWgslData | UnknownData,\n): Snippet {\n return ctx.defineVariable(id, dataType);\n}\n\nexport function generateIdentifier(ctx: GenerationCtx, id: string): Snippet {\n const res = ctx.getById(id);\n if (!res) {\n throw new Error(`Identifier ${id} not found`);\n }\n\n return res;\n}\n\n/**\n * A wrapper for `generateExpression` that updates `ctx.expectedType`\n * and tries to convert the result when it does not match the expected type.\n */\nexport function generateTypedExpression(\n ctx: GenerationCtx,\n expression: tinyest.Expression,\n expectedType: AnyData,\n) {\n const prevExpectedType = ctx.expectedType;\n ctx.expectedType = expectedType;\n\n try {\n const result = generateExpression(ctx, expression);\n return tryConvertSnippet(ctx, result, expectedType);\n } finally {\n ctx.expectedType = prevExpectedType;\n }\n}\n\nexport function generateExpression(\n ctx: GenerationCtx,\n expression: tinyest.Expression,\n): Snippet {\n if (typeof expression === 'string') {\n return generateIdentifier(ctx, expression);\n }\n\n if (typeof expression === 'boolean') {\n return snip(expression ? 'true' : 'false', bool);\n }\n\n if (\n expression[0] === NODE.logicalExpr ||\n expression[0] === NODE.binaryExpr ||\n expression[0] === NODE.assignmentExpr\n ) {\n // Logical/Binary/Assignment Expression\n const [_, lhs, op, rhs] = expression;\n const lhsExpr = generateExpression(ctx, lhs);\n const rhsExpr = generateExpression(ctx, rhs);\n\n const forcedType = expression[0] === NODE.assignmentExpr\n ? lhsExpr.dataType.type === 'ptr'\n ? [lhsExpr.dataType.inner as AnyData]\n : [lhsExpr.dataType as AnyData]\n : undefined;\n\n const converted = convertToCommonType({\n ctx,\n values: [lhsExpr, rhsExpr],\n restrictTo: op === '/' ? [f32, f16] : forcedType,\n concretizeTypes: op === '/',\n verbose: op !== '/',\n }) as\n | [Snippet, Snippet]\n | undefined;\n const [convLhs, convRhs] = converted || [lhsExpr, rhsExpr];\n\n const lhsStr = ctx.resolve(convLhs.value);\n const rhsStr = ctx.resolve(convRhs.value);\n const type = operatorToType(convLhs.dataType, op, convRhs.dataType);\n\n return snip(\n parenthesizedOps.includes(op)\n ? `(${lhsStr} ${op} ${rhsStr})`\n : `${lhsStr} ${op} ${rhsStr}`,\n type,\n );\n }\n\n if (expression[0] === NODE.postUpdate) {\n // Post-Update Expression\n const [_, op, arg] = expression;\n const argExpr = generateExpression(ctx, arg);\n const argStr = ctx.resolve(argExpr.value);\n\n return snip(`${argStr}${op}`, argExpr.dataType);\n }\n\n if (expression[0] === NODE.unaryExpr) {\n // Unary Expression\n const [_, op, arg] = expression;\n const argExpr = generateExpression(ctx, arg);\n const argStr = ctx.resolve(argExpr.value);\n\n const type = operatorToType(argExpr.dataType, op);\n return snip(`${op}${argStr}`, type);\n }\n\n if (expression[0] === NODE.memberAccess) {\n // Member Access\n const [_, targetNode, property] = expression;\n const target = generateExpression(ctx, targetNode);\n\n if (\n infixKinds.includes(target.dataType.type) &&\n property in infixOperators\n ) {\n return {\n value: new InfixDispatch(\n property,\n target,\n infixOperators[property as InfixOperator][$internal].gpuImpl,\n ),\n dataType: UnknownData,\n };\n }\n\n if (target.dataType.type === 'unknown') {\n // No idea what the type is, so we act on the snippet's value and try to guess\n\n // biome-ignore lint/suspicious/noExplicitAny: we're inspecting the value, and it could be any value\n const propValue = (target.value as any)[property];\n\n // We try to extract any type information based on the prop's value\n return coerceToSnippet(propValue);\n }\n\n if (wgsl.isPtr(target.dataType)) {\n return snip(\n `(*${ctx.resolve(target.value)}).${property}`,\n getTypeForPropAccess(target.dataType.inner as AnyData, property),\n );\n }\n\n if (wgsl.isWgslArray(target.dataType) && property === 'length') {\n if (target.dataType.elementCount === 0) {\n // Dynamically-sized array\n return snip(`arrayLength(&${ctx.resolve(target.value)})`, u32);\n }\n\n return snip(String(target.dataType.elementCount), abstractInt);\n }\n\n if (wgsl.isMat(target.dataType) && property === 'columns') {\n return snip(target.value, target.dataType);\n }\n\n if (\n wgsl.isVec(target.dataType) && wgsl.isVecInstance(target.value)\n ) {\n // We're operating on a vector that's known at resolution time\n // biome-ignore lint/suspicious/noExplicitAny: it's probably a swizzle\n return coerceToSnippet((target.value as any)[property]);\n }\n\n return snip(\n `${ctx.resolve(target.value)}.${property}`,\n getTypeForPropAccess(target.dataType, property),\n );\n }\n\n if (expression[0] === NODE.indexAccess) {\n // Index Access\n const [_, targetNode, propertyNode] = expression;\n const target = generateExpression(ctx, targetNode);\n const property = generateExpression(ctx, propertyNode);\n const targetStr = ctx.resolve(target.value);\n const propertyStr = ctx.resolve(property.value);\n\n if (target.dataType.type === 'unknown') {\n // No idea what the type is, so we act on the snippet's value and try to guess\n\n if (\n Array.isArray(propertyNode) && propertyNode[0] === NODE.numericLiteral\n ) {\n return coerceToSnippet(\n // biome-ignore lint/suspicious/noExplicitAny: we're inspecting the value, and it could be any value\n (target.value as any)[propertyNode[1] as number],\n );\n }\n\n throw new Error(\n `Cannot index value ${targetStr} of unknown type with index ${propertyStr}`,\n );\n }\n\n if (wgsl.isPtr(target.dataType)) {\n return snip(\n `(*${targetStr})[${propertyStr}]`,\n getTypeForIndexAccess(target.dataType.inner as AnyData),\n );\n }\n\n return snip(\n `${targetStr}[${propertyStr}]`,\n isData(target.dataType)\n ? getTypeForIndexAccess(target.dataType)\n : UnknownData,\n );\n }\n\n if (expression[0] === NODE.numericLiteral) {\n // Numeric Literal\n const type = numericLiteralToSnippet(expression[1]);\n if (!type) {\n throw new Error(`Invalid numeric literal ${expression[1]}`);\n }\n return type;\n }\n\n if (expression[0] === NODE.call) {\n // Function Call\n const [_, calleeNode, argNodes] = expression;\n const callee = generateExpression(ctx, calleeNode);\n\n if (wgsl.isWgslStruct(callee.value) || wgsl.isWgslArray(callee.value)) {\n // Struct/array schema call.\n if (argNodes.length > 1) {\n throw new WgslTypeError(\n 'Array and struct schemas should always be called with at most 1 argument',\n );\n }\n\n // No arguments `Struct()`, resolve struct name and return.\n if (!argNodes[0]) {\n return snip(\n `${ctx.resolve(callee.value)}()`,\n /* the schema becomes the data type */ callee.value,\n );\n }\n\n const arg = generateTypedExpression(ctx, argNodes[0], callee.value);\n\n // Either `Struct({ x: 1, y: 2 })`, or `Struct(otherStruct)`.\n // In both cases, we just let the argument resolve everything.\n return snip(ctx.resolve(arg.value), callee.value);\n }\n\n if (callee.value instanceof InfixDispatch) {\n // Infix operator dispatch.\n if (!argNodes[0]) {\n throw new WgslTypeError(\n `An infix operator '${callee.value.name}' was called without any arguments`,\n );\n }\n return callee.value.operator(\n callee.value.lhs,\n generateExpression(ctx, argNodes[0]),\n );\n }\n\n if (!isMarkedInternal(callee.value)) {\n throw new Error(\n `Function ${String(callee.value)} ${\n getName(callee.value)\n } has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`,\n );\n }\n\n // Other, including tgsl functions, std and vector/matrix schema calls.\n\n const argConversionHint = callee.value[$internal]\n ?.argConversionHint as FnArgsConversionHint ?? 'keep';\n try {\n let convertedArguments: Snippet[];\n\n if (Array.isArray(argConversionHint)) {\n // The hint is an array of schemas.\n convertedArguments = argNodes.map((arg, i) => {\n const argType = argConversionHint[i];\n if (!argType) {\n throw new WgslTypeError(\n `Function '${\n getName(callee.value)\n }' was called with too many arguments`,\n );\n }\n return generateTypedExpression(ctx, arg, argType);\n });\n } else {\n const resolvedSnippets = argNodes\n .map((arg) => generateExpression(ctx, arg))\n .map((res) => snip(ctx.resolve(res.value), res.dataType));\n\n if (argConversionHint === 'keep') {\n // The hint tells us to do nothing.\n convertedArguments = resolvedSnippets;\n } else if (argConversionHint === 'unify') {\n // The hint tells us to unify the types.\n convertedArguments =\n convertToCommonType({ ctx, values: resolvedSnippets }) ??\n resolvedSnippets;\n } else {\n // The hint is a function that converts the arguments.\n convertedArguments = argConversionHint(...resolvedSnippets)\n .map((type, i) => [type, resolvedSnippets[i] as Snippet] as const)\n .map(([type, sn]) => tryConvertSnippet(ctx, sn, type));\n }\n }\n // Assuming that `callee` is callable\n const fnRes =\n (callee.value as unknown as (...args: unknown[]) => unknown)(\n ...convertedArguments,\n ) as Snippet;\n // We need to reset the indentation level during function body resolution to ignore the indentation level of the function call\n return snip(\n ctx.withResetIndentLevel(() => ctx.resolve(fnRes.value)),\n fnRes.dataType,\n );\n } catch (error) {\n throw new ResolutionError(error, [{\n toString: () => getName(callee.value),\n }]);\n }\n }\n\n if (expression[0] === NODE.objectExpr) {\n // Object Literal\n const obj = expression[1];\n\n const structType = ctx.expectedType;\n\n if (!structType || !wgsl.isWgslStruct(structType)) {\n throw new WgslTypeError(\n `No target type could be inferred for object with keys [${\n Object.keys(obj).join(', ')\n }], please wrap the object in the corresponding schema.`,\n );\n }\n\n const entries = Object.fromEntries(\n Object.entries(structType.propTypes).map(([key, value]) => {\n const val = obj[key];\n if (val === undefined) {\n throw new WgslTypeError(\n `Missing property ${key} in object literal for struct ${structType}`,\n );\n }\n const result = generateTypedExpression(ctx, val, value as AnyData);\n return [key, result];\n }),\n );\n\n const convertedValues = convertStructValues(ctx, structType, entries);\n\n return snip(\n `${ctx.resolve(structType)}(${\n convertedValues.map((v) => ctx.resolve(v.value)).join(', ')\n })`,\n structType,\n );\n }\n\n if (expression[0] === NODE.arrayExpr) {\n const [_, valueNodes] = expression;\n // Array Expression\n const arrType = ctx.expectedType;\n let elemType: AnyData;\n let values: Snippet[];\n\n if (wgsl.isWgslArray(arrType)) {\n elemType = arrType.elementType as AnyData;\n // The array is typed, so its elements should be as well.\n values = valueNodes.map((value) =>\n generateTypedExpression(ctx, value, elemType)\n );\n // Since it's an expected type, we enforce the length\n if (values.length !== arrType.elementCount) {\n throw new WgslTypeError(\n `Cannot create value of type '${arrType}' from an array of length: ${values.length}`,\n );\n }\n } else {\n // The array is not typed, so we try to guess the types.\n const valuesSnippets = valueNodes.map((value) =>\n generateExpression(ctx, value as tinyest.Expression)\n );\n\n if (valuesSnippets.length === 0) {\n throw new WgslTypeError(\n 'Cannot infer the type of an empty array literal.',\n );\n }\n\n const maybeValues = convertToCommonType({ ctx, values: valuesSnippets });\n if (!maybeValues) {\n throw new WgslTypeError(\n 'The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema',\n );\n }\n\n values = maybeValues;\n elemType = concretize(values[0]?.dataType as wgsl.AnyWgslData);\n }\n\n const arrayType = `array<${ctx.resolve(elemType)}, ${values.length}>`;\n const arrayValues = values.map((sn) => ctx.resolve(sn.value));\n\n return snip(\n `${arrayType}(${arrayValues.join(', ')})`,\n arrayOf(\n elemType as wgsl.AnyWgslData,\n values.length,\n ) as wgsl.AnyWgslData,\n );\n }\n\n if (expression[0] === NODE.stringLiteral) {\n throw new Error('Cannot use string literals in TGSL.');\n }\n\n if (expression[0] === NODE.preUpdate) {\n throw new Error('Cannot use pre-updates in TGSL.');\n }\n\n assertExhaustive(expression);\n}\n\nfunction blockifySingleStatement(statement: tinyest.Statement): tinyest.Block {\n return typeof statement !== 'object' ||\n statement[0] !== NODE.block\n ? [NODE.block, [statement]]\n : statement;\n}\n\nexport function generateStatement(\n ctx: GenerationCtx,\n statement: tinyest.Statement,\n): string {\n if (typeof statement === 'string') {\n return `${ctx.pre}${\n ctx.resolve(generateIdentifier(ctx, statement).value)\n };`;\n }\n\n if (typeof statement === 'boolean') {\n return `${ctx.pre}${statement ? 'true' : 'false'};`;\n }\n\n if (statement[0] === NODE.return) {\n const returnNode = statement[1];\n\n const returnValue = returnNode !== undefined\n ? ctx.resolve(\n generateTypedExpression(\n ctx,\n returnNode,\n ctx.topFunctionReturnType,\n ).value,\n )\n : undefined;\n\n return returnValue\n ? `${ctx.pre}return ${returnValue};`\n : `${ctx.pre}return;`;\n }\n\n if (statement[0] === NODE.if) {\n const [_, cond, cons, alt] = statement;\n const condition = ctx.resolve(\n generateTypedExpression(ctx, cond, bool).value,\n );\n\n const consequent = generateBlock(ctx, blockifySingleStatement(cons));\n const alternate = alt\n ? generateBlock(ctx, blockifySingleStatement(alt))\n : undefined;\n\n if (!alternate) {\n return `${ctx.pre}if (${condition}) ${consequent}`;\n }\n\n return `\\\n${ctx.pre}if (${condition}) ${consequent}\n${ctx.pre}else ${alternate}`;\n }\n\n if (statement[0] === NODE.let || statement[0] === NODE.const) {\n const [_, rawId, rawValue] = statement;\n const eq = rawValue !== undefined\n ? generateExpression(ctx, rawValue)\n : undefined;\n\n if (!eq) {\n throw new Error(\n `Cannot create variable '${rawId}' without an initial value.`,\n );\n }\n\n if (isLooseData(eq.dataType)) {\n throw new Error(\n `Cannot create variable '${rawId}' with loose data type.`,\n );\n }\n\n registerBlockVariable(\n ctx,\n rawId,\n concretize(eq.dataType as wgsl.AnyWgslData),\n );\n const id = ctx.resolve(generateIdentifier(ctx, rawId).value);\n\n return `${ctx.pre}var ${id} = ${ctx.resolve(eq.value)};`;\n }\n\n if (statement[0] === NODE.block) {\n return generateBlock(ctx, statement);\n }\n\n if (statement[0] === NODE.for) {\n const [_, init, condition, update, body] = statement;\n\n const [initStatement, conditionExpr, updateStatement] = ctx\n .withResetIndentLevel(\n () => [\n init ? generateStatement(ctx, init) : undefined,\n condition ? generateExpression(ctx, condition) : undefined,\n update ? generateStatement(ctx, update) : undefined,\n ],\n );\n\n const initStr = initStatement ? initStatement.slice(0, -1) : '';\n\n const condSnippet = condition\n ? generateTypedExpression(ctx, condition, bool)\n : undefined;\n const conditionStr = condSnippet ? ctx.resolve(condSnippet.value) : '';\n\n const updateStr = updateStatement ? updateStatement.slice(0, -1) : '';\n\n const bodyStr = generateBlock(ctx, blockifySingleStatement(body));\n return `${ctx.pre}for (${initStr}; ${conditionStr}; ${updateStr}) ${bodyStr}`;\n }\n\n if (statement[0] === NODE.while) {\n const [_, condition, body] = statement;\n const condSnippet = generateTypedExpression(ctx, condition, bool);\n const conditionStr = ctx.resolve(condSnippet.value);\n\n const bodyStr = generateBlock(ctx, blockifySingleStatement(body));\n return `${ctx.pre}while (${conditionStr}) ${bodyStr}`;\n }\n\n if (statement[0] === NODE.continue) {\n return `${ctx.pre}continue;`;\n }\n\n if (statement[0] === NODE.break) {\n return `${ctx.pre}break;`;\n }\n\n return `${ctx.pre}${ctx.resolve(generateExpression(ctx, statement).value)};`;\n}\n\nexport function generateFunction(\n ctx: GenerationCtx,\n body: tinyest.Block,\n): string {\n return generateBlock(ctx, body);\n}\n","/**\n * @param value\n * @param modulo has to be power of 2\n */\nexport const roundUp = (value: number, modulo: number) => {\n const bitMask = modulo - 1;\n const invBitMask = ~bitMask;\n return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;\n};\n","export const vertexFormats = [\n 'uint8',\n 'uint8x2',\n 'uint8x4',\n 'sint8',\n 'sint8x2',\n 'sint8x4',\n 'unorm8',\n 'unorm8x2',\n 'unorm8x4',\n 'snorm8',\n 'snorm8x2',\n 'snorm8x4',\n 'uint16',\n 'uint16x2',\n 'uint16x4',\n 'sint16',\n 'sint16x2',\n 'sint16x4',\n 'unorm16',\n 'unorm16x2',\n 'unorm16x4',\n 'snorm16',\n 'snorm16x2',\n 'snorm16x4',\n 'float16',\n 'float16x2',\n 'float16x4',\n 'float32',\n 'float32x2',\n 'float32x3',\n 'float32x4',\n 'uint32',\n 'uint32x2',\n 'uint32x3',\n 'uint32x4',\n 'sint32',\n 'sint32x2',\n 'sint32x3',\n 'sint32x4',\n 'unorm10-10-10-2',\n 'unorm8x4-bgra',\n] as const;\n\nexport type VertexFormat = (typeof vertexFormats)[number];\n\nexport const kindToDefaultFormatMap = {\n f32: 'float32',\n vec2f: 'float32x2',\n vec3f: 'float32x3',\n vec4f: 'float32x4',\n f16: 'float16',\n vec2h: 'float16x2',\n // vec3h has no direct equivalent in the spec\n vec4h: 'float16x4',\n u32: 'uint32',\n vec2u: 'uint32x2',\n vec3u: 'uint32x3',\n vec4u: 'uint32x4',\n i32: 'sint32',\n vec2i: 'sint32x2',\n vec3i: 'sint32x3',\n vec4i: 'sint32x4',\n} as const;\n\nexport type KindToDefaultFormatMap = typeof kindToDefaultFormatMap;\n\nexport interface TgpuVertexAttrib<TFormat extends VertexFormat = VertexFormat> {\n readonly format: TFormat;\n readonly offset: number;\n}\n\nexport type AnyVertexAttribs =\n | Record<string, TgpuVertexAttrib>\n | TgpuVertexAttrib;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * an single or multi component u32 in a shader.\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype U32CompatibleFormats =\n | TgpuVertexAttrib<'uint8'>\n | TgpuVertexAttrib<'uint8x2'>\n | TgpuVertexAttrib<'uint8x4'>\n | TgpuVertexAttrib<'uint16'>\n | TgpuVertexAttrib<'uint16x2'>\n | TgpuVertexAttrib<'uint16x4'>\n | TgpuVertexAttrib<'uint32'>\n | TgpuVertexAttrib<'uint32x2'>\n | TgpuVertexAttrib<'uint32x3'>\n | TgpuVertexAttrib<'uint32x4'>;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * an single or multi component i32 in a shader.\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype I32CompatibleFormats =\n | TgpuVertexAttrib<'sint8'>\n | TgpuVertexAttrib<'sint8x2'>\n | TgpuVertexAttrib<'sint8x4'>\n | TgpuVertexAttrib<'sint16'>\n | TgpuVertexAttrib<'sint16x2'>\n | TgpuVertexAttrib<'sint16x4'>\n | TgpuVertexAttrib<'sint32'>\n | TgpuVertexAttrib<'sint32x2'>\n | TgpuVertexAttrib<'sint32x3'>\n | TgpuVertexAttrib<'sint32x4'>;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * an single or multi component f32 in a shader.\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype F32CompatibleFormats =\n | TgpuVertexAttrib<'unorm8'>\n | TgpuVertexAttrib<'unorm8x2'>\n | TgpuVertexAttrib<'unorm8x4'>\n | TgpuVertexAttrib<'snorm8'>\n | TgpuVertexAttrib<'snorm8x2'>\n | TgpuVertexAttrib<'snorm8x4'>\n | TgpuVertexAttrib<'unorm16'>\n | TgpuVertexAttrib<'unorm16x2'>\n | TgpuVertexAttrib<'unorm16x4'>\n | TgpuVertexAttrib<'snorm16'>\n | TgpuVertexAttrib<'snorm16x2'>\n | TgpuVertexAttrib<'snorm16x4'>\n | TgpuVertexAttrib<'float16'>\n | TgpuVertexAttrib<'float16x2'>\n | TgpuVertexAttrib<'float16x4'>\n | TgpuVertexAttrib<'float32'>\n | TgpuVertexAttrib<'float32x2'>\n | TgpuVertexAttrib<'float32x3'>\n | TgpuVertexAttrib<'float32x4'>\n | TgpuVertexAttrib<'unorm10-10-10-2'>\n | TgpuVertexAttrib<'unorm8x4-bgra'>;\n\n/**\n * All vertex attribute formats that can be interpreted as\n * a single or multi component f16 in a shader. (same as f32 on the shader side)\n * https://www.w3.org/TR/webgpu/#vertex-formats\n */\ntype F16CompatibleFormats = F32CompatibleFormats;\n\nexport type KindToAcceptedAttribMap = {\n u32: U32CompatibleFormats;\n vec2u: U32CompatibleFormats;\n vec3u: U32CompatibleFormats;\n vec4u: U32CompatibleFormats;\n\n i32: I32CompatibleFormats;\n vec2i: I32CompatibleFormats;\n vec3i: I32CompatibleFormats;\n vec4i: I32CompatibleFormats;\n\n f16: F16CompatibleFormats;\n vec2h: F16CompatibleFormats;\n vec3h: F16CompatibleFormats;\n vec4h: F16CompatibleFormats;\n\n f32: F32CompatibleFormats;\n vec2f: F32CompatibleFormats;\n vec3f: F32CompatibleFormats;\n vec4f: F32CompatibleFormats;\n};\n","import type { TgpuNamable } from '../shared/meta.ts';\nimport type {\n Infer,\n InferGPURecord,\n InferPartial,\n InferPartialRecord,\n InferRecord,\n IsValidVertexSchema,\n MemIdentityRecord,\n} from '../shared/repr.ts';\nimport type {\n $gpuRepr,\n $invalidSchemaReason,\n $memIdent,\n $repr,\n $reprPartial,\n $validVertexSchema,\n} from '../shared/symbols.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { Prettify } from '../shared/utilityTypes.ts';\nimport { vertexFormats } from '../shared/vertexFormat.ts';\nimport type { FnArgsConversionHint } from '../types.ts';\nimport type { MapValueToSnippet, Snippet } from './snippet.ts';\nimport type { PackedData } from './vertexFormatData.ts';\nimport * as wgsl from './wgslTypes.ts';\n\nexport type TgpuDualFn<TImpl extends (...args: never[]) => unknown> =\n & TImpl\n & {\n [$internal]: {\n jsImpl: TImpl | string;\n gpuImpl: (...args: MapValueToSnippet<Parameters<TImpl>>) => Snippet;\n argConversionHint: FnArgsConversionHint;\n };\n };\n\n/**\n * Array schema constructed via `d.disarrayOf` function.\n *\n * Useful for defining vertex buffers.\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n */\nexport interface Disarray<TElement extends wgsl.BaseData = wgsl.BaseData>\n extends wgsl.BaseData {\n readonly type: 'disarray';\n readonly elementCount: number;\n readonly elementType: TElement;\n\n // Type-tokens, not available at runtime\n readonly [$repr]: Infer<TElement>[];\n readonly [$reprPartial]:\n | { idx: number; value: InferPartial<TElement> }[]\n | undefined;\n readonly [$validVertexSchema]: IsValidVertexSchema<TElement>;\n readonly [$invalidSchemaReason]:\n 'Disarrays are not host-shareable, use arrays instead';\n // ---\n}\n\n/**\n * Struct schema constructed via `d.unstruct` function.\n *\n * Useful for defining vertex buffers, as the standard layout restrictions do not apply.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n */\nexport interface Unstruct<\n // biome-ignore lint/suspicious/noExplicitAny: the widest type that works with both covariance and contravariance\n TProps extends Record<string, wgsl.BaseData> = any,\n> extends wgsl.BaseData, TgpuNamable {\n (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;\n readonly type: 'unstruct';\n readonly propTypes: TProps;\n\n // Type-tokens, not available at runtime\n readonly [$repr]: Prettify<InferRecord<TProps>>;\n readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;\n readonly [$memIdent]: Unstruct<Prettify<MemIdentityRecord<TProps>>>;\n readonly [$reprPartial]:\n | Prettify<Partial<InferPartialRecord<TProps>>>\n | undefined;\n readonly [$validVertexSchema]: {\n [K in keyof TProps]: IsValidVertexSchema<TProps[K]>;\n }[keyof TProps] extends true ? true : false;\n readonly [$invalidSchemaReason]:\n 'Unstructs are not host-shareable, use structs instead';\n // ---\n}\n\n/** @deprecated Just use `Unstruct` without any type parameters */\nexport type AnyUnstruct = Unstruct;\n\nexport interface LooseDecorated<\n TInner extends wgsl.BaseData = wgsl.BaseData,\n TAttribs extends unknown[] = unknown[],\n> extends wgsl.BaseData {\n readonly type: 'loose-decorated';\n readonly inner: TInner;\n readonly attribs: TAttribs;\n\n // Type-tokens, not available at runtime\n readonly [$repr]: Infer<TInner>;\n readonly [$invalidSchemaReason]:\n 'Loosely decorated schemas are not host-shareable';\n readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;\n // ---\n}\n\nconst looseTypeLiterals = [\n 'unstruct',\n 'disarray',\n 'loose-decorated',\n ...vertexFormats,\n] as const;\n\nexport type LooseTypeLiteral = (typeof looseTypeLiterals)[number];\n\nexport type AnyLooseData = Disarray | Unstruct | LooseDecorated | PackedData;\n\nexport function isLooseData(data: unknown): data is AnyLooseData {\n return (\n (data as AnyLooseData)?.[$internal] &&\n looseTypeLiterals.includes((data as AnyLooseData)?.type)\n );\n}\n\n/**\n * Checks whether the passed in value is a disarray schema,\n * as opposed to, e.g., a regular array schema.\n *\n * Array schemas can be used to describe uniform and storage buffers,\n * whereas disarray schemas cannot. Disarrays are useful for\n * defining vertex buffers instead.\n *\n * @example\n * isDisarray(d.arrayOf(d.u32, 4)) // false\n * isDisarray(d.disarrayOf(d.u32, 4)) // true\n * isDisarray(d.vec3f) // false\n */\nexport function isDisarray<T extends Disarray>(\n schema: T | unknown,\n): schema is T {\n return (schema as T)?.[$internal] && (schema as T)?.type === 'disarray';\n}\n\n/**\n * Checks whether passed in value is a unstruct schema,\n * as opposed to, e.g., a struct schema.\n *\n * Struct schemas can be used to describe uniform and storage buffers,\n * whereas unstruct schemas cannot. Unstructs are useful for\n * defining vertex buffers instead.\n *\n * @example\n * isUnstruct(d.struct({ a: d.u32 })) // false\n * isUnstruct(d.unstruct({ a: d.u32 })) // true\n * isUnstruct(d.vec3f) // false\n */\nexport function isUnstruct<T extends Unstruct>(\n schema: T | unknown,\n): schema is T {\n return (schema as T)?.[$internal] && (schema as T)?.type === 'unstruct';\n}\n\nexport function isLooseDecorated<T extends LooseDecorated>(\n value: T | unknown,\n): value is T {\n return (value as T)?.[$internal] && (value as T)?.type === 'loose-decorated';\n}\n\nexport function getCustomAlignment(data: wgsl.BaseData): number | undefined {\n return (data as unknown as wgsl.Decorated | LooseDecorated).attribs?.find(\n wgsl.isAlignAttrib,\n )?.params[0];\n}\n\nexport function getCustomSize(data: wgsl.BaseData): number | undefined {\n return (data as unknown as wgsl.Decorated | LooseDecorated).attribs?.find(\n wgsl.isSizeAttrib,\n )?.params[0];\n}\n\nexport function getCustomLocation(data: wgsl.BaseData): number | undefined {\n return (data as unknown as wgsl.Decorated | LooseDecorated).attribs?.find(\n wgsl.isLocationAttrib,\n )?.params[0];\n}\n\nexport function isData(value: unknown): value is AnyData {\n return wgsl.isWgslData(value) || isLooseData(value);\n}\n\nexport type AnyData = wgsl.AnyWgslData | AnyLooseData;\nexport type AnyConcreteData = Exclude<\n AnyData,\n wgsl.AbstractInt | wgsl.AbstractFloat | wgsl.Void\n>;\n\nexport interface UnknownData {\n readonly type: 'unknown';\n}\n\nexport const UnknownData = {\n type: 'unknown' as const,\n toString() {\n return 'unknown';\n },\n} as UnknownData;\n\nexport class InfixDispatch {\n constructor(\n readonly name: string,\n readonly lhs: Snippet,\n readonly operator: (lhs: Snippet, rhs: Snippet) => Snippet,\n ) {}\n}\n","import type { Infer } from '../shared/repr.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type {\n $invalidSchemaReason,\n $repr,\n $validVertexSchema,\n} from '../shared/symbols.ts';\nimport type { VertexFormat } from '../shared/vertexFormat.ts';\nimport { f32, i32, u32 } from './numeric.ts';\nimport {\n vec2f,\n vec2i,\n vec2u,\n vec3f,\n vec3i,\n vec3u,\n vec4f,\n vec4i,\n vec4u,\n} from './vector.ts';\nimport type { BaseData } from './wgslTypes.ts';\n\nexport type FormatToWGSLType<T extends VertexFormat> =\n (typeof formatToWGSLType)[T];\n\nexport interface TgpuVertexFormatData<T extends VertexFormat> extends BaseData {\n readonly type: T;\n\n // Type-tokens, not available at runtime\n readonly [$repr]: Infer<FormatToWGSLType<T>>;\n readonly [$validVertexSchema]: true;\n readonly [$invalidSchemaReason]:\n 'Vertex formats are not host-shareable, use concrete types instead';\n // ---\n}\n\nclass TgpuVertexFormatDataImpl<T extends VertexFormat>\n implements TgpuVertexFormatData<T> {\n public readonly [$internal] = true;\n\n // Type-tokens, not available at runtime\n declare readonly [$repr]: Infer<FormatToWGSLType<T>>;\n declare readonly [$validVertexSchema]: true;\n declare readonly [$invalidSchemaReason]:\n 'Vertex formats are not host-shareable, use concrete types instead';\n // ---\n\n constructor(public readonly type: T) {}\n}\n\nexport const formatToWGSLType = {\n uint8: u32,\n uint8x2: vec2u,\n uint8x4: vec4u,\n sint8: i32,\n sint8x2: vec2i,\n sint8x4: vec4i,\n unorm8: f32,\n unorm8x2: vec2f,\n unorm8x4: vec4f,\n snorm8: f32,\n snorm8x2: vec2f,\n snorm8x4: vec4f,\n uint16: u32,\n uint16x2: vec2u,\n uint16x4: vec4u,\n sint16: i32,\n sint16x2: vec2i,\n sint16x4: vec4i,\n unorm16: f32,\n unorm16x2: vec2f,\n unorm16x4: vec4f,\n snorm16: f32,\n snorm16x2: vec2f,\n snorm16x4: vec4f,\n float16: f32,\n float16x2: vec2f,\n float16x4: vec4f,\n float32: f32,\n float32x2: vec2f,\n float32x3: vec3f,\n float32x4: vec4f,\n uint32: u32,\n uint32x2: vec2u,\n uint32x3: vec3u,\n uint32x4: vec4u,\n sint32: i32,\n sint32x2: vec2i,\n sint32x3: vec3i,\n sint32x4: vec4i,\n 'unorm10-10-10-2': vec4f,\n 'unorm8x4-bgra': vec4f,\n} as const;\n\nexport const packedFormats = new Set(Object.keys(formatToWGSLType));\n\nexport type uint8 = TgpuVertexFormatData<'uint8'>;\nexport const uint8 = new TgpuVertexFormatDataImpl('uint8') as uint8;\n\nexport type uint8x2 = TgpuVertexFormatData<'uint8x2'>;\nexport const uint8x2 = new TgpuVertexFormatDataImpl('uint8x2') as uint8x2;\n\nexport type uint8x4 = TgpuVertexFormatData<'uint8x4'>;\nexport const uint8x4 = new TgpuVertexFormatDataImpl('uint8x4') as uint8x4;\n\nexport type sint8 = TgpuVertexFormatData<'sint8'>;\nexport const sint8 = new TgpuVertexFormatDataImpl('sint8') as sint8;\n\nexport type sint8x2 = TgpuVertexFormatData<'sint8x2'>;\nexport const sint8x2 = new TgpuVertexFormatDataImpl('sint8x2') as sint8x2;\n\nexport type sint8x4 = TgpuVertexFormatData<'sint8x4'>;\nexport const sint8x4 = new TgpuVertexFormatDataImpl('sint8x4') as sint8x4;\n\nexport type unorm8 = TgpuVertexFormatData<'unorm8'>;\nexport const unorm8 = new TgpuVertexFormatDataImpl('unorm8') as unorm8;\n\nexport type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;\nexport const unorm8x2 = new TgpuVertexFormatDataImpl('unorm8x2') as unorm8x2;\n\nexport type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;\nexport const unorm8x4 = new TgpuVertexFormatDataImpl('unorm8x4') as unorm8x4;\n\nexport type snorm8 = TgpuVertexFormatData<'snorm8'>;\nexport const snorm8 = new TgpuVertexFormatDataImpl('snorm8') as snorm8;\n\nexport type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;\nexport const snorm8x2 = new TgpuVertexFormatDataImpl('snorm8x2') as snorm8x2;\n\nexport type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;\nexport const snorm8x4 = new TgpuVertexFormatDataImpl('snorm8x4') as snorm8x4;\n\nexport type uint16 = TgpuVertexFormatData<'uint16'>;\nexport const uint16 = new TgpuVertexFormatDataImpl('uint16') as uint16;\n\nexport type uint16x2 = TgpuVertexFormatData<'uint16x2'>;\nexport const uint16x2 = new TgpuVertexFormatDataImpl('uint16x2') as uint16x2;\n\nexport type uint16x4 = TgpuVertexFormatData<'uint16x4'>;\nexport const uint16x4 = new TgpuVertexFormatDataImpl('uint16x4') as uint16x4;\n\nexport type sint16 = TgpuVertexFormatData<'sint16'>;\nexport const sint16 = new TgpuVertexFormatDataImpl('sint16') as sint16;\n\nexport type sint16x2 = TgpuVertexFormatData<'sint16x2'>;\nexport const sint16x2 = new TgpuVertexFormatDataImpl('sint16x2') as sint16x2;\n\nexport type sint16x4 = TgpuVertexFormatData<'sint16x4'>;\nexport const sint16x4 = new TgpuVertexFormatDataImpl('sint16x4') as sint16x4;\n\nexport type unorm16 = TgpuVertexFormatData<'unorm16'>;\nexport const unorm16 = new TgpuVertexFormatDataImpl('unorm16') as unorm16;\n\nexport type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;\nexport const unorm16x2 = new TgpuVertexFormatDataImpl('unorm16x2') as unorm16x2;\n\nexport type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;\nexport const unorm16x4 = new TgpuVertexFormatDataImpl('unorm16x4') as unorm16x4;\n\nexport type snorm16 = TgpuVertexFormatData<'snorm16'>;\nexport const snorm16 = new TgpuVertexFormatDataImpl('snorm16') as snorm16;\n\nexport type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;\nexport const snorm16x2 = new TgpuVertexFormatDataImpl('snorm16x2') as snorm16x2;\n\nexport type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;\nexport const snorm16x4 = new TgpuVertexFormatDataImpl('snorm16x4') as snorm16x4;\n\nexport type float16 = TgpuVertexFormatData<'float16'>;\nexport const float16 = new TgpuVertexFormatDataImpl('float16') as float16;\n\nexport type float16x2 = TgpuVertexFormatData<'float16x2'>;\nexport const float16x2 = new TgpuVertexFormatDataImpl('float16x2') as float16x2;\n\nexport type float16x4 = TgpuVertexFormatData<'float16x4'>;\nexport const float16x4 = new TgpuVertexFormatDataImpl('float16x4') as float16x4;\n\nexport type float32 = TgpuVertexFormatData<'float32'>;\nexport const float32 = new TgpuVertexFormatDataImpl('float32') as float32;\n\nexport type float32x2 = TgpuVertexFormatData<'float32x2'>;\nexport const float32x2 = new TgpuVertexFormatDataImpl('float32x2') as float32x2;\n\nexport type float32x3 = TgpuVertexFormatData<'float32x3'>;\nexport const float32x3 = new TgpuVertexFormatDataImpl('float32x3') as float32x3;\n\nexport type float32x4 = TgpuVertexFormatData<'float32x4'>;\nexport const float32x4 = new TgpuVertexFormatDataImpl('float32x4') as float32x4;\n\nexport type uint32 = TgpuVertexFormatData<'uint32'>;\nexport const uint32 = new TgpuVertexFormatDataImpl('uint32') as uint32;\n\nexport type uint32x2 = TgpuVertexFormatData<'uint32x2'>;\nexport const uint32x2 = new TgpuVertexFormatDataImpl('uint32x2') as uint32x2;\n\nexport type uint32x3 = TgpuVertexFormatData<'uint32x3'>;\nexport const uint32x3 = new TgpuVertexFormatDataImpl('uint32x3') as uint32x3;\n\nexport type uint32x4 = TgpuVertexFormatData<'uint32x4'>;\nexport const uint32x4 = new TgpuVertexFormatDataImpl('uint32x4') as uint32x4;\n\nexport type sint32 = TgpuVertexFormatData<'sint32'>;\nexport const sint32 = new TgpuVertexFormatDataImpl('sint32') as sint32;\n\nexport type sint32x2 = TgpuVertexFormatData<'sint32x2'>;\nexport const sint32x2 = new TgpuVertexFormatDataImpl('sint32x2') as sint32x2;\n\nexport type sint32x3 = TgpuVertexFormatData<'sint32x3'>;\nexport const sint32x3 = new TgpuVertexFormatDataImpl('sint32x3') as sint32x3;\n\nexport type sint32x4 = TgpuVertexFormatData<'sint32x4'>;\nexport const sint32x4 = new TgpuVertexFormatDataImpl('sint32x4') as sint32x4;\n\nexport type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;\nexport const unorm10_10_10_2 = new TgpuVertexFormatDataImpl(\n 'unorm10-10-10-2',\n) as unorm10_10_10_2;\n\nexport type unorm8x4_bgra = TgpuVertexFormatData<'unorm8x4-bgra'>;\nexport const unorm8x4_bgra = new TgpuVertexFormatDataImpl(\n 'unorm8x4-bgra',\n) as unorm8x4_bgra;\n\nexport type PackedData =\n | uint8\n | uint8x2\n | uint8x4\n | sint8\n | sint8x2\n | sint8x4\n | unorm8\n | unorm8x2\n | unorm8x4\n | snorm8\n | snorm8x2\n | snorm8x4\n | uint16\n | uint16x2\n | uint16x4\n | sint16\n | sint16x2\n | sint16x4\n | unorm16\n | unorm16x2\n | unorm16x4\n | snorm16\n | snorm16x2\n | snorm16x4\n | float16\n | float16x2\n | float16x4\n | float32\n | float32x2\n | float32x3\n | float32x4\n | uint32\n | uint32x2\n | uint32x3\n | uint32x4\n | sint32\n | sint32x2\n | sint32x3\n | sint32x4\n | unorm10_10_10_2\n | unorm8x4_bgra;\n\nexport function isPackedData(\n value: unknown,\n): value is PackedData {\n return (value as PackedData)?.[$internal] &&\n packedFormats.has(\n (value as PackedData)?.type,\n );\n}\n","import {\n type AnyData,\n getCustomAlignment,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nimport { packedFormats } from './vertexFormatData.ts';\nimport {\n type BaseData,\n isDecorated,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes.ts';\n\nconst knownAlignmentMap: Record<string, number> = {\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n u16: 2,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n vec3f: 16,\n vec3h: 8,\n vec3i: 16,\n vec3u: 16,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n mat2x2f: 8,\n mat3x3f: 16,\n mat4x4f: 16,\n atomic: 4,\n};\n\nfunction computeAlignment(data: object): number {\n const dataType = (data as BaseData)?.type;\n const knownAlignment = knownAlignmentMap[dataType];\n if (knownAlignment !== undefined) {\n return knownAlignment;\n }\n\n if (isWgslStruct(data)) {\n return Object.values(data.propTypes as Record<string, BaseData>)\n .map(alignmentOf)\n .reduce((a, b) => (a > b ? a : b));\n }\n\n if (isWgslArray(data)) {\n return alignmentOf(data.elementType);\n }\n\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp =\n Object.values(data.propTypes as Record<string, BaseData>)[0];\n return firstProp ? (getCustomAlignment(firstProp) ?? 1) : 1;\n }\n\n if (isDisarray(data)) {\n return getCustomAlignment(data.elementType) ?? 1;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? alignmentOf(data.inner);\n }\n\n if (packedFormats.has(dataType)) {\n return 1;\n }\n\n throw new Error(\n `Cannot determine alignment of data: ${JSON.stringify(data)}`,\n );\n}\n\nfunction computeCustomAlignment(data: BaseData): number {\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp =\n Object.values(data.propTypes as Record<string, BaseData>)[0];\n return firstProp ? customAlignmentOf(firstProp) : 1;\n }\n\n if (isDisarray(data)) {\n return customAlignmentOf(data.elementType);\n }\n\n if (isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? customAlignmentOf(data.inner);\n }\n\n return getCustomAlignment(data) ?? 1;\n}\n\n/**\n * Since alignments can be inferred from data types, they are not stored on them.\n * Instead, this weak map acts as an extended property of those data types.\n */\nconst cachedAlignments = new WeakMap<object, number>();\n\nconst cachedCustomAlignments = new WeakMap<object, number>();\n\nexport function alignmentOf(data: BaseData): number {\n let alignment = cachedAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeAlignment(data);\n cachedAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\nexport function customAlignmentOf(data: BaseData): number {\n let alignment = cachedCustomAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeCustomAlignment(data);\n cachedCustomAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\n/**\n * Returns the alignment (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_alignmentOf(schema: AnyData): number {\n return alignmentOf(schema);\n}\n","import { arrayOf } from '../data/array.ts';\nimport {\n type AnyData,\n isDisarray,\n isUnstruct,\n UnknownData,\n} from '../data/dataTypes.ts';\nimport { isSnippet, snip, type Snippet } from '../data/snippet.ts';\nimport { mat2x2f, mat3x3f, mat4x4f } from '../data/matrix.ts';\nimport {\n abstractFloat,\n abstractInt,\n bool,\n f16,\n f32,\n i32,\n u32,\n} from '../data/numeric.ts';\nimport {\n vec2b,\n vec2f,\n vec2h,\n vec2i,\n vec2u,\n vec3b,\n vec3f,\n vec3h,\n vec3i,\n vec3u,\n vec4b,\n vec4f,\n vec4h,\n vec4i,\n vec4u,\n vecTypeToPrimitive,\n} from '../data/vector.ts';\nimport {\n type AnyWgslData,\n type F16,\n type F32,\n hasInternalDataType,\n type I32,\n isMat,\n isMatInstance,\n isVec,\n isVecInstance,\n isWgslArray,\n isWgslStruct,\n type U32,\n type WgslStruct,\n} from '../data/wgslTypes.ts';\nimport { invariant, WgslTypeError } from '../errors.ts';\nimport { getResolutionCtx } from '../execMode.ts';\nimport { DEV } from '../shared/env.ts';\nimport { $wgslDataType } from '../shared/symbols.ts';\nimport { assertExhaustive } from '../shared/utilityTypes.ts';\nimport { isNumericSchema } from '../std/numeric.ts';\nimport type { ResolutionCtx } from '../types.ts';\nimport { undecorate } from '../data/decorateUtils.ts';\n\ntype SwizzleableType = 'f' | 'h' | 'i' | 'u' | 'b';\ntype SwizzleLength = 1 | 2 | 3 | 4;\n\nconst swizzleLenToType: Record<\n SwizzleableType,\n Record<SwizzleLength, AnyData>\n> = {\n f: {\n 1: f32,\n 2: vec2f,\n 3: vec3f,\n 4: vec4f,\n },\n h: {\n 1: f16,\n 2: vec2h,\n 3: vec3h,\n 4: vec4h,\n },\n i: {\n 1: i32,\n 2: vec2i,\n 3: vec3i,\n 4: vec4i,\n },\n u: {\n 1: u32,\n 2: vec2u,\n 3: vec3u,\n 4: vec4u,\n },\n b: {\n 1: bool,\n 2: vec2b,\n 3: vec3b,\n 4: vec4b,\n },\n} as const;\n\nconst kindToSchema = {\n vec2f: vec2f,\n vec2h: vec2h,\n vec2i: vec2i,\n vec2u: vec2u,\n 'vec2<bool>': vec2b,\n vec3f: vec3f,\n vec3h: vec3h,\n vec3i: vec3i,\n vec3u: vec3u,\n 'vec3<bool>': vec3b,\n vec4f: vec4f,\n vec4h: vec4h,\n vec4i: vec4i,\n vec4u: vec4u,\n 'vec4<bool>': vec4b,\n mat2x2f: mat2x2f,\n mat3x3f: mat3x3f,\n mat4x4f: mat4x4f,\n} as const;\n\nconst indexableTypeToResult = {\n vec2f: f32,\n vec2h: f16,\n vec2i: i32,\n vec2u: u32,\n 'vec2<bool>': bool,\n vec3f: f32,\n vec3h: f16,\n vec3i: i32,\n vec3u: u32,\n 'vec3<bool>': bool,\n vec4f: f32,\n vec4h: f16,\n vec4i: i32,\n vec4u: u32,\n 'vec4<bool>': bool,\n mat2x2f: vec2f,\n mat3x3f: vec3f,\n mat4x4f: vec4f,\n} as const;\n\nexport function getTypeForPropAccess(\n targetType: AnyData,\n propName: string,\n): AnyData | UnknownData {\n if (isWgslStruct(targetType) || isUnstruct(targetType)) {\n return targetType.propTypes[propName] as AnyData ?? UnknownData;\n }\n\n if (targetType === bool || isNumericSchema(targetType)) {\n // No props to be accessed here\n return UnknownData;\n }\n\n const propLength = propName.length;\n if (\n isVec(targetType) &&\n propLength >= 1 &&\n propLength <= 4\n ) {\n const swizzleTypeChar = targetType.type.includes('bool')\n ? 'b'\n : (targetType.type[4] as SwizzleableType);\n const swizzleType =\n swizzleLenToType[swizzleTypeChar][propLength as SwizzleLength];\n if (swizzleType) {\n return swizzleType;\n }\n }\n\n return UnknownData;\n}\n\nexport function getTypeForIndexAccess(\n dataType: AnyData,\n): AnyData | UnknownData {\n // array\n if (isWgslArray(dataType) || isDisarray(dataType)) {\n return dataType.elementType as AnyData;\n }\n\n // vector or matrix\n if (dataType.type in indexableTypeToResult) {\n return indexableTypeToResult[\n dataType.type as keyof typeof indexableTypeToResult\n ];\n }\n\n return UnknownData;\n}\n\nexport function numericLiteralToSnippet(value: string): Snippet | undefined {\n // Hex literals\n if (/^0x[0-9a-f]+$/i.test(value)) {\n return snip(value, abstractInt);\n }\n\n // Binary literals\n if (/^0b[01]+$/i.test(value)) {\n return snip(`${Number.parseInt(value.slice(2), 2)}`, abstractInt);\n }\n\n // Floating point literals\n if (/^-?(?:\\d+\\.\\d*|\\d*\\.\\d+)$/i.test(value)) {\n return snip(value, abstractFloat);\n }\n\n // Floating point literals with scientific notation\n if (/^-?\\d+(?:\\.\\d+)?e-?\\d+$/i.test(value)) {\n return snip(value, abstractFloat);\n }\n\n // Integer literals\n if (/^-?\\d+$/i.test(value)) {\n return snip(value, abstractInt);\n }\n\n return undefined;\n}\n\ntype ConversionAction = 'ref' | 'deref' | 'cast' | 'none';\n\ntype ConversionRankInfo =\n | { rank: number; action: 'cast'; targetType: AnyData }\n | { rank: number; action: Exclude<ConversionAction, 'cast'> };\n\nconst INFINITE_RANK: ConversionRankInfo = {\n rank: Number.POSITIVE_INFINITY,\n action: 'none',\n};\n\nfunction getVectorComponent(type: AnyData): AnyData | undefined {\n return isVec(type) ? vecTypeToPrimitive[type.type] : undefined;\n}\n\nfunction getAutoConversionRank(\n src: AnyData,\n dest: AnyData,\n): ConversionRankInfo {\n const trueSrc = undecorate(src);\n const trueDst = undecorate(dest);\n\n if (trueSrc.type === trueDst.type) {\n return { rank: 0, action: 'none' };\n }\n\n if (trueSrc.type === 'abstractFloat') {\n if (trueDst.type === 'f32') return { rank: 1, action: 'none' };\n if (trueDst.type === 'f16') return { rank: 2, action: 'none' };\n }\n\n if (trueSrc.type === 'abstractInt') {\n if (trueDst.type === 'i32') return { rank: 3, action: 'none' };\n if (trueDst.type === 'u32') return { rank: 4, action: 'none' };\n if (trueDst.type === 'abstractFloat') return { rank: 5, action: 'none' };\n if (trueDst.type === 'f32') return { rank: 6, action: 'none' };\n if (trueDst.type === 'f16') return { rank: 7, action: 'none' };\n }\n\n if (isVec(trueSrc) && isVec(trueDst)) {\n const compSrc = getVectorComponent(trueSrc);\n const compDest = getVectorComponent(trueDst);\n if (compSrc && compDest) {\n return getAutoConversionRank(compSrc, compDest);\n }\n }\n\n if (isMat(trueSrc) && isMat(trueDst)) {\n // Matrix conversion rank depends only on component type (always f32 for now)\n return { rank: 0, action: 'none' };\n }\n\n return INFINITE_RANK;\n}\n\nfunction getImplicitConversionRank(\n src: AnyData,\n dest: AnyData,\n): ConversionRankInfo {\n const trueSrc = undecorate(src);\n const trueDst = undecorate(dest);\n\n if (\n trueSrc.type === 'ptr' &&\n getAutoConversionRank(trueSrc.inner as AnyData, trueDst).rank <\n Number.POSITIVE_INFINITY\n ) {\n return { rank: 0, action: 'deref' };\n }\n\n if (\n trueDst.type === 'ptr' &&\n getAutoConversionRank(trueSrc, trueDst.inner as AnyData).rank <\n Number.POSITIVE_INFINITY\n ) {\n return { rank: 1, action: 'ref' };\n }\n\n const primitivePreference = {\n f32: 0,\n f16: 1,\n i32: 2,\n u32: 3,\n bool: 4,\n } as const;\n type PrimitiveType = keyof typeof primitivePreference;\n\n if (\n trueSrc.type in primitivePreference &&\n trueDst.type in primitivePreference\n ) {\n const srcType = trueSrc.type as PrimitiveType;\n const destType = trueDst.type as PrimitiveType;\n\n if (srcType !== destType) {\n const srcPref = primitivePreference[srcType];\n const destPref = primitivePreference[destType];\n\n const rank = destPref < srcPref ? 10 : 20;\n\n return { rank: rank, action: 'cast', targetType: trueDst };\n }\n }\n\n return INFINITE_RANK;\n}\n\nfunction getConversionRank(\n src: AnyData,\n dest: AnyData,\n allowImplicit: boolean,\n): ConversionRankInfo {\n const autoRank = getAutoConversionRank(src, dest);\n if (autoRank.rank < Number.POSITIVE_INFINITY) {\n return autoRank;\n }\n if (allowImplicit) {\n return getImplicitConversionRank(src, dest);\n }\n return INFINITE_RANK;\n}\n\nexport type ConversionResultAction = {\n sourceIndex: number;\n action: ConversionAction;\n targetType?: U32 | F32 | I32 | F16;\n};\n\nexport type ConversionResult = {\n targetType: AnyData;\n actions: ConversionResultAction[];\n hasImplicitConversions?: boolean;\n};\n\nfunction findBestType(\n types: AnyData[],\n uniqueTypes: AnyData[],\n allowImplicit: boolean,\n): ConversionResult | undefined {\n let bestType: AnyData | undefined;\n let minSum = Number.POSITIVE_INFINITY;\n const conversionDetails = new Map<AnyData, ConversionRankInfo[]>();\n\n for (const targetType of uniqueTypes) {\n let currentSum = 0;\n const currentDetails: ConversionRankInfo[] = [];\n let possible = true;\n\n for (const sourceType of types) {\n const conversion = getConversionRank(\n sourceType,\n targetType,\n allowImplicit,\n );\n if (conversion.rank === Number.POSITIVE_INFINITY) {\n possible = false;\n break;\n }\n currentSum += conversion.rank;\n currentDetails.push(conversion);\n }\n\n if (possible && currentSum < minSum) {\n minSum = currentSum;\n bestType = targetType;\n conversionDetails.set(bestType, currentDetails);\n }\n }\n\n if (!bestType) {\n return undefined;\n }\n\n const bestDetails = conversionDetails.get(bestType) as ConversionRankInfo[];\n const actions: ConversionResultAction[] = bestDetails.map(\n (detail, index) => ({\n sourceIndex: index,\n action: detail.action,\n ...(detail.action === 'cast' && {\n targetType: detail.targetType as U32 | F32 | I32 | F16,\n }),\n }),\n );\n\n const hasCasts = actions.some((action) => action.action === 'cast');\n\n return { targetType: bestType, actions, hasImplicitConversions: hasCasts };\n}\n\nexport function concretize(type: AnyWgslData): AnyWgslData {\n if (type.type === 'abstractFloat') {\n return f32;\n }\n\n if (type.type === 'abstractInt') {\n return i32;\n }\n\n return type;\n}\n\nexport function getBestConversion(\n types: AnyData[],\n targetTypes?: AnyData[],\n): ConversionResult | undefined {\n if (types.length === 0) return undefined;\n\n const uniqueTypes = [...new Set(types.map(undecorate))];\n const uniqueTargetTypes = targetTypes\n ? [...new Set(targetTypes.map(undecorate))]\n : uniqueTypes;\n\n const explicitResult = findBestType(types, uniqueTargetTypes, false);\n if (explicitResult) {\n return explicitResult;\n }\n\n const implicitResult = findBestType(types, uniqueTargetTypes, true);\n if (implicitResult) {\n implicitResult.hasImplicitConversions = implicitResult.actions.some(\n (action) => action.action === 'cast',\n );\n return implicitResult;\n }\n\n return undefined;\n}\n\nexport function convertType(\n sourceType: AnyData,\n targetType: AnyData,\n allowImplicit = true,\n): ConversionResult | undefined {\n const conversion = getConversionRank(sourceType, targetType, allowImplicit);\n\n if (conversion.rank < Number.POSITIVE_INFINITY) {\n const actionDetail: ConversionResultAction = {\n sourceIndex: 0,\n action: conversion.action,\n };\n if (conversion.action === 'cast') {\n actionDetail.targetType = conversion.targetType as U32 | F32 | I32 | F16;\n }\n return {\n targetType: undecorate(targetType),\n actions: [actionDetail],\n hasImplicitConversions: conversion.action === 'cast',\n };\n }\n\n return undefined;\n}\n\nexport type GenerationCtx = ResolutionCtx & {\n readonly pre: string;\n /**\n * Used by `generateTypedExpression` to signal downstream\n * expression resolution what type is expected of them.\n *\n * It is used exclusively for inferring the types of structs and arrays.\n * It is modified exclusively by `generateTypedExpression` function.\n */\n expectedType: AnyData | undefined;\n readonly topFunctionReturnType: AnyData;\n indent(): string;\n dedent(): string;\n withResetIndentLevel<T>(callback: () => T): T;\n pushBlockScope(): void;\n popBlockScope(): void;\n getById(id: string): Snippet | null;\n defineVariable(id: string, dataType: AnyWgslData | UnknownData): Snippet;\n};\n\nfunction applyActionToSnippet(\n ctx: GenerationCtx,\n value: Snippet,\n action: ConversionResultAction,\n targetType: AnyData,\n): Snippet {\n if (action.action === 'none') {\n return snip(value.value, targetType);\n }\n\n const resolvedValue = ctx.resolve(value.value);\n\n switch (action.action) {\n case 'ref':\n return snip(`&${resolvedValue}`, targetType);\n case 'deref':\n return snip(`*${resolvedValue}`, targetType);\n case 'cast': {\n return snip(`${ctx.resolve(targetType)}(${resolvedValue})`, targetType);\n }\n default: {\n assertExhaustive(action.action, 'applyActionToSnippet');\n }\n }\n}\n\nexport type ConvertToCommonTypeOptions = {\n ctx: GenerationCtx;\n values: Snippet[];\n restrictTo?: AnyData[] | undefined;\n concretizeTypes?: boolean | undefined;\n verbose?: boolean | undefined;\n};\n\nexport function convertToCommonType({\n ctx,\n values,\n restrictTo,\n concretizeTypes = false,\n verbose = true,\n}: ConvertToCommonTypeOptions): Snippet[] | undefined {\n const types = values.map((value) =>\n concretizeTypes ? concretize(value.dataType as AnyWgslData) : value.dataType\n );\n\n if (types.some((type) => type === UnknownData)) {\n return undefined;\n }\n\n if (DEV && verbose && Array.isArray(restrictTo) && restrictTo.length === 0) {\n console.warn(\n 'convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.',\n );\n }\n\n const conversion = getBestConversion(types as AnyData[], restrictTo);\n if (!conversion) {\n return undefined;\n }\n\n if (DEV && verbose && conversion.hasImplicitConversions) {\n console.warn(\n `Implicit conversions from [\\n${\n values\n .map((v) => ` ${v.value}: ${v.dataType.type}`)\n .join(\n ',\\n',\n )\n }\\n] to ${conversion.targetType.type} are supported, but not recommended.\nConsider using explicit conversions instead.`,\n );\n }\n\n return values.map((value, index) => {\n const action = conversion.actions[index];\n invariant(action, 'Action should not be undefined');\n return applyActionToSnippet(ctx, value, action, conversion.targetType);\n });\n}\n\nexport function tryConvertSnippet(\n ctx: GenerationCtx,\n value: Snippet,\n targetDataType: AnyData,\n): Snippet {\n if (targetDataType === value.dataType) {\n return value;\n }\n\n if (targetDataType.type === 'void') {\n throw new WgslTypeError(\n `Cannot convert value of type '${value.dataType.type}' to type 'void'`,\n );\n }\n\n const converted = convertToCommonType({\n ctx,\n values: [value],\n restrictTo: [targetDataType],\n });\n\n if (!converted) {\n throw new WgslTypeError(\n `Cannot convert value of type '${value.dataType.type}' to type '${targetDataType.type}'`,\n );\n }\n\n return converted[0] as Snippet;\n}\n\nexport function convertStructValues(\n ctx: GenerationCtx,\n structType: WgslStruct,\n values: Record<string, Snippet>,\n): Snippet[] {\n const propKeys = Object.keys(structType.propTypes);\n\n return propKeys.map((key) => {\n const val = values[key];\n if (!val) {\n throw new Error(`Missing property ${key}`);\n }\n\n const targetType = structType.propTypes[key];\n const converted = convertToCommonType({\n ctx,\n values: [val],\n restrictTo: [targetType as AnyData],\n });\n return converted?.[0] ?? val;\n });\n}\n\nexport function coerceToSnippet(value: unknown): Snippet {\n if (isSnippet(value)) {\n // Already a snippet\n return value;\n }\n\n if (hasInternalDataType(value)) {\n // The value knows better about what type it is\n return snip(value, value[$wgslDataType] as AnyData);\n }\n\n if (isVecInstance(value) || isMatInstance(value)) {\n return snip(value, kindToSchema[value.kind]);\n }\n\n if (Array.isArray(value)) {\n const coerced = value.map(coerceToSnippet).filter(Boolean);\n const context = getResolutionCtx() as GenerationCtx | undefined;\n if (!context) {\n throw new Error('Tried to coerce array without a context');\n }\n\n const converted = convertToCommonType({\n ctx: context,\n values: coerced as Snippet[],\n });\n const commonType = getBestConversion(\n coerced.map((v) => v.dataType as AnyData),\n )?.targetType as AnyWgslData | undefined;\n\n if (!converted || !commonType) {\n return snip(value, UnknownData);\n }\n\n return snip(\n converted.map((v) => v.value).join(', '),\n arrayOf(concretize(commonType), value.length),\n );\n }\n\n if (\n typeof value === 'string' || typeof value === 'function' ||\n typeof value === 'object' || typeof value === 'symbol' ||\n typeof value === 'undefined' || value === null\n ) {\n // Nothing representable in WGSL as-is, so unknown\n return snip(value, UnknownData);\n }\n\n if (typeof value === 'number' || typeof value === 'bigint') {\n return snip(\n value,\n numericLiteralToSnippet(String(value))?.dataType ?? UnknownData,\n );\n }\n\n if (typeof value === 'boolean') {\n return snip(value, bool);\n }\n\n return snip(value, UnknownData);\n}\n","import { arrayOf } from './data/array.ts';\nimport { attribute } from './data/attributes.ts';\nimport type { LooseDecorated } from './data/dataTypes.ts';\nimport { bool, f32, u32 } from './data/numeric.ts';\nimport { vec3u, vec4f } from './data/vector.ts';\nimport type {\n AnyWgslData,\n BaseData,\n Bool,\n Builtin,\n Decorated,\n F32,\n U32,\n Vec3u,\n Vec4f,\n WgslArray,\n} from './data/wgslTypes.ts';\nimport { $internal } from './shared/symbols.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;\nexport type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;\nexport type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;\nexport type BuiltinClipDistances = Decorated<\n WgslArray<U32>,\n [Builtin<'clip_distances'>]\n>;\nexport type BuiltinFrontFacing = Decorated<Bool, [Builtin<'front_facing'>]>;\nexport type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;\nexport type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;\nexport type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;\nexport type BuiltinLocalInvocationId = Decorated<\n Vec3u,\n [Builtin<'local_invocation_id'>]\n>;\nexport type BuiltinLocalInvocationIndex = Decorated<\n U32,\n [Builtin<'local_invocation_index'>]\n>;\nexport type BuiltinGlobalInvocationId = Decorated<\n Vec3u,\n [Builtin<'global_invocation_id'>]\n>;\nexport type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;\nexport type BuiltinNumWorkgroups = Decorated<\n Vec3u,\n [Builtin<'num_workgroups'>]\n>;\nexport type BuiltinSubgroupInvocationId = Decorated<\n U32,\n [Builtin<'subgroup_invocation_id'>]\n>;\nexport type BuiltinSubgroupSize = Decorated<U32, [Builtin<'subgroup_size'>]>;\n\nfunction defineBuiltin<T extends Decorated | LooseDecorated>(\n dataType: AnyWgslData,\n value: T['attribs'][0] extends { params: [infer TValue] } ? TValue : never,\n): T {\n return attribute(dataType, {\n [$internal]: true,\n type: '@builtin',\n // biome-ignore lint/suspicious/noExplicitAny: it's fine\n params: [value as any],\n }) as T;\n}\n\nexport const builtin = {\n vertexIndex: defineBuiltin<BuiltinVertexIndex>(u32, 'vertex_index'),\n instanceIndex: defineBuiltin<BuiltinInstanceIndex>(u32, 'instance_index'),\n position: defineBuiltin<BuiltinPosition>(vec4f, 'position'),\n clipDistances: defineBuiltin<BuiltinClipDistances>(\n arrayOf(u32, 8),\n 'clip_distances',\n ),\n frontFacing: defineBuiltin<BuiltinFrontFacing>(bool, 'front_facing'),\n fragDepth: defineBuiltin<BuiltinFragDepth>(f32, 'frag_depth'),\n sampleIndex: defineBuiltin<BuiltinSampleIndex>(u32, 'sample_index'),\n sampleMask: defineBuiltin<BuiltinSampleMask>(u32, 'sample_mask'),\n localInvocationId: defineBuiltin<BuiltinLocalInvocationId>(\n vec3u,\n 'local_invocation_id',\n ),\n localInvocationIndex: defineBuiltin<BuiltinLocalInvocationIndex>(\n u32,\n 'local_invocation_index',\n ),\n globalInvocationId: defineBuiltin<BuiltinGlobalInvocationId>(\n vec3u,\n 'global_invocation_id',\n ),\n workgroupId: defineBuiltin<BuiltinWorkgroupId>(vec3u, 'workgroup_id'),\n numWorkgroups: defineBuiltin<BuiltinNumWorkgroups>(vec3u, 'num_workgroups'),\n subgroupInvocationId: defineBuiltin<BuiltinSubgroupInvocationId>(\n u32,\n 'subgroup_invocation_id',\n ),\n subgroupSize: defineBuiltin<BuiltinSubgroupSize>(u32, 'subgroup_size'),\n} as const;\n\nexport type AnyBuiltin = (typeof builtin)[keyof typeof builtin];\nexport type AnyComputeBuiltin =\n | BuiltinLocalInvocationId\n | BuiltinLocalInvocationIndex\n | BuiltinGlobalInvocationId\n | BuiltinWorkgroupId\n | BuiltinNumWorkgroups\n | BuiltinSubgroupInvocationId\n | BuiltinSubgroupSize;\nexport type AnyVertexInputBuiltin = BuiltinVertexIndex | BuiltinInstanceIndex;\nexport type AnyVertexOutputBuiltin = BuiltinClipDistances | BuiltinPosition;\nexport type AnyFragmentInputBuiltin =\n | BuiltinPosition\n | BuiltinFrontFacing\n | BuiltinSampleIndex\n | BuiltinSampleMask\n | BuiltinSubgroupInvocationId\n | BuiltinSubgroupSize;\nexport type AnyFragmentOutputBuiltin = BuiltinFragDepth | BuiltinSampleMask;\n\nexport type OmitBuiltins<S> = S extends AnyBuiltin ? never\n : S extends BaseData ? S\n : {\n [Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];\n };\n"]}
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10;var z="0.7.0";var o=Symbol(`typegpu:${z}:$internal`),st= exports.b =Symbol(`typegpu:${z}:$wgslDataType`),Nn= exports.c =Symbol(`typegpu:${z}:$gpuValueOf`),Ye= exports.d =Symbol(`typegpu:${z}:$getNameForward`),it= exports.e =Symbol(`typegpu:${z}:$providing`),at= exports.f =Symbol(`typegpu:${z}:$repr`),Fn= exports.g =Symbol(`typegpu:${z}:$gpuRepr`),Pn=Symbol(`typegpu:${z}:$reprPartial`),Rn=Symbol(`typegpu:${z}:$memIdent`),En=Symbol(`typegpu:${z}:$invalidStorageSchema`),Un=Symbol(`typegpu:${z}:$validUniformSchema`),Cn=Symbol(`typegpu:${z}:$validVertexSchema`),On=Symbol(`typegpu:${z}:$invalidSchemaReason`);var Ce=globalThis.process.env.NODE_ENV==="development",ot=globalThis.process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>Ut(e)&&_optionalChain([e, 'optionalAccess', _2 => _2[o]])&&!ie(e)?e.$name(t):e});var Re=globalThis,Gn= exports.i =(Ce||ot)&&{get enabled(){return!!Re.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=Re.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function Et(e){return!!_optionalChain([e, 'optionalAccess', _3 => _3[Ye]])}function ie(e){return Et(e)?ie(e[Ye]):_optionalChain([Ct, 'call', _4 => _4(e), 'optionalAccess', _5 => _5.name])}function ct(e,t){Ot(e,{name:t})}function Ut(e){return!!_optionalChain([e, 'optionalAccess', _6 => _6.$name])}function Ct(e){return Re.__TYPEGPU_META__.get(e)}function Ot(e,t){Re.__TYPEGPU_META__??=new WeakMap;let n=Re.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var He="Invariant failed";function gt(e,t){if(e)return;if(!Ce)throw new Error(He);let n=typeof t=="function"?t():t,r=n?`${He}: ${n}`:He;throw new Error(r)}var ut=class e extends Error{constructor(n,r){let s=r.map(y=>`- ${y}`);s.length>20&&(s=[...s.slice(0,11),"...",...s.slice(-10)]);super(`Resolution of the following tree failed:
2
+ ${s.join(`
3
+ `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},yt= exports.p =class e extends Error{constructor(n,r){let s=r.map(y=>`- ${y}`);s.length>20&&(s=[...s.slice(0,11),"...",...s.slice(-10)]);super(`Execution of the following tree failed:
4
+ ${s.join(`
5
+ `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},ht= exports.q =class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},lt= exports.r =class e extends Error{constructor(t){super(`Buffer '${_nullishCoalesce(ie(t), () => ("<unnamed>"))}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},xt= exports.s =class e extends Error{constructor(t,n){super(`The function '${_nullishCoalesce(t, () => ("<unnamed>"))}' is missing links to the following external values: ${n}.`),Object.setPrototypeOf(this,e.prototype)}},dt= exports.t =class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>_nullishCoalesce(ie(n), () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},mt= exports.u =class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>_nullishCoalesce(ie(n), () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},wt= exports.v =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},pt= exports.w =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},vt= exports.x =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function ft(e){return _optionalChain([e, 'optionalAccess', _7 => _7.resourceType])==="slot"}function Tt(e){return _optionalChain([e, 'optionalAccess', _8 => _8.resourceType])==="derived"}function bt(e){return _optionalChain([e, 'optionalAccess', _9 => _9[it]])!==void 0}function tr(e){return _optionalChain([e, 'optionalAccess', _10 => _10.resourceType])==="accessor"}function sr(e){return!!_optionalChain([e, 'optionalAccess', _11 => _11[st]])}var ir={[o]:!0,type:"void"},Wt=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void"];function p(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _12 => _12[o]])&&typeof _optionalChain([t, 'access', _13 => _13.kind, 'optionalAccess', _14 => _14.startsWith])=="function"&&t.kind.startsWith("vec")}function Kt(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _15 => _15[o]])&&typeof _optionalChain([t, 'access', _16 => _16.type, 'optionalAccess', _17 => _17.startsWith])=="function"&&_optionalChain([t, 'access', _18 => _18.type, 'access', _19 => _19.startsWith, 'optionalCall', _20 => _20("vec2")])}function Lt(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _21 => _21[o]])&&typeof _optionalChain([t, 'access', _22 => _22.type, 'optionalAccess', _23 => _23.startsWith])=="function"&&t.type.startsWith("vec3")}function jt(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _24 => _24[o]])&&typeof _optionalChain([t, 'access', _25 => _25.type, 'optionalAccess', _26 => _26.startsWith])=="function"&&t.type.startsWith("vec4")}function zt(e){return Kt(e)||Lt(e)||jt(e)}function N(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _27 => _27[o]])&&typeof _optionalChain([t, 'access', _28 => _28.kind, 'optionalAccess', _29 => _29.startsWith])=="function"&&t.kind.startsWith("mat")}function Gt(e){return _optionalChain([e, 'optionalAccess', _30 => _30[o]])&&_optionalChain([e, 'optionalAccess', _31 => _31.type])==="mat2x2f"}function qt(e){return _optionalChain([e, 'optionalAccess', _32 => _32[o]])&&_optionalChain([e, 'optionalAccess', _33 => _33.type])==="mat3x3f"}function Yt(e){return _optionalChain([e, 'optionalAccess', _34 => _34[o]])&&_optionalChain([e, 'optionalAccess', _35 => _35.type])==="mat4x4f"}function ar(e){return Gt(e)||qt(e)||Yt(e)}function Ze(e){return p(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function Vt(e){return _optionalChain([e, 'optionalAccess', _36 => _36[o]])&&Wt.includes(_optionalChain([e, 'optionalAccess', _37 => _37.type]))}function or(e){return _optionalChain([e, 'optionalAccess', _38 => _38[o]])&&_optionalChain([e, 'optionalAccess', _39 => _39.type])==="array"}function cr(e){return _optionalChain([e, 'optionalAccess', _40 => _40[o]])&&_optionalChain([e, 'optionalAccess', _41 => _41.type])==="struct"}function ur(e){return _optionalChain([e, 'optionalAccess', _42 => _42[o]])&&_optionalChain([e, 'optionalAccess', _43 => _43.type])==="ptr"}function yr(e){return _optionalChain([e, 'optionalAccess', _44 => _44[o]])&&_optionalChain([e, 'optionalAccess', _45 => _45.type])==="atomic"}function hr(e){return _optionalChain([e, 'optionalAccess', _46 => _46[o]])&&_optionalChain([e, 'optionalAccess', _47 => _47.type])==="@align"}function lr(e){return _optionalChain([e, 'optionalAccess', _48 => _48[o]])&&_optionalChain([e, 'optionalAccess', _49 => _49.type])==="@size"}function xr(e){return _optionalChain([e, 'optionalAccess', _50 => _50[o]])&&_optionalChain([e, 'optionalAccess', _51 => _51.type])==="@location"}function dr(e){return _optionalChain([e, 'optionalAccess', _52 => _52[o]])&&_optionalChain([e, 'optionalAccess', _53 => _53.type])==="@interpolate"}function mr(e){return _optionalChain([e, 'optionalAccess', _54 => _54[o]])&&_optionalChain([e, 'optionalAccess', _55 => _55.type])==="@builtin"}function St(e){return _optionalChain([e, 'optionalAccess', _56 => _56[o]])&&_optionalChain([e, 'optionalAccess', _57 => _57.type])==="decorated"}function wr(e){return _optionalChain([e, 'optionalAccess', _58 => _58[o]])&&e.type==="void"}var Oe= (_class =class{constructor() { _class.prototype.__init.call(this); }__init() {this.type="normal"}}, _class),_t= exports._ = (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.type="codegen"}}, _class2),Mt= exports.$ = (_class3 =class{constructor(t,n){;_class3.prototype.__init3.call(this);this.buffers=t;this.vars=n}__init3() {this.type="simulate"}}, _class3);function Ht(e){return typeof _optionalChain([e, 'optionalAccess', _59 => _59["~resolve"]])=="function"}function Tr(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Ht(e)||Vt(e)||ft(e)||Tt(e)||bt(e)}function br(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function zr(e){return _optionalChain([e, 'optionalAccess', _60 => _60.resourceType])==="buffer-usage"}function Vr(e){return!!_optionalChain([e, 'optionalAccess', _61 => _61[o]])}var We=!1;function $r(e){if(We)return e();try{return We=!0,e()}finally{We=!1}}function Ir(){return We}var O;function Ar(e,t){if(gt(O===void 0||O===e,"Cannot nest context providers"),O===e)return t();O=e;try{return t()}finally{O=void 0}}function kr(){return O}var Zt=new Oe;function Br(){return _nullishCoalesce(_optionalChain([O, 'optionalAccess', _62 => _62.mode]), () => (Zt))}function $t(){return _optionalChain([O, 'optionalAccess', _63 => _63.mode, 'optionalAccess', _64 => _64.type])==="codegen"}function i(e,t,n,r="keep"){let s=(...y)=>$t()?t(...y):e(...y);return ct(s,n),s.toString=()=>n,s[o]={jsImpl:e,gpuImpl:t,argConversionHint:r},s}function It(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}var Ke=class{constructor(t,n){this.value=t;this.dataType=n}};function Cr(e){return e instanceof Ke}function a(e,t){return new Ke(e,It(t))}var jr={[o]:!0,type:"abstractInt"},Gr= exports.ra ={[o]:!0,type:"abstractFloat"},Xt=i(e=>e===void 0?!1:typeof e=="boolean"?e:!!e,e=>a(`bool(${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _65 => _65.value]), () => (""))})`,F),"boolCast"),F= exports.sa =Object.assign(Xt,{type:"bool"}),Jt=i(e=>e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0,e=>a(`u32(${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _66 => _66.value]), () => (""))})`,P),"u32Cast"),P= exports.ta =Object.assign(Jt,{type:"u32"}),Qt=i(e=>e===void 0?0:typeof e=="boolean"?e?1:0:e|0,e=>a(`i32(${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _67 => _67.value]), () => (""))})`,R),"i32Cast"),qr= exports.ua ={[o]:!0,type:"u16"},R= exports.va =Object.assign(Qt,{type:"i32"}),en=i(e=>e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e),e=>a(`f32(${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _68 => _68.value]), () => (""))})`,V),"f32Cast"),V= exports.wa =Object.assign(en,{type:"f32"}),At=new ArrayBuffer(4),tn=new Float32Array(At),nn=new Uint32Array(At);function rn(e){tn[0]=e;let t=nn[0],n=t>>>31&1,r=t>>>23&255,s=t&8388607;return r===255?n<<15|31744|(s?512:0):(r=r-127+15,r<=0?r<-10?n<<15:(s=(s|8388608)>>1-r,s=s+4096>>13,n<<15|s):r>=31||(s=s+4096,s&8388608&&(s=0,++r,r>=31))?n<<15|31744:n<<15|r<<10|s>>13)}function sn(e){let t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?r?t*r*2**-24:t*0:n===31?r?Number.NaN:t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t*(1+r/1024)*2**(n-15)}function an(e){return sn(rn(e))}var on=i(e=>e===void 0?0:typeof e=="boolean"?e?1:0:an(e),e=>a(`f16(${_nullishCoalesce(_optionalChain([e, 'optionalAccess', _69 => _69.value]), () => (""))})`,E),"f16Cast"),E= exports.xa =Object.assign(on,{type:"f16"});var Ee= (_class4 =class extends Array{constructor(...args) { super(...args); _class4.prototype.__init4.call(this); }__init4() {this[o]=!0}"~resolve"(){return`${this.kind}(${this.join(", ")})`}toString(){return this["~resolve"]()}get xx(){return new this._Vec2(this[0],this[0])}get xy(){return new this._Vec2(this[0],this[1])}get xz(){return new this._Vec2(this[0],this[2])}get xw(){return new this._Vec2(this[0],this[3])}get yx(){return new this._Vec2(this[1],this[0])}get yy(){return new this._Vec2(this[1],this[1])}get yz(){return new this._Vec2(this[1],this[2])}get yw(){return new this._Vec2(this[1],this[3])}get zx(){return new this._Vec2(this[2],this[0])}get zy(){return new this._Vec2(this[2],this[1])}get zz(){return new this._Vec2(this[2],this[2])}get zw(){return new this._Vec2(this[2],this[3])}get wx(){return new this._Vec2(this[3],this[0])}get wy(){return new this._Vec2(this[3],this[1])}get wz(){return new this._Vec2(this[3],this[2])}get ww(){return new this._Vec2(this[3],this[3])}get xxx(){return new this._Vec3(this[0],this[0],this[0])}get xxy(){return new this._Vec3(this[0],this[0],this[1])}get xxz(){return new this._Vec3(this[0],this[0],this[2])}get xxw(){return new this._Vec3(this[0],this[0],this[3])}get xyx(){return new this._Vec3(this[0],this[1],this[0])}get xyy(){return new this._Vec3(this[0],this[1],this[1])}get xyz(){return new this._Vec3(this[0],this[1],this[2])}get xyw(){return new this._Vec3(this[0],this[1],this[3])}get xzx(){return new this._Vec3(this[0],this[2],this[0])}get xzy(){return new this._Vec3(this[0],this[2],this[1])}get xzz(){return new this._Vec3(this[0],this[2],this[2])}get xzw(){return new this._Vec3(this[0],this[2],this[3])}get xwx(){return new this._Vec3(this[0],this[3],this[0])}get xwy(){return new this._Vec3(this[0],this[3],this[1])}get xwz(){return new this._Vec3(this[0],this[3],this[2])}get xww(){return new this._Vec3(this[0],this[3],this[3])}get yxx(){return new this._Vec3(this[1],this[0],this[0])}get yxy(){return new this._Vec3(this[1],this[0],this[1])}get yxz(){return new this._Vec3(this[1],this[0],this[2])}get yxw(){return new this._Vec3(this[1],this[0],this[3])}get yyx(){return new this._Vec3(this[1],this[1],this[0])}get yyy(){return new this._Vec3(this[1],this[1],this[1])}get yyz(){return new this._Vec3(this[1],this[1],this[2])}get yyw(){return new this._Vec3(this[1],this[1],this[3])}get yzx(){return new this._Vec3(this[1],this[2],this[0])}get yzy(){return new this._Vec3(this[1],this[2],this[1])}get yzz(){return new this._Vec3(this[1],this[2],this[2])}get yzw(){return new this._Vec3(this[1],this[2],this[3])}get ywx(){return new this._Vec3(this[1],this[3],this[0])}get ywy(){return new this._Vec3(this[1],this[3],this[1])}get ywz(){return new this._Vec3(this[1],this[3],this[2])}get yww(){return new this._Vec3(this[1],this[3],this[3])}get zxx(){return new this._Vec3(this[2],this[0],this[0])}get zxy(){return new this._Vec3(this[2],this[0],this[1])}get zxz(){return new this._Vec3(this[2],this[0],this[2])}get zxw(){return new this._Vec3(this[2],this[0],this[3])}get zyx(){return new this._Vec3(this[2],this[1],this[0])}get zyy(){return new this._Vec3(this[2],this[1],this[1])}get zyz(){return new this._Vec3(this[2],this[1],this[2])}get zyw(){return new this._Vec3(this[2],this[1],this[3])}get zzx(){return new this._Vec3(this[2],this[2],this[0])}get zzy(){return new this._Vec3(this[2],this[2],this[1])}get zzz(){return new this._Vec3(this[2],this[2],this[2])}get zzw(){return new this._Vec3(this[2],this[2],this[3])}get zwx(){return new this._Vec3(this[2],this[3],this[0])}get zwy(){return new this._Vec3(this[2],this[3],this[1])}get zwz(){return new this._Vec3(this[2],this[3],this[2])}get zww(){return new this._Vec3(this[2],this[3],this[3])}get wxx(){return new this._Vec3(this[3],this[0],this[0])}get wxy(){return new this._Vec3(this[3],this[0],this[1])}get wxz(){return new this._Vec3(this[3],this[0],this[2])}get wxw(){return new this._Vec3(this[3],this[0],this[3])}get wyx(){return new this._Vec3(this[3],this[1],this[0])}get wyy(){return new this._Vec3(this[3],this[1],this[1])}get wyz(){return new this._Vec3(this[3],this[1],this[2])}get wyw(){return new this._Vec3(this[3],this[1],this[3])}get wzx(){return new this._Vec3(this[3],this[2],this[0])}get wzy(){return new this._Vec3(this[3],this[2],this[1])}get wzz(){return new this._Vec3(this[3],this[2],this[2])}get wzw(){return new this._Vec3(this[3],this[2],this[3])}get wwx(){return new this._Vec3(this[3],this[3],this[0])}get wwy(){return new this._Vec3(this[3],this[3],this[1])}get wwz(){return new this._Vec3(this[3],this[3],this[2])}get www(){return new this._Vec3(this[3],this[3],this[3])}get xxxx(){return new this._Vec4(this[0],this[0],this[0],this[0])}get xxxy(){return new this._Vec4(this[0],this[0],this[0],this[1])}get xxxz(){return new this._Vec4(this[0],this[0],this[0],this[2])}get xxxw(){return new this._Vec4(this[0],this[0],this[0],this[3])}get xxyx(){return new this._Vec4(this[0],this[0],this[1],this[0])}get xxyy(){return new this._Vec4(this[0],this[0],this[1],this[1])}get xxyz(){return new this._Vec4(this[0],this[0],this[1],this[2])}get xxyw(){return new this._Vec4(this[0],this[0],this[1],this[3])}get xxzx(){return new this._Vec4(this[0],this[0],this[2],this[0])}get xxzy(){return new this._Vec4(this[0],this[0],this[2],this[1])}get xxzz(){return new this._Vec4(this[0],this[0],this[2],this[2])}get xxzw(){return new this._Vec4(this[0],this[0],this[2],this[3])}get xxwx(){return new this._Vec4(this[0],this[0],this[3],this[0])}get xxwy(){return new this._Vec4(this[0],this[0],this[3],this[1])}get xxwz(){return new this._Vec4(this[0],this[0],this[3],this[2])}get xxww(){return new this._Vec4(this[0],this[0],this[3],this[3])}get xyxx(){return new this._Vec4(this[0],this[1],this[0],this[0])}get xyxy(){return new this._Vec4(this[0],this[1],this[0],this[1])}get xyxz(){return new this._Vec4(this[0],this[1],this[0],this[2])}get xyxw(){return new this._Vec4(this[0],this[1],this[0],this[3])}get xyyx(){return new this._Vec4(this[0],this[1],this[1],this[0])}get xyyy(){return new this._Vec4(this[0],this[1],this[1],this[1])}get xyyz(){return new this._Vec4(this[0],this[1],this[1],this[2])}get xyyw(){return new this._Vec4(this[0],this[1],this[1],this[3])}get xyzx(){return new this._Vec4(this[0],this[1],this[2],this[0])}get xyzy(){return new this._Vec4(this[0],this[1],this[2],this[1])}get xyzz(){return new this._Vec4(this[0],this[1],this[2],this[2])}get xyzw(){return new this._Vec4(this[0],this[1],this[2],this[3])}get xywx(){return new this._Vec4(this[0],this[1],this[3],this[0])}get xywy(){return new this._Vec4(this[0],this[1],this[3],this[1])}get xywz(){return new this._Vec4(this[0],this[1],this[3],this[2])}get xyww(){return new this._Vec4(this[0],this[1],this[3],this[3])}get xzxx(){return new this._Vec4(this[0],this[2],this[0],this[0])}get xzxy(){return new this._Vec4(this[0],this[2],this[0],this[1])}get xzxz(){return new this._Vec4(this[0],this[2],this[0],this[2])}get xzxw(){return new this._Vec4(this[0],this[2],this[0],this[3])}get xzyx(){return new this._Vec4(this[0],this[2],this[1],this[0])}get xzyy(){return new this._Vec4(this[0],this[2],this[1],this[1])}get xzyz(){return new this._Vec4(this[0],this[2],this[1],this[2])}get xzyw(){return new this._Vec4(this[0],this[2],this[1],this[3])}get xzzx(){return new this._Vec4(this[0],this[2],this[2],this[0])}get xzzy(){return new this._Vec4(this[0],this[2],this[2],this[1])}get xzzz(){return new this._Vec4(this[0],this[2],this[2],this[2])}get xzzw(){return new this._Vec4(this[0],this[2],this[2],this[3])}get xzwx(){return new this._Vec4(this[0],this[2],this[3],this[0])}get xzwy(){return new this._Vec4(this[0],this[2],this[3],this[1])}get xzwz(){return new this._Vec4(this[0],this[2],this[3],this[2])}get xzww(){return new this._Vec4(this[0],this[2],this[3],this[3])}get xwxx(){return new this._Vec4(this[0],this[3],this[0],this[0])}get xwxy(){return new this._Vec4(this[0],this[3],this[0],this[1])}get xwxz(){return new this._Vec4(this[0],this[3],this[0],this[2])}get xwxw(){return new this._Vec4(this[0],this[3],this[0],this[3])}get xwyx(){return new this._Vec4(this[0],this[3],this[1],this[0])}get xwyy(){return new this._Vec4(this[0],this[3],this[1],this[1])}get xwyz(){return new this._Vec4(this[0],this[3],this[1],this[2])}get xwyw(){return new this._Vec4(this[0],this[3],this[1],this[3])}get xwzx(){return new this._Vec4(this[0],this[3],this[2],this[0])}get xwzy(){return new this._Vec4(this[0],this[3],this[2],this[1])}get xwzz(){return new this._Vec4(this[0],this[3],this[2],this[2])}get xwzw(){return new this._Vec4(this[0],this[3],this[2],this[3])}get xwwx(){return new this._Vec4(this[0],this[3],this[3],this[0])}get xwwy(){return new this._Vec4(this[0],this[3],this[3],this[1])}get xwwz(){return new this._Vec4(this[0],this[3],this[3],this[2])}get xwww(){return new this._Vec4(this[0],this[3],this[3],this[3])}get yxxx(){return new this._Vec4(this[1],this[0],this[0],this[0])}get yxxy(){return new this._Vec4(this[1],this[0],this[0],this[1])}get yxxz(){return new this._Vec4(this[1],this[0],this[0],this[2])}get yxxw(){return new this._Vec4(this[1],this[0],this[0],this[3])}get yxyx(){return new this._Vec4(this[1],this[0],this[1],this[0])}get yxyy(){return new this._Vec4(this[1],this[0],this[1],this[1])}get yxyz(){return new this._Vec4(this[1],this[0],this[1],this[2])}get yxyw(){return new this._Vec4(this[1],this[0],this[1],this[3])}get yxzx(){return new this._Vec4(this[1],this[0],this[2],this[0])}get yxzy(){return new this._Vec4(this[1],this[0],this[2],this[1])}get yxzz(){return new this._Vec4(this[1],this[0],this[2],this[2])}get yxzw(){return new this._Vec4(this[1],this[0],this[2],this[3])}get yxwx(){return new this._Vec4(this[1],this[0],this[3],this[0])}get yxwy(){return new this._Vec4(this[1],this[0],this[3],this[1])}get yxwz(){return new this._Vec4(this[1],this[0],this[3],this[2])}get yxww(){return new this._Vec4(this[1],this[0],this[3],this[3])}get yyxx(){return new this._Vec4(this[1],this[1],this[0],this[0])}get yyxy(){return new this._Vec4(this[1],this[1],this[0],this[1])}get yyxz(){return new this._Vec4(this[1],this[1],this[0],this[2])}get yyxw(){return new this._Vec4(this[1],this[1],this[0],this[3])}get yyyx(){return new this._Vec4(this[1],this[1],this[1],this[0])}get yyyy(){return new this._Vec4(this[1],this[1],this[1],this[1])}get yyyz(){return new this._Vec4(this[1],this[1],this[1],this[2])}get yyyw(){return new this._Vec4(this[1],this[1],this[1],this[3])}get yyzx(){return new this._Vec4(this[1],this[1],this[2],this[0])}get yyzy(){return new this._Vec4(this[1],this[1],this[2],this[1])}get yyzz(){return new this._Vec4(this[1],this[1],this[2],this[2])}get yyzw(){return new this._Vec4(this[1],this[1],this[2],this[3])}get yywx(){return new this._Vec4(this[1],this[1],this[3],this[0])}get yywy(){return new this._Vec4(this[1],this[1],this[3],this[1])}get yywz(){return new this._Vec4(this[1],this[1],this[3],this[2])}get yyww(){return new this._Vec4(this[1],this[1],this[3],this[3])}get yzxx(){return new this._Vec4(this[1],this[2],this[0],this[0])}get yzxy(){return new this._Vec4(this[1],this[2],this[0],this[1])}get yzxz(){return new this._Vec4(this[1],this[2],this[0],this[2])}get yzxw(){return new this._Vec4(this[1],this[2],this[0],this[3])}get yzyx(){return new this._Vec4(this[1],this[2],this[1],this[0])}get yzyy(){return new this._Vec4(this[1],this[2],this[1],this[1])}get yzyz(){return new this._Vec4(this[1],this[2],this[1],this[2])}get yzyw(){return new this._Vec4(this[1],this[2],this[1],this[3])}get yzzx(){return new this._Vec4(this[1],this[2],this[2],this[0])}get yzzy(){return new this._Vec4(this[1],this[2],this[2],this[1])}get yzzz(){return new this._Vec4(this[1],this[2],this[2],this[2])}get yzzw(){return new this._Vec4(this[1],this[2],this[2],this[3])}get yzwx(){return new this._Vec4(this[1],this[2],this[3],this[0])}get yzwy(){return new this._Vec4(this[1],this[2],this[3],this[1])}get yzwz(){return new this._Vec4(this[1],this[2],this[3],this[2])}get yzww(){return new this._Vec4(this[1],this[2],this[3],this[3])}get ywxx(){return new this._Vec4(this[1],this[3],this[0],this[0])}get ywxy(){return new this._Vec4(this[1],this[3],this[0],this[1])}get ywxz(){return new this._Vec4(this[1],this[3],this[0],this[2])}get ywxw(){return new this._Vec4(this[1],this[3],this[0],this[3])}get ywyx(){return new this._Vec4(this[1],this[3],this[1],this[0])}get ywyy(){return new this._Vec4(this[1],this[3],this[1],this[1])}get ywyz(){return new this._Vec4(this[1],this[3],this[1],this[2])}get ywyw(){return new this._Vec4(this[1],this[3],this[1],this[3])}get ywzx(){return new this._Vec4(this[1],this[3],this[2],this[0])}get ywzy(){return new this._Vec4(this[1],this[3],this[2],this[1])}get ywzz(){return new this._Vec4(this[1],this[3],this[2],this[2])}get ywzw(){return new this._Vec4(this[1],this[3],this[2],this[3])}get ywwx(){return new this._Vec4(this[1],this[3],this[3],this[0])}get ywwy(){return new this._Vec4(this[1],this[3],this[3],this[1])}get ywwz(){return new this._Vec4(this[1],this[3],this[3],this[2])}get ywww(){return new this._Vec4(this[1],this[3],this[3],this[3])}get zxxx(){return new this._Vec4(this[2],this[0],this[0],this[0])}get zxxy(){return new this._Vec4(this[2],this[0],this[0],this[1])}get zxxz(){return new this._Vec4(this[2],this[0],this[0],this[2])}get zxxw(){return new this._Vec4(this[2],this[0],this[0],this[3])}get zxyx(){return new this._Vec4(this[2],this[0],this[1],this[0])}get zxyy(){return new this._Vec4(this[2],this[0],this[1],this[1])}get zxyz(){return new this._Vec4(this[2],this[0],this[1],this[2])}get zxyw(){return new this._Vec4(this[2],this[0],this[1],this[3])}get zxzx(){return new this._Vec4(this[2],this[0],this[2],this[0])}get zxzy(){return new this._Vec4(this[2],this[0],this[2],this[1])}get zxzz(){return new this._Vec4(this[2],this[0],this[2],this[2])}get zxzw(){return new this._Vec4(this[2],this[0],this[2],this[3])}get zxwx(){return new this._Vec4(this[2],this[0],this[3],this[0])}get zxwy(){return new this._Vec4(this[2],this[0],this[3],this[1])}get zxwz(){return new this._Vec4(this[2],this[0],this[3],this[2])}get zxww(){return new this._Vec4(this[2],this[0],this[3],this[3])}get zyxx(){return new this._Vec4(this[2],this[1],this[0],this[0])}get zyxy(){return new this._Vec4(this[2],this[1],this[0],this[1])}get zyxz(){return new this._Vec4(this[2],this[1],this[0],this[2])}get zyxw(){return new this._Vec4(this[2],this[1],this[0],this[3])}get zyyx(){return new this._Vec4(this[2],this[1],this[1],this[0])}get zyyy(){return new this._Vec4(this[2],this[1],this[1],this[1])}get zyyz(){return new this._Vec4(this[2],this[1],this[1],this[2])}get zyyw(){return new this._Vec4(this[2],this[1],this[1],this[3])}get zyzx(){return new this._Vec4(this[2],this[1],this[2],this[0])}get zyzy(){return new this._Vec4(this[2],this[1],this[2],this[1])}get zyzz(){return new this._Vec4(this[2],this[1],this[2],this[2])}get zyzw(){return new this._Vec4(this[2],this[1],this[2],this[3])}get zywx(){return new this._Vec4(this[2],this[1],this[3],this[0])}get zywy(){return new this._Vec4(this[2],this[1],this[3],this[1])}get zywz(){return new this._Vec4(this[2],this[1],this[3],this[2])}get zyww(){return new this._Vec4(this[2],this[1],this[3],this[3])}get zzxx(){return new this._Vec4(this[2],this[2],this[0],this[0])}get zzxy(){return new this._Vec4(this[2],this[2],this[0],this[1])}get zzxz(){return new this._Vec4(this[2],this[2],this[0],this[2])}get zzxw(){return new this._Vec4(this[2],this[2],this[0],this[3])}get zzyx(){return new this._Vec4(this[2],this[2],this[1],this[0])}get zzyy(){return new this._Vec4(this[2],this[2],this[1],this[1])}get zzyz(){return new this._Vec4(this[2],this[2],this[1],this[2])}get zzyw(){return new this._Vec4(this[2],this[2],this[1],this[3])}get zzzx(){return new this._Vec4(this[2],this[2],this[2],this[0])}get zzzy(){return new this._Vec4(this[2],this[2],this[2],this[1])}get zzzz(){return new this._Vec4(this[2],this[2],this[2],this[2])}get zzzw(){return new this._Vec4(this[2],this[2],this[2],this[3])}get zzwx(){return new this._Vec4(this[2],this[2],this[3],this[0])}get zzwy(){return new this._Vec4(this[2],this[2],this[3],this[1])}get zzwz(){return new this._Vec4(this[2],this[2],this[3],this[2])}get zzww(){return new this._Vec4(this[2],this[2],this[3],this[3])}get zwxx(){return new this._Vec4(this[2],this[3],this[0],this[0])}get zwxy(){return new this._Vec4(this[2],this[3],this[0],this[1])}get zwxz(){return new this._Vec4(this[2],this[3],this[0],this[2])}get zwxw(){return new this._Vec4(this[2],this[3],this[0],this[3])}get zwyx(){return new this._Vec4(this[2],this[3],this[1],this[0])}get zwyy(){return new this._Vec4(this[2],this[3],this[1],this[1])}get zwyz(){return new this._Vec4(this[2],this[3],this[1],this[2])}get zwyw(){return new this._Vec4(this[2],this[3],this[1],this[3])}get zwzx(){return new this._Vec4(this[2],this[3],this[2],this[0])}get zwzy(){return new this._Vec4(this[2],this[3],this[2],this[1])}get zwzz(){return new this._Vec4(this[2],this[3],this[2],this[2])}get zwzw(){return new this._Vec4(this[2],this[3],this[2],this[3])}get zwwx(){return new this._Vec4(this[2],this[3],this[3],this[0])}get zwwy(){return new this._Vec4(this[2],this[3],this[3],this[1])}get zwwz(){return new this._Vec4(this[2],this[3],this[3],this[2])}get zwww(){return new this._Vec4(this[2],this[3],this[3],this[3])}get wxxx(){return new this._Vec4(this[3],this[0],this[0],this[0])}get wxxy(){return new this._Vec4(this[3],this[0],this[0],this[1])}get wxxz(){return new this._Vec4(this[3],this[0],this[0],this[2])}get wxxw(){return new this._Vec4(this[3],this[0],this[0],this[3])}get wxyx(){return new this._Vec4(this[3],this[0],this[1],this[0])}get wxyy(){return new this._Vec4(this[3],this[0],this[1],this[1])}get wxyz(){return new this._Vec4(this[3],this[0],this[1],this[2])}get wxyw(){return new this._Vec4(this[3],this[0],this[1],this[3])}get wxzx(){return new this._Vec4(this[3],this[0],this[2],this[0])}get wxzy(){return new this._Vec4(this[3],this[0],this[2],this[1])}get wxzz(){return new this._Vec4(this[3],this[0],this[2],this[2])}get wxzw(){return new this._Vec4(this[3],this[0],this[2],this[3])}get wxwx(){return new this._Vec4(this[3],this[0],this[3],this[0])}get wxwy(){return new this._Vec4(this[3],this[0],this[3],this[1])}get wxwz(){return new this._Vec4(this[3],this[0],this[3],this[2])}get wxww(){return new this._Vec4(this[3],this[0],this[3],this[3])}get wyxx(){return new this._Vec4(this[3],this[1],this[0],this[0])}get wyxy(){return new this._Vec4(this[3],this[1],this[0],this[1])}get wyxz(){return new this._Vec4(this[3],this[1],this[0],this[2])}get wyxw(){return new this._Vec4(this[3],this[1],this[0],this[3])}get wyyx(){return new this._Vec4(this[3],this[1],this[1],this[0])}get wyyy(){return new this._Vec4(this[3],this[1],this[1],this[1])}get wyyz(){return new this._Vec4(this[3],this[1],this[1],this[2])}get wyyw(){return new this._Vec4(this[3],this[1],this[1],this[3])}get wyzx(){return new this._Vec4(this[3],this[1],this[2],this[0])}get wyzy(){return new this._Vec4(this[3],this[1],this[2],this[1])}get wyzz(){return new this._Vec4(this[3],this[1],this[2],this[2])}get wyzw(){return new this._Vec4(this[3],this[1],this[2],this[3])}get wywx(){return new this._Vec4(this[3],this[1],this[3],this[0])}get wywy(){return new this._Vec4(this[3],this[1],this[3],this[1])}get wywz(){return new this._Vec4(this[3],this[1],this[3],this[2])}get wyww(){return new this._Vec4(this[3],this[1],this[3],this[3])}get wzxx(){return new this._Vec4(this[3],this[2],this[0],this[0])}get wzxy(){return new this._Vec4(this[3],this[2],this[0],this[1])}get wzxz(){return new this._Vec4(this[3],this[2],this[0],this[2])}get wzxw(){return new this._Vec4(this[3],this[2],this[0],this[3])}get wzyx(){return new this._Vec4(this[3],this[2],this[1],this[0])}get wzyy(){return new this._Vec4(this[3],this[2],this[1],this[1])}get wzyz(){return new this._Vec4(this[3],this[2],this[1],this[2])}get wzyw(){return new this._Vec4(this[3],this[2],this[1],this[3])}get wzzx(){return new this._Vec4(this[3],this[2],this[2],this[0])}get wzzy(){return new this._Vec4(this[3],this[2],this[2],this[1])}get wzzz(){return new this._Vec4(this[3],this[2],this[2],this[2])}get wzzw(){return new this._Vec4(this[3],this[2],this[2],this[3])}get wzwx(){return new this._Vec4(this[3],this[2],this[3],this[0])}get wzwy(){return new this._Vec4(this[3],this[2],this[3],this[1])}get wzwz(){return new this._Vec4(this[3],this[2],this[3],this[2])}get wzww(){return new this._Vec4(this[3],this[2],this[3],this[3])}get wwxx(){return new this._Vec4(this[3],this[3],this[0],this[0])}get wwxy(){return new this._Vec4(this[3],this[3],this[0],this[1])}get wwxz(){return new this._Vec4(this[3],this[3],this[0],this[2])}get wwxw(){return new this._Vec4(this[3],this[3],this[0],this[3])}get wwyx(){return new this._Vec4(this[3],this[3],this[1],this[0])}get wwyy(){return new this._Vec4(this[3],this[3],this[1],this[1])}get wwyz(){return new this._Vec4(this[3],this[3],this[1],this[2])}get wwyw(){return new this._Vec4(this[3],this[3],this[1],this[3])}get wwzx(){return new this._Vec4(this[3],this[3],this[2],this[0])}get wwzy(){return new this._Vec4(this[3],this[3],this[2],this[1])}get wwzz(){return new this._Vec4(this[3],this[3],this[2],this[2])}get wwzw(){return new this._Vec4(this[3],this[3],this[2],this[3])}get wwwx(){return new this._Vec4(this[3],this[3],this[3],this[0])}get wwwy(){return new this._Vec4(this[3],this[3],this[3],this[1])}get wwwz(){return new this._Vec4(this[3],this[3],this[3],this[2])}get wwww(){return new this._Vec4(this[3],this[3],this[3],this[3])}}, _class4),W=class extends Ee{constructor(t,n){super(2),this.e0=this.getElementSchema()(t),this.e1=this.getElementSchema()(_nullishCoalesce(n, () => (t)))}get 0(){return this.e0}get 1(){return this.e1}set 0(t){this.e0=this.getElementSchema()(t)}set 1(t){this.e1=this.getElementSchema()(t)}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=this.getElementSchema()(t)}set y(t){this[1]=this.getElementSchema()(t)}},K=class extends Ee{constructor(t,n,r){super(3),this.e0=this.getElementSchema()(t),this.e1=this.getElementSchema()(_nullishCoalesce(n, () => (t))),this.e2=this.getElementSchema()(_nullishCoalesce(r, () => (t)))}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}set 0(t){this.e0=this.getElementSchema()(t)}set 1(t){this.e1=this.getElementSchema()(t)}set 2(t){this.e2=this.getElementSchema()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=this.getElementSchema()(t)}set y(t){this[1]=this.getElementSchema()(t)}set z(t){this[2]=this.getElementSchema()(t)}},L=class extends Ee{constructor(t,n,r,s){super(4),this.e0=this.getElementSchema()(t),this.e1=this.getElementSchema()(_nullishCoalesce(n, () => (t))),this.e2=this.getElementSchema()(_nullishCoalesce(r, () => (t))),this.e3=this.getElementSchema()(_nullishCoalesce(s, () => (t)))}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}get 3(){return this.e3}set 0(t){this.e0=this.getElementSchema()(t)}set 1(t){this.e1=this.getElementSchema()(t)}set 2(t){this.e2=this.getElementSchema()(t)}set 3(t){this.e3=this.getElementSchema()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set w(t){this[3]=t}},ae=class e extends W{getElementSchema(){return V}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return he}get _Vec4(){return we}},oe=class e extends W{getElementSchema(){return E}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return le}get _Vec4(){return pe}},ce=class e extends W{getElementSchema(){return R}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return xe}get _Vec4(){return ve}},ue=class e extends W{getElementSchema(){return P}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return de}get _Vec4(){return ge}},ye=class e extends W{getElementSchema(){return F}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return me}get _Vec4(){return fe}},he=class e extends K{getElementSchema(){return V}get kind(){return"vec3f"}get _Vec2(){return ae}get _Vec3(){return e}get _Vec4(){return we}},le=class e extends K{getElementSchema(){return E}get kind(){return"vec3h"}get _Vec2(){return oe}get _Vec3(){return e}get _Vec4(){return pe}},xe=class e extends K{getElementSchema(){return R}get kind(){return"vec3i"}get _Vec2(){return ce}get _Vec3(){return e}get _Vec4(){return ve}},de=class e extends K{getElementSchema(){return P}get kind(){return"vec3u"}get _Vec2(){return ue}get _Vec3(){return e}get _Vec4(){return ge}},me=class e extends K{getElementSchema(){return F}get kind(){return"vec3<bool>"}get _Vec2(){return ye}get _Vec3(){return e}get _Vec4(){return fe}},we=class e extends L{getElementSchema(){return V}get kind(){return"vec4f"}get _Vec2(){return ae}get _Vec3(){return he}get _Vec4(){return e}},pe=class e extends L{getElementSchema(){return E}get kind(){return"vec4h"}get _Vec2(){return oe}get _Vec3(){return le}get _Vec4(){return e}},ve=class e extends L{getElementSchema(){return R}get kind(){return"vec4i"}get _Vec2(){return ce}get _Vec3(){return xe}get _Vec4(){return e}},ge=class e extends L{getElementSchema(){return P}get kind(){return"vec4u"}get _Vec2(){return ue}get _Vec3(){return de}get _Vec4(){return e}},fe=class e extends L{getElementSchema(){return F}get kind(){return"vec4<bool>"}get _Vec2(){return ye}get _Vec3(){return me}get _Vec4(){return e}};var f=b(ae),A= exports.Aa =b(oe),j= exports.Ba =b(ce),G= exports.Ca =b(ue),S= exports.Da =b(ye),v= exports.Ea =b(he),I= exports.Fa =b(le),q= exports.Ga =b(xe),Y= exports.Ha =b(de),_= exports.Ia =b(me),T= exports.Ja =b(we),k= exports.Ka =b(pe),H= exports.La =b(ve),Z= exports.Ma =b(ge),M= exports.Na =b(fe),Te={vec2f:f,vec2h:A,vec2i:j,vec2u:G,"vec2<bool>":S,vec3f:v,vec3h:I,vec3i:q,vec3u:Y,"vec3<bool>":_,vec4f:T,vec4h:k,vec4i:H,vec4u:Z,"vec4<bool>":M},cn= exports.Oa ={vec2f:V,vec2h:E,vec2i:R,vec2u:P,"vec2<bool>":F,vec3f:V,vec3h:E,vec3i:R,vec3u:P,"vec3<bool>":F,vec4f:V,vec4h:E,vec4i:R,vec4u:P,"vec4<bool>":F};function b(e){let{kind:t,length:n}=new e,r=i((...s)=>{let y=new Array(s.length),$=0;for(let Pe of s)if(typeof Pe=="number"||typeof Pe=="boolean")y[$++]=Pe;else for(let qe=0;qe<Pe.length;++qe)y[$++]=Pe[qe];if(y.length<=1||y.length===n)return new e(...y);throw new Error(`'${t}' constructor called with invalid number of arguments.`)},(...s)=>a(`${t}(${s.map(y=>y.value).join(", ")})`,Te[t]),t,(...s)=>s.map(y=>{let $=y.dataType;return St($)&&($=$.inner),zt($)?$:cn[t]}));return Object.assign(r,{type:t,[at]:void 0})}var Ue=class{};function rt(e){let t={[o]:!0,type:e.type,identity:ln[e.columns],translation:e.columns===4?xn:void 0,scaling:e.columns===4?dn:void 0,rotationX:e.columns===4?mn:void 0,rotationY:e.columns===4?wn:void 0,rotationZ:e.columns===4?pn:void 0},n=i((...r)=>{let s=[];for(let y of r)if(typeof y=="number")s.push(y);else for(let $=0;$<y.length;++$)s.push(y[$]);if(s.length!==0&&s.length!==e.columns*e.rows)throw new Error(`'${e.type}' constructor called with invalid number of arguments.`);for(let y=s.length;y<e.columns*e.rows;++y)s.push(0);return new e.MatImpl(...s)},(...r)=>a(`${t.type}(${r.map(s=>s.value).join(", ")})`,t),t.type);return Object.assign(n,t)}var Xe= (_class5 =class extends Ue{__init5() {this[o]=!0}__init6() {this.length=4}constructor(...t){super();_class5.prototype.__init5.call(this);_class5.prototype.__init6.call(this);,this.columns=[this.makeColumn(t[0],t[1]),this.makeColumn(t[2],t[3])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[1].x}get 3(){return this.columns[1].y}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[1].x=t}set 3(t){this.columns[1].y=t}*[Symbol.iterator](){yield this[0],yield this[1],yield this[2],yield this[3]}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}}, _class5),Je= (_class6 =class extends Xe{constructor(...args2) { super(...args2); _class6.prototype.__init7.call(this); }__init7() {this.kind="mat2x2f"}makeColumn(t,n){return f(t,n)}}, _class6),Qe= (_class7 =class extends Ue{__init8() {this[o]=!0}__init9() {this.length=12}constructor(...t){super();_class7.prototype.__init8.call(this);_class7.prototype.__init9.call(this);,this.columns=[this.makeColumn(t[0],t[1],t[2]),this.makeColumn(t[3],t[4],t[5]),this.makeColumn(t[6],t[7],t[8])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return 0}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return 0}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return 0}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){}*[Symbol.iterator](){for(let t=0;t<12;t++)yield this[t]}"~resolve"(){return`${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`}}, _class7),et= (_class8 =class extends Qe{constructor(...args3) { super(...args3); _class8.prototype.__init10.call(this); }__init10() {this.kind="mat3x3f"}makeColumn(t,n,r){return v(t,n,r)}}, _class8),tt= (_class9 =class extends Ue{__init11() {this[o]=!0}constructor(...t){super();_class9.prototype.__init11.call(this);_class9.prototype.__init12.call(this);,this.columns=[this.makeColumn(t[0],t[1],t[2],t[3]),this.makeColumn(t[4],t[5],t[6],t[7]),this.makeColumn(t[8],t[9],t[10],t[11]),this.makeColumn(t[12],t[13],t[14],t[15])]}__init12() {this.length=16}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return this.columns[0].w}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return this.columns[1].w}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return this.columns[2].w}get 12(){return this.columns[3].x}get 13(){return this.columns[3].y}get 14(){return this.columns[3].z}get 15(){return this.columns[3].w}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){this.columns[0].w=t}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){this.columns[1].w=t}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){this.columns[2].w=t}set 12(t){this.columns[3].x=t}set 13(t){this.columns[3].y=t}set 14(t){this.columns[3].z=t}set 15(t){this.columns[3].w=t}*[Symbol.iterator](){for(let t=0;t<16;t++)yield this[t]}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}}, _class9),nt= (_class10 =class extends tt{constructor(...args4) { super(...args4); _class10.prototype.__init13.call(this); }__init13() {this.kind="mat4x4f"}makeColumn(t,n,r,s){return T(t,n,r,s)}}, _class10),un= exports.Qa =i(()=>be(1,0,0,1),()=>({value:`mat4x4f(
6
+ 1.0, 0.0,
7
+ 0.0, 1.0
8
+ )`,dataType:be}),"identity2"),yn= exports.Ra =i(()=>ze(1,0,0,0,1,0,0,0,1),()=>({value:`mat4x4f(
9
+ 1.0, 0.0, 0.0,
10
+ 0.0, 1.0, 0.0,
11
+ 0.0, 0.0, 1.0,
12
+ )`,dataType:ze}),"identity3"),hn= exports.Sa =i(()=>g(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),()=>({value:`mat4x4f(
13
+ 1.0, 0.0, 0.0, 0.0,
14
+ 0.0, 1.0, 0.0, 0.0,
15
+ 0.0, 0.0, 1.0, 0.0,
16
+ 0.0, 0.0, 0.0, 1.0
17
+ )`,dataType:g}),"identity4"),ln={2:un,3:yn,4:hn},xn= exports.Ta =i(e=>g(1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1),e=>({value:`mat4x4f(
18
+ 1, 0, 0, 0,
19
+ 0, 1, 0, 0,
20
+ 0, 0, 1, 0,
21
+ ${e.value}.x, ${e.value}.y, ${e.value}.z, 1
22
+ )`,dataType:g}),"translation4"),dn= exports.Ua =i(e=>g(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),e=>({value:`mat4x4f(
23
+ ${e.value}.x, 0, 0, 0,
24
+ 0, ${e.value}.y, 0, 0,
25
+ 0, 0, ${e.value}.z, 0,
26
+ 0, 0, 0, 1
27
+ )`,dataType:g}),"scaling4"),mn= exports.Va =i(e=>g(1,0,0,0,0,Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1),e=>a(`mat4x4f(
28
+ 1, 0, 0, 0,
29
+ 0, cos(${e.value}), sin(${e.value}), 0,
30
+ 0, -sin(${e.value}), cos(${e.value}), 0,
31
+ 0, 0, 0, 1
32
+ )`,g),"rotationX4"),wn= exports.Wa =i(e=>g(Math.cos(e),0,-Math.sin(e),0,0,1,0,0,Math.sin(e),0,Math.cos(e),0,0,0,0,1),e=>a(`mat4x4f(
33
+ cos(${e.value}), 0, -sin(${e.value}), 0,
34
+ 0, 1, 0, 0,
35
+ sin(${e.value}), 0, cos(${e.value}), 0,
36
+ 0, 0, 0, 1
37
+ )`,g),"rotationY4"),pn= exports.Xa =i(e=>g(Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1,0,0,0,0,1),e=>a(`mat4x4f(
38
+ cos(${e.value}), sin(${e.value}), 0, 0,
39
+ -sin(${e.value}), cos(${e.value}), 0, 0,
40
+ 0, 0, 1, 0,
41
+ 0, 0, 0, 1
42
+ )`,g),"rotationZ4"),be= exports.Ya =rt({type:"mat2x2f",rows:2,columns:2,MatImpl:Je}),ze= exports.Za =rt({type:"mat3x3f",rows:3,columns:3,MatImpl:et}),g= exports._a =rt({type:"mat4x4f",rows:4,columns:4,MatImpl:nt});function us(e){return e.kind==="mat3x3f"?[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]:Array.from({length:e.length}).map((t,n)=>e[n])}var U=(e,t,n)=>{if(e===t)return 0;let r=u((n-e)/(t-e),0,1);return r*r*(3-2*r)},u=(e,t,n)=>Math.min(Math.max(t,e),n),X=(e,t)=>t===0?e:Math.trunc(e/t);var Ve=e=>Math.sqrt(e.x**2+e.y**2),Se=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),_e=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),Le=(e,t)=>e.x*t.x+e.y*t.y,je=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,Ge=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,x=e=>t=>f(e(t.x),e(t.y)),d=e=>t=>A(e(t.x),e(t.y)),J=e=>t=>j(e(t.x),e(t.y)),Me=e=>t=>G(e(t.x),e(t.y)),l=e=>t=>v(e(t.x),e(t.y),e(t.z)),m=e=>t=>I(e(t.x),e(t.y),e(t.z)),Q=e=>t=>q(e(t.x),e(t.y),e(t.z)),$e=e=>t=>Y(e(t.x),e(t.y),e(t.z)),h=e=>t=>T(e(t.x),e(t.y),e(t.z),e(t.w)),w=e=>t=>k(e(t.x),e(t.y),e(t.z),e(t.w)),ee=e=>t=>H(e(t.x),e(t.y),e(t.z),e(t.w)),Ie=e=>t=>Z(e(t.x),e(t.y),e(t.z),e(t.w)),kt=e=>t=>{let n=t.columns;return be(x(e)(n[0]),x(e)(n[1]))},Bt=e=>t=>{let n=t.columns;return ze(l(e)(n[0]),l(e)(n[1]),l(e)(n[2]))},Dt=e=>t=>{let n=t.columns;return g(h(e)(n[0]),h(e)(n[1]),h(e)(n[2]),h(e)(n[3]))},C=e=>(t,n)=>f(e(t.x,n.x),e(t.y,n.y)),te=e=>(t,n)=>A(e(t.x,n.x),e(t.y,n.y)),Ae=e=>(t,n)=>j(e(t.x,n.x),e(t.y,n.y)),ke=e=>(t,n)=>G(e(t.x,n.x),e(t.y,n.y)),D=e=>(t,n)=>v(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),ne=e=>(t,n)=>I(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),Be=e=>(t,n)=>q(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),De=e=>(t,n)=>Y(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),B=e=>(t,n)=>T(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),re=e=>(t,n)=>k(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Ne=e=>(t,n)=>H(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Fe=e=>(t,n)=>Z(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),vn=e=>(t,n)=>{let r=t.columns,s=n.columns;return be(C(e)(r[0],s[0]),C(e)(r[1],s[1]))},gn=e=>(t,n)=>{let r=t.columns,s=n.columns;return ze(D(e)(r[0],s[0]),D(e)(r[1],s[1]),D(e)(r[2],s[2]))},fn=e=>(t,n)=>{let r=t.columns,s=n.columns;return g(B(e)(r[0],s[0]),B(e)(r[1],s[1]),B(e)(r[2],s[2]),B(e)(r[3],s[3]))},Tn=e=>(t,n,r)=>f(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),bn=e=>(t,n,r)=>A(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),zn=e=>(t,n,r)=>v(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),Vn=e=>(t,n,r)=>I(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),Sn=e=>(t,n,r)=>T(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z),e(t.w,n.w,r.w)),_n=e=>(t,n,r)=>k(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z),e(t.w,n.w,r.w)),c= exports.ab ={eq:{vec2f:(e,t)=>S(e.x===t.x,e.y===t.y),vec2h:(e,t)=>S(e.x===t.x,e.y===t.y),vec2i:(e,t)=>S(e.x===t.x,e.y===t.y),vec2u:(e,t)=>S(e.x===t.x,e.y===t.y),"vec2<bool>":(e,t)=>S(e.x===t.x,e.y===t.y),vec3f:(e,t)=>_(e.x===t.x,e.y===t.y,e.z===t.z),vec3h:(e,t)=>_(e.x===t.x,e.y===t.y,e.z===t.z),vec3i:(e,t)=>_(e.x===t.x,e.y===t.y,e.z===t.z),vec3u:(e,t)=>_(e.x===t.x,e.y===t.y,e.z===t.z),"vec3<bool>":(e,t)=>_(e.x===t.x,e.y===t.y,e.z===t.z),vec4f:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4h:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4i:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4u:(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),"vec4<bool>":(e,t)=>M(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w)},lt:{vec2f:(e,t)=>S(e.x<t.x,e.y<t.y),vec2h:(e,t)=>S(e.x<t.x,e.y<t.y),vec2i:(e,t)=>S(e.x<t.x,e.y<t.y),vec2u:(e,t)=>S(e.x<t.x,e.y<t.y),vec3f:(e,t)=>_(e.x<t.x,e.y<t.y,e.z<t.z),vec3h:(e,t)=>_(e.x<t.x,e.y<t.y,e.z<t.z),vec3i:(e,t)=>_(e.x<t.x,e.y<t.y,e.z<t.z),vec3u:(e,t)=>_(e.x<t.x,e.y<t.y,e.z<t.z),vec4f:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4h:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4i:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4u:(e,t)=>M(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w)},or:{"vec2<bool>":(e,t)=>S(e.x||t.x,e.y||t.y),"vec3<bool>":(e,t)=>_(e.x||t.x,e.y||t.y,e.z||t.z),"vec4<bool>":(e,t)=>M(e.x||t.x,e.y||t.y,e.z||t.z,e.w||t.w)},all:{"vec2<bool>":e=>e.x&&e.y,"vec3<bool>":e=>e.x&&e.y&&e.z,"vec4<bool>":e=>e.x&&e.y&&e.z&&e.w},abs:{vec2f:x(Math.abs),vec2h:d(Math.abs),vec2i:J(Math.abs),vec2u:Me(Math.abs),vec3f:l(Math.abs),vec3h:m(Math.abs),vec3i:Q(Math.abs),vec3u:$e(Math.abs),vec4f:h(Math.abs),vec4h:w(Math.abs),vec4i:ee(Math.abs),vec4u:Ie(Math.abs)},atan2:{vec2f:C(Math.atan2),vec2h:te(Math.atan2),vec3f:D(Math.atan2),vec3h:ne(Math.atan2),vec4f:B(Math.atan2),vec4h:re(Math.atan2)},acos:{vec2f:x(Math.acos),vec2h:d(Math.acos),vec2i:J(Math.acos),vec2u:Me(Math.acos),vec3f:l(Math.acos),vec3h:m(Math.acos),vec3i:Q(Math.acos),vec3u:$e(Math.acos),vec4f:h(Math.acos),vec4h:w(Math.acos),vec4i:ee(Math.acos),vec4u:Ie(Math.acos)},acosh:{vec2f:x(Math.acosh),vec2h:d(Math.acosh),vec3f:l(Math.acosh),vec3h:m(Math.acosh),vec4f:h(Math.acosh),vec4h:w(Math.acosh)},asin:{vec2f:x(Math.asin),vec2h:d(Math.asin),vec2i:J(Math.asin),vec2u:Me(Math.asin),vec3f:l(Math.asin),vec3h:m(Math.asin),vec3i:Q(Math.asin),vec3u:$e(Math.asin),vec4f:h(Math.asin),vec4h:w(Math.asin),vec4i:ee(Math.asin),vec4u:Ie(Math.asin)},ceil:{vec2f:x(Math.ceil),vec2h:d(Math.ceil),vec3f:l(Math.ceil),vec3h:m(Math.ceil),vec4f:h(Math.ceil),vec4h:w(Math.ceil)},clamp:{vec2f:(e,t,n)=>f(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2h:(e,t,n)=>A(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2i:(e,t,n)=>j(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2u:(e,t,n)=>G(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec3f:(e,t,n)=>v(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec3h:(e,t,n)=>I(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec3i:(e,t,n)=>q(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec3u:(e,t,n)=>Y(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec4f:(e,t,n)=>T(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w)),vec4h:(e,t,n)=>k(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w)),vec4i:(e,t,n)=>H(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w)),vec4u:(e,t,n)=>Z(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w))},length:{vec2f:Ve,vec2h:Ve,vec3f:Se,vec3h:Se,vec4f:_e,vec4h:_e},add:{vec2f:C((e,t)=>e+t),vec2h:te((e,t)=>e+t),vec2i:Ae((e,t)=>e+t),vec2u:ke((e,t)=>e+t),vec3f:D((e,t)=>e+t),vec3h:ne((e,t)=>e+t),vec3i:Be((e,t)=>e+t),vec3u:De((e,t)=>e+t),vec4f:B((e,t)=>e+t),vec4h:re((e,t)=>e+t),vec4i:Ne((e,t)=>e+t),vec4u:Fe((e,t)=>e+t),mat2x2f:vn((e,t)=>e+t),mat3x3f:gn((e,t)=>e+t),mat4x4f:fn((e,t)=>e+t)},smoothstep:{vec2f:Tn(U),vec2h:bn(U),vec3f:zn(U),vec3h:Vn(U),vec4f:Sn(U),vec4h:_n(U)},addMixed:{vec2f:(e,t)=>x(n=>n+t)(e),vec2h:(e,t)=>d(n=>n+t)(e),vec2i:(e,t)=>J(n=>n+t)(e),vec2u:(e,t)=>Me(n=>n+t)(e),vec3f:(e,t)=>l(n=>n+t)(e),vec3h:(e,t)=>m(n=>n+t)(e),vec3i:(e,t)=>Q(n=>n+t)(e),vec3u:(e,t)=>$e(n=>n+t)(e),vec4f:(e,t)=>h(n=>n+t)(e),vec4h:(e,t)=>w(n=>n+t)(e),vec4i:(e,t)=>ee(n=>n+t)(e),vec4u:(e,t)=>Ie(n=>n+t)(e),mat2x2f:(e,t)=>kt(n=>n+t)(e),mat3x3f:(e,t)=>Bt(n=>n+t)(e),mat4x4f:(e,t)=>Dt(n=>n+t)(e)},mulSxV:{vec2f:(e,t)=>x(n=>e*n)(t),vec2h:(e,t)=>d(n=>e*n)(t),vec2i:(e,t)=>J(n=>e*n)(t),vec2u:(e,t)=>Me(n=>e*n)(t),vec3f:(e,t)=>l(n=>e*n)(t),vec3h:(e,t)=>m(n=>e*n)(t),vec3i:(e,t)=>Q(n=>e*n)(t),vec3u:(e,t)=>$e(n=>e*n)(t),vec4f:(e,t)=>h(n=>e*n)(t),vec4h:(e,t)=>w(n=>e*n)(t),vec4i:(e,t)=>ee(n=>e*n)(t),vec4u:(e,t)=>Ie(n=>e*n)(t),mat2x2f:(e,t)=>kt(n=>e*n)(t),mat3x3f:(e,t)=>Bt(n=>e*n)(t),mat4x4f:(e,t)=>Dt(n=>e*n)(t)},mulVxV:{vec2f:C((e,t)=>e*t),vec2h:te((e,t)=>e*t),vec2i:Ae((e,t)=>e*t),vec2u:ke((e,t)=>e*t),vec3f:D((e,t)=>e*t),vec3h:ne((e,t)=>e*t),vec3i:Be((e,t)=>e*t),vec3u:De((e,t)=>e*t),vec4f:B((e,t)=>e*t),vec4h:re((e,t)=>e*t),vec4i:Ne((e,t)=>e*t),vec4u:Fe((e,t)=>e*t),mat2x2f:(e,t)=>{let n=e.columns,r=t.columns;return be(n[0].x*r[0].x+n[1].x*r[0].y,n[0].y*r[0].x+n[1].y*r[0].y,n[0].x*r[1].x+n[1].x*r[1].y,n[0].y*r[1].x+n[1].y*r[1].y)},mat3x3f:(e,t)=>{let n=e.columns,r=t.columns;return ze(n[0].x*r[0].x+n[1].x*r[0].y+n[2].x*r[0].z,n[0].y*r[0].x+n[1].y*r[0].y+n[2].y*r[0].z,n[0].z*r[0].x+n[1].z*r[0].y+n[2].z*r[0].z,n[0].x*r[1].x+n[1].x*r[1].y+n[2].x*r[1].z,n[0].y*r[1].x+n[1].y*r[1].y+n[2].y*r[1].z,n[0].z*r[1].x+n[1].z*r[1].y+n[2].z*r[1].z,n[0].x*r[2].x+n[1].x*r[2].y+n[2].x*r[2].z,n[0].y*r[2].x+n[1].y*r[2].y+n[2].y*r[2].z,n[0].z*r[2].x+n[1].z*r[2].y+n[2].z*r[2].z)},mat4x4f:(e,t)=>{let n=e.columns,r=t.columns;return g(n[0].x*r[0].x+n[1].x*r[0].y+n[2].x*r[0].z+n[3].x*r[0].w,n[0].y*r[0].x+n[1].y*r[0].y+n[2].y*r[0].z+n[3].y*r[0].w,n[0].z*r[0].x+n[1].z*r[0].y+n[2].z*r[0].z+n[3].z*r[0].w,n[0].w*r[0].x+n[1].w*r[0].y+n[2].w*r[0].z+n[3].w*r[0].w,n[0].x*r[1].x+n[1].x*r[1].y+n[2].x*r[1].z+n[3].x*r[1].w,n[0].y*r[1].x+n[1].y*r[1].y+n[2].y*r[1].z+n[3].y*r[1].w,n[0].z*r[1].x+n[1].z*r[1].y+n[2].z*r[1].z+n[3].z*r[1].w,n[0].w*r[1].x+n[1].w*r[1].y+n[2].w*r[1].z+n[3].w*r[1].w,n[0].x*r[2].x+n[1].x*r[2].y+n[2].x*r[2].z+n[3].x*r[2].w,n[0].y*r[2].x+n[1].y*r[2].y+n[2].y*r[2].z+n[3].y*r[2].w,n[0].z*r[2].x+n[1].z*r[2].y+n[2].z*r[2].z+n[3].z*r[2].w,n[0].w*r[2].x+n[1].w*r[2].y+n[2].w*r[2].z+n[3].w*r[2].w,n[0].x*r[3].x+n[1].x*r[3].y+n[2].x*r[3].z+n[3].x*r[3].w,n[0].y*r[3].x+n[1].y*r[3].y+n[2].y*r[3].z+n[3].y*r[3].w,n[0].z*r[3].x+n[1].z*r[3].y+n[2].z*r[3].z+n[3].z*r[3].w,n[0].w*r[3].x+n[1].w*r[3].y+n[2].w*r[3].z+n[3].w*r[3].w)}},mulMxV:{mat2x2f:(e,t)=>{let n=e.columns;return f(n[0].x*t.x+n[1].x*t.y,n[0].y*t.x+n[1].y*t.y)},mat3x3f:(e,t)=>{let n=e.columns;return v(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z)},mat4x4f:(e,t)=>{let n=e.columns;return T(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z+n[3].x*t.w,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z+n[3].y*t.w,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z+n[3].z*t.w,n[0].w*t.x+n[1].w*t.y+n[2].w*t.z+n[3].w*t.w)}},mulVxM:{mat2x2f:(e,t)=>{let n=t.columns;return f(e.x*n[0].x+e.y*n[0].y,e.x*n[1].x+e.y*n[1].y)},mat3x3f:(e,t)=>{let n=t.columns;return v(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z)},mat4x4f:(e,t)=>{let n=t.columns;return T(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z+e.w*n[0].w,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z+e.w*n[1].w,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z+e.w*n[2].w,e.x*n[3].x+e.y*n[3].y+e.z*n[3].z+e.w*n[3].w)}},div:{vec2f:C((e,t)=>e/t),vec2h:te((e,t)=>e/t),vec2i:Ae(X),vec2u:ke(X),vec3f:D((e,t)=>e/t),vec3h:ne((e,t)=>e/t),vec3i:Be(X),vec3u:De(X),vec4f:B((e,t)=>e/t),vec4h:re((e,t)=>e/t),vec4i:Ne(X),vec4u:Fe(X)},dot:{vec2f:Le,vec2h:Le,vec2i:Le,vec2u:Le,vec3f:je,vec3h:je,vec3i:je,vec3u:je,vec4f:Ge,vec4h:Ge,vec4i:Ge,vec4u:Ge},normalize:{vec2f:e=>{let t=Ve(e);return f(e.x/t,e.y/t)},vec2h:e=>{let t=Ve(e);return A(e.x/t,e.y/t)},vec2i:e=>{let t=Ve(e);return j(e.x/t,e.y/t)},vec2u:e=>{let t=Ve(e);return G(e.x/t,e.y/t)},vec3f:e=>{let t=Se(e);return v(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=Se(e);return I(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=Se(e);return q(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=Se(e);return Y(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=_e(e);return T(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=_e(e);return k(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=_e(e);return H(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=_e(e);return Z(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>v(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3h:(e,t)=>I(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)},mod:{vec2f:C((e,t)=>e%t),vec2h:te((e,t)=>e%t),vec2i:Ae((e,t)=>e%t),vec2u:ke((e,t)=>e%t),vec3f:D((e,t)=>e%t),vec3h:ne((e,t)=>e%t),vec3i:Be((e,t)=>e%t),vec3u:De((e,t)=>e%t),vec4f:B((e,t)=>e%t),vec4h:re((e,t)=>e%t),vec4i:Ne((e,t)=>e%t),vec4u:Fe((e,t)=>e%t)},floor:{vec2f:x(Math.floor),vec2h:d(Math.floor),vec3f:l(Math.floor),vec3h:m(Math.floor),vec4f:h(Math.floor),vec4h:w(Math.floor)},max:{vec2f:C(Math.max),vec2h:te(Math.max),vec2i:Ae(Math.max),vec2u:ke(Math.max),vec3f:D(Math.max),vec3h:ne(Math.max),vec3i:Be(Math.max),vec3u:De(Math.max),vec4f:B(Math.max),vec4h:re(Math.max),vec4i:Ne(Math.max),vec4u:Fe(Math.max)},min:{vec2f:C(Math.min),vec2h:te(Math.min),vec2i:Ae(Math.min),vec2u:ke(Math.min),vec3f:D(Math.min),vec3h:ne(Math.min),vec3i:Be(Math.min),vec3u:De(Math.min),vec4f:B(Math.min),vec4h:re(Math.min),vec4i:Ne(Math.min),vec4u:Fe(Math.min)},pow:{vec2f:(e,t)=>f(e.x**t.x,e.y**t.y),vec2h:(e,t)=>A(e.x**t.x,e.y**t.y),vec3f:(e,t)=>v(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>I(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>T(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>k(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},sign:{vec2f:x(Math.sign),vec2h:d(Math.sign),vec2i:J(Math.sign),vec3f:l(Math.sign),vec3h:m(Math.sign),vec3i:Q(Math.sign),vec4f:h(Math.sign),vec4h:w(Math.sign),vec4i:ee(Math.sign)},sqrt:{vec2f:x(Math.sqrt),vec2h:d(Math.sqrt),vec3f:l(Math.sqrt),vec3h:m(Math.sqrt),vec4f:h(Math.sqrt),vec4h:w(Math.sqrt)},mix:{vec2f:(e,t,n)=>typeof n=="number"?f(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):f(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec2h:(e,t,n)=>typeof n=="number"?A(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):A(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec3f:(e,t,n)=>typeof n=="number"?v(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):v(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec3h:(e,t,n)=>typeof n=="number"?I(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):I(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec4f:(e,t,n)=>typeof n=="number"?T(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):T(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w),vec4h:(e,t,n)=>typeof n=="number"?k(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):k(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w)},sin:{vec2f:x(Math.sin),vec2h:d(Math.sin),vec3f:l(Math.sin),vec3h:m(Math.sin),vec4f:h(Math.sin),vec4h:w(Math.sin)},cos:{vec2f:x(Math.cos),vec2h:d(Math.cos),vec3f:l(Math.cos),vec3h:m(Math.cos),vec4f:h(Math.cos),vec4h:w(Math.cos)},cosh:{vec2f:x(Math.cosh),vec2h:d(Math.cosh),vec3f:l(Math.cosh),vec3h:m(Math.cosh),vec4f:h(Math.cosh),vec4h:w(Math.cosh)},exp:{vec2f:x(Math.exp),vec2h:d(Math.exp),vec3f:l(Math.exp),vec3h:m(Math.exp),vec4f:h(Math.exp),vec4h:w(Math.exp)},exp2:{vec2f:x(e=>2**e),vec2h:d(e=>2**e),vec3f:l(e=>2**e),vec3h:m(e=>2**e),vec4f:h(e=>2**e),vec4h:w(e=>2**e)},log:{vec2f:x(Math.log),vec2h:d(Math.log),vec3f:l(Math.log),vec3h:m(Math.log),vec4f:h(Math.log),vec4h:w(Math.log)},log2:{vec2f:x(Math.log2),vec2h:d(Math.log2),vec3f:l(Math.log2),vec3h:m(Math.log2),vec4f:h(Math.log2),vec4h:w(Math.log2)},fract:{vec2f:x(e=>e-Math.floor(e)),vec2h:d(e=>e-Math.floor(e)),vec3f:l(e=>e-Math.floor(e)),vec3h:m(e=>e-Math.floor(e)),vec4f:h(e=>e-Math.floor(e)),vec4h:w(e=>e-Math.floor(e))},isCloseToZero:{vec2f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec2h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec3f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec3h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec4f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t,vec4h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t},neg:{vec2f:x(e=>-e),vec2h:d(e=>-e),vec2i:J(e=>-e),vec2u:Me(e=>-e),"vec2<bool>":e=>S(!e.x,!e.y),vec3f:l(e=>-e),vec3h:m(e=>-e),vec3i:Q(e=>-e),vec3u:$e(e=>-e),"vec3<bool>":e=>_(!e.x,!e.y,!e.z),vec4f:h(e=>-e),vec4h:w(e=>-e),vec4i:ee(e=>-e),vec4u:Ie(e=>-e),"vec4<bool>":e=>M(!e.x,!e.y,!e.z,!e.w)},select:{vec2f:(e,t,n)=>f(n.x?t.x:e.x,n.y?t.y:e.y),vec2h:(e,t,n)=>A(n.x?t.x:e.x,n.y?t.y:e.y),vec2i:(e,t,n)=>j(n.x?t.x:e.x,n.y?t.y:e.y),vec2u:(e,t,n)=>G(n.x?t.x:e.x,n.y?t.y:e.y),"vec2<bool>":(e,t,n)=>S(n.x?t.x:e.x,n.y?t.y:e.y),vec3f:(e,t,n)=>v(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3h:(e,t,n)=>I(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3i:(e,t,n)=>q(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3u:(e,t,n)=>Y(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),"vec3<bool>":(e,t,n)=>_(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec4f:(e,t,n)=>T(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4h:(e,t,n)=>k(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4i:(e,t,n)=>H(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),vec4u:(e,t,n)=>Z(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w),"vec4<bool>":(e,t,n)=>M(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z,n.w?t.w:e.w)},tanh:{vec2f:x(Math.tanh),vec2h:d(Math.tanh),vec3f:l(Math.tanh),vec3h:m(Math.tanh),vec4f:h(Math.tanh),vec4h:w(Math.tanh)}};function se(e){return Mn(e.dataType)}function Mn(e){let t=_optionalChain([e, 'optionalAccess', _70 => _70.type]);return!!_optionalChain([e, 'optionalAccess', _71 => _71[o]])&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}function Nt(e,t){if(typeof e=="number"&&typeof t=="number")return e+t;if(typeof e=="number"&&p(t))return c.addMixed[t.kind](t,e);if(p(e)&&typeof t=="number")return c.addMixed[e.kind](e,t);if(p(e)&&p(t)||N(e)&&N(t))return c.add[e.kind](e,t);throw new Error("Add/Sub called with invalid arguments.")}var Vs=i(Nt,(e,t)=>a(`(${e.value} + ${t.value})`,se(e)?t.dataType:e.dataType),"unify");function $n(e,t){return Nt(e,Pt(-1,t))}var Ft=i($n,(e,t)=>a(`(${e.value} - ${t.value})`,se(e)?t.dataType:e.dataType),"sub","unify");function In(e,t){if(typeof e=="number"&&typeof t=="number")return e*t;if(typeof e=="number"&&(p(t)||N(t)))return c.mulSxV[t.kind](e,t);if((p(e)||N(e))&&typeof t=="number")return c.mulSxV[e.kind](t,e);if(p(e)&&p(t))return c.mulVxV[e.kind](e,t);if(Ze(e)&&N(t))return c.mulVxM[t.kind](e,t);if(N(e)&&Ze(t))return c.mulMxV[e.kind](e,t);if(N(e)&&N(t))return c.mulVxV[e.kind](e,t);throw new Error("Mul called with invalid arguments.")}var Pt=i(In,(e,t)=>{let n=se(e)?t.dataType:se(t)||e.dataType.type.startsWith("vec")?e.dataType:t.dataType.type.startsWith("vec")?t.dataType:e.dataType;return a(`(${e.value} * ${t.value})`,n)},"mul"),Ss= exports.gb =i((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e/t;if(typeof e=="number"&&p(t)){let n=Te[t.kind];return c.div[t.kind](n(e),t)}if(p(e)&&typeof t=="number"){let n=Te[e.kind];return c.div[e.kind](e,n(t))}if(p(e)&&p(t))return c.div[e.kind](e,t);throw new Error("Div called with invalid arguments.")},(e,t)=>se(e)&&se(t)?a(`(f32(${e.value}) / ${t.value})`,V):a(`(${e.value} / ${t.value})`,e.dataType),"div"),_s= exports.hb =i(e=>typeof e=="number"?Math.abs(e):c.abs[e.kind](e),e=>a(`abs(${e.value})`,e.dataType),"abs"),Ms= exports.ib =i((e,t)=>typeof e=="number"&&typeof t=="number"?Math.atan2(e,t):c.atan2[e.kind](e,t),(e,t)=>a(`atan2(${e.value}, ${t.value})`,e.dataType),"atan2"),$s= exports.jb =i(e=>typeof e=="number"?Math.acos(e):c.acos[e.kind](e),e=>a(`acos(${e.value})`,e.dataType),"acos"),Is= exports.kb =i(e=>typeof e=="number"?Math.acosh(e):c.acosh[e.kind](e),e=>a(`acosh(${e.value})`,e.dataType),"acosh"),As= exports.lb =i(e=>typeof e=="number"?Math.asin(e):c.asin[e.kind](e),e=>a(`asin(${e.value})`,e.dataType),"asin"),ks= exports.mb =i(e=>typeof e=="number"?Math.ceil(e):c.ceil[e.kind](e),e=>a(`ceil(${e.value})`,e.dataType),"ceil"),Bs= exports.nb =i((e,t,n)=>typeof e=="number"?Math.min(Math.max(t,e),n):c.clamp[e.kind](e,t,n),(e,t,n)=>a(`clamp(${e.value}, ${t.value}, ${n.value})`,e.dataType),"clamp"),Ds= exports.ob =i(e=>typeof e=="number"?Math.cos(e):c.cos[e.kind](e),e=>a(`cos(${e.value})`,e.dataType),"cos"),Ns= exports.pb =i(e=>typeof e=="number"?Math.cosh(e):c.cosh[e.kind](e),e=>a(`cosh(${e.value})`,e.dataType),"cosh"),Fs= exports.qb =i((e,t)=>c.cross[e.kind](e,t),(e,t)=>a(`cross(${e.value}, ${t.value})`,e.dataType),"cross"),An= exports.rb =i((e,t)=>c.dot[e.kind](e,t),(e,t)=>a(`dot(${e.value}, ${t.value})`,V),"dot"),Ps= exports.sb =i(e=>c.normalize[e.kind](e),e=>a(`normalize(${e.value})`,e.dataType),"normalize"),Rs= exports.tb =i(e=>typeof e=="number"?Math.floor(e):c.floor[e.kind](e),e=>a(`floor(${e.value})`,e.dataType),"floor"),Es= exports.ub =i(e=>typeof e=="number"?e-Math.floor(e):c.fract[e.kind](e),e=>a(`fract(${e.value})`,e.dataType),"fract"),kn= exports.vb =i(e=>typeof e=="number"?Math.abs(e):c.length[e.kind](e),e=>a(`length(${e.value})`,V),"length"),Us= exports.wb =i(e=>typeof e=="number"?Math.log(e):c.log[e.kind](e),e=>a(`log(${e.value})`,e.dataType),"log"),Cs= exports.xb =i(e=>typeof e=="number"?Math.log2(e):c.log2[e.kind](e),e=>a(`log2(${e.value})`,e.dataType),"log2"),Os= exports.yb =i((e,t)=>typeof e=="number"?Math.max(e,t):c.max[e.kind](e,t),(e,t)=>a(`max(${e.value}, ${t.value})`,e.dataType),"max","unify"),Ws= exports.zb =i((e,t)=>typeof e=="number"?Math.min(e,t):c.min[e.kind](e,t),(e,t)=>a(`min(${e.value}, ${t.value})`,e.dataType),"min","unify"),Ks= exports.Ab =i(e=>typeof e=="number"?Math.sign(e):c.sign[e.kind](e),e=>a(`sign(${e.value})`,e.dataType),"sign"),Ls= exports.Bb =i(e=>typeof e=="number"?Math.sin(e):c.sin[e.kind](e),e=>a(`sin(${e.value})`,e.dataType),"sin"),js= exports.Cb =i((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e%t;if(typeof e=="number"&&p(t)){let n=Te[t.kind];return c.mod[t.kind](n(e),t)}if(p(e)&&typeof t=="number"){let n=Te[e.kind];return c.mod[e.kind](e,n(t))}if(p(e)&&p(t))return c.mod[e.kind](e,t);throw new Error("Mod called with invalid arguments, expected types: number or vector.")},(e,t)=>{let n=se(e)?t.dataType:e.dataType;return a(`(${e.value} % ${t.value})`,n)},"mod"),Gs= exports.Db =i(e=>typeof e=="number"?Math.exp(e):c.exp[e.kind](e),e=>a(`exp(${e.value})`,e.dataType),"exp"),qs= exports.Eb =i(e=>typeof e=="number"?2**e:c.exp2[e.kind](e),e=>a(`exp2(${e.value})`,e.dataType),"exp2"),Ys= exports.Fb =i((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e**t;if(typeof e=="object"&&typeof t=="object"&&"kind"in e&&"kind"in t)return c.pow[e.kind](e,t);throw new Error("Invalid arguments to pow()")},(e,t)=>a(`pow(${e.value}, ${t.value})`,e.dataType),"pow"),Hs= exports.Gb =i((e,t,n)=>{if(typeof e=="number"){if(typeof n!="number"||typeof t!="number")throw new Error("When e1 and e2 are numbers, the blend factor must be a number.");return e*(1-n)+t*n}if(typeof e=="number"||typeof t=="number")throw new Error("e1 and e2 need to both be vectors of the same kind.");return c.mix[e.kind](e,t,n)},(e,t,n)=>a(`mix(${e.value}, ${t.value}, ${n.value})`,e.dataType),"mix"),Zs= exports.Hb =i((e,t)=>Ft(e,Pt(2*An(t,e),t)),(e,t)=>a(`reflect(${e.value}, ${t.value})`,e.dataType),"reflect"),Xs= exports.Ib =i((e,t)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t):kn(Ft(e,t)),(e,t)=>a(`distance(${e.value}, ${t.value})`,V),"distance"),Js= exports.Jb =i(e=>typeof e=="number"?-e:c.neg[e.kind](e),e=>a(`-(${e.value})`,e.dataType),"neg"),Qs= exports.Kb =i(e=>typeof e=="number"?Math.sqrt(e):c.sqrt[e.kind](e),e=>a(`sqrt(${e.value})`,e.dataType),"sqrt"),ei= exports.Lb =i(e=>typeof e=="number"?Math.tanh(e):c.tanh[e.kind](e),e=>a(`tanh(${e.value})`,e.dataType),"tanh"),ti= exports.Mb =i((e,t,n)=>typeof n=="number"?U(e,t,n):c.smoothstep[n.kind](e,t,n),(e,t,n)=>a(`smoothstep(${e.value}, ${t.value}, ${n.value})`,n.dataType),"smoothstep");function si(e){return{[o]:!0,type:"ptr",inner:e,addressSpace:"function",access:"read-write"}}function ii(e){return{[o]:!0,type:"ptr",inner:e,addressSpace:"private",access:"read-write"}}function ai(e){return{[o]:!0,type:"ptr",inner:e,addressSpace:"workgroup",access:"read-write"}}function oi(e,t="read"){return{[o]:!0,type:"ptr",inner:e,addressSpace:"storage",access:t}}function ci(e){return{[o]:!0,type:"ptr",inner:e,addressSpace:"uniform",access:"read"}}function ui(e){return{[o]:!0,type:"ptr",inner:e,addressSpace:"handle",access:"read"}}exports.a = o; exports.b = st; exports.c = Nn; exports.d = Ye; exports.e = it; exports.f = at; exports.g = Fn; exports.h = Ce; exports.i = Gn; exports.j = ie; exports.k = ct; exports.l = Ut; exports.m = Ct; exports.n = gt; exports.o = ut; exports.p = yt; exports.q = ht; exports.r = lt; exports.s = xt; exports.t = dt; exports.u = mt; exports.v = wt; exports.w = pt; exports.x = vt; exports.y = ft; exports.z = Tt; exports.A = bt; exports.B = tr; exports.C = sr; exports.D = ir; exports.E = p; exports.F = Kt; exports.G = Lt; exports.H = jt; exports.I = zt; exports.J = N; exports.K = Gt; exports.L = qt; exports.M = ar; exports.N = Vt; exports.O = or; exports.P = cr; exports.Q = ur; exports.R = yr; exports.S = hr; exports.T = lr; exports.U = xr; exports.V = dr; exports.W = mr; exports.X = St; exports.Y = wr; exports.Z = Oe; exports._ = _t; exports.$ = Mt; exports.aa = Ht; exports.ba = Tr; exports.ca = br; exports.da = zr; exports.ea = Vr; exports.fa = $r; exports.ga = Ir; exports.ha = Ar; exports.ia = kr; exports.ja = Zt; exports.ka = Br; exports.la = $t; exports.ma = i; exports.na = It; exports.oa = Cr; exports.pa = a; exports.qa = jr; exports.ra = Gr; exports.sa = F; exports.ta = P; exports.ua = qr; exports.va = R; exports.wa = V; exports.xa = E; exports.ya = Ee; exports.za = f; exports.Aa = A; exports.Ba = j; exports.Ca = G; exports.Da = S; exports.Ea = v; exports.Fa = I; exports.Ga = q; exports.Ha = Y; exports.Ia = _; exports.Ja = T; exports.Ka = k; exports.La = H; exports.Ma = Z; exports.Na = M; exports.Oa = cn; exports.Pa = Ue; exports.Qa = un; exports.Ra = yn; exports.Sa = hn; exports.Ta = xn; exports.Ua = dn; exports.Va = mn; exports.Wa = wn; exports.Xa = pn; exports.Ya = be; exports.Za = ze; exports._a = g; exports.$a = us; exports.ab = c; exports.bb = se; exports.cb = Mn; exports.db = Vs; exports.eb = Ft; exports.fb = Pt; exports.gb = Ss; exports.hb = _s; exports.ib = Ms; exports.jb = $s; exports.kb = Is; exports.lb = As; exports.mb = ks; exports.nb = Bs; exports.ob = Ds; exports.pb = Ns; exports.qb = Fs; exports.rb = An; exports.sb = Ps; exports.tb = Rs; exports.ub = Es; exports.vb = kn; exports.wb = Us; exports.xb = Cs; exports.yb = Os; exports.zb = Ws; exports.Ab = Ks; exports.Bb = Ls; exports.Cb = js; exports.Db = Gs; exports.Eb = qs; exports.Fb = Ys; exports.Gb = Hs; exports.Hb = Zs; exports.Ib = Xs; exports.Jb = Js; exports.Kb = Qs; exports.Lb = ei; exports.Mb = ti; exports.Nb = si; exports.Ob = ii; exports.Pb = ai; exports.Qb = oi; exports.Rb = ci; exports.Sb = ui;
43
+ //# sourceMappingURL=chunk-BF35NEOX.cjs.map