typegpu 0.6.0 → 0.7.1

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 (42) hide show
  1. package/chunk-2VTISQYP.cjs +10 -0
  2. package/chunk-2VTISQYP.cjs.map +1 -0
  3. package/chunk-CYZBRBPD.cjs +6 -0
  4. package/chunk-CYZBRBPD.cjs.map +1 -0
  5. package/chunk-SAMYKEUN.js +6 -0
  6. package/chunk-SAMYKEUN.js.map +1 -0
  7. package/chunk-WP6W72RY.js +10 -0
  8. package/chunk-WP6W72RY.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 +17 -5
  12. package/data/index.d.ts +17 -5
  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 +38 -3
  17. package/index.d.ts +38 -3
  18. package/index.js +18 -29
  19. package/index.js.map +1 -1
  20. package/{matrix-S8W4dk8I.d.ts → matrix-4h_aOtIE.d.cts} +9 -9
  21. package/{matrix-BN6ObiMv.d.cts → matrix-Domrg-ap.d.ts} +9 -9
  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 +274 -112
  26. package/std/index.d.ts +274 -112
  27. package/std/index.js +1 -1
  28. package/std/index.js.map +1 -1
  29. package/{tgpuComputeFn-DOUjhQua.d.ts → tgpuConstant-BSgcF4zi.d.cts} +3058 -2938
  30. package/{tgpuComputeFn-DOUjhQua.d.cts → tgpuConstant-BSgcF4zi.d.ts} +3058 -2938
  31. package/chunk-APTRHY5Y.js +0 -41
  32. package/chunk-APTRHY5Y.js.map +0 -1
  33. package/chunk-RC26P3MP.cjs +0 -2
  34. package/chunk-RC26P3MP.cjs.map +0 -1
  35. package/chunk-RK6TMFVW.js +0 -2
  36. package/chunk-RK6TMFVW.js.map +0 -1
  37. package/chunk-S62QJDM6.js +0 -2
  38. package/chunk-S62QJDM6.js.map +0 -1
  39. package/chunk-TG4A6AM3.cjs +0 -2
  40. package/chunk-TG4A6AM3.cjs.map +0 -1
  41. package/chunk-UMHCZDPA.cjs +0 -41
  42. package/chunk-UMHCZDPA.cjs.map +0 -1
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;var C="0.7.1";var i=Symbol(`typegpu:${C}:$internal`),lt= exports.b =Symbol(`typegpu:${C}:$wgslDataType`),Wr= exports.c =Symbol(`typegpu:${C}:$gpuValueOf`),At= exports.d =Symbol(`typegpu:${C}:$getNameForward`),Gt= exports.e =Symbol(`typegpu:${C}:$providing`),Yt=Symbol(`typegpu:${C}:$repr`),Lr=Symbol(`typegpu:${C}:$gpuRepr`),jr=Symbol(`typegpu:${C}:$reprPartial`),Kr=Symbol(`typegpu:${C}:$memIdent`),Gr=Symbol(`typegpu:${C}:$invalidStorageSchema`),Yr=Symbol(`typegpu:${C}:$validUniformSchema`),qr=Symbol(`typegpu:${C}:$validVertexSchema`),Hr=Symbol(`typegpu:${C}:$invalidSchemaReason`);var X=globalThis.process.env.NODE_ENV==="development",qt=globalThis.process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>En(e)&&_optionalChain([e, 'optionalAccess', _2 => _2[i]])&&!te(e)?e.$name(t):e});var Ze=globalThis,es= exports.f =(X||qt)&&{get enabled(){return!!Ze.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=Ze.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function Un(e){return!!_optionalChain([e, 'optionalAccess', _3 => _3[At]])}function te(e){return Un(e)?te(e[At]):_optionalChain([On, 'call', _4 => _4(e), 'optionalAccess', _5 => _5.name])}function ht(e,t){Wn(e,{name:t})}function En(e){return!!_optionalChain([e, 'optionalAccess', _6 => _6.$name])}function On(e){return Ze.__TYPEGPU_META__.get(e)}function Wn(e,t){Ze.__TYPEGPU_META__??=new WeakMap;let n=Ze.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var Mt="Invariant failed";function pt(e,t){if(e)return;if(!X)throw new Error(Mt);let n=typeof t=="function"?t():t,r=n?`${Mt}: ${n}`:Mt;throw new Error(r)}var Ht=class e extends Error{constructor(n,r){let s=r.map(a=>`- ${a}`);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)}},Xt= exports.m =class e extends Error{constructor(n,r){let s=r.map(a=>`- ${a}`);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)}},Zt= exports.n =class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},Jt= exports.o =class e extends Error{constructor(t){super(`Buffer '${_nullishCoalesce(te(t), () => ("<unnamed>"))}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},Qt= exports.p =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)}},en= exports.q =class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>_nullishCoalesce(te(n), () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},tn= exports.r =class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>_nullishCoalesce(te(n), () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},nn= exports.s =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},rn= exports.t =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},xt= exports.u =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function sn(e){return _optionalChain([e, 'optionalAccess', _7 => _7.resourceType])==="slot"}function an(e){return _optionalChain([e, 'optionalAccess', _8 => _8.resourceType])==="derived"}function on(e){return _optionalChain([e, 'optionalAccess', _9 => _9[Gt]])!==void 0}function cs(e){return _optionalChain([e, 'optionalAccess', _10 => _10.resourceType])==="accessor"}function cn(e){return!!_optionalChain([e, 'optionalAccess', _11 => _11[lt]])}var ls={[i]:!0,type:"void"},Ln=["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 y(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _12 => _12[i]])&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function jn(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _13 => _13[i]])&&typeof t.type=="string"&&t.type.startsWith("vec2")}function Kn(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _14 => _14[i]])&&typeof t.type=="string"&&t.type.startsWith("vec3")}function Gn(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _15 => _15[i]])&&typeof t.type=="string"&&t.type.startsWith("vec4")}function ce(e){return jn(e)||Kn(e)||Gn(e)}function A(e){let t=e;return!!_optionalChain([t, 'optionalAccess', _16 => _16[i]])&&typeof _optionalChain([t, 'access', _17 => _17.kind, 'optionalAccess', _18 => _18.startsWith])=="function"&&t.kind.startsWith("mat")}function Yn(e){return _optionalChain([e, 'optionalAccess', _19 => _19[i]])&&_optionalChain([e, 'optionalAccess', _20 => _20.type])==="mat2x2f"}function qn(e){return _optionalChain([e, 'optionalAccess', _21 => _21[i]])&&_optionalChain([e, 'optionalAccess', _22 => _22.type])==="mat3x3f"}function Hn(e){return _optionalChain([e, 'optionalAccess', _23 => _23[i]])&&_optionalChain([e, 'optionalAccess', _24 => _24.type])==="mat4x4f"}function $t(e){return Yn(e)||qn(e)||Hn(e)}function Dt(e){return y(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function mt(e){return _optionalChain([e, 'optionalAccess', _25 => _25[i]])&&Ln.includes(_optionalChain([e, 'optionalAccess', _26 => _26.type]))}function un(e){return _optionalChain([e, 'optionalAccess', _27 => _27[i]])&&_optionalChain([e, 'optionalAccess', _28 => _28.type])==="array"}function yn(e){return _optionalChain([e, 'optionalAccess', _29 => _29[i]])&&_optionalChain([e, 'optionalAccess', _30 => _30.type])==="struct"}function hs(e){return _optionalChain([e, 'optionalAccess', _31 => _31[i]])&&_optionalChain([e, 'optionalAccess', _32 => _32.type])==="ptr"}function xs(e){return _optionalChain([e, 'optionalAccess', _33 => _33[i]])&&_optionalChain([e, 'optionalAccess', _34 => _34.type])==="atomic"}function ln(e){return _optionalChain([e, 'optionalAccess', _35 => _35[i]])&&_optionalChain([e, 'optionalAccess', _36 => _36.type])==="@align"}function hn(e){return _optionalChain([e, 'optionalAccess', _37 => _37[i]])&&_optionalChain([e, 'optionalAccess', _38 => _38.type])==="@size"}function xn(e){return _optionalChain([e, 'optionalAccess', _39 => _39[i]])&&_optionalChain([e, 'optionalAccess', _40 => _40.type])==="@location"}function ps(e){return _optionalChain([e, 'optionalAccess', _41 => _41[i]])&&_optionalChain([e, 'optionalAccess', _42 => _42.type])==="@interpolate"}function ms(e){return _optionalChain([e, 'optionalAccess', _43 => _43[i]])&&_optionalChain([e, 'optionalAccess', _44 => _44.type])==="@builtin"}function pn(e){return _optionalChain([e, 'optionalAccess', _45 => _45[i]])&&_optionalChain([e, 'optionalAccess', _46 => _46.type])==="decorated"}function ds(e){return _optionalChain([e, 'optionalAccess', _47 => _47[i]])&&e.type==="void"}function dt(e){let t=_optionalChain([e, 'optionalAccess', _48 => _48.type]);return!!_optionalChain([e, 'optionalAccess', _49 => _49[i]])&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}var mn=["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"],ws= exports.ia ={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 Zn=["unstruct","disarray","loose-decorated",...mn];function Jn(e){return _optionalChain([e, 'optionalAccess', _50 => _50[i]])&&Zn.includes(_optionalChain([e, 'optionalAccess', _51 => _51.type]))}function wn(e){return _optionalChain([e, 'optionalAccess', _52 => _52[i]])&&_optionalChain([e, 'optionalAccess', _53 => _53.type])==="disarray"}function fn(e){return _optionalChain([e, 'optionalAccess', _54 => _54[i]])&&_optionalChain([e, 'optionalAccess', _55 => _55.type])==="unstruct"}function Ts(e){return _optionalChain([e, 'optionalAccess', _56 => _56[i]])&&_optionalChain([e, 'optionalAccess', _57 => _57.type])==="loose-decorated"}function bs(e){return _optionalChain([e, 'access', _58 => _58.attribs, 'optionalAccess', _59 => _59.find, 'call', _60 => _60(ln), 'optionalAccess', _61 => _61.params, 'access', _62 => _62[0]])}function zs(e){return _optionalChain([e, 'access', _63 => _63.attribs, 'optionalAccess', _64 => _64.find, 'call', _65 => _65(hn), 'optionalAccess', _66 => _66.params, 'access', _67 => _67[0]])}function Vs(e){return _optionalChain([e, 'access', _68 => _68.attribs, 'optionalAccess', _69 => _69.find, 'call', _70 => _70(xn), 'optionalAccess', _71 => _71.params, 'access', _72 => _72[0]])}function Ss(e){return mt(e)||Jn(e)}var ne={type:"unknown",toString(){return"unknown"}},dn= exports.sa =class{constructor(t,n,r){this.name=t;this.lhs=n;this.operator=r}};var wt= (_class =class{constructor() { _class.prototype.__init.call(this); }__init() {this.type="normal"}}, _class),vn= exports.V = (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.type="codegen"}}, _class2),gn= exports.W = (_class3 =class{constructor(t,n){;_class3.prototype.__init3.call(this);this.buffers=t;this.vars=n}__init3() {this.type="simulate"}}, _class3);function Qn(e){return er(e)&&typeof _optionalChain([e, 'optionalAccess', _73 => _73["~resolve"]])=="function"}function $s(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Qn(e)||mt(e)||sn(e)||an(e)||on(e)}function Ds(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function ks(e){return _optionalChain([e, 'optionalAccess', _74 => _74.resourceType])==="buffer-usage"}function er(e){return!!_optionalChain([e, 'optionalAccess', _75 => _75[i]])}var ft=!1;function Rs(e){if(ft)return e();try{return ft=!0,e()}finally{ft=!1}}function Ns(){return ft}var re;function Bs(e,t){if(pt(re===void 0||re===e,"Cannot nest context providers"),re===e)return t();re=e;try{return t()}finally{re=void 0}}function vt(){return re}var tr=new wt;function Us(){return _nullishCoalesce(_optionalChain([re, 'optionalAccess', _76 => _76.mode]), () => (tr))}function Tn(){return _optionalChain([re, 'optionalAccess', _77 => _77.mode, 'access', _78 => _78.type])==="codegen"}function m(e,...t){let n=vt();function r(a){return typeof a=="string"?a:n.resolve(a.value,a.dataType)}let s="";for(let a=0;a<e.length;++a){s+=e[a];let l=t[a];Array.isArray(l)?s+=l.filter(x=>x!==void 0).map(r).join(", "):l&&(s+=r(l))}return s}function w(e,t,n,r="keep"){let s=(...a)=>Tn()?t(...a):e(...a);return ht(s,n),s.toString=()=>n,Object.defineProperty(s,i,{value:{jsImpl:e,gpuImpl:t,argConversionHint:r}}),s}function Z(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}var gt=class{constructor(t,n){this.value=t;this.dataType=n}};function kt(e){return e instanceof gt}function we(e){return dt(e.dataType)}function o(e,t){if(X&&kt(e))throw new Error("Cannot nest snippets");return new gt(e,Z(t))}var bn={[i]:!0,type:"abstractInt"},zn= exports.Aa ={[i]:!0,type:"abstractFloat"},nr=w(e=>e===void 0?!1:typeof e=="boolean"?e:!!e,e=>o(m`bool(${e})`,$),"boolCast"),$= exports.Ba =Object.assign(nr,{type:"bool"}),rr=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0,e=>o(m`u32(${e})`,V),"u32Cast"),V= exports.Ca =Object.assign(rr,{type:"u32"}),sr=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:e|0,e=>o(m`i32(${e})`,z),"i32Cast"),ni= exports.Da ={[i]:!0,type:"u16"},z= exports.Ea =Object.assign(sr,{type:"i32"}),ir=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e),e=>o(m`f32(${e})`,v),"f32Cast"),v= exports.Fa =Object.assign(ir,{type:"f32"}),Vn=new ArrayBuffer(4),ar=new Float32Array(Vn),or=new Uint32Array(Vn);function cr(e){ar[0]=e;let t=or[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 ur(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 yr(e){return ur(cr(e))}var lr=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:yr(e),e=>o(m`f16(${e})`,D),"f16Cast"),D= exports.Ga =Object.assign(lr,{type:"f16"});var Je= (_class4 =class extends Array{constructor(...args) { super(...args); _class4.prototype.__init4.call(this); }__init4() {this[i]=!0}"~resolve"(){return this.every(t=>!t)?`${this.kind}()`:this.every(t=>this[0]===t)?`${this.kind}(${this[0]})`:`${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),ue=class extends Je{constructor(t,n){super(2),this.e0=this.castElement()(t),this.e1=this.castElement()(_nullishCoalesce(n, () => (t)))}get 0(){return this.e0}get 1(){return this.e1}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}},ye=class extends Je{constructor(t,n,r){super(3),this.e0=this.castElement()(t),this.e1=this.castElement()(_nullishCoalesce(n, () => (t))),this.e2=this.castElement()(_nullishCoalesce(r, () => (t)))}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}set z(t){this[2]=this.castElement()(t)}},le=class extends Je{constructor(t,n,r,s){super(4),this.e0=this.castElement()(t),this.e1=this.castElement()(_nullishCoalesce(n, () => (t))),this.e2=this.castElement()(_nullishCoalesce(r, () => (t))),this.e3=this.castElement()(_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.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}set 3(t){this.e3=this.castElement()(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}},fe=class e extends ue{castElement(){return v[i].jsImpl}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return ze}get _Vec4(){return Ae}},ve=class e extends ue{castElement(){return D[i].jsImpl}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return Ve}get _Vec4(){return Me}},ge=class e extends ue{castElement(){return z[i].jsImpl}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return Se}get _Vec4(){return $e}},Te=class e extends ue{castElement(){return V[i].jsImpl}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return _e}get _Vec4(){return De}},be=class e extends ue{castElement(){return $[i].jsImpl}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return Ie}get _Vec4(){return ke}},ze=class e extends ye{castElement(){return v[i].jsImpl}get kind(){return"vec3f"}get _Vec2(){return fe}get _Vec3(){return e}get _Vec4(){return Ae}},Ve=class e extends ye{castElement(){return D[i].jsImpl}get kind(){return"vec3h"}get _Vec2(){return ve}get _Vec3(){return e}get _Vec4(){return Me}},Se=class e extends ye{castElement(){return z[i].jsImpl}get kind(){return"vec3i"}get _Vec2(){return ge}get _Vec3(){return e}get _Vec4(){return $e}},_e=class e extends ye{castElement(){return V[i].jsImpl}get kind(){return"vec3u"}get _Vec2(){return Te}get _Vec3(){return e}get _Vec4(){return De}},Ie=class e extends ye{castElement(){return $[i].jsImpl}get kind(){return"vec3<bool>"}get _Vec2(){return be}get _Vec3(){return e}get _Vec4(){return ke}},Ae=class e extends le{castElement(){return v[i].jsImpl}get kind(){return"vec4f"}get _Vec2(){return fe}get _Vec3(){return ze}get _Vec4(){return e}},Me=class e extends le{castElement(){return D[i].jsImpl}get kind(){return"vec4h"}get _Vec2(){return ve}get _Vec3(){return Ve}get _Vec4(){return e}},$e=class e extends le{castElement(){return z[i].jsImpl}get kind(){return"vec4i"}get _Vec2(){return ge}get _Vec3(){return Se}get _Vec4(){return e}},De=class e extends le{castElement(){return V[i].jsImpl}get kind(){return"vec4u"}get _Vec2(){return Te}get _Vec3(){return _e}get _Vec4(){return e}},ke=class e extends le{castElement(){return $[i].jsImpl}get kind(){return"vec4<bool>"}get _Vec2(){return be}get _Vec3(){return Ie}get _Vec4(){return e}};var k=F(fe),Fe= exports.Ja =F(ve),j= exports.Ka =F(ge),K= exports.La =F(Te),Ce= exports.Ma =F(be),E= exports.Na =F(ze),Pe= exports.Oa =F(Ve),se= exports.Pa =F(Se),ie= exports.Qa =F(_e),Re= exports.Ra =F(Ie),S= exports.Sa =F(Ae),Ne= exports.Ta =F(Me),G= exports.Ua =F($e),Y= exports.Va =F(De),Be= exports.Wa =F(ke),Qe={vec2f:k,vec2h:Fe,vec2i:j,vec2u:K,"vec2<bool>":Ce,vec3f:E,vec3h:Pe,vec3i:se,vec3u:ie,"vec3<bool>":Re,vec4f:S,vec4h:Ne,vec4i:G,vec4u:Y,"vec4<bool>":Be},Ft={vec2f:v,vec2h:D,vec2i:z,vec2u:V,"vec2<bool>":$,vec3f:v,vec3h:D,vec3i:z,vec3u:V,"vec3<bool>":$,vec4f:v,vec4h:D,vec4i:z,vec4u:V,"vec4<bool>":$};function F(e){let{kind:t,length:n}=new e,r=(...l)=>{let x=new Array(l.length),p=0;for(let I of l)if(typeof I=="number"||typeof I=="boolean")x[p++]=I;else for(let P=0;P<I.length;++P)x[p++]=I[P];if(x.length<=1||x.length===n)return new e(...x);throw new Error(`'${t}' constructor called with invalid number of arguments.`)},s=w(r,(...l)=>{if(l.every(x=>typeof x.value=="number"||y(x.value))){let x=l.map(p=>p.value);return o(r(...x),a)}return o(m`${t}(${l})`,a)},t,(...l)=>l.map(x=>{let p=x.dataType;return pn(p)&&(p=p.inner),ce(p)?p:Ft[t]})),a=Object.assign(s,{type:t,[Yt]:void 0});return a}var et=class{};function Et(e){let t=w((...r)=>{let s=[];for(let a of r)if(typeof a=="number")s.push(a);else for(let l=0;l<a.length;++l)s.push(a[l]);if(s.length!==0&&s.length!==e.columns*e.rows)throw new Error(`'${e.type}' constructor called with invalid number of arguments.`);for(let a=s.length;a<e.columns*e.rows;++a)s.push(0);return new e.MatImpl(...s)},(...r)=>o(m`${e.type}(${r})`,n),e.type),n=Object.assign(t,{type:e.type,identity:dr[e.columns],translation:e.columns===4?wr:void 0,scaling:e.columns===4?fr:void 0,rotationX:e.columns===4?vr:void 0,rotationY:e.columns===4?gr:void 0,rotationZ:e.columns===4?Tr:void 0});return n}var Ct= (_class5 =class extends et{__init5() {this[i]=!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),Pt= (_class6 =class extends Ct{constructor(...args2) { super(...args2); _class6.prototype.__init7.call(this); }__init7() {this.kind="mat2x2f"}makeColumn(t,n){return k(t,n)}}, _class6),Rt= (_class7 =class extends et{__init8() {this[i]=!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),Nt= (_class8 =class extends Rt{constructor(...args3) { super(...args3); _class8.prototype.__init10.call(this); }__init10() {this.kind="mat3x3f"}makeColumn(t,n,r){return E(t,n,r)}}, _class8),Bt= (_class9 =class extends et{__init11() {this[i]=!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),Ut= (_class10 =class extends Bt{constructor(...args4) { super(...args4); _class10.prototype.__init13.call(this); }__init13() {this.kind="mat4x4f"}makeColumn(t,n,r,s){return S(t,n,r,s)}}, _class10),xr= exports.Ya =w(()=>ae(1,0,0,1),()=>o("mat2x2f(1, 0, 0, 1)",ae),"identity2"),pr= exports.Za =w(()=>oe(1,0,0,0,1,0,0,0,1),()=>o("mat3x3f(1, 0, 0, 0, 1, 0, 0, 0, 1)",oe),"identity3"),mr= exports._a =w(()=>_(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),()=>o("mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)",_),"identity4"),dr={2:xr,3:pr,4:mr},wr= exports.$a =w(e=>_(1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1),e=>o(m`mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ${e}.x, ${e}.y, ${e}.z, 1)`,_),"translation4"),fr= exports.ab =w(e=>_(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),e=>o(m`mat4x4f(${e}.x, 0, 0, 0, 0, ${e}.y, 0, 0, 0, 0, ${e}.z, 0, 0, 0, 0, 1)`,_),"scaling4"),vr= exports.bb =w(e=>_(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=>o(m`mat4x4f(1, 0, 0, 0, 0, cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1)`,_),"rotationX4"),gr= exports.cb =w(e=>_(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=>o(m`mat4x4f(cos(${e}), 0, -sin(${e}), 0, 0, 1, 0, 0, sin(${e}), 0, cos(${e}), 0, 0, 0, 0, 1)`,_),"rotationY4"),Tr= exports.db =w(e=>_(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=>o(m`mat4x4f(cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)`,_),"rotationZ4"),ae= exports.eb =Et({type:"mat2x2f",rows:2,columns:2,MatImpl:Pt}),oe= exports.fb =Et({type:"mat3x3f",rows:3,columns:3,MatImpl:Nt}),_= exports.gb =Et({type:"mat4x4f",rows:4,columns:4,MatImpl:Ut});function vi(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 c= (_class11 =class{constructor(t){;_class11.prototype.__init14.call(this);this.type=t}__init14() {this[i]=!0}}, _class11),Tt= exports.sb ={uint8:V,uint8x2:K,uint8x4:Y,sint8:z,sint8x2:j,sint8x4:G,unorm8:v,unorm8x2:k,unorm8x4:S,snorm8:v,snorm8x2:k,snorm8x4:S,uint16:V,uint16x2:K,uint16x4:Y,sint16:z,sint16x2:j,sint16x4:G,unorm16:v,unorm16x2:k,unorm16x4:S,snorm16:v,snorm16x2:k,snorm16x4:S,float16:v,float16x2:k,float16x4:S,float32:v,float32x2:k,float32x3:E,float32x4:S,uint32:V,uint32x2:K,uint32x3:ie,uint32x4:Y,sint32:z,sint32x2:j,sint32x3:se,sint32x4:G,"unorm10-10-10-2":S,"unorm8x4-bgra":S},br= exports.tb =new Set(Object.keys(Tt)),Vi= exports.ub =new c("uint8"),Si= exports.vb =new c("uint8x2"),_i= exports.wb =new c("uint8x4"),Ii= exports.xb =new c("sint8"),Ai= exports.yb =new c("sint8x2"),Mi= exports.zb =new c("sint8x4"),$i= exports.Ab =new c("unorm8"),Di= exports.Bb =new c("unorm8x2"),ki= exports.Cb =new c("unorm8x4"),Fi= exports.Db =new c("snorm8"),Ci= exports.Eb =new c("snorm8x2"),Pi= exports.Fb =new c("snorm8x4"),Ri= exports.Gb =new c("uint16"),Ni= exports.Hb =new c("uint16x2"),Bi= exports.Ib =new c("uint16x4"),Ui= exports.Jb =new c("sint16"),Ei= exports.Kb =new c("sint16x2"),Oi= exports.Lb =new c("sint16x4"),Wi= exports.Mb =new c("unorm16"),Li= exports.Nb =new c("unorm16x2"),ji= exports.Ob =new c("unorm16x4"),Ki= exports.Pb =new c("snorm16"),Gi= exports.Qb =new c("snorm16x2"),Yi= exports.Rb =new c("snorm16x4"),qi= exports.Sb =new c("float16"),Hi= exports.Tb =new c("float16x2"),Xi= exports.Ub =new c("float16x4"),Zi= exports.Vb =new c("float32"),Ji= exports.Wb =new c("float32x2"),Qi= exports.Xb =new c("float32x3"),ea= exports.Yb =new c("float32x4"),ta= exports.Zb =new c("uint32"),na= exports._b =new c("uint32x2"),ra= exports.$b =new c("uint32x3"),sa= exports.ac =new c("uint32x4"),ia= exports.bc =new c("sint32"),aa= exports.cc =new c("sint32x2"),oa= exports.dc =new c("sint32x3"),ca= exports.ec =new c("sint32x4"),ua= exports.fc =new c("unorm10-10-10-2"),ya= exports.gc =new c("unorm8x4-bgra");function la(e){return _optionalChain([e, 'optionalAccess', _79 => _79[i]])&&br.has(_optionalChain([e, 'optionalAccess', _80 => _80.type]))}function Sn(e,t){let n=_optionalChain([e, 'optionalAccess', _81 => _81.type]);try{let r=n in Tt?Tt[n]:e;return t===void 0?r():r(t)}catch (e4){throw new Error(`Schema of type ${_nullishCoalesce(n, () => ("<unknown>"))} is not callable or was called with invalid arguments.`)}}function fa(e){return _n(e,!1)}function va(e){return _n(e,!0)}function _n(e,t){let n=r=>Object.fromEntries(Object.entries(e).map(([s,a])=>[s,Sn(a,_optionalChain([r, 'optionalAccess', _82 => _82[s]]))]));return Object.setPrototypeOf(n,zr),n.propTypes=e,Object.defineProperty(n,i,{value:{isAbstruct:t}}),n}var zr={type:"struct",$name(e){return ht(this,e),this},toString(){return`struct:${_nullishCoalesce(te(this), () => ("<unnamed>"))}`}};var he=(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),xe=(e,t)=>t===0?e:Math.trunc(e/t);var R=Ce[i].jsImpl,O=k[i].jsImpl,Q=Fe[i].jsImpl,st=j[i].jsImpl,it=K[i].jsImpl,N=Re[i].jsImpl,U=E[i].jsImpl,q=Pe[i].jsImpl,at=se[i].jsImpl,ot=ie[i].jsImpl,B=Be[i].jsImpl,W=S[i].jsImpl,ee=Ne[i].jsImpl,ct=G[i].jsImpl,ut=Y[i].jsImpl,Ue=e=>Math.sqrt(e.x**2+e.y**2),Ee=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),Oe=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),bt=(e,t)=>e.x*t.x+e.y*t.y,zt=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,Vt=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,f=e=>t=>O(e(t.x),e(t.y)),g=e=>t=>Q(e(t.x),e(t.y)),We=e=>t=>st(e(t.x),e(t.y)),tt=e=>t=>it(e(t.x),e(t.y)),d=e=>t=>U(e(t.x),e(t.y),e(t.z)),T=e=>t=>q(e(t.x),e(t.y),e(t.z)),Le=e=>t=>at(e(t.x),e(t.y),e(t.z)),nt=e=>t=>ot(e(t.x),e(t.y),e(t.z)),h=e=>t=>W(e(t.x),e(t.y),e(t.z),e(t.w)),b=e=>t=>ee(e(t.x),e(t.y),e(t.z),e(t.w)),je=e=>t=>ct(e(t.x),e(t.y),e(t.z),e(t.w)),rt=e=>t=>ut(e(t.x),e(t.y),e(t.z),e(t.w)),In=e=>t=>{let n=t.columns;return ae(f(e)(n[0]),f(e)(n[1]))},An=e=>t=>{let n=t.columns;return oe(d(e)(n[0]),d(e)(n[1]),d(e)(n[2]))},Mn=e=>t=>{let n=t.columns;return _(h(e)(n[0]),h(e)(n[1]),h(e)(n[2]),h(e)(n[3]))},J=e=>(t,n)=>O(e(t.x,n.x),e(t.y,n.y)),pe=e=>(t,n)=>Q(e(t.x,n.x),e(t.y,n.y)),Ke=e=>(t,n)=>st(e(t.x,n.x),e(t.y,n.y)),Ge=e=>(t,n)=>it(e(t.x,n.x),e(t.y,n.y)),H=e=>(t,n)=>U(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),me=e=>(t,n)=>q(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),Ye=e=>(t,n)=>at(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),qe=e=>(t,n)=>ot(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),L=e=>(t,n)=>W(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),de=e=>(t,n)=>ee(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),He=e=>(t,n)=>ct(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Xe=e=>(t,n)=>ut(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Vr=e=>(t,n)=>{let r=t.columns,s=n.columns;return ae(J(e)(r[0],s[0]),J(e)(r[1],s[1]))},Sr=e=>(t,n)=>{let r=t.columns,s=n.columns;return oe(H(e)(r[0],s[0]),H(e)(r[1],s[1]),H(e)(r[2],s[2]))},_r=e=>(t,n)=>{let r=t.columns,s=n.columns;return _(L(e)(r[0],s[0]),L(e)(r[1],s[1]),L(e)(r[2],s[2]),L(e)(r[3],s[3]))},Ir=e=>(t,n,r)=>O(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),Ar=e=>(t,n,r)=>Q(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),Mr=e=>(t,n,r)=>U(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),$r=e=>(t,n,r)=>q(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),Dr=e=>(t,n,r)=>W(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)),kr=e=>(t,n,r)=>ee(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)),M= exports.mc ={eq:{vec2f:(e,t)=>R(e.x===t.x,e.y===t.y),vec2h:(e,t)=>R(e.x===t.x,e.y===t.y),vec2i:(e,t)=>R(e.x===t.x,e.y===t.y),vec2u:(e,t)=>R(e.x===t.x,e.y===t.y),"vec2<bool>":(e,t)=>R(e.x===t.x,e.y===t.y),vec3f:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec3h:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec3i:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec3u:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),"vec3<bool>":(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec4f:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4h:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4i:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4u:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),"vec4<bool>":(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w)},lt:{vec2f:(e,t)=>R(e.x<t.x,e.y<t.y),vec2h:(e,t)=>R(e.x<t.x,e.y<t.y),vec2i:(e,t)=>R(e.x<t.x,e.y<t.y),vec2u:(e,t)=>R(e.x<t.x,e.y<t.y),vec3f:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec3h:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec3i:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec3u:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec4f:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4h:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4i:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4u:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w)},or:{"vec2<bool>":(e,t)=>R(e.x||t.x,e.y||t.y),"vec3<bool>":(e,t)=>N(e.x||t.x,e.y||t.y,e.z||t.z),"vec4<bool>":(e,t)=>B(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:f(Math.abs),vec2h:g(Math.abs),vec2i:We(Math.abs),vec2u:tt(Math.abs),vec3f:d(Math.abs),vec3h:T(Math.abs),vec3i:Le(Math.abs),vec3u:nt(Math.abs),vec4f:h(Math.abs),vec4h:b(Math.abs),vec4i:je(Math.abs),vec4u:rt(Math.abs)},atan2:{vec2f:J(Math.atan2),vec2h:pe(Math.atan2),vec3f:H(Math.atan2),vec3h:me(Math.atan2),vec4f:L(Math.atan2),vec4h:de(Math.atan2)},acos:{vec2f:f(Math.acos),vec2h:g(Math.acos),vec2i:We(Math.acos),vec2u:tt(Math.acos),vec3f:d(Math.acos),vec3h:T(Math.acos),vec3i:Le(Math.acos),vec3u:nt(Math.acos),vec4f:h(Math.acos),vec4h:b(Math.acos),vec4i:je(Math.acos),vec4u:rt(Math.acos)},acosh:{vec2f:f(Math.acosh),vec2h:g(Math.acosh),vec3f:d(Math.acosh),vec3h:T(Math.acosh),vec4f:h(Math.acosh),vec4h:b(Math.acosh)},asin:{vec2f:f(Math.asin),vec2h:g(Math.asin),vec3f:d(Math.asin),vec3h:T(Math.asin),vec4f:h(Math.asin),vec4h:b(Math.asin)},asinh:{vec2f:f(Math.asinh),vec2h:g(Math.asinh),vec3f:d(Math.asinh),vec3h:T(Math.asinh),vec4f:h(Math.asinh),vec4h:b(Math.asinh)},atan:{vec2f:f(Math.atan),vec2h:g(Math.atan),vec3f:d(Math.atan),vec3h:T(Math.atan),vec4f:h(Math.atan),vec4h:b(Math.atan)},atanh:{vec2f:f(Math.atanh),vec2h:g(Math.atanh),vec3f:d(Math.atanh),vec3h:T(Math.atanh),vec4f:h(Math.atanh),vec4h:b(Math.atanh)},ceil:{vec2f:f(Math.ceil),vec2h:g(Math.ceil),vec3f:d(Math.ceil),vec3h:T(Math.ceil),vec4f:h(Math.ceil),vec4h:b(Math.ceil)},clamp:{vec2f:(e,t,n)=>O(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2h:(e,t,n)=>Q(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2i:(e,t,n)=>st(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2u:(e,t,n)=>it(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec3f:(e,t,n)=>U(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)=>q(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)=>at(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)=>ot(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)=>W(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)=>ee(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)=>ct(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)=>ut(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:Ue,vec2h:Ue,vec3f:Ee,vec3h:Ee,vec4f:Oe,vec4h:Oe},add:{vec2f:J((e,t)=>e+t),vec2h:pe((e,t)=>e+t),vec2i:Ke((e,t)=>e+t),vec2u:Ge((e,t)=>e+t),vec3f:H((e,t)=>e+t),vec3h:me((e,t)=>e+t),vec3i:Ye((e,t)=>e+t),vec3u:qe((e,t)=>e+t),vec4f:L((e,t)=>e+t),vec4h:de((e,t)=>e+t),vec4i:He((e,t)=>e+t),vec4u:Xe((e,t)=>e+t),mat2x2f:Vr((e,t)=>e+t),mat3x3f:Sr((e,t)=>e+t),mat4x4f:_r((e,t)=>e+t)},smoothstep:{vec2f:Ir(he),vec2h:Ar(he),vec3f:Mr(he),vec3h:$r(he),vec4f:Dr(he),vec4h:kr(he)},addMixed:{vec2f:(e,t)=>f(n=>n+t)(e),vec2h:(e,t)=>g(n=>n+t)(e),vec2i:(e,t)=>We(n=>n+t)(e),vec2u:(e,t)=>tt(n=>n+t)(e),vec3f:(e,t)=>d(n=>n+t)(e),vec3h:(e,t)=>T(n=>n+t)(e),vec3i:(e,t)=>Le(n=>n+t)(e),vec3u:(e,t)=>nt(n=>n+t)(e),vec4f:(e,t)=>h(n=>n+t)(e),vec4h:(e,t)=>b(n=>n+t)(e),vec4i:(e,t)=>je(n=>n+t)(e),vec4u:(e,t)=>rt(n=>n+t)(e),mat2x2f:(e,t)=>In(n=>n+t)(e),mat3x3f:(e,t)=>An(n=>n+t)(e),mat4x4f:(e,t)=>Mn(n=>n+t)(e)},mulSxV:{vec2f:(e,t)=>f(n=>e*n)(t),vec2h:(e,t)=>g(n=>e*n)(t),vec2i:(e,t)=>We(n=>e*n)(t),vec2u:(e,t)=>tt(n=>e*n)(t),vec3f:(e,t)=>d(n=>e*n)(t),vec3h:(e,t)=>T(n=>e*n)(t),vec3i:(e,t)=>Le(n=>e*n)(t),vec3u:(e,t)=>nt(n=>e*n)(t),vec4f:(e,t)=>h(n=>e*n)(t),vec4h:(e,t)=>b(n=>e*n)(t),vec4i:(e,t)=>je(n=>e*n)(t),vec4u:(e,t)=>rt(n=>e*n)(t),mat2x2f:(e,t)=>In(n=>e*n)(t),mat3x3f:(e,t)=>An(n=>e*n)(t),mat4x4f:(e,t)=>Mn(n=>e*n)(t)},mulVxV:{vec2f:J((e,t)=>e*t),vec2h:pe((e,t)=>e*t),vec2i:Ke((e,t)=>e*t),vec2u:Ge((e,t)=>e*t),vec3f:H((e,t)=>e*t),vec3h:me((e,t)=>e*t),vec3i:Ye((e,t)=>e*t),vec3u:qe((e,t)=>e*t),vec4f:L((e,t)=>e*t),vec4h:de((e,t)=>e*t),vec4i:He((e,t)=>e*t),vec4u:Xe((e,t)=>e*t),mat2x2f:(e,t)=>{let n=e.columns,r=t.columns;return ae(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 oe(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 _(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 O(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 U(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 W(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 O(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 U(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 W(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:J((e,t)=>e/t),vec2h:pe((e,t)=>e/t),vec2i:Ke(xe),vec2u:Ge(xe),vec3f:H((e,t)=>e/t),vec3h:me((e,t)=>e/t),vec3i:Ye(xe),vec3u:qe(xe),vec4f:L((e,t)=>e/t),vec4h:de((e,t)=>e/t),vec4i:He(xe),vec4u:Xe(xe)},dot:{vec2f:bt,vec2h:bt,vec2i:bt,vec2u:bt,vec3f:zt,vec3h:zt,vec3i:zt,vec3u:zt,vec4f:Vt,vec4h:Vt,vec4i:Vt,vec4u:Vt},normalize:{vec2f:e=>{let t=Ue(e);return O(e.x/t,e.y/t)},vec2h:e=>{let t=Ue(e);return Q(e.x/t,e.y/t)},vec2i:e=>{let t=Ue(e);return st(e.x/t,e.y/t)},vec2u:e=>{let t=Ue(e);return it(e.x/t,e.y/t)},vec3f:e=>{let t=Ee(e);return U(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=Ee(e);return q(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=Ee(e);return at(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=Ee(e);return ot(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=Oe(e);return W(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=Oe(e);return ee(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=Oe(e);return ct(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=Oe(e);return ut(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>U(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)=>q(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:J((e,t)=>e%t),vec2h:pe((e,t)=>e%t),vec2i:Ke((e,t)=>e%t),vec2u:Ge((e,t)=>e%t),vec3f:H((e,t)=>e%t),vec3h:me((e,t)=>e%t),vec3i:Ye((e,t)=>e%t),vec3u:qe((e,t)=>e%t),vec4f:L((e,t)=>e%t),vec4h:de((e,t)=>e%t),vec4i:He((e,t)=>e%t),vec4u:Xe((e,t)=>e%t)},floor:{vec2f:f(Math.floor),vec2h:g(Math.floor),vec3f:d(Math.floor),vec3h:T(Math.floor),vec4f:h(Math.floor),vec4h:b(Math.floor)},max:{vec2f:J(Math.max),vec2h:pe(Math.max),vec2i:Ke(Math.max),vec2u:Ge(Math.max),vec3f:H(Math.max),vec3h:me(Math.max),vec3i:Ye(Math.max),vec3u:qe(Math.max),vec4f:L(Math.max),vec4h:de(Math.max),vec4i:He(Math.max),vec4u:Xe(Math.max)},min:{vec2f:J(Math.min),vec2h:pe(Math.min),vec2i:Ke(Math.min),vec2u:Ge(Math.min),vec3f:H(Math.min),vec3h:me(Math.min),vec3i:Ye(Math.min),vec3u:qe(Math.min),vec4f:L(Math.min),vec4h:de(Math.min),vec4i:He(Math.min),vec4u:Xe(Math.min)},pow:{vec2f:(e,t)=>O(e.x**t.x,e.y**t.y),vec2h:(e,t)=>Q(e.x**t.x,e.y**t.y),vec3f:(e,t)=>U(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>q(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>W(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>ee(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},sign:{vec2f:f(Math.sign),vec2h:g(Math.sign),vec2i:We(Math.sign),vec3f:d(Math.sign),vec3h:T(Math.sign),vec3i:Le(Math.sign),vec4f:h(Math.sign),vec4h:b(Math.sign),vec4i:je(Math.sign)},sqrt:{vec2f:f(Math.sqrt),vec2h:g(Math.sqrt),vec3f:d(Math.sqrt),vec3h:T(Math.sqrt),vec4f:h(Math.sqrt),vec4h:b(Math.sqrt)},mix:{vec2f:(e,t,n)=>typeof n=="number"?O(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):O(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"?Q(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):Q(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"?U(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):U(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"?q(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):q(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"?W(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):W(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"?ee(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):ee(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:f(Math.sin),vec2h:g(Math.sin),vec3f:d(Math.sin),vec3h:T(Math.sin),vec4f:h(Math.sin),vec4h:b(Math.sin)},cos:{vec2f:f(Math.cos),vec2h:g(Math.cos),vec3f:d(Math.cos),vec3h:T(Math.cos),vec4f:h(Math.cos),vec4h:b(Math.cos)},cosh:{vec2f:f(Math.cosh),vec2h:g(Math.cosh),vec3f:d(Math.cosh),vec3h:T(Math.cosh),vec4f:h(Math.cosh),vec4h:b(Math.cosh)},exp:{vec2f:f(Math.exp),vec2h:g(Math.exp),vec3f:d(Math.exp),vec3h:T(Math.exp),vec4f:h(Math.exp),vec4h:b(Math.exp)},exp2:{vec2f:f(e=>2**e),vec2h:g(e=>2**e),vec3f:d(e=>2**e),vec3h:T(e=>2**e),vec4f:h(e=>2**e),vec4h:b(e=>2**e)},log:{vec2f:f(Math.log),vec2h:g(Math.log),vec3f:d(Math.log),vec3h:T(Math.log),vec4f:h(Math.log),vec4h:b(Math.log)},log2:{vec2f:f(Math.log2),vec2h:g(Math.log2),vec3f:d(Math.log2),vec3h:T(Math.log2),vec4f:h(Math.log2),vec4h:b(Math.log2)},fract:{vec2f:f(e=>e-Math.floor(e)),vec2h:g(e=>e-Math.floor(e)),vec3f:d(e=>e-Math.floor(e)),vec3h:T(e=>e-Math.floor(e)),vec4f:h(e=>e-Math.floor(e)),vec4h:b(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:f(e=>-e),vec2h:g(e=>-e),vec2i:We(e=>-e),vec2u:tt(e=>-e),"vec2<bool>":e=>R(!e.x,!e.y),vec3f:d(e=>-e),vec3h:T(e=>-e),vec3i:Le(e=>-e),vec3u:nt(e=>-e),"vec3<bool>":e=>N(!e.x,!e.y,!e.z),vec4f:h(e=>-e),vec4h:b(e=>-e),vec4i:je(e=>-e),vec4u:rt(e=>-e),"vec4<bool>":e=>B(!e.x,!e.y,!e.z,!e.w)},select:{vec2f:(e,t,n)=>O(n.x?t.x:e.x,n.y?t.y:e.y),vec2h:(e,t,n)=>Q(n.x?t.x:e.x,n.y?t.y:e.y),vec2i:(e,t,n)=>st(n.x?t.x:e.x,n.y?t.y:e.y),vec2u:(e,t,n)=>it(n.x?t.x:e.x,n.y?t.y:e.y),"vec2<bool>":(e,t,n)=>R(n.x?t.x:e.x,n.y?t.y:e.y),vec3f:(e,t,n)=>U(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3h:(e,t,n)=>q(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3i:(e,t,n)=>at(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec3u:(e,t,n)=>ot(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),"vec3<bool>":(e,t,n)=>N(n.x?t.x:e.x,n.y?t.y:e.y,n.z?t.z:e.z),vec4f:(e,t,n)=>W(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)=>ee(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)=>ct(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)=>ut(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)=>B(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:f(Math.tanh),vec2h:g(Math.tanh),vec3f:d(Math.tanh),vec3h:T(Math.tanh),vec4f:h(Math.tanh),vec4h:b(Math.tanh)}};function $n(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var Fr={f:{1:v,2:k,3:E,4:S},h:{1:D,2:Fe,3:Pe,4:Ne},i:{1:z,2:j,3:se,4:G},u:{1:V,2:K,3:ie,4:Y},b:{1:$,2:Ce,3:Re,4:Be}},Cr={vec2f:k,vec2h:Fe,vec2i:j,vec2u:K,"vec2<bool>":Ce,vec3f:E,vec3h:Pe,vec3i:se,vec3u:ie,"vec3<bool>":Re,vec4f:S,vec4h:Ne,vec4i:G,vec4u:Y,"vec4<bool>":Be,mat2x2f:ae,mat3x3f:oe,mat4x4f:_},Dn={vec2f:v,vec2h:D,vec2i:z,vec2u:V,"vec2<bool>":$,vec3f:v,vec3h:D,vec3i:z,vec3u:V,"vec3<bool>":$,vec4f:v,vec4h:D,vec4i:z,vec4u:V,"vec4<bool>":$,mat2x2f:k,mat3x3f:E,mat4x4f:S};function Wa(e,t){if(yn(e)||fn(e))return _nullishCoalesce(e.propTypes[t], () => (ne));if(e===$||dt(e))return ne;let n=t.length;if(ce(e)&&n>=1&&n<=4){let r=e.type.includes("bool")?"b":e.type[4],s=Fr[r][n];if(s)return s}return ne}function La(e){return un(e)||wn(e)?e.elementType:e.type in Dn?Dn[e.type]:ne}function ja(e){return/^0x[0-9a-f]+$/i.test(e)?Number.parseInt(e):/^0b[01]+$/i.test(e)?Number.parseInt(e.slice(2),2):Number.parseFloat(e)}function Pr(e){return Number.isInteger(e)&&e>=-2147483648&&e<=2147483647?o(e,bn):o(e,zn)}var Ot={rank:Number.POSITIVE_INFINITY,action:"none"};function kn(e){return ce(e)?Ft[e.type]:void 0}function St(e,t){let n=Z(e),r=Z(t);if(n.type===r.type)return{rank:0,action:"none"};if(n.type==="abstractFloat"){if(r.type==="f32")return{rank:1,action:"none"};if(r.type==="f16")return{rank:2,action:"none"}}if(n.type==="abstractInt"){if(r.type==="i32")return{rank:3,action:"none"};if(r.type==="u32")return{rank:4,action:"none"};if(r.type==="abstractFloat")return{rank:5,action:"none"};if(r.type==="f32")return{rank:6,action:"none"};if(r.type==="f16")return{rank:7,action:"none"}}if(ce(n)&&ce(r)){let s=kn(n),a=kn(r);if(s&&a)return St(s,a)}return $t(n)&&$t(r)?{rank:0,action:"none"}:Ot}function Rr(e,t){let n=Z(e),r=Z(t);if(n.type==="ptr"&&St(n.inner,r).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(r.type==="ptr"&&St(n,r.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let s={f32:0,f16:1,i32:2,u32:3,bool:4};if(n.type in s&&r.type in s){let a=n.type,l=r.type;if(a!==l){let x=s[a];return{rank:s[l]<x?10:20,action:"cast",targetType:r}}}return Ot}function Nr(e,t,n){let r=St(e,t);return r.rank<Number.POSITIVE_INFINITY?r:n?Rr(e,t):Ot}function Fn(e,t,n){let r,s=Number.POSITIVE_INFINITY,a=new Map;for(let I of t){let P=0,jt=[],Kt=!0;for(let Nn of e){let It=Nr(Nn,I,n);if(It.rank===Number.POSITIVE_INFINITY){Kt=!1;break}P+=It.rank,jt.push(It)}Kt&&P<s&&(s=P,r=I,a.set(r,jt))}if(!r)return;let x=a.get(r).map((I,P)=>({sourceIndex:P,action:I.action,...I.action==="cast"&&{targetType:I.targetType}})),p=x.some(I=>I.action==="cast");return{targetType:r,actions:x,hasImplicitConversions:p}}function Cn(e){return e.type==="abstractFloat"?v:e.type==="abstractInt"?z:e}function Br(e,t){if(e.length===0)return;let n=[...new Set(e.map(Z))],r=t?[...new Set(t.map(Z))]:n,s=Fn(e,r,!1);if(s)return s;let a=Fn(e,r,!0);if(a)return a.hasImplicitConversions=a.actions.some(l=>l.action==="cast"),a}function Ur(e,t,n,r){if(n.action==="none")return o(t.value,r);switch(n.action){case"ref":return o(m`&${t}`,r);case"deref":return o(m`*${t}`,r);case"cast":return o(m`${e.resolve(r)}(${t})`,r);default:$n(n.action,"applyActionToSnippet")}}function _t({ctx:e,values:t,restrictTo:n,concretizeTypes:r=!1,verbose:s=!0}){let a=r&&!t.some(p=>Cn(p.dataType)===p.dataType),l=t.map(p=>a?Cn(p.dataType):p.dataType);if(l.some(p=>p===ne))return;X&&s&&Array.isArray(n)&&n.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 x=Br(l,n);if(x)return X&&s&&x.hasImplicitConversions&&console.warn(`Implicit conversions from [
6
+ ${t.map(p=>` ${p.value}: ${p.dataType.type}`).join(`,
7
+ `)}
8
+ ] to ${x.targetType.type} are supported, but not recommended.
9
+ Consider using explicit conversions instead.`),t.map((p,I)=>{let P=x.actions[I];return pt(P,"Action should not be undefined"),Ur(e,p,P,x.targetType)})}function Ka(e,t,n){if(n===t.dataType)return t;if(t.dataType.type==="unknown")return o(e.resolve(t.value,n),n);let r=_t({ctx:e,values:[t],restrictTo:[n]});if(!r)throw new xt(`Cannot convert value of type '${t.dataType.type}' to type '${n.type}'`);return r[0]}function Ga(e,t,n){return Object.keys(t.propTypes).map(s=>{let a=n[s];if(!a)throw new Error(`Missing property ${s}`);let l=t.propTypes[s];return _nullishCoalesce(_optionalChain([_t, 'call', _83 => _83({ctx:e,values:[a],restrictTo:[l]}), 'optionalAccess', _84 => _84[0]]), () => (a))})}function Ya(e){return kt(e)?e:cn(e)?o(e,e[lt]):y(e)||A(e)?o(e,Cr[e.kind]):typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?o(e,ne):typeof e=="number"?Pr(e):typeof e=="boolean"?o(e,$):o(e,ne)}function yt(e,t,n=!1,r=!0){let s=vt();return _nullishCoalesce(_t({ctx:s,values:e,restrictTo:t,concretizeTypes:n,verbose:r}), () => (e))}function Wt(e,t){if(typeof e=="number"&&typeof t=="number")return e+t;if(typeof e=="number"&&y(t))return M.addMixed[t.kind](t,e);if(y(e)&&typeof t=="number")return M.addMixed[e.kind](e,t);if(y(e)&&y(t)||A(e)&&A(t))return M.add[e.kind](e,t);throw new Error("Add/Sub called with invalid arguments.")}var io=w(Wt,(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:n.dataType;return(typeof e.value=="number"||y(e.value)||A(e.value))&&(typeof t.value=="number"||y(t.value)||A(t.value))?o(Wt(e.value,t.value),s):o(m`(${n} + ${r})`,s)},"add");function Pn(e,t){return Wt(e,Lt(-1,t))}var ao=w(Pn,(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:n.dataType;return(typeof e.value=="number"||y(e.value)||A(e.value))&&(typeof t.value=="number"||y(t.value)||A(t.value))?o(Pn(e.value,t.value),s):o(m`(${n} - ${r})`,s)},"sub");function Lt(e,t){if(typeof e=="number"&&typeof t=="number")return e*t;if(typeof e=="number"&&(y(t)||A(t)))return M.mulSxV[t.kind](e,t);if((y(e)||A(e))&&typeof t=="number")return M.mulSxV[e.kind](t,e);if(y(e)&&y(t))return M.mulVxV[e.kind](e,t);if(Dt(e)&&A(t))return M.mulVxM[t.kind](e,t);if(A(e)&&Dt(t))return M.mulMxV[e.kind](e,t);if(A(e)&&A(t))return M.mulVxV[e.kind](e,t);throw new Error("Mul called with invalid arguments.")}var oo=w(Lt,(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:we(r)||n.dataType.type.startsWith("vec")?n.dataType:r.dataType.type.startsWith("vec")?r.dataType:n.dataType;return(typeof e.value=="number"||y(e.value)||A(e.value))&&(typeof t.value=="number"||y(t.value)||A(t.value))?o(Lt(e.value,t.value),s):o(m`(${n} * ${r})`,s)},"mul");function Rn(e,t){if(typeof e=="number"&&typeof t=="number")return e/t;if(typeof e=="number"&&y(t)){let n=Qe[t.kind][i].jsImpl;return M.div[t.kind](n(e),t)}if(y(e)&&typeof t=="number"){let n=Qe[e.kind][i].jsImpl;return M.div[e.kind](e,n(t))}if(y(e)&&y(t))return M.div[e.kind](e,t);throw new Error("Div called with invalid arguments.")}var co=w(Rn,(e,t)=>{let[n,r]=yt([e,t],[v,D],!0,!1);return(typeof e.value=="number"||y(e.value))&&(typeof t.value=="number"||y(t.value))?o(Rn(e.value,t.value),n.dataType):o(m`(${n} / ${r})`,n.dataType)},"div"),uo= exports.rc =w((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e%t;if(typeof e=="number"&&y(t)){let n=Qe[t.kind];return M.mod[t.kind](n(e),t)}if(y(e)&&typeof t=="number"){let n=Qe[e.kind];return M.mod[e.kind](e,n(t))}if(y(e)&&y(t))return M.mod[e.kind](e,t);throw new Error("Mod called with invalid arguments, expected types: number or vector.")},(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:n.dataType;return o(m`(${n} % ${r})`,s)},"mod"),yo= exports.sc =w(e=>typeof e=="number"?-e:M.neg[e.kind](e),e=>o(m`-(${e})`,e.dataType),"neg");function xo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"function",access:"read-write"}}function po(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"private",access:"read-write"}}function mo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"workgroup",access:"read-write"}}function wo(e,t="read"){return{[i]:!0,type:"ptr",inner:e,addressSpace:"storage",access:t}}function fo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"uniform",access:"read"}}function vo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"handle",access:"read"}}exports.a = i; exports.b = lt; exports.c = Wr; exports.d = At; exports.e = Gt; exports.f = es; exports.g = te; exports.h = ht; exports.i = En; exports.j = On; exports.k = pt; exports.l = Ht; exports.m = Xt; exports.n = Zt; exports.o = Jt; exports.p = Qt; exports.q = en; exports.r = tn; exports.s = nn; exports.t = rn; exports.u = xt; exports.v = sn; exports.w = an; exports.x = on; exports.y = cs; exports.z = ls; exports.A = y; exports.B = jn; exports.C = Kn; exports.D = Gn; exports.E = ce; exports.F = Yn; exports.G = qn; exports.H = $t; exports.I = mt; exports.J = un; exports.K = yn; exports.L = hs; exports.M = xs; exports.N = ln; exports.O = hn; exports.P = xn; exports.Q = ps; exports.R = ms; exports.S = pn; exports.T = ds; exports.U = wt; exports.V = vn; exports.W = gn; exports.X = Qn; exports.Y = $s; exports.Z = Ds; exports._ = ks; exports.$ = er; exports.aa = Rs; exports.ba = Ns; exports.ca = Bs; exports.da = vt; exports.ea = tr; exports.fa = Us; exports.ga = Tn; exports.ha = mn; exports.ia = ws; exports.ja = Jn; exports.ka = wn; exports.la = fn; exports.ma = Ts; exports.na = bs; exports.oa = zs; exports.pa = Vs; exports.qa = Ss; exports.ra = ne; exports.sa = dn; exports.ta = Z; exports.ua = kt; exports.va = we; exports.wa = o; exports.xa = m; exports.ya = w; exports.za = bn; exports.Aa = zn; exports.Ba = $; exports.Ca = V; exports.Da = ni; exports.Ea = z; exports.Fa = v; exports.Ga = D; exports.Ha = Je; exports.Ia = k; exports.Ja = Fe; exports.Ka = j; exports.La = K; exports.Ma = Ce; exports.Na = E; exports.Oa = Pe; exports.Pa = se; exports.Qa = ie; exports.Ra = Re; exports.Sa = S; exports.Ta = Ne; exports.Ua = G; exports.Va = Y; exports.Wa = Be; exports.Xa = et; exports.Ya = xr; exports.Za = pr; exports._a = mr; exports.$a = wr; exports.ab = fr; exports.bb = vr; exports.cb = gr; exports.db = Tr; exports.eb = ae; exports.fb = oe; exports.gb = _; exports.hb = vi; exports.ib = $n; exports.jb = Wa; exports.kb = La; exports.lb = ja; exports.mb = Pr; exports.nb = Cn; exports.ob = _t; exports.pb = Ka; exports.qb = Ga; exports.rb = Ya; exports.sb = Tt; exports.tb = br; exports.ub = Vi; exports.vb = Si; exports.wb = _i; exports.xb = Ii; exports.yb = Ai; exports.zb = Mi; exports.Ab = $i; exports.Bb = Di; exports.Cb = ki; exports.Db = Fi; exports.Eb = Ci; exports.Fb = Pi; exports.Gb = Ri; exports.Hb = Ni; exports.Ib = Bi; exports.Jb = Ui; exports.Kb = Ei; exports.Lb = Oi; exports.Mb = Wi; exports.Nb = Li; exports.Ob = ji; exports.Pb = Ki; exports.Qb = Gi; exports.Rb = Yi; exports.Sb = qi; exports.Tb = Hi; exports.Ub = Xi; exports.Vb = Zi; exports.Wb = Ji; exports.Xb = Qi; exports.Yb = ea; exports.Zb = ta; exports._b = na; exports.$b = ra; exports.ac = sa; exports.bc = ia; exports.cc = aa; exports.dc = oa; exports.ec = ca; exports.fc = ua; exports.gc = ya; exports.hc = la; exports.ic = Sn; exports.jc = fa; exports.kc = va; exports.lc = he; exports.mc = M; exports.nc = io; exports.oc = ao; exports.pc = oo; exports.qc = co; exports.rc = uo; exports.sc = yo; exports.tc = xo; exports.uc = po; exports.vc = mo; exports.wc = wo; exports.xc = fo; exports.yc = vo;
10
+ //# sourceMappingURL=chunk-2VTISQYP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/shared/symbols.ts","../src/shared/env.ts","../src/shared/meta.ts","../src/errors.ts","../src/tgsl/generationHelpers.ts","../src/std/operators.ts"],"names":["version","$internal","$wgslDataType","$gpuValueOf","$getNameForward","$providing","$repr","$gpuRepr","$reprPartial","$memIdent","$validStorageSchema","$validUniformSchema","$validVertexSchema","$invalidSchemaReason","DEV","TEST","exp","label","isNamable","getName","globalWithMeta","PERF","name","data","records","entries","isForwarded","value","definition","getMetaData","setName","setMetaData","metaData","map","prefix","invariant","condition","message","provided"],"mappings":"AAGE,q0BAAAA,CAAAA,CAAW,OAAA,CCEN,IAAMC,CAAAA,CAAY,MAAA,CAAO,CAAA,QAAA,EAAWD,CAAO,CAAA,UAAA,CAAY,CAAA,CAIjDE,EAAAA,aAAgB,MAAA,CAAO,CAAA,QAAA,EAAWF,CAAO,CAAA,cAAA,CAAgB,CAAA,CAIzDG,EAAAA,aAAc,MAAA,CAAO,CAAA,QAAA,EAAWH,CAAO,CAAA,YAAA,CAAc,CAAA,CACrDI,EAAAA,aAAkB,MAAA,CAAO,CAAA,QAAA,EAAWJ,CAAO,CAAA,gBAAA,CAAkB,CAAA,CAI7DK,EAAAA,aAAa,MAAA,CAAO,CAAA,QAAA,EAAWL,CAAO,CAAA,WAAA,CAAa,CAAA,CASnDM,EAAAA,CAAQ,MAAA,CAAO,CAAA,QAAA,EAAWN,CAAO,CAAA,MAAA,CAAQ,CAAA,CAKzCO,EAAAA,CAAW,MAAA,CAAO,CAAA,QAAA,EAAWP,CAAO,CAAA,SAAA,CAAW,CAAA,CAK/CQ,EAAAA,CAAe,MAAA,CAAO,CAAA,QAAA,EAAWR,CAAO,CAAA,aAAA,CAAe,CAAA,CAIvDS,EAAAA,CAAY,MAAA,CAAO,CAAA,QAAA,EAAWT,CAAO,CAAA,UAAA,CAAY,CAAA,CAKjDU,EAAAA,CAAsB,MAAA,CACjC,CAAA,QAAA,EAAWV,CAAO,CAAA,sBAAA,CACpB,CAAA,CAIaW,EAAAA,CAAsB,MAAA,CACjC,CAAA,QAAA,EAAWX,CAAO,CAAA,oBAAA,CACpB,CAAA,CAIaY,EAAAA,CAAqB,MAAA,CAChC,CAAA,QAAA,EAAWZ,CAAO,CAAA,mBAAA,CACpB,CAAA,CAIaa,EAAAA,CAAuB,MAAA,CAClC,CAAA,QAAA,EAAWb,CAAO,CAAA,qBAAA,CACpB,CAAA,CC3DO,IAAMc,CAAAA,CAAM,UAAA,CAAW,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,aAAA,CAE1CC,EAAAA,CAAO,UAAA,CAAW,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,MAAA,CCsBxD,MAAA,CAAO,MAAA,CAAO,UAAA,CAAY,CACxB,oBAAA,CAAwB,CAAIC,CAAAA,CAAQC,CAAAA,CAAAA,EAClCC,EAAAA,CAAUF,CAAG,CAAA,kBACVA,CAAAA,4BAAAA,CAA8Cf,CAAS,GAAA,EAAK,CAACkB,EAAAA,CAAQH,CAAG,CAAA,CACvEA,CAAAA,CAAI,KAAA,CAAMC,CAAK,CAAA,CACfD,CACR,CAAC,CAAA,CAED,IAAMI,EAAAA,CAAiB,UAAA,CAKVC,EAAAA,aAAAA,CAAQP,CAAAA,EAAOC,EAAAA,CAAAA,EAAU,CAChC,IAAI,OAAA,CAAA,CAAU,CACZ,MAAO,CAAC,CAACK,EAAAA,CAAe,wBAC1B,CAAA,CACA,MAAA,CAAOE,CAAAA,CAAcC,CAAAA,CAAe,CAElC,IAAMC,CAAAA,CAAWJ,EAAAA,CAAe,wBAAA,GAA6B,IAAI,GAAA,CAC7DK,CAAAA,CAAUD,CAAAA,CAAQ,GAAA,CAAIF,CAAI,CAAA,CACzBG,CAAAA,EAAAA,CACHA,CAAAA,CAAU,CAAC,CAAA,CACXD,CAAAA,CAAQ,GAAA,CAAIF,CAAAA,CAAMG,CAAO,CAAA,CAAA,CAE3BA,CAAAA,CAAQ,IAAA,CAAKF,CAAI,CACnB,CACF,CAAA,EAAM,KAAA,CAAA,CAEV,SAASG,EAAAA,CAAYC,CAAAA,CAAyD,CAC5E,MAAO,CAAC,iBAAEA,CAAAA,4BAAAA,CAA4CvB,EAAe,GACvE,CAEO,SAASe,EAAAA,CAAQS,CAAAA,CAAyC,CAC/D,OAAIF,EAAAA,CAAYE,CAAU,CAAA,CACjBT,EAAAA,CAAQS,CAAAA,CAAWxB,EAAe,CAAC,CAAA,iBAErCyB,EAAAA,mBAAYD,CAAU,CAAA,6BAAG,MAClC,CAEO,SAASE,EAAAA,CAAQF,CAAAA,CAAoBN,CAAAA,CAAoB,CAC9DS,EAAAA,CAAYH,CAAAA,CAAY,CAAE,IAAA,CAAAN,CAAK,CAAC,CAClC,CAYO,SAASJ,EAAAA,CAAUS,CAAAA,CAAsC,CAC9D,MAAO,CAAC,iBAAEA,CAAAA,6BAAuB,OACnC,CAEO,SAASE,EAAAA,CACdD,CAAAA,CACsB,CACtB,OAAOR,EAAAA,CAAe,gBAAA,CAAiB,GAAA,CAErCQ,CACF,CACF,CAEO,SAASG,EAAAA,CAAYH,CAAAA,CAAoBI,CAAAA,CAAkB,CAChEZ,EAAAA,CAAe,gBAAA,GAAqB,IAAI,OAAA,CACxC,IAAMa,CAAAA,CAAMb,EAAAA,CAAe,gBAAA,CAC3Ba,CAAAA,CAAI,GAAA,CAAIL,CAAAA,CAAY,CAAE,GAAGK,CAAAA,CAAI,GAAA,CAAIL,CAAU,CAAA,CAAG,GAAGI,CAAS,CAAC,CAC7D,CC7FA,IAAME,EAAAA,CAAS,kBAAA,CAKR,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACmB,CACnB,EAAA,CAAID,CAAAA,CAEF,MAAA,CAIF,EAAA,CAAI,CAACtB,CAAAA,CACH,MAAM,IAAI,KAAA,CAAMoB,EAAM,CAAA,CAMxB,IAAMI,CAAAA,CAAW,OAAOD,CAAAA,EAAY,UAAA,CAAaA,CAAAA,CAAQ,CAAA,CAAIA,CAAAA,CAKvDV,CAAAA,CAAQW,CAAAA,CAAW,CAAA,EAAA;AAwBqC;AAqC1D;AAAyD;AAmGrC;ACwWd;AAEN;AAAoC,KAAA;AC1dnC,4CAAA","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-2VTISQYP.cjs","sourcesContent":["{\n \"name\": \"typegpu\",\n \"private\": true,\n \"version\": \"0.7.1\",\n \"description\": \"A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": \"./src/index.ts\",\n \"./data\": \"./src/data/index.ts\",\n \"./std\": \"./src/std/index.ts\"\n },\n \"publishConfig\": {\n \"directory\": \"dist\",\n \"linkDirectory\": false,\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \"./package.json\": \"./dist/package.json\",\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"module\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"default\": \"./dist/index.cjs\"\n },\n \"./data\": {\n \"types\": \"./dist/data/index.d.ts\",\n \"module\": \"./dist/data/index.js\",\n \"import\": \"./dist/data/index.js\",\n \"default\": \"./dist/data/index.cjs\"\n },\n \"./std\": {\n \"types\": \"./dist/std/index.d.ts\",\n \"module\": \"./dist/std/index.js\",\n \"import\": \"./dist/std/index.js\",\n \"default\": \"./dist/std/index.cjs\"\n }\n }\n },\n \"sideEffects\": false,\n \"scripts\": {\n \"build\": \"tsup\",\n \"test:types\": \"pnpm tsc --p ./tsconfig.test.json --noEmit\",\n \"prepublishOnly\": \"tgpu-dev-cli prepack\"\n },\n \"engines\": {\n \"node\": \">=12.20.0\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/software-mansion/TypeGPU.git\"\n },\n \"keywords\": [\n \"webgpu\",\n \"wgpu\",\n \"wgsl\",\n \"typescript\",\n \"compute\",\n \"shader\",\n \"shaders\",\n \"gpgpu\"\n ],\n \"bugs\": {\n \"url\": \"https://github.com/software-mansion/TypeGPU/issues\"\n },\n \"homepage\": \"https://typegpu.com\",\n \"devDependencies\": {\n \"@ark/attest\": \"^0.46.0\",\n \"@typegpu/tgpu-dev-cli\": \"workspace:*\",\n \"@webgpu/types\": \"catalog:types\",\n \"arktype\": \"catalog:\",\n \"jiti\": \"catalog:build\",\n \"tsup\": \"catalog:build\",\n \"typescript\": \"catalog:types\",\n \"unplugin-typegpu\": \"workspace:*\",\n \"wesl\": \"0.6.7\",\n \"wgpu-matrix\": \"catalog:example\"\n },\n \"packageManager\": \"pnpm@10.4.1+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af\",\n \"dependencies\": {\n \"tinyest\": \"workspace:~0.1.1\",\n \"typed-binary\": \"^4.3.1\"\n }\n}\n","// The version is inlined during build-time 🎉\n// It helps us identify problems when two versions of\n// TypeGPU are used at the same time.\nimport { version } from '../../package.json';\n\nexport const $internal = Symbol(`typegpu:${version}:$internal`);\n/**\n * A value's data type as seen by the WGSL generator\n */\nexport const $wgslDataType = Symbol(`typegpu:${version}:$wgslDataType`);\n/**\n * The getter to the value of this resource, accessible on the GPU\n */\nexport const $gpuValueOf = Symbol(`typegpu:${version}:$gpuValueOf`);\nexport const $getNameForward = Symbol(`typegpu:${version}:$getNameForward`);\n/**\n * Marks an object with slot-value bindings\n */\nexport const $providing = Symbol(`typegpu:${version}:$providing`);\n\n//\n// Type tokens\n//\n\n/**\n * Type token for the inferred (CPU & GPU) representation of a resource\n */\nexport const $repr = Symbol(`typegpu:${version}:$repr`);\n/**\n * Type token for the inferred (GPU-side) representation of a resource\n * If present, it shadows the value of `$repr` for GPU-side inference.\n */\nexport const $gpuRepr = Symbol(`typegpu:${version}:$gpuRepr`);\n/**\n * Type token for the inferred partial representation of a resource.\n * If present, it shadows the value of `$repr` for use in partial IO.\n */\nexport const $reprPartial = Symbol(`typegpu:${version}:$reprPartial`);\n/**\n * Type token holding schemas that are identical in memory layout.\n */\nexport const $memIdent = Symbol(`typegpu:${version}:$memIdent`);\n\n/**\n * Type token, signaling that a schema can be used in a storage buffer.\n */\nexport const $validStorageSchema = Symbol(\n `typegpu:${version}:$invalidStorageSchema`,\n);\n/**\n * Type token, signaling that a schema can be used in a uniform buffer.\n */\nexport const $validUniformSchema = Symbol(\n `typegpu:${version}:$validUniformSchema`,\n);\n/**\n * Type token, signaling that a schema can be used in a vertex buffer.\n */\nexport const $validVertexSchema = Symbol(\n `typegpu:${version}:$validVertexSchema`,\n);\n/**\n * Type token, containing a reason for why the schema is invalid (if it is).\n */\nexport const $invalidSchemaReason = Symbol(\n `typegpu:${version}:$invalidSchemaReason`,\n);\n","/**\n * This can be used to branch functionality between \"dev\" and \"prod\" modes, so that our\n * library can omit doing unnecessary work once it's out in the wild\n *\n * Even though the value of this constant uses Node.js specific APIs, pretty much every\n * bundler replaces the expression below with either `development` or `production`\n */\nexport const DEV = globalThis.process.env.NODE_ENV === 'development';\n\nexport const TEST = globalThis.process.env.NODE_ENV === 'test';\n","import type { Block, FuncParameter } from 'tinyest';\nimport { $getNameForward, $internal } from './symbols.ts';\nimport { DEV, TEST } from './env.ts';\n\nexport interface MetaData {\n name?: string | undefined;\n ast?: {\n v: number;\n params: FuncParameter[];\n body: Block;\n externalNames: string[];\n } | undefined;\n externals?: Record<string, unknown> | undefined;\n}\n\n/**\n * Don't use or you WILL get fired from your job.\n *\n * The information that this type describes is additional\n * properties that we add onto `globalThis`, used by tools\n * like `unplugin-typegpu` or our test suite.\n *\n * @internal\n */\nexport type INTERNAL_GlobalExt = typeof globalThis & {\n __TYPEGPU_META__: WeakMap<object, MetaData>;\n __TYPEGPU_AUTONAME__: <T>(exp: T, label: string) => T;\n __TYPEGPU_MEASURE_PERF__?: boolean | undefined;\n __TYPEGPU_PERF_RECORDS__?: Map<string, unknown[]> | undefined;\n};\n\nObject.assign(globalThis, {\n '__TYPEGPU_AUTONAME__': <T>(exp: T, label: string): T =>\n isNamable(exp) &&\n (exp as unknown as { [$internal]: unknown })?.[$internal] && !getName(exp)\n ? exp.$name(label)\n : exp,\n});\n\nconst globalWithMeta = globalThis as INTERNAL_GlobalExt;\n\n/**\n * Performance measurements are only enabled in dev & test environments for now\n */\nexport const PERF = (DEV || TEST) && ({\n get enabled() {\n return !!globalWithMeta.__TYPEGPU_MEASURE_PERF__;\n },\n record(name: string, data: unknown) {\n // biome-ignore lint/suspicious/noAssignInExpressions: it's fine\n const records = (globalWithMeta.__TYPEGPU_PERF_RECORDS__ ??= new Map());\n let entries = records.get(name);\n if (!entries) {\n entries = [];\n records.set(name, entries);\n }\n entries.push(data);\n },\n }) || undefined;\n\nfunction isForwarded(value: unknown): value is { [$getNameForward]: unknown } {\n return !!(value as { [$getNameForward]?: unknown })?.[$getNameForward];\n}\n\nexport function getName(definition: unknown): string | undefined {\n if (isForwarded(definition)) {\n return getName(definition[$getNameForward]);\n }\n return getMetaData(definition)?.name;\n}\n\nexport function setName(definition: object, name: string): void {\n setMetaData(definition, { name });\n}\n\n/**\n * Can be assigned a name. Not to be confused with\n * being able to HAVE a name.\n * The `$name` function should use `setName` to rename the object itself,\n * or rename the object `$getNameForward` symbol points to instead if applicable.\n */\nexport interface TgpuNamable {\n $name(label: string): this;\n}\n\nexport function isNamable(value: unknown): value is TgpuNamable {\n return !!(value as TgpuNamable)?.$name;\n}\n\nexport function getMetaData(\n definition: unknown,\n): MetaData | undefined {\n return globalWithMeta.__TYPEGPU_META__.get(\n // it's fine, if it's not an object, the get will return undefined\n definition as object,\n );\n}\n\nexport function setMetaData(definition: object, metaData: object) {\n globalWithMeta.__TYPEGPU_META__ ??= new WeakMap();\n const map = globalWithMeta.__TYPEGPU_META__;\n map.set(definition, { ...map.get(definition), ...metaData });\n}\n","import type { TgpuBuffer } from './core/buffer/buffer.ts';\nimport type { TgpuSlot } from './core/slot/slotTypes.ts';\nimport type { TgpuVertexLayout } from './core/vertexLayout/vertexLayout.ts';\nimport type { AnyData, Disarray } from './data/dataTypes.ts';\nimport type { WgslArray } from './data/wgslTypes.ts';\nimport { getName } from './shared/meta.ts';\nimport { DEV } from './shared/env.ts';\nimport type { TgpuBindGroupLayout } from './tgpuBindGroupLayout.ts';\n\nconst prefix = 'Invariant failed';\n\n/**\n * Inspired by: https://github.com/alexreardon/tiny-invariant/blob/master/src/tiny-invariant.ts\n */\nexport function invariant(\n condition: unknown,\n message?: string | (() => string),\n): asserts condition {\n if (condition) {\n // Condition passed\n return;\n }\n\n // In production we strip the message but still throw\n if (!DEV) {\n throw new Error(prefix);\n }\n\n // When not in production we allow the message to pass through\n // *This block will be removed in production builds*\n\n const provided = typeof message === 'function' ? message() : message;\n\n // Options:\n // 1. message provided: `${prefix}: ${provided}`\n // 2. message not provided: prefix\n const value = provided ? `${prefix}: ${provided}` : prefix;\n throw new Error(value);\n}\n\n/**\n * An error that happens during resolution of WGSL code.\n * Contains a trace of all ancestor resolvables in\n * which this error originated.\n *\n * @category Errors\n */\nexport class ResolutionError extends Error {\n constructor(\n public readonly cause: unknown,\n public readonly trace: unknown[],\n ) {\n let entries = trace.map((ancestor) => `- ${ancestor}`);\n\n // Showing only the root and leaf nodes.\n if (entries.length > 20) {\n entries = [...entries.slice(0, 11), '...', ...entries.slice(-10)];\n }\n\n super(\n `Resolution of the following tree failed:\\n${entries.join('\\n')}: ${\n cause && typeof cause === 'object' && 'message' in cause\n ? cause.message\n : cause\n }`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, ResolutionError.prototype);\n }\n\n appendToTrace(ancestor: unknown): ResolutionError {\n const newTrace = [ancestor, ...this.trace];\n\n return new ResolutionError(this.cause, newTrace);\n }\n}\n\n/**\n * An error that happens during execution of TypeGPU functions.\n * Contains a trace of all TypeGPU functions called along the way.\n *\n * @category Errors\n */\nexport class ExecutionError extends Error {\n constructor(\n public readonly cause: unknown,\n public readonly trace: unknown[],\n ) {\n let entries = trace.map((ancestor) => `- ${ancestor}`);\n\n // Showing only the root and leaf nodes.\n if (entries.length > 20) {\n entries = [...entries.slice(0, 11), '...', ...entries.slice(-10)];\n }\n\n super(\n `Execution of the following tree failed:\\n${entries.join('\\n')}: ${\n cause && typeof cause === 'object' && 'message' in cause\n ? cause.message\n : cause\n }`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, ExecutionError.prototype);\n }\n\n appendToTrace(ancestor: unknown): ExecutionError {\n const newTrace = [ancestor, ...this.trace];\n\n return new ExecutionError(this.cause, newTrace);\n }\n}\n\n/**\n * @category Errors\n */\nexport class MissingSlotValueError extends Error {\n constructor(public readonly slot: TgpuSlot<unknown>) {\n super(`Missing value for '${slot}'`);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingSlotValueError.prototype);\n }\n}\n\n/**\n * @category Errors\n */\nexport class NotUniformError extends Error {\n constructor(value: TgpuBuffer<AnyData>) {\n super(\n `Buffer '${\n getName(value) ?? '<unnamed>'\n }' is not bindable as a uniform. Use .$usage('uniform') to allow it.`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, NotUniformError.prototype);\n }\n}\n\nexport class MissingLinksError extends Error {\n constructor(fnLabel: string | undefined, externalNames: string[]) {\n super(\n `The function '${\n fnLabel ?? '<unnamed>'\n }' is missing links to the following external values: ${externalNames}.`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingLinksError.prototype);\n }\n}\n\nexport class MissingBindGroupsError extends Error {\n constructor(layouts: Iterable<TgpuBindGroupLayout>) {\n super(\n `Missing bind groups for layouts: '${\n [...layouts].map((layout) => getName(layout) ?? '<unnamed>').join(', ')\n }'. Please provide it using pipeline.with(layout, bindGroup).(...)`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingBindGroupsError.prototype);\n }\n}\n\nexport class MissingVertexBuffersError extends Error {\n constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>) {\n super(\n `Missing vertex buffers for layouts: '${\n [...layouts].map((layout) => getName(layout) ?? '<unnamed>').join(', ')\n }'. Please provide it using pipeline.with(layout, buffer).(...)`,\n );\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, MissingVertexBuffersError.prototype);\n }\n}\n\nexport class IllegalVarAccessError extends Error {\n constructor(msg: string) {\n super(msg);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, IllegalVarAccessError.prototype);\n }\n}\n\nexport class IllegalBufferAccessError extends Error {\n constructor(msg: string) {\n super(msg);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, IllegalBufferAccessError.prototype);\n }\n}\n\nexport class WgslTypeError extends Error {\n constructor(msg: string) {\n super(msg);\n\n // Set the prototype explicitly.\n Object.setPrototypeOf(this, WgslTypeError.prototype);\n }\n}\n","import {\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 { DEV } from '../shared/env.ts';\nimport { $wgslDataType } from '../shared/symbols.ts';\nimport { assertExhaustive } from '../shared/utilityTypes.ts';\nimport type { ResolutionCtx } from '../types.ts';\nimport { undecorate } from '../data/decorateUtils.ts';\nimport { isNumericSchema } from '../data/wgslTypes.ts';\nimport { MAX_INT32, MIN_INT32 } from '../shared/constants.ts';\nimport { stitch } from '../core/resolve/stitch.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 parseNumericString(str: string): number {\n // Hex literals\n if (/^0x[0-9a-f]+$/i.test(str)) {\n return Number.parseInt(str);\n }\n\n // Binary literals\n if (/^0b[01]+$/i.test(str)) {\n return Number.parseInt(str.slice(2), 2);\n }\n\n return Number.parseFloat(str);\n}\n\nexport function numericLiteralToSnippet(value: number): Snippet {\n if (Number.isInteger(value) && value >= MIN_INT32 && value <= MAX_INT32) {\n return snip(value, abstractInt);\n }\n return snip(value, abstractFloat);\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 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: ResolutionCtx,\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 switch (action.action) {\n case 'ref':\n return snip(stitch`&${value}`, targetType);\n case 'deref':\n return snip(stitch`*${value}`, targetType);\n case 'cast': {\n return snip(stitch`${ctx.resolve(targetType)}(${value})`, targetType);\n }\n default: {\n assertExhaustive(action.action, 'applyActionToSnippet');\n }\n }\n}\n\nexport type ConvertToCommonTypeOptions<T extends Snippet[]> = {\n ctx: ResolutionCtx;\n values: T;\n restrictTo?: AnyData[] | undefined;\n concretizeTypes?: boolean | undefined;\n verbose?: boolean | undefined;\n};\n\nexport function convertToCommonType<T extends Snippet[]>({\n ctx,\n values,\n restrictTo,\n concretizeTypes = false,\n verbose = true,\n}: ConvertToCommonTypeOptions<T>): T | undefined {\n const needsConcretization = concretizeTypes &&\n // If we have any concrete type among the values, we don't need to concretize\n !values.some((value) =>\n concretize(value.dataType as AnyWgslData) === value.dataType\n );\n\n const types = values.map((value) =>\n needsConcretization\n ? concretize(value.dataType as AnyWgslData)\n : 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 }) as T;\n}\n\nexport function tryConvertSnippet(\n ctx: ResolutionCtx,\n snippet: Snippet,\n targetDataType: AnyData,\n): Snippet {\n if (targetDataType === snippet.dataType) {\n return snippet;\n }\n\n if (snippet.dataType.type === 'unknown') {\n // This is it, it's now or never. We expect a specific type, and we're going to get it\n return snip(ctx.resolve(snippet.value, targetDataType), targetDataType);\n }\n\n const converted = convertToCommonType({\n ctx,\n values: [snippet],\n restrictTo: [targetDataType],\n });\n\n if (!converted) {\n throw new WgslTypeError(\n `Cannot convert value of type '${snippet.dataType.type}' to type '${targetDataType.type}'`,\n );\n }\n\n return converted[0] as Snippet;\n}\n\nexport function convertStructValues(\n ctx: ResolutionCtx,\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 (\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') {\n return numericLiteralToSnippet(value);\n }\n\n if (typeof value === 'boolean') {\n return snip(value, bool);\n }\n\n return snip(value, UnknownData);\n}\n","import { stitch } from '../core/resolve/stitch.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\nimport { isSnippetNumeric, snip, type Snippet } from '../data/snippet.ts';\nimport { vecTypeToConstructor } from '../data/vector.ts';\nimport { VectorOps } from '../data/vectorOps.ts';\nimport {\n type AnyMatInstance,\n type AnyNumericVecInstance,\n type AnyWgslData,\n isFloat32VecInstance,\n isMatInstance,\n isVecInstance,\n type mBaseForVec,\n type vBaseForMat,\n} from '../data/wgslTypes.ts';\nimport { convertToCommonType } from '../tgsl/generationHelpers.ts';\nimport { getResolutionCtx } from '../execMode.ts';\nimport type { ResolutionCtx } from '../types.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { f16, f32 } from '../data/numeric.ts';\n\nfunction tryUnify<T extends Snippet[]>(\n values: T,\n restrictTo?: AnyWgslData[],\n concretizeTypes = false,\n verbose = true,\n): T {\n const ctx = getResolutionCtx() as ResolutionCtx;\n const converted = convertToCommonType({\n ctx,\n values,\n restrictTo,\n concretizeTypes,\n verbose,\n });\n return converted ?? values;\n}\n\ntype NumVec = AnyNumericVecInstance;\ntype Mat = AnyMatInstance;\n\nfunction cpuAdd(lhs: number, rhs: number): number; // default addition\nfunction cpuAdd<T extends NumVec>(lhs: number, rhs: T): T; // mixed addition\nfunction cpuAdd<T extends NumVec>(lhs: T, rhs: number): T; // mixed addition\nfunction cpuAdd<T extends NumVec | Mat>(lhs: T, rhs: T): T; // component-wise addition\nfunction cpuAdd<\n // union overload\n Lhs extends number | NumVec | Mat,\n Rhs extends Lhs extends number ? number | NumVec\n : Lhs extends NumVec ? number | Lhs\n : Lhs extends Mat ? Lhs\n : never,\n>(lhs: Lhs, rhs: Rhs): Lhs | Rhs;\nfunction cpuAdd(lhs: number | NumVec | Mat, rhs: number | NumVec | Mat) {\n if (typeof lhs === 'number' && typeof rhs === 'number') {\n return lhs + rhs; // default addition\n }\n if (typeof lhs === 'number' && isVecInstance(rhs)) {\n return VectorOps.addMixed[rhs.kind](rhs, lhs); // mixed addition\n }\n if (isVecInstance(lhs) && typeof rhs === 'number') {\n return VectorOps.addMixed[lhs.kind](lhs, rhs); // mixed addition\n }\n if (\n (isVecInstance(lhs) && isVecInstance(rhs)) ||\n (isMatInstance(lhs) && isMatInstance(rhs))\n ) {\n return VectorOps.add[lhs.kind](lhs, rhs); // component-wise addition\n }\n\n throw new Error('Add/Sub called with invalid arguments.');\n}\n\nexport const add = createDualImpl(\n // CPU implementation\n cpuAdd,\n // CODEGEN implementation\n (lhs, rhs) => {\n const [convLhs, convRhs] = tryUnify([lhs, rhs]);\n const resultType = isSnippetNumeric(convLhs)\n ? convRhs.dataType\n : convLhs.dataType;\n\n if (\n (typeof lhs.value === 'number' ||\n isVecInstance(lhs.value) ||\n isMatInstance(lhs.value)) &&\n (typeof rhs.value === 'number' ||\n isVecInstance(rhs.value) ||\n isMatInstance(rhs.value))\n ) {\n // Precomputing...\n return snip(cpuAdd(lhs.value as never, rhs.value as never), resultType);\n }\n\n return snip(stitch`(${convLhs} + ${convRhs})`, resultType);\n },\n 'add',\n);\n\nfunction cpuSub(lhs: number, rhs: number): number; // default subtraction\nfunction cpuSub<T extends NumVec>(lhs: number, rhs: T): T; // mixed subtraction\nfunction cpuSub<T extends NumVec>(lhs: T, rhs: number): T; // mixed subtraction\nfunction cpuSub<T extends NumVec | Mat>(lhs: T, rhs: T): T; // component-wise subtraction\nfunction cpuSub<\n // union overload\n Lhs extends number | NumVec | Mat,\n Rhs extends Lhs extends number ? number | NumVec\n : Lhs extends NumVec ? number | Lhs\n : Lhs extends Mat ? Lhs\n : never,\n>(lhs: Lhs, rhs: Rhs): Lhs | Rhs;\nfunction cpuSub(lhs: number | NumVec | Mat, rhs: number | NumVec | Mat) {\n // while illegal on the wgsl side, we can do this in js\n return cpuAdd(lhs, cpuMul(-1, rhs));\n}\n\nexport const sub = createDualImpl(\n // CPU implementation\n cpuSub,\n // CODEGEN implementation\n (lhs, rhs) => {\n const [convLhs, convRhs] = tryUnify([lhs, rhs]);\n const resultType = isSnippetNumeric(convLhs)\n ? convRhs.dataType\n : convLhs.dataType;\n\n if (\n (typeof lhs.value === 'number' ||\n isVecInstance(lhs.value) ||\n isMatInstance(lhs.value)) &&\n (typeof rhs.value === 'number' ||\n isVecInstance(rhs.value) ||\n isMatInstance(rhs.value))\n ) {\n // Precomputing...\n return snip(cpuSub(lhs.value as never, rhs.value as never), resultType);\n }\n\n return snip(stitch`(${convLhs} - ${convRhs})`, resultType);\n },\n 'sub',\n);\n\nfunction cpuMul(lhs: number, rhs: number): number; // default multiplication\nfunction cpuMul<MV extends NumVec | Mat>(lhs: number, rhs: MV): MV; // scale\nfunction cpuMul<MV extends NumVec | Mat>(lhs: MV, rhs: number): MV; // scale\nfunction cpuMul<V extends NumVec>(lhs: V, rhs: V): V; // component-wise multiplication\nfunction cpuMul<M extends Mat, V extends vBaseForMat<M>>(lhs: V, rhs: M): V; // row-vector-matrix\nfunction cpuMul<M extends Mat, V extends vBaseForMat<M>>(lhs: M, rhs: V): V; // matrix-column-vector\nfunction cpuMul<M extends Mat>(lhs: M, rhs: M): M; // matrix multiplication\nfunction cpuMul<\n // union overload\n Lhs extends number | NumVec | Mat,\n Rhs extends Lhs extends number ? number | NumVec | Mat\n : Lhs extends NumVec ? number | Lhs | mBaseForVec<Lhs>\n : Lhs extends Mat ? number | vBaseForMat<Lhs> | Lhs\n : never,\n>(lhs: Lhs, rhs: Rhs): Lhs | Rhs;\nfunction cpuMul(lhs: number | NumVec | Mat, rhs: number | NumVec | Mat) {\n if (typeof lhs === 'number' && typeof rhs === 'number') {\n return lhs * rhs; // default multiplication\n }\n if (typeof lhs === 'number' && (isVecInstance(rhs) || isMatInstance(rhs))) {\n return VectorOps.mulSxV[rhs.kind](lhs, rhs); // scale\n }\n if ((isVecInstance(lhs) || isMatInstance(lhs)) && typeof rhs === 'number') {\n return VectorOps.mulSxV[lhs.kind](rhs, lhs); // scale\n }\n if (isVecInstance(lhs) && isVecInstance(rhs)) {\n return VectorOps.mulVxV[lhs.kind](lhs, rhs); // component-wise\n }\n if (isFloat32VecInstance(lhs) && isMatInstance(rhs)) {\n return VectorOps.mulVxM[rhs.kind](lhs, rhs); // row-vector-matrix\n }\n if (isMatInstance(lhs) && isFloat32VecInstance(rhs)) {\n return VectorOps.mulMxV[lhs.kind](lhs, rhs); // matrix-column-vector\n }\n if (isMatInstance(lhs) && isMatInstance(rhs)) {\n return VectorOps.mulVxV[lhs.kind](lhs, rhs); // matrix multiplication\n }\n\n throw new Error('Mul called with invalid arguments.');\n}\n\nexport const mul = createDualImpl(\n // CPU implementation\n cpuMul,\n // GPU implementation\n (lhs, rhs) => {\n const [convLhs, convRhs] = tryUnify([lhs, rhs]);\n const returnType = isSnippetNumeric(convLhs)\n // Scalar * Scalar/Vector/Matrix\n ? convRhs.dataType\n : isSnippetNumeric(convRhs)\n // Vector/Matrix * Scalar\n ? convLhs.dataType\n : convLhs.dataType.type.startsWith('vec')\n // Vector * Vector/Matrix\n ? convLhs.dataType\n : convRhs.dataType.type.startsWith('vec')\n // Matrix * Vector\n ? convRhs.dataType\n // Matrix * Matrix\n : convLhs.dataType;\n\n if (\n (typeof lhs.value === 'number' ||\n isVecInstance(lhs.value) ||\n isMatInstance(lhs.value)) &&\n (typeof rhs.value === 'number' ||\n isVecInstance(rhs.value) ||\n isMatInstance(rhs.value))\n ) {\n // Precomputing...\n return snip(cpuMul(lhs.value as never, rhs.value as never), returnType);\n }\n\n return snip(stitch`(${convLhs} * ${convRhs})`, returnType);\n },\n 'mul',\n);\n\nfunction cpuDiv(lhs: number, rhs: number): number; // default js division\nfunction cpuDiv<T extends NumVec | number>(lhs: T, rhs: T): T; // component-wise division\nfunction cpuDiv<T extends NumVec | number>(lhs: number, rhs: T): T; // mixed division\nfunction cpuDiv<T extends NumVec | number>(lhs: T, rhs: number): T; // mixed division\nfunction cpuDiv(lhs: NumVec | number, rhs: NumVec | number): NumVec | number {\n if (typeof lhs === 'number' && typeof rhs === 'number') {\n return lhs / rhs;\n }\n if (typeof lhs === 'number' && isVecInstance(rhs)) {\n const schema = vecTypeToConstructor[rhs.kind][$internal].jsImpl;\n return VectorOps.div[rhs.kind](schema(lhs), rhs);\n }\n if (isVecInstance(lhs) && typeof rhs === 'number') {\n const schema = vecTypeToConstructor[lhs.kind][$internal].jsImpl;\n return VectorOps.div[lhs.kind](lhs, schema(rhs));\n }\n if (isVecInstance(lhs) && isVecInstance(rhs)) {\n return VectorOps.div[lhs.kind](lhs, rhs);\n }\n throw new Error('Div called with invalid arguments.');\n}\n\nexport const div = createDualImpl(\n // CPU implementation\n cpuDiv,\n // CODEGEN implementation\n (lhs, rhs) => {\n const [convLhs, convRhs] = tryUnify([lhs, rhs], [f32, f16], true, false);\n\n if (\n (typeof lhs.value === 'number' || isVecInstance(lhs.value)) &&\n (typeof rhs.value === 'number' || isVecInstance(rhs.value))\n ) {\n // Precomputing\n return snip(\n cpuDiv(lhs.value as never, rhs.value as never),\n convLhs.dataType,\n );\n }\n\n return snip(stitch`(${convLhs} / ${convRhs})`, convLhs.dataType);\n },\n 'div',\n);\n\ntype ModOverload = {\n (a: number, b: number): number;\n <T extends NumVec>(a: T, b: T): T;\n <T extends NumVec>(a: number, b: T): T;\n <T extends NumVec>(a: T, b: number): T;\n};\n\n/**\n * @privateRemarks\n * Both JS and WGSL implementations use truncated definition of modulo\n */\nexport const mod: ModOverload = createDualImpl(\n // CPU implementation\n <T extends NumVec | number>(a: T, b: T): T => {\n if (typeof a === 'number' && typeof b === 'number') {\n return (a % b) as T; // scalar % scalar\n }\n if (typeof a === 'number' && isVecInstance(b)) {\n // scalar % vector\n const schema = vecTypeToConstructor[b.kind];\n return VectorOps.mod[b.kind](schema(a), b) as T;\n }\n if (isVecInstance(a) && typeof b === 'number') {\n const schema = vecTypeToConstructor[a.kind];\n // vector % scalar\n return VectorOps.mod[a.kind](a, schema(b)) as T;\n }\n\n if (isVecInstance(a) && isVecInstance(b)) {\n // vector % vector\n return VectorOps.mod[a.kind](a, b) as T;\n }\n throw new Error(\n 'Mod called with invalid arguments, expected types: number or vector.',\n );\n },\n // GPU implementation\n (a, b) => {\n const [convA, convB] = tryUnify([a, b]);\n const type = isSnippetNumeric(convA) ? convB.dataType : convA.dataType;\n return snip(stitch`(${convA} % ${convB})`, type);\n },\n 'mod',\n);\n\nexport const neg = createDualImpl(\n // CPU implementation\n <T extends NumVec | number>(value: T): T => {\n if (typeof value === 'number') {\n return -value as T;\n }\n return VectorOps.neg[value.kind](value) as T;\n },\n // GPU implementation\n (value) => snip(stitch`-(${value})`, value.dataType),\n 'neg',\n);\n"]}
@@ -0,0 +1,6 @@
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 _chunk2VTISQYPcjs = require('./chunk-2VTISQYP.cjs');var _tinyest = require('tinyest'); var Je = _interopRequireWildcard(_tinyest);var V=(e,t)=>{let o=t-1,n=~o;return(e&o)===0?e:(e&n)+t};var Pe={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 Ne(e){let t=_optionalChain([e, 'optionalAccess', _2 => _2.type]),o=Pe[t];if(o!==void 0)return o;if(_chunk2VTISQYPcjs.K.call(void 0, e))return Object.values(e.propTypes).map(b).reduce((n,i)=>n>i?n:i);if(_chunk2VTISQYPcjs.J.call(void 0, e))return b(e.elementType);if(_chunk2VTISQYPcjs.la.call(void 0, e)){let n=Object.values(e.propTypes)[0];return n?_nullishCoalesce(_chunk2VTISQYPcjs.na.call(void 0, n), () => (1)):1}if(_chunk2VTISQYPcjs.ka.call(void 0, e))return _nullishCoalesce(_chunk2VTISQYPcjs.na.call(void 0, e.elementType), () => (1));if(_chunk2VTISQYPcjs.S.call(void 0, e)||_chunk2VTISQYPcjs.ma.call(void 0, e))return _nullishCoalesce(_chunk2VTISQYPcjs.na.call(void 0, e), () => (b(e.inner)));if(_chunk2VTISQYPcjs.tb.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${JSON.stringify(e)}`)}function Fe(e){if(_chunk2VTISQYPcjs.la.call(void 0, e)){let t=Object.values(e.propTypes)[0];return t?C(t):1}return _chunk2VTISQYPcjs.ka.call(void 0, e)?C(e.elementType):_chunk2VTISQYPcjs.ma.call(void 0, e)?_nullishCoalesce(_chunk2VTISQYPcjs.na.call(void 0, e), () => (C(e.inner))):_nullishCoalesce(_chunk2VTISQYPcjs.na.call(void 0, e), () => (1))}var Oe=new WeakMap,_e=new WeakMap;function b(e){let t=Oe.get(e);return t===void 0&&(t=Ne(e),Oe.set(e,t)),t}function C(e){let t=_e.get(e);return t===void 0&&(t=Fe(e),_e.set(e,t)),t}function je(e){return b(e)}var Me={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 Re(e){let t=0,o=e.propTypes;for(let n of Object.values(o)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=V(t,b(n)),t+=h(n),Number.isNaN(t)&&n.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return V(t,b(e))}function Ge(e){let t=0,o=e.propTypes;for(let n of Object.values(o)){let i=C(n);t=V(t,i),t+=h(n)}return t}function He(e){let t=Me[_optionalChain([e, 'optionalAccess', _3 => _3.type])];if(t!==void 0)return t;if(_chunk2VTISQYPcjs.K.call(void 0, e))return Re(e);if(_chunk2VTISQYPcjs.la.call(void 0, e))return Ge(e);if(_chunk2VTISQYPcjs.J.call(void 0, e)){if(e.elementCount===0)return Number.NaN;let o=b(e.elementType);return V(h(e.elementType),o)*e.elementCount}if(_chunk2VTISQYPcjs.ka.call(void 0, e)){let o=C(e.elementType);return V(h(e.elementType),o)*e.elementCount}if(_chunk2VTISQYPcjs.S.call(void 0, e)||_chunk2VTISQYPcjs.ma.call(void 0, e))return _nullishCoalesce(_chunk2VTISQYPcjs.oa.call(void 0, e), () => (h(e.inner)));throw new Error(`Cannot determine size of data: ${e}`)}var We=new WeakMap;function h(e){let t=We.get(e);return t===void 0&&(t=He(e),We.set(e,t)),t}function Ke(e){return h(e)}function U(e,t){if(t===void 0)return n=>U(e,n);let o=n=>{if(n&&n.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);return Array.from({length:t},(i,r)=>_chunk2VTISQYPcjs.ic.call(void 0, e,_optionalChain([n, 'optionalAccess', _4 => _4[r]])))};if(Object.setPrototypeOf(o,qe),Number.isNaN(h(e)))throw new Error("Cannot nest runtime sized arrays.");if(o.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return o.elementCount=t,o}var qe={[_chunk2VTISQYPcjs.a]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};var{NodeTypeCatalog:u}=Je,Qe=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],Xe=["&&","||","==","!=","<","<=",">",">="],Ye=["vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"],Q={add:_chunk2VTISQYPcjs.nc,sub:_chunk2VTISQYPcjs.oc,mul:_chunk2VTISQYPcjs.pc,div:_chunk2VTISQYPcjs.qc};function Ve(e,t,o){return o?Xe.includes(t)?_chunk2VTISQYPcjs.Ba:t==="="?o:e:t==="!"||t==="~"?_chunk2VTISQYPcjs.Ba:e}function Ze(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function z(e,[t,o]){e.pushBlockScope();try{e.indent();let n=o.map(i=>ve(e,i)).join(`
2
+ `);return e.dedent(),`{
3
+ ${n}
4
+ ${e.pre}}`}finally{e.popBlockScope()}}function et(e,t,o){return e.defineVariable(t,o)}function Te(e,t){let o=e.getById(t);if(!o)throw new Error(`Identifier ${t} not found`);return o}function B(e,t,o){let n=e.expectedType;e.expectedType=o;try{let i=y(e,t);return _chunk2VTISQYPcjs.pb.call(void 0, e,i,o)}finally{e.expectedType=n}}var tt={"+":_chunk2VTISQYPcjs.nc[_chunk2VTISQYPcjs.a].gpuImpl,"-":_chunk2VTISQYPcjs.oc[_chunk2VTISQYPcjs.a].gpuImpl,"*":_chunk2VTISQYPcjs.pc[_chunk2VTISQYPcjs.a].gpuImpl,"/":_chunk2VTISQYPcjs.qc[_chunk2VTISQYPcjs.a].gpuImpl};function y(e,t){if(typeof t=="string")return Te(e,t);if(typeof t=="boolean")return _chunk2VTISQYPcjs.wa.call(void 0, t?"true":"false",_chunk2VTISQYPcjs.Ba);if(t[0]===u.logicalExpr||t[0]===u.binaryExpr||t[0]===u.assignmentExpr){let[o,n,i,r]=t,a=y(e,n),s=y(e,r),c=tt[i];if(c)return c(a,s);let p=t[0]===u.assignmentExpr?a.dataType.type==="ptr"?[a.dataType.inner]:[a.dataType]:void 0,d=_chunk2VTISQYPcjs.ob.call(void 0, {ctx:e,values:[a,s],restrictTo:p}),[g,F]=d||[a,s],j=e.resolve(g.value),M=e.resolve(F.value),ze=Ve(g.dataType,i,F.dataType);return _chunk2VTISQYPcjs.wa.call(void 0, Qe.includes(i)?`(${j} ${i} ${M})`:`${j} ${i} ${M}`,ze)}if(t[0]===u.postUpdate){let[o,n,i]=t,r=y(e,i),a=e.resolve(r.value);return _chunk2VTISQYPcjs.wa.call(void 0, `${a}${n}`,r.dataType)}if(t[0]===u.unaryExpr){let[o,n,i]=t,r=y(e,i),a=e.resolve(r.value),s=Ve(r.dataType,n);return _chunk2VTISQYPcjs.wa.call(void 0, `${n}${a}`,s)}if(t[0]===u.memberAccess){let[o,n,i]=t,r=y(e,n);if(Ye.includes(r.dataType.type)&&i in Q)return{value:new (0, _chunk2VTISQYPcjs.sa)(i,r,Q[i][_chunk2VTISQYPcjs.a].gpuImpl),dataType:_chunk2VTISQYPcjs.ra};if(r.dataType.type==="unknown"){let a=r.value[i];return _chunk2VTISQYPcjs.rb.call(void 0, a)}return _chunk2VTISQYPcjs.L.call(void 0, r.dataType)?_chunk2VTISQYPcjs.wa.call(void 0, `(*${e.resolve(r.value)}).${i}`,_chunk2VTISQYPcjs.jb.call(void 0, r.dataType.inner,i)):_chunk2VTISQYPcjs.J.call(void 0, r.dataType)&&i==="length"?r.dataType.elementCount===0?_chunk2VTISQYPcjs.wa.call(void 0, `arrayLength(&${e.resolve(r.value)})`,_chunk2VTISQYPcjs.Ca):_chunk2VTISQYPcjs.wa.call(void 0, String(r.dataType.elementCount),_chunk2VTISQYPcjs.za):_chunk2VTISQYPcjs.H.call(void 0, r.dataType)&&i==="columns"?_chunk2VTISQYPcjs.wa.call(void 0, r.value,r.dataType):_chunk2VTISQYPcjs.E.call(void 0, r.dataType)&&_chunk2VTISQYPcjs.A.call(void 0, r.value)?_chunk2VTISQYPcjs.rb.call(void 0, r.value[i]):_chunk2VTISQYPcjs.wa.call(void 0, `${e.resolve(r.value)}.${i}`,_chunk2VTISQYPcjs.jb.call(void 0, r.dataType,i))}if(t[0]===u.indexAccess){let[o,n,i]=t,r=y(e,n),a=y(e,i),s=e.resolve(r.value),c=e.resolve(a.value);if(r.dataType.type==="unknown"){if(Array.isArray(i)&&i[0]===u.numericLiteral)return _chunk2VTISQYPcjs.rb.call(void 0, r.value[i[1]]);throw new Error(`Cannot index value ${s} of unknown type with index ${c}`)}return _chunk2VTISQYPcjs.L.call(void 0, r.dataType)?_chunk2VTISQYPcjs.wa.call(void 0, `(*${s})[${c}]`,_chunk2VTISQYPcjs.kb.call(void 0, r.dataType.inner)):_chunk2VTISQYPcjs.wa.call(void 0, `${s}[${c}]`,_chunk2VTISQYPcjs.qa.call(void 0, r.dataType)?_chunk2VTISQYPcjs.kb.call(void 0, r.dataType):_chunk2VTISQYPcjs.ra)}if(t[0]===u.numericLiteral){let o=typeof t[1]=="string"?_chunk2VTISQYPcjs.mb.call(void 0, _chunk2VTISQYPcjs.lb.call(void 0, t[1])):_chunk2VTISQYPcjs.mb.call(void 0, t[1]);if(!o)throw new Error(`Invalid numeric literal ${t[1]}`);return o}if(t[0]===u.call){let[o,n,i]=t,r=y(e,n);if(_chunk2VTISQYPcjs.K.call(void 0, r.value)||_chunk2VTISQYPcjs.J.call(void 0, r.value)){if(i.length>1)throw new (0, _chunk2VTISQYPcjs.u)("Array and struct schemas should always be called with at most 1 argument");if(!i[0])return _chunk2VTISQYPcjs.wa.call(void 0, `${e.resolve(r.value)}()`,r.value);let s=B(e,i[0],r.value);return _chunk2VTISQYPcjs.wa.call(void 0, e.resolve(s.value,r.value),r.value)}if(r.value instanceof _chunk2VTISQYPcjs.sa){if(!i[0])throw new (0, _chunk2VTISQYPcjs.u)(`An infix operator '${r.value.name}' was called without any arguments`);let s=y(e,i[0]);return r.value.operator(r.value.lhs,s)}if(!_chunk2VTISQYPcjs.$.call(void 0, r.value))throw new Error(`Function ${String(r.value)} ${_chunk2VTISQYPcjs.g.call(void 0, r.value)} has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`);let a=_nullishCoalesce(_optionalChain([r, 'access', _5 => _5.value, 'access', _6 => _6[_chunk2VTISQYPcjs.a], 'optionalAccess', _7 => _7.argConversionHint]), () => ("keep"));try{let s;if(Array.isArray(a))s=i.map((p,d)=>{let g=a[d];if(!g)throw new (0, _chunk2VTISQYPcjs.u)(`Function '${_chunk2VTISQYPcjs.g.call(void 0, r.value)}' was called with too many arguments`);return B(e,p,g)});else{let p=i.map(d=>y(e,d));a==="keep"?s=p:a==="unify"?s=_nullishCoalesce(_chunk2VTISQYPcjs.ob.call(void 0, {ctx:e,values:p}), () => (p)):s=a(...p).map((d,g)=>[d,p[g]]).map(([d,g])=>_chunk2VTISQYPcjs.pb.call(void 0, e,g,d))}let c=r.value(...s);if(!_chunk2VTISQYPcjs.ua.call(void 0, c))throw new Error("Functions running in codegen mode must return snippets");return c}catch(s){throw new (0, _chunk2VTISQYPcjs.l)(s,[{toString:()=>_chunk2VTISQYPcjs.g.call(void 0, r.value)}])}}if(t[0]===u.objectExpr){let o=t[1],n=e.expectedType;if(!n||!_chunk2VTISQYPcjs.K.call(void 0, n))throw new (0, _chunk2VTISQYPcjs.u)(`No target type could be inferred for object with keys [${Object.keys(o).join(", ")}], please wrap the object in the corresponding schema.`);let i=Object.fromEntries(Object.entries(n.propTypes).map(([a,s])=>{let c=o[a];if(c===void 0)throw new (0, _chunk2VTISQYPcjs.u)(`Missing property ${a} in object literal for struct ${n}`);let p=B(e,c,s);return[a,p]})),r=_chunk2VTISQYPcjs.qb.call(void 0, e,n,i);return _chunk2VTISQYPcjs.wa.call(void 0, `${e.resolve(n)}(${r.map(a=>e.resolve(a.value)).join(", ")})`,n)}if(t[0]===u.arrayExpr){let[o,n]=t,i=e.expectedType,r,a;if(_chunk2VTISQYPcjs.J.call(void 0, i)){if(r=i.elementType,a=n.map(p=>B(e,p,r)),a.length!==i.elementCount)throw new (0, _chunk2VTISQYPcjs.u)(`Cannot create value of type '${i}' from an array of length: ${a.length}`)}else{let p=n.map(g=>y(e,g));if(p.length===0)throw new (0, _chunk2VTISQYPcjs.u)("Cannot infer the type of an empty array literal.");let d=_chunk2VTISQYPcjs.ob.call(void 0, {ctx:e,values:p});if(!d)throw new (0, _chunk2VTISQYPcjs.u)("The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema");a=d,r=_chunk2VTISQYPcjs.nb.call(void 0, _optionalChain([a, 'access', _8 => _8[0], 'optionalAccess', _9 => _9.dataType]))}let s=`array<${e.resolve(r)}, ${a.length}>`,c=a.map(p=>e.resolve(p.value));return _chunk2VTISQYPcjs.wa.call(void 0, `${s}(${c.join(", ")})`,U(r,a.length))}if(t[0]===u.stringLiteral)throw new Error("Cannot use string literals in TGSL.");if(t[0]===u.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");Ze(t)}function J(e){return typeof e!="object"||e[0]!==u.block?[u.block,[e]]:e}function ve(e,t){if(typeof t=="string")return`${e.pre}${e.resolve(Te(e,t).value)};`;if(typeof t=="boolean")return`${e.pre}${t?"true":"false"};`;if(t[0]===u.return){let o=t[1],n=o!==void 0?e.resolve(B(e,o,e.topFunctionReturnType).value):void 0;return n?`${e.pre}return ${n};`:`${e.pre}return;`}if(t[0]===u.if){let[o,n,i,r]=t,a=e.resolve(B(e,n,_chunk2VTISQYPcjs.Ba).value),s=z(e,J(i)),c=r?z(e,J(r)):void 0;return c?`${e.pre}if (${a}) ${s}
5
+ ${e.pre}else ${c}`:`${e.pre}if (${a}) ${s}`}if(t[0]===u.let||t[0]===u.const){let[o,n,i]=t,r=i!==void 0?y(e,i):void 0;if(!r)throw new Error(`Cannot create variable '${n}' without an initial value.`);if(_chunk2VTISQYPcjs.ja.call(void 0, r.dataType))throw new Error(`Cannot create variable '${n}' with loose data type.`);et(e,n,_chunk2VTISQYPcjs.nb.call(void 0, r.dataType));let a=e.resolve(Te(e,n).value);return`${e.pre}var ${a} = ${e.resolve(r.value)};`}if(t[0]===u.block)return z(e,t);if(t[0]===u.for){let[o,n,i,r,a]=t,[s,c,p]=e.withResetIndentLevel(()=>[n?ve(e,n):void 0,i?y(e,i):void 0,r?ve(e,r):void 0]),d=s?s.slice(0,-1):"",g=i?B(e,i,_chunk2VTISQYPcjs.Ba):void 0,F=g?e.resolve(g.value):"",j=p?p.slice(0,-1):"",M=z(e,J(a));return`${e.pre}for (${d}; ${F}; ${j}) ${M}`}if(t[0]===u.while){let[o,n,i]=t,r=B(e,n,_chunk2VTISQYPcjs.Ba),a=e.resolve(r.value),s=z(e,J(i));return`${e.pre}while (${a}) ${s}`}return t[0]===u.continue?`${e.pre}continue;`:t[0]===u.break?`${e.pre}break;`:`${e.pre}${e.resolve(y(e,t).value)};`}function Ut(e,t){return z(e,t)}function Ce(e,t){if(t===void 0)return n=>Ce(e,n);let o=n=>{if(n&&n.length!==t)throw new Error(`Disarray schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);return Array.from({length:t},(i,r)=>_chunk2VTISQYPcjs.ic.call(void 0, e,_optionalChain([n, 'optionalAccess', _10 => _10[r]])))};if(Object.setPrototypeOf(o,nt),o.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create disarray schema with invalid element count: ${t}.`);return o.elementCount=t,o}var nt={[_chunk2VTISQYPcjs.a]:!0,type:"disarray",toString(){return`disarrayOf(${this.elementType}, ${this.elementCount})`}};function rt(e){let t=o=>Object.fromEntries(Object.entries(e).map(([n,i])=>[n,_chunk2VTISQYPcjs.ic.call(void 0, i,_optionalChain([o, 'optionalAccess', _11 => _11[n]]))]));return Object.setPrototypeOf(t,it),t.propTypes=e,t}var it={[_chunk2VTISQYPcjs.a]:!0,type:"unstruct",$name(e){return _chunk2VTISQYPcjs.h.call(void 0, this,e),this},toString(){return`unstruct:${_nullishCoalesce(_chunk2VTISQYPcjs.g.call(void 0, this), () => ("<unnamed>"))}`}};function ot(e){return new be(e)}var be= (_class =class{constructor(t){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);this.inner=t}__init() {this[_chunk2VTISQYPcjs.a]=!0}__init2() {this.type="atomic"}}, _class);function S(e,t){return _chunk2VTISQYPcjs.S.call(void 0, e)?new Y(e.inner,[t,...e.attribs]):_chunk2VTISQYPcjs.ma.call(void 0, e)?new Z(e.inner,[t,...e.attribs]):_chunk2VTISQYPcjs.ja.call(void 0, e)?new Z(e,[t]):new Y(e,[t])}function at(e,t){return S(t,{[_chunk2VTISQYPcjs.a]:!0,type:"@align",params:[e]})}function st(e,t){return S(t,{[_chunk2VTISQYPcjs.a]:!0,type:"@size",params:[e]})}function lt(e,t){return S(t,{[_chunk2VTISQYPcjs.a]:!0,type:"@location",params:[e]})}function ut(e,t){return S(t,{[_chunk2VTISQYPcjs.a]:!0,type:"@interpolate",params:[e]})}function pt(e){if(!Ue(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=_chunk2VTISQYPcjs.S.call(void 0, e)||_chunk2VTISQYPcjs.ma.call(void 0, e)?e.attribs.find(_chunk2VTISQYPcjs.R):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 S(e,{[_chunk2VTISQYPcjs.a]:!0,type:"@invariant",params:[]})}function Ue(e){return(_chunk2VTISQYPcjs.S.call(void 0, e)||_chunk2VTISQYPcjs.ma.call(void 0, e))&&e.attribs.find(_chunk2VTISQYPcjs.R)!==void 0}function Zt(e){return!_chunk2VTISQYPcjs.S.call(void 0, e)&&!_chunk2VTISQYPcjs.ma.call(void 0, e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var X= (_class2 =class{constructor(t,o){;_class2.prototype.__init3.call(this);this.inner=t;this.attribs=o;let n=_optionalChain([o, 'access', _12 => _12.find, 'call', _13 => _13(_chunk2VTISQYPcjs.N), 'optionalAccess', _14 => _14.params, 'access', _15 => _15[0]]),i=_optionalChain([o, 'access', _16 => _16.find, 'call', _17 => _17(_chunk2VTISQYPcjs.O), 'optionalAccess', _18 => _18.params, 'access', _19 => _19[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(_chunk2VTISQYPcjs.I.call(void 0, this.inner)&&n%b(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${n}, expected multiple of: ${b(this.inner)}.`)}if(i!==void 0){if(i<h(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${i}, expected at least: ${h(this.inner)}.`);if(i<=0)throw new Error(`Custom data size must be a positive number. Got: ${i}.`)}}__init3() {this[_chunk2VTISQYPcjs.a]=!0}}, _class2),Y= (_class3 =class extends X{constructor(...args) { super(...args); _class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this); }__init4() {this[_chunk2VTISQYPcjs.a]=!0}__init5() {this.type="decorated"}}, _class3),Z= (_class4 =class extends X{constructor(...args2) { super(...args2); _class4.prototype.__init6.call(this);_class4.prototype.__init7.call(this); }__init6() {this[_chunk2VTISQYPcjs.a]=!0}__init7() {this.type="loose-decorated"}}, _class4);function f(e,t){return S(e,{[_chunk2VTISQYPcjs.a]:!0,type:"@builtin",params:[t]})}var ct={vertexIndex:f(_chunk2VTISQYPcjs.Ca,"vertex_index"),instanceIndex:f(_chunk2VTISQYPcjs.Ca,"instance_index"),position:f(_chunk2VTISQYPcjs.Sa,"position"),clipDistances:f(U(_chunk2VTISQYPcjs.Ca,8),"clip_distances"),frontFacing:f(_chunk2VTISQYPcjs.Ba,"front_facing"),fragDepth:f(_chunk2VTISQYPcjs.Fa,"frag_depth"),sampleIndex:f(_chunk2VTISQYPcjs.Ca,"sample_index"),sampleMask:f(_chunk2VTISQYPcjs.Ca,"sample_mask"),localInvocationId:f(_chunk2VTISQYPcjs.Qa,"local_invocation_id"),localInvocationIndex:f(_chunk2VTISQYPcjs.Ca,"local_invocation_index"),globalInvocationId:f(_chunk2VTISQYPcjs.Qa,"global_invocation_id"),workgroupId:f(_chunk2VTISQYPcjs.Qa,"workgroup_id"),numWorkgroups:f(_chunk2VTISQYPcjs.Qa,"num_workgroups"),subgroupInvocationId:f(_chunk2VTISQYPcjs.Ca,"subgroup_invocation_id"),subgroupSize:f(_chunk2VTISQYPcjs.Ca,"subgroup_size")};function $(e,t){let o=e.prototype,n=Q[t][_chunk2VTISQYPcjs.a].jsImpl;o[t]=function(i){return n(this,i)}}$(_chunk2VTISQYPcjs.Ha,"add");$(_chunk2VTISQYPcjs.Ha,"sub");$(_chunk2VTISQYPcjs.Ha,"mul");$(_chunk2VTISQYPcjs.Ha,"div");$(_chunk2VTISQYPcjs.Xa,"add");$(_chunk2VTISQYPcjs.Xa,"sub");$(_chunk2VTISQYPcjs.Xa,"mul");exports.a = b; exports.b = C; exports.c = je; exports.d = V; exports.e = h; exports.f = Ke; exports.g = at; exports.h = st; exports.i = lt; exports.j = ut; exports.k = pt; exports.l = Ue; exports.m = Zt; exports.n = U; exports.o = Ut; exports.p = Ce; exports.q = rt; exports.r = ot; exports.s = ct;
6
+ //# sourceMappingURL=chunk-CYZBRBPD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-CYZBRBPD.cjs","../src/tgsl/wgslGenerator.ts","../src/mathUtils.ts","../src/data/alignmentOf.ts","../src/data/disarray.ts"],"names":["roundUp","value","modulo","bitMask","invBitMask","knownAlignmentMap","computeAlignment","data","dataType","knownAlignment","isWgslStruct","alignmentOf","a","b","isWgslArray","isUnstruct","firstProp","getCustomAlignment","isDisarray","isDecorated","isLooseDecorated","packedFormats"],"mappings":"AAAA,8iCAAqc,8ECA5a,ICIZA,CAAAA,CAAU,CAACC,CAAAA,CAAeC,CAAAA,CAAAA,EAAmB,CACxD,IAAMC,CAAAA,CAAUD,CAAAA,CAAS,CAAA,CACnBE,CAAAA,CAAa,CAACD,CAAAA,CACpB,MAAA,CAAQF,CAAAA,CAAQE,CAAAA,CAAAA,GAAa,CAAA,CAAIF,CAAAA,CAAAA,CAASA,CAAAA,CAAQG,CAAAA,CAAAA,CAAcF,CAClE,CAAA,CCOA,IAAMG,EAAAA,CAA4C,CAChD,GAAA,CAAK,CAAA,CACL,GAAA,CAAK,CAAA,CACL,GAAA,CAAK,CAAA,CACL,GAAA,CAAK,CAAA,CACL,GAAA,CAAK,CAAA,CACL,KAAA,CAAO,CAAA,CACP,KAAA,CAAO,CAAA,CACP,KAAA,CAAO,CAAA,CACP,KAAA,CAAO,CAAA,CACP,KAAA,CAAO,EAAA,CACP,KAAA,CAAO,CAAA,CACP,KAAA,CAAO,EAAA,CACP,KAAA,CAAO,EAAA,CACP,KAAA,CAAO,EAAA,CACP,KAAA,CAAO,CAAA,CACP,KAAA,CAAO,EAAA,CACP,KAAA,CAAO,EAAA,CACP,OAAA,CAAS,CAAA,CACT,OAAA,CAAS,EAAA,CACT,OAAA,CAAS,EAAA,CACT,MAAA,CAAQ,CACV,CAAA,CAEA,SAASC,EAAAA,CAAiBC,CAAAA,CAAsB,CAC9C,IAAMC,CAAAA,iBAAYD,CAAAA,6BAAmB,MAAA,CAC/BE,CAAAA,CAAiBJ,EAAAA,CAAkBG,CAAQ,CAAA,CACjD,EAAA,CAAIC,CAAAA,GAAmB,KAAA,CAAA,CACrB,OAAOA,CAAAA,CAGT,EAAA,CAAIC,iCAAAA,CAAiB,CAAA,CACnB,OAAO,MAAA,CAAO,MAAA,CAAOH,CAAAA,CAAK,SAAqC,CAAA,CAC5D,GAAA,CAAII,CAAW,CAAA,CACf,MAAA,CAAO,CAACC,CAAAA,CAAGC,CAAAA,CAAAA,EAAOD,CAAAA,CAAIC,CAAAA,CAAID,CAAAA,CAAIC,CAAE,CAAA,CAGrC,EAAA,CAAIC,iCAAAA,CAAgB,CAAA,CAClB,OAAOH,CAAAA,CAAYJ,CAAAA,CAAK,WAAW,CAAA,CAGrC,EAAA,CAAIQ,kCAAAA,CAAe,CAAA,CAAG,CAEpB,IAAMC,CAAAA,CACJ,MAAA,CAAO,MAAA,CAAOT,CAAAA,CAAK,SAAqC,CAAA,CAAE,CAAC,CAAA,CAC7D,OAAOS,CAAAA,kBAAaC,kCAAAA,CAA4B,CAAA,SAAK,GAAA,CAAK,CAC5D,CAEA,EAAA,CAAIC,kCAAAA,CAAe,CAAA,CACjB,wBAAOD,kCAAAA,CAAmBV,CAAK,WAAW,CAAA,SAAK,GAAA,CAGjD,EAAA,CAAIY,iCAAAA,CAAgB,CAAA,EAAKC,kCAAAA,CAAqB,CAAA,CAC5C,wBAAOH,kCAAAA,CAAuB,CAAA,SAAKN,CAAAA,CAAYJ,CAAAA,CAAK,KAAK,GAAA,CAG3D,EAAA,CAAIc,oBAAAA,CAAc,GAAA,CAAIb,CAAQ,CAAA,CAC5B,OAAO,CAAA,CAGT,MAAM,IAAI,KAAA,CACR,CAAA,oCAAA,EAAuC,IAAA,CAAK,SAAA,CAAUD,CAAI,CAAC,CAAA,CAAA;AFoDpD;AACL;AA4HY;AGzM4F","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-CYZBRBPD.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 { isSnippet, snip, type Snippet } from '../data/snippet.ts';\nimport { abstractInt, bool, 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 { 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 parseNumericString,\n tryConvertSnippet,\n} from './generationHelpers.ts';\nimport { add, div, mul, sub } from '../std/operators.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\nconst opCodeToCodegen = {\n '+': add[$internal].gpuImpl,\n '-': sub[$internal].gpuImpl,\n '*': mul[$internal].gpuImpl,\n '/': div[$internal].gpuImpl,\n} satisfies Partial<\n Record<tinyest.BinaryOperator, (...args: never[]) => unknown>\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 codegen = opCodeToCodegen[op as keyof typeof opCodeToCodegen];\n if (codegen) {\n return codegen(lhsExpr, rhsExpr);\n }\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] as const,\n restrictTo: forcedType,\n });\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 = typeof expression[1] === 'string'\n ? numericLiteralToSnippet(parseNumericString(expression[1]))\n : 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), 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 const rhs = generateExpression(ctx, argNodes[0]);\n return callee.value.operator(callee.value.lhs, rhs);\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 snippets = argNodes.map((arg) => generateExpression(ctx, arg));\n\n if (argConversionHint === 'keep') {\n // The hint tells us to do nothing.\n convertedArguments = snippets;\n } else if (argConversionHint === 'unify') {\n // The hint tells us to unify the types.\n convertedArguments = convertToCommonType({ ctx, values: snippets }) ??\n snippets;\n } else {\n // The hint is a function that converts the arguments.\n convertedArguments = argConversionHint(...snippets)\n .map((type, i) => [type, snippets[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 );\n\n if (!isSnippet(fnRes)) {\n throw new Error(\n 'Functions running in codegen mode must return snippets',\n );\n }\n return fnRes;\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","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 { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Disarray } from './dataTypes.ts';\nimport { schemaCallWrapper } from './utils.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates an array schema that can be used to construct vertex buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\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 *\n * @example\n * const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f\n *\n * @example\n * const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const disarray = d.disarrayOf(d.vec3f);\n * // ^? (n: number) => Disarray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport function disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n): Disarray<TElement>;\n\nexport function disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount?: undefined,\n): (elementCount: number) => Disarray<TElement>;\n\nexport function disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount?: number | undefined,\n): Disarray<TElement> | ((elementCount: number) => Disarray<TElement>) {\n if (elementCount === undefined) {\n return (n: number) => disarrayOf(elementType, n);\n }\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const disarraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Disarray schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`,\n );\n }\n\n return Array.from(\n { length: elementCount },\n (_, i) => schemaCallWrapper(elementType, elements?.[i]),\n );\n };\n Object.setPrototypeOf(disarraySchema, DisarrayImpl);\n\n disarraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create disarray schema with invalid element count: ${elementCount}.`,\n );\n }\n disarraySchema.elementCount = elementCount;\n\n return disarraySchema as unknown as Disarray<TElement>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst DisarrayImpl = {\n [$internal]: true,\n type: 'disarray',\n\n toString(this: Disarray): string {\n return `disarrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import{$ as Ae,A as Ie,Ba as I,Ca as T,E as xe,Fa as ae,H as we,Ha as N,I as ee,J as w,K as A,L as R,N as te,O as ne,Qa as _,R as G,S as D,Sa as se,Xa as H,a as l,g as k,h as he,ic as W,ja as P,jb as le,ka as E,kb as ue,l as De,la as L,lb as ke,ma as v,mb as pe,na as O,nb as ce,nc as ye,oa as Be,ob as K,oc as fe,pb as me,pc as de,qa as re,qb as Ee,qc as ge,ra as ie,rb as q,sa as oe,tb as Le,u as x,ua as Se,wa as m,za as $e}from"./chunk-WP6W72RY.js";import*as Je from"tinyest";var V=(e,t)=>{let o=t-1,n=~o;return(e&o)===0?e:(e&n)+t};var Pe={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 Ne(e){let t=e?.type,o=Pe[t];if(o!==void 0)return o;if(A(e))return Object.values(e.propTypes).map(b).reduce((n,i)=>n>i?n:i);if(w(e))return b(e.elementType);if(L(e)){let n=Object.values(e.propTypes)[0];return n?O(n)??1:1}if(E(e))return O(e.elementType)??1;if(D(e)||v(e))return O(e)??b(e.inner);if(Le.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${JSON.stringify(e)}`)}function Fe(e){if(L(e)){let t=Object.values(e.propTypes)[0];return t?C(t):1}return E(e)?C(e.elementType):v(e)?O(e)??C(e.inner):O(e)??1}var Oe=new WeakMap,_e=new WeakMap;function b(e){let t=Oe.get(e);return t===void 0&&(t=Ne(e),Oe.set(e,t)),t}function C(e){let t=_e.get(e);return t===void 0&&(t=Fe(e),_e.set(e,t)),t}function je(e){return b(e)}var Me={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 Re(e){let t=0,o=e.propTypes;for(let n of Object.values(o)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=V(t,b(n)),t+=h(n),Number.isNaN(t)&&n.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return V(t,b(e))}function Ge(e){let t=0,o=e.propTypes;for(let n of Object.values(o)){let i=C(n);t=V(t,i),t+=h(n)}return t}function He(e){let t=Me[e?.type];if(t!==void 0)return t;if(A(e))return Re(e);if(L(e))return Ge(e);if(w(e)){if(e.elementCount===0)return Number.NaN;let o=b(e.elementType);return V(h(e.elementType),o)*e.elementCount}if(E(e)){let o=C(e.elementType);return V(h(e.elementType),o)*e.elementCount}if(D(e)||v(e))return Be(e)??h(e.inner);throw new Error(`Cannot determine size of data: ${e}`)}var We=new WeakMap;function h(e){let t=We.get(e);return t===void 0&&(t=He(e),We.set(e,t)),t}function Ke(e){return h(e)}function U(e,t){if(t===void 0)return n=>U(e,n);let o=n=>{if(n&&n.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);return Array.from({length:t},(i,r)=>W(e,n?.[r]))};if(Object.setPrototypeOf(o,qe),Number.isNaN(h(e)))throw new Error("Cannot nest runtime sized arrays.");if(o.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return o.elementCount=t,o}var qe={[l]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};var{NodeTypeCatalog:u}=Je,Qe=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"],Xe=["&&","||","==","!=","<","<=",">",">="],Ye=["vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"],Q={add:ye,sub:fe,mul:de,div:ge};function Ve(e,t,o){return o?Xe.includes(t)?I:t==="="?o:e:t==="!"||t==="~"?I:e}function Ze(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function z(e,[t,o]){e.pushBlockScope();try{e.indent();let n=o.map(i=>ve(e,i)).join(`
2
+ `);return e.dedent(),`{
3
+ ${n}
4
+ ${e.pre}}`}finally{e.popBlockScope()}}function et(e,t,o){return e.defineVariable(t,o)}function Te(e,t){let o=e.getById(t);if(!o)throw new Error(`Identifier ${t} not found`);return o}function B(e,t,o){let n=e.expectedType;e.expectedType=o;try{let i=y(e,t);return me(e,i,o)}finally{e.expectedType=n}}var tt={"+":ye[l].gpuImpl,"-":fe[l].gpuImpl,"*":de[l].gpuImpl,"/":ge[l].gpuImpl};function y(e,t){if(typeof t=="string")return Te(e,t);if(typeof t=="boolean")return m(t?"true":"false",I);if(t[0]===u.logicalExpr||t[0]===u.binaryExpr||t[0]===u.assignmentExpr){let[o,n,i,r]=t,a=y(e,n),s=y(e,r),c=tt[i];if(c)return c(a,s);let p=t[0]===u.assignmentExpr?a.dataType.type==="ptr"?[a.dataType.inner]:[a.dataType]:void 0,d=K({ctx:e,values:[a,s],restrictTo:p}),[g,F]=d||[a,s],j=e.resolve(g.value),M=e.resolve(F.value),ze=Ve(g.dataType,i,F.dataType);return m(Qe.includes(i)?`(${j} ${i} ${M})`:`${j} ${i} ${M}`,ze)}if(t[0]===u.postUpdate){let[o,n,i]=t,r=y(e,i),a=e.resolve(r.value);return m(`${a}${n}`,r.dataType)}if(t[0]===u.unaryExpr){let[o,n,i]=t,r=y(e,i),a=e.resolve(r.value),s=Ve(r.dataType,n);return m(`${n}${a}`,s)}if(t[0]===u.memberAccess){let[o,n,i]=t,r=y(e,n);if(Ye.includes(r.dataType.type)&&i in Q)return{value:new oe(i,r,Q[i][l].gpuImpl),dataType:ie};if(r.dataType.type==="unknown"){let a=r.value[i];return q(a)}return R(r.dataType)?m(`(*${e.resolve(r.value)}).${i}`,le(r.dataType.inner,i)):w(r.dataType)&&i==="length"?r.dataType.elementCount===0?m(`arrayLength(&${e.resolve(r.value)})`,T):m(String(r.dataType.elementCount),$e):we(r.dataType)&&i==="columns"?m(r.value,r.dataType):xe(r.dataType)&&Ie(r.value)?q(r.value[i]):m(`${e.resolve(r.value)}.${i}`,le(r.dataType,i))}if(t[0]===u.indexAccess){let[o,n,i]=t,r=y(e,n),a=y(e,i),s=e.resolve(r.value),c=e.resolve(a.value);if(r.dataType.type==="unknown"){if(Array.isArray(i)&&i[0]===u.numericLiteral)return q(r.value[i[1]]);throw new Error(`Cannot index value ${s} of unknown type with index ${c}`)}return R(r.dataType)?m(`(*${s})[${c}]`,ue(r.dataType.inner)):m(`${s}[${c}]`,re(r.dataType)?ue(r.dataType):ie)}if(t[0]===u.numericLiteral){let o=typeof t[1]=="string"?pe(ke(t[1])):pe(t[1]);if(!o)throw new Error(`Invalid numeric literal ${t[1]}`);return o}if(t[0]===u.call){let[o,n,i]=t,r=y(e,n);if(A(r.value)||w(r.value)){if(i.length>1)throw new x("Array and struct schemas should always be called with at most 1 argument");if(!i[0])return m(`${e.resolve(r.value)}()`,r.value);let s=B(e,i[0],r.value);return m(e.resolve(s.value,r.value),r.value)}if(r.value instanceof oe){if(!i[0])throw new x(`An infix operator '${r.value.name}' was called without any arguments`);let s=y(e,i[0]);return r.value.operator(r.value.lhs,s)}if(!Ae(r.value))throw new Error(`Function ${String(r.value)} ${k(r.value)} has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`);let a=r.value[l]?.argConversionHint??"keep";try{let s;if(Array.isArray(a))s=i.map((p,d)=>{let g=a[d];if(!g)throw new x(`Function '${k(r.value)}' was called with too many arguments`);return B(e,p,g)});else{let p=i.map(d=>y(e,d));a==="keep"?s=p:a==="unify"?s=K({ctx:e,values:p})??p:s=a(...p).map((d,g)=>[d,p[g]]).map(([d,g])=>me(e,g,d))}let c=r.value(...s);if(!Se(c))throw new Error("Functions running in codegen mode must return snippets");return c}catch(s){throw new De(s,[{toString:()=>k(r.value)}])}}if(t[0]===u.objectExpr){let o=t[1],n=e.expectedType;if(!n||!A(n))throw new x(`No target type could be inferred for object with keys [${Object.keys(o).join(", ")}], please wrap the object in the corresponding schema.`);let i=Object.fromEntries(Object.entries(n.propTypes).map(([a,s])=>{let c=o[a];if(c===void 0)throw new x(`Missing property ${a} in object literal for struct ${n}`);let p=B(e,c,s);return[a,p]})),r=Ee(e,n,i);return m(`${e.resolve(n)}(${r.map(a=>e.resolve(a.value)).join(", ")})`,n)}if(t[0]===u.arrayExpr){let[o,n]=t,i=e.expectedType,r,a;if(w(i)){if(r=i.elementType,a=n.map(p=>B(e,p,r)),a.length!==i.elementCount)throw new x(`Cannot create value of type '${i}' from an array of length: ${a.length}`)}else{let p=n.map(g=>y(e,g));if(p.length===0)throw new x("Cannot infer the type of an empty array literal.");let d=K({ctx:e,values:p});if(!d)throw new x("The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema");a=d,r=ce(a[0]?.dataType)}let s=`array<${e.resolve(r)}, ${a.length}>`,c=a.map(p=>e.resolve(p.value));return m(`${s}(${c.join(", ")})`,U(r,a.length))}if(t[0]===u.stringLiteral)throw new Error("Cannot use string literals in TGSL.");if(t[0]===u.preUpdate)throw new Error("Cannot use pre-updates in TGSL.");Ze(t)}function J(e){return typeof e!="object"||e[0]!==u.block?[u.block,[e]]:e}function ve(e,t){if(typeof t=="string")return`${e.pre}${e.resolve(Te(e,t).value)};`;if(typeof t=="boolean")return`${e.pre}${t?"true":"false"};`;if(t[0]===u.return){let o=t[1],n=o!==void 0?e.resolve(B(e,o,e.topFunctionReturnType).value):void 0;return n?`${e.pre}return ${n};`:`${e.pre}return;`}if(t[0]===u.if){let[o,n,i,r]=t,a=e.resolve(B(e,n,I).value),s=z(e,J(i)),c=r?z(e,J(r)):void 0;return c?`${e.pre}if (${a}) ${s}
5
+ ${e.pre}else ${c}`:`${e.pre}if (${a}) ${s}`}if(t[0]===u.let||t[0]===u.const){let[o,n,i]=t,r=i!==void 0?y(e,i):void 0;if(!r)throw new Error(`Cannot create variable '${n}' without an initial value.`);if(P(r.dataType))throw new Error(`Cannot create variable '${n}' with loose data type.`);et(e,n,ce(r.dataType));let a=e.resolve(Te(e,n).value);return`${e.pre}var ${a} = ${e.resolve(r.value)};`}if(t[0]===u.block)return z(e,t);if(t[0]===u.for){let[o,n,i,r,a]=t,[s,c,p]=e.withResetIndentLevel(()=>[n?ve(e,n):void 0,i?y(e,i):void 0,r?ve(e,r):void 0]),d=s?s.slice(0,-1):"",g=i?B(e,i,I):void 0,F=g?e.resolve(g.value):"",j=p?p.slice(0,-1):"",M=z(e,J(a));return`${e.pre}for (${d}; ${F}; ${j}) ${M}`}if(t[0]===u.while){let[o,n,i]=t,r=B(e,n,I),a=e.resolve(r.value),s=z(e,J(i));return`${e.pre}while (${a}) ${s}`}return t[0]===u.continue?`${e.pre}continue;`:t[0]===u.break?`${e.pre}break;`:`${e.pre}${e.resolve(y(e,t).value)};`}function Ut(e,t){return z(e,t)}function Ce(e,t){if(t===void 0)return n=>Ce(e,n);let o=n=>{if(n&&n.length!==t)throw new Error(`Disarray schema of ${t} elements of type ${e.type} called with ${n.length} argument(s).`);return Array.from({length:t},(i,r)=>W(e,n?.[r]))};if(Object.setPrototypeOf(o,nt),o.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create disarray schema with invalid element count: ${t}.`);return o.elementCount=t,o}var nt={[l]:!0,type:"disarray",toString(){return`disarrayOf(${this.elementType}, ${this.elementCount})`}};function rt(e){let t=o=>Object.fromEntries(Object.entries(e).map(([n,i])=>[n,W(i,o?.[n])]));return Object.setPrototypeOf(t,it),t.propTypes=e,t}var it={[l]:!0,type:"unstruct",$name(e){return he(this,e),this},toString(){return`unstruct:${k(this)??"<unnamed>"}`}};function ot(e){return new be(e)}var be=class{constructor(t){this.inner=t}[l]=!0;type="atomic"};function S(e,t){return D(e)?new Y(e.inner,[t,...e.attribs]):v(e)?new Z(e.inner,[t,...e.attribs]):P(e)?new Z(e,[t]):new Y(e,[t])}function at(e,t){return S(t,{[l]:!0,type:"@align",params:[e]})}function st(e,t){return S(t,{[l]:!0,type:"@size",params:[e]})}function lt(e,t){return S(t,{[l]:!0,type:"@location",params:[e]})}function ut(e,t){return S(t,{[l]:!0,type:"@interpolate",params:[e]})}function pt(e){if(!Ue(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=D(e)||v(e)?e.attribs.find(G):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 S(e,{[l]:!0,type:"@invariant",params:[]})}function Ue(e){return(D(e)||v(e))&&e.attribs.find(G)!==void 0}function Zt(e){return!D(e)&&!v(e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var X=class{constructor(t,o){this.inner=t;this.attribs=o;let n=o.find(te)?.params[0],i=o.find(ne)?.params[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(ee(this.inner)&&n%b(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${n}, expected multiple of: ${b(this.inner)}.`)}if(i!==void 0){if(i<h(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${i}, expected at least: ${h(this.inner)}.`);if(i<=0)throw new Error(`Custom data size must be a positive number. Got: ${i}.`)}}[l]=!0},Y=class extends X{[l]=!0;type="decorated"},Z=class extends X{[l]=!0;type="loose-decorated"};function f(e,t){return S(e,{[l]:!0,type:"@builtin",params:[t]})}var ct={vertexIndex:f(T,"vertex_index"),instanceIndex:f(T,"instance_index"),position:f(se,"position"),clipDistances:f(U(T,8),"clip_distances"),frontFacing:f(I,"front_facing"),fragDepth:f(ae,"frag_depth"),sampleIndex:f(T,"sample_index"),sampleMask:f(T,"sample_mask"),localInvocationId:f(_,"local_invocation_id"),localInvocationIndex:f(T,"local_invocation_index"),globalInvocationId:f(_,"global_invocation_id"),workgroupId:f(_,"workgroup_id"),numWorkgroups:f(_,"num_workgroups"),subgroupInvocationId:f(T,"subgroup_invocation_id"),subgroupSize:f(T,"subgroup_size")};function $(e,t){let o=e.prototype,n=Q[t][l].jsImpl;o[t]=function(i){return n(this,i)}}$(N,"add");$(N,"sub");$(N,"mul");$(N,"div");$(H,"add");$(H,"sub");$(H,"mul");export{b as a,C as b,je as c,V as d,h as e,Ke as f,at as g,st as h,lt as i,ut as j,pt as k,Ue as l,Zt as m,U as n,Ut as o,Ce as p,rt as q,ot as r,ct as s};
6
+ //# sourceMappingURL=chunk-SAMYKEUN.js.map