typegpu 0.8.1 → 0.8.2

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 (47) hide show
  1. package/{chunk-7S3IK3D4.js → chunk-6U5HPHCJ.js} +2 -2
  2. package/{chunk-7XFSK632.js → chunk-CGQB3SER.js} +2 -2
  3. package/{chunk-4W5Z7BO4.js → chunk-CRZWTZM2.js} +2 -2
  4. package/chunk-CRZWTZM2.js.map +1 -0
  5. package/{chunk-2UXPGML5.js → chunk-ECR2EGZX.js} +2 -2
  6. package/{chunk-VOVQAOVG.js → chunk-PWBIFP67.js} +2 -2
  7. package/common/index.d.ts +1 -1
  8. package/common/index.js +1 -1
  9. package/data/index.d.ts +3 -3
  10. package/data/index.js +1 -1
  11. package/index.d.ts +2 -2
  12. package/index.js +14 -14
  13. package/index.js.map +1 -1
  14. package/{matrix-DLipCOZF.d.ts → matrix-DIfOiRyz.d.ts} +1 -1
  15. package/package.json +5 -13
  16. package/std/index.d.ts +2 -2
  17. package/std/index.js +1 -1
  18. package/{tgpuConstant-BU72w5qs.d.cts → tgpuConstant-BTQFNlQH.d.ts} +9 -0
  19. package/chunk-3246CM7C.cjs +0 -2
  20. package/chunk-3246CM7C.cjs.map +0 -1
  21. package/chunk-4W5Z7BO4.js.map +0 -1
  22. package/chunk-5Y6GTBWR.cjs +0 -3
  23. package/chunk-5Y6GTBWR.cjs.map +0 -1
  24. package/chunk-PRMFGUQT.cjs +0 -2
  25. package/chunk-PRMFGUQT.cjs.map +0 -1
  26. package/chunk-TRE7NUKE.cjs +0 -10
  27. package/chunk-TRE7NUKE.cjs.map +0 -1
  28. package/chunk-ZYGTVBDH.cjs +0 -7
  29. package/chunk-ZYGTVBDH.cjs.map +0 -1
  30. package/common/index.cjs +0 -7
  31. package/common/index.cjs.map +0 -1
  32. package/common/index.d.cts +0 -24
  33. package/data/index.cjs +0 -2
  34. package/data/index.cjs.map +0 -1
  35. package/data/index.d.cts +0 -402
  36. package/index.cjs +0 -192
  37. package/index.cjs.map +0 -1
  38. package/index.d.cts +0 -369
  39. package/matrix-DHFT4O8f.d.cts +0 -122
  40. package/std/index.cjs +0 -2
  41. package/std/index.cjs.map +0 -1
  42. package/std/index.d.cts +0 -639
  43. package/tgpuConstant-BU72w5qs.d.ts +0 -5192
  44. /package/{chunk-7S3IK3D4.js.map → chunk-6U5HPHCJ.js.map} +0 -0
  45. /package/{chunk-7XFSK632.js.map → chunk-CGQB3SER.js.map} +0 -0
  46. /package/{chunk-2UXPGML5.js.map → chunk-ECR2EGZX.js.map} +0 -0
  47. /package/{chunk-VOVQAOVG.js.map → chunk-PWBIFP67.js.map} +0 -0
@@ -1,3 +0,0 @@
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 _chunkTRE7NUKEcjs = require('./chunk-TRE7NUKE.cjs');var _tinyest = require('tinyest');function S(n,e){for(let[r,t]of Object.entries(e))n[r]=t,t&&(typeof t=="object"||typeof t=="function")&&_chunkTRE7NUKEcjs.j.call(void 0, t)===void 0&&_chunkTRE7NUKEcjs.k.call(void 0, t,r)}function Se(n,e,r){let t=[...n.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(s=>s?s[1]:void 0);r(Object.fromEntries(e.flatMap((s,i)=>{let o=t?t[i]:void 0;return _chunkTRE7NUKEcjs.D.call(void 0, s)&&o!==void 0?[[o,s]]:[]})))}function $e(n,e,r){let t=n.match(/->\s(?<output>[\w\d_]+)\s{/),s=t?_optionalChain([t, 'access', _2 => _2[1], 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]):void 0;_chunkTRE7NUKEcjs.D.call(void 0, e)&&s&&!/\s/g.test(s)&&r({[s]:e})}function ue(n){return new RegExp(`(?<![\\w\\$_.])${n.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function R(n,e,r){return Object.entries(e).reduce((t,[s,i])=>{let o=ue(s);if(r&&s!=="Out"&&s!=="In"&&!o.test(r)&&console.warn(`The external '${s}' wasn't used in the resolved template.`),_chunkTRE7NUKEcjs.va.call(void 0, i)||_chunkTRE7NUKEcjs.Q.call(void 0, i)||_chunkTRE7NUKEcjs.m.call(void 0, i))return t.replaceAll(o,n.resolve(i).value);if(i!==null&&typeof i=="object"){let a=[...r.matchAll(new RegExp(`${s.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(d=>d[1]);return[...new Set(a)].reduce((d,f)=>f&&f in i?R(n,{[`${s}.${f}`]:i[f]},d):d,t)}return console.warn(`During resolution, the external '${s}' has been omitted. Only primitives, TGPU resources and plain JS objects can be used as externals.`),t},r)}function Y(n){let{strippedCode:e,argRange:r}=pe(n),t=new $(e);t.consume("(");let s=[];for(;!t.isAt(")");){let o=[];for(;t.isAt("@");)t.parseUntil(Q,X),t.consume(")"),o.push(t.lastParsed);t.parseUntil(ce);let a=t.lastParsed,l;t.isAt(":")&&(t.consume(":"),t.parseUntil(de,fe),l=t.lastParsed),s.push({identifier:a,attributes:o,type:l}),t.isAt(",")&&t.consume(",")}t.consume(")");let i;if(t.isAt("->")){t.consume("->");let o=[];for(;t.isAt("@");)t.parseUntil(Q,X),t.consume(")"),o.push(t.lastParsed);i={type:t.str.slice(t.pos),attributes:o}}return{args:s,ret:i,range:{begin:r[0],end:r[1]}}}function pe(n){let e=new $(n),r="",t;for(;!e.isFinished();){if(e.isAt(le)){e.advanceBy(1);continue}if(e.isAt("//")){e.consume("//"),e.parseUntil(Z),e.advanceBy(1);continue}if(e.isAt("/*")){e.parseUntil(me,ge),e.consume("*/");continue}if(e.isAt("{"))return{strippedCode:r,argRange:[t,e.pos]};e.isAt("(")&&t===void 0&&(t=e.pos),t!==void 0&&(r+=e.str[e.pos]),e.advanceBy(1)}throw new Error("Invalid wgsl code!")}var $=class{constructor(e){this.str=e;this.#e=0}#t;#e;get pos(){return this.#e}get lastParsed(){if(this.#t===void 0)throw new Error("Parse was not called yet!");return this.str.slice(this.#t,this.pos)}isFinished(){return this.#e>=this.str.length}isAt(e){if(typeof e=="string"){for(let r=0;r<e.length;r++)if(this.str[this.#e+r]!==e[r])return!1;return!0}for(let r of e)if(this.isAt(r))return!0;return!1}parseUntil(e,r){this.#t=this.#e;let t=0;for(;this.#e<this.str.length;){if(r&&this.isAt(r[0])&&(t+=1),r&&this.isAt(r[1])&&(t-=1),t===0&&this.isAt(e))return this.#e;this.#e+=1}throw new Error("Reached the end of the string without finding a match!")}advanceBy(e){this.#e+=e}consume(e){if(!this.isAt(e))throw new Error(`Expected '${e}' at position ${this.#e}, but found '${this.str.slice(this.#e,this.#e+e.length)}'`);this.advanceBy(e.length)}},Z=new Set([`
2
- `,"\v","\f","\r","\x85","\u2028","\u2029"]),le=new Set([...Z," "," ","\u200E","\u200F"]),Q=new Set([")"]),ce=new Set([":",",",")"]),de=new Set([",",")"]),me=new Set(["*/"]),X=["(",")"],fe=["<",">"],ge=["/*","*/"];function ne(n,e=""){let r=[],t={applyExternals(i){r.push(i)},resolve(i,o,a){let l={};for(let u of r)S(l,u);let d=i.getUniqueName(this);if(typeof n=="string"){if(!a)throw new Error("Explicit return type is required for string implementation");let u=R(i,l,n),m="",x="";if(e!==""){let p=_chunkTRE7NUKEcjs.D.call(void 0, o[0])?`(in: ${i.resolve(o[0]).value})`:"()",c=_chunkTRE7NUKEcjs.B.call(void 0, a)?_chunkTRE7NUKEcjs.pc.call(void 0, a):"",b=a!==_chunkTRE7NUKEcjs.q?_chunkTRE7NUKEcjs.D.call(void 0, a)?`-> ${i.resolve(a).value}`:`-> ${c!==""?c:"@location(0)"} ${i.resolve(a).value}`:"";m=`${p} ${b} `,x=u}else{let p=Y(u);if(p.args.length!==o.length)throw new Error(`WGSL implementation has ${p.args.length} arguments, while the shell has ${o.length} arguments.`);let c=p.args.map((E,ae)=>`${E.identifier}: ${te(i,`parameter ${E.identifier}`,E.type,o[ae])}`).join(", "),b=a===_chunkTRE7NUKEcjs.q?"":`-> ${te(i,"return type",_optionalChain([p, 'access', _5 => _5.ret, 'optionalAccess', _6 => _6.type]),a)}`;m=`(${c}) ${b}`,x=u.slice(p.range.end)}return i.addDeclaration(`${e}fn ${d}${m}${x}`),_chunkTRE7NUKEcjs.aa.call(void 0, d,a)}let f=_chunkTRE7NUKEcjs.n.call(void 0, n);if(_optionalChain([f, 'optionalAccess', _7 => _7.externals])){let u=Object.fromEntries(Object.entries(f.externals).filter(([m])=>!(m in l)));S(l,u)}let O=_optionalChain([f, 'optionalAccess', _8 => _8.ast]);if(!O)throw new Error("Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)");let B=O.externalNames.filter(u=>!(u in l));if(B.length>0)throw new (0, _chunkTRE7NUKEcjs.ga)(_chunkTRE7NUKEcjs.j.call(void 0, this),B);let A=O.params[1];A&&A.type==="i"&&e!==""&&S(l,{[A.name]:_chunkTRE7NUKEcjs.P.call(void 0, a)});let V=[],v=[];for(let[u,m]of o.entries()){let x=O.params[u];switch(_optionalChain([x, 'optionalAccess', _9 => _9.type])){case _tinyest.FuncParameterType.identifier:{let p=x.name,c=_chunkTRE7NUKEcjs.aa.call(void 0, i.makeNameValid(p),m);V.push(c),c.value!==p&&v.push([p,c]);break}case _tinyest.FuncParameterType.destructuredObject:{V.push(_chunkTRE7NUKEcjs.aa.call(void 0, `_arg_${u}`,m)),v.push(...x.props.map(({name:p,alias:c})=>[c,_chunkTRE7NUKEcjs.aa.call(void 0, `_arg_${u}.${p}`,o[u].propTypes[p])]));break}case void 0:V.push(_chunkTRE7NUKEcjs.aa.call(void 0, `_arg_${u}`,m))}}let{head:ie,body:se,returnType:oe}=i.fnToWgsl({args:V,argAliases:Object.fromEntries(v),returnType:a,body:O.body,externalMap:l});return i.addDeclaration(`${e}fn ${d}${i.resolve(ie).value}${i.resolve(se).value}`),_chunkTRE7NUKEcjs.aa.call(void 0, d,oe)}},s=_chunkTRE7NUKEcjs.j.call(void 0, n);return s!==void 0&&_chunkTRE7NUKEcjs.k.call(void 0, t,s),t}function te(n,e,r,t){let s=n.resolve(t).value.replace(/\s/g,"");if(!r)return s;let i=r.replace(/\s/g,"");if(i!==s)throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${e}, JS type "${s}", WGSL type "${i}".`);return r}function xe(n,e={}){let r=0,t=new Set;return Object.fromEntries(Object.entries(_nullishCoalesce(n, () => ({}))).map(([s,i])=>{let o=_chunkTRE7NUKEcjs.U.call(void 0, i);if(o!==void 0){if(t.has(o))throw new Error("Duplicate custom location attributes found");t.add(o)}return[s,i]}).map(([s,i])=>{if(_chunkTRE7NUKEcjs.oc.call(void 0, i))return[s,i];if(_chunkTRE7NUKEcjs.U.call(void 0, i)!==void 0)return[s,i];if(e[s])return[s,_chunkTRE7NUKEcjs.lc.call(void 0, e[s],i)];for(;t.has(r);)r++;return[s,_chunkTRE7NUKEcjs.lc.call(void 0, r++,i)]}))}function F(n,e={}){return _chunkTRE7NUKEcjs.V.call(void 0, n)?_chunkTRE7NUKEcjs.M.call(void 0, n)||_chunkTRE7NUKEcjs.U.call(void 0, n)!==void 0?n:_chunkTRE7NUKEcjs.lc.call(void 0, 0,n):_chunkTRE7NUKEcjs.rc.call(void 0, xe(n,e))}function re(n,...e){return ye(n)?he(n,...e):n}function ye(n){return Array.isArray(n)&&"raw"in n&&Array.isArray(n.raw)&&n.raw.every(e=>typeof e=="string")}function he(n,...e){return n.slice(1).reduce((r,t,s)=>`${r}${e[s]}${t}`,n[0])}function Qe(n){if(Object.keys(n.out).length===0)throw new Error("A vertexFn output cannot be empty since it must include the 'position' builtin.");let e={in:n.in,out:n.out,argTypes:n.in&&Object.keys(n.in).length!==0?[F(n.in)]:[],isEntry:!0},r=(t,...s)=>Ie(e,re(t,...s));return Object.assign(Object.assign(r,e),{does:r})}function Ie(n,e){let r=ne(e,"@vertex "),t=n.argTypes[0];return{shell:n,$uses(i){return r.applyExternals(i),this},[_chunkTRE7NUKEcjs.a]:!0,[_chunkTRE7NUKEcjs.c]:r,$name(i){return _chunkTRE7NUKEcjs.k.call(void 0, r,i),_chunkTRE7NUKEcjs.l.call(void 0, t)&&t.$name(`${i}_Input`),this},[_chunkTRE7NUKEcjs.f](i){let o=F(n.out,i.varyingLocations).$name(`${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => (""))}_Output`);return typeof e=="string"&&(t&&r.applyExternals({In:t}),r.applyExternals({Out:o})),r.resolve(i,n.argTypes,o)},toString(){return`vertexFn:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, r), () => ("<unnamed>"))}`}}}exports.a = S; exports.b = Se; exports.c = $e; exports.d = R; exports.e = ne; exports.f = F; exports.g = re; exports.h = Qe;
3
- //# sourceMappingURL=chunk-5Y6GTBWR.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-5Y6GTBWR.cjs","../src/core/function/fnCore.ts","../src/core/resolve/externals.ts"],"names":["applyExternals","existing","newExternals","key","value","getName","setName","addArgTypesToExternals","implementation","argTypes","argTypeNames","found","argType","argTypeName","isWgslStruct","addReturnTypeToExternals","returnType","matched","outputName","identifierRegex","name","replaceExternalsInWgsl","ctx","externalMap","wgsl","acc","externalName","external","externalRegex","isWgsl","isLooseData","hasTinyestMetadata","foundProperties"],"mappings":"AAAA,yuBAAyM,kCCAvK,SCiBlBA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACA,CACA,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQF,CAAY,CAAA,CACpDD,CAAAA,CAASE,CAAG,CAAA,CAAIC,CAAAA,CAIdA,CAAAA,EAAAA,CAAU,OAAOA,CAAAA,EAAU,QAAA,EAAY,OAAOA,CAAAA,EAAU,UAAA,CAAA,EACxDC,iCAAAA,CAAa,CAAA,GAAM,KAAA,CAAA,EAEnBC,iCAAAA,CAAQF,CAAOD,CAAG,CAGxB,CAEO,SAASI,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAT,CAAAA,CACA,CACA,IAAMU,CAAAA,CAAe,CACnB,GAAGF,CAAAA,CAAe,QAAA,CAAS,yBAAyB,CACtD,CAAA,CAAE,GAAA,CAAKG,CAAAA,EAAWA,CAAAA,CAAQA,CAAAA,CAAM,CAAC,CAAA,CAAI,KAAA,CAAU,CAAA,CAE/CX,CAAAA,CACE,MAAA,CAAO,WAAA,CACLS,CAAAA,CAAS,OAAA,CAAQ,CAACG,CAAAA,CAAS,CAAA,CAAA,EAAM,CAC/B,IAAMC,CAAAA,CAAcH,CAAAA,CAAeA,CAAAA,CAAa,CAAC,CAAA,CAAI,KAAA,CAAA,CACrD,OAAOI,iCAAAA,CAAoB,CAAA,EAAKD,CAAAA,GAAgB,KAAA,CAAA,CAC5C,CAAC,CAACA,CAAAA,CAAaD,CAAO,CAAC,CAAA,CACvB,CAAC,CACP,CAAC,CACH,CACF,CACF,CAEO,SAASG,EAAAA,CACdP,CAAAA,CACAQ,CAAAA,CACAhB,CAAAA,CACA,CACA,IAAMiB,CAAAA,CAAUT,CAAAA,CAAe,KAAA,CAAM,4BAA4B,CAAA,CAC3DU,CAAAA,CAAaD,CAAAA,iBAAUA,CAAAA,qBAAQ,CAAC,CAAA,6BAAG,IAAA,mBAAK,GAAA,CAAI,KAAA,CAAA,CAE9CH,iCAAAA,CAAuB,CAAA,EAAKI,CAAAA,EAAc,CAAC,KAAA,CAAM,IAAA,CAAKA,CAAU,CAAA,EAClElB,CAAAA,CAAe,CAAE,CAACkB,CAAU,CAAA,CAAGF,CAAW,CAAC,CAE/C,CAEA,SAASG,EAAAA,CAAgBC,CAAAA,CAAc,CACrC,OAAO,IAAI,MAAA,CACT,CAAA,eAAA,EACEA,CAAAA,CAAK,UAAA,CAAW,GAAA,CAAK,KAAK,CAAA,CAAE,UAAA,CAAW,GAAA,CAAK,KAAK,CACnD,CAAA,aAAA,CAAA,CACA,GACF,CACF,CAWO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACQ,CACR,OAAO,MAAA,CAAO,OAAA,CAAQD,CAAW,CAAA,CAAE,MAAA,CAAO,CAACE,CAAAA,CAAK,CAACC,CAAAA,CAAcC,CAAQ,CAAA,CAAA,EAAM,CAC3E,IAAMC,CAAAA,CAAgBT,EAAAA,CAAgBO,CAAY,CAAA,CAalD,EAAA,CAXEF,CAAAA,EACAE,CAAAA,GAAiB,KAAA,EACjBA,CAAAA,GAAiB,IAAA,EACjB,CAACE,CAAAA,CAAc,IAAA,CAAKJ,CAAI,CAAA,EAExB,OAAA,CAAQ,IAAA,CACN,CAAA,cAAA,EAAiBE,CAAY,CAAA,uCAAA,CAC/B,CAAA,CAKAG,kCAAAA,CAAe,CAAA,EAAKC,iCAAAA,CAAoB,CAAA,EAAKC,iCAAAA,CAA2B,CAAA,CAExE,OAAON,CAAAA,CAAI,UAAA,CAAWG,CAAAA,CAAeN,CAAAA,CAAI,OAAA,CAAQK,CAAQ,CAAA,CAAE,KAAK,CAAA,CAGlE,EAAA,CAAIA,CAAAA,GAAa,IAAA,EAAQ,OAAOA,CAAAA,EAAa,QAAA,CAAU,CACrD,IAAMK,CAAAA,CAAkB,CACtB,GAAGR,CAAAA,CAAK,QAAA,CACN,IAAI,MAAA,CACF,CAAA,EAAA;AD6BJ","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-5Y6GTBWR.cjs","sourcesContent":[null,"import { FuncParameterType } from 'tinyest';\nimport { getAttributesString } from '../../data/attributes.ts';\nimport { type AnyData, undecorate } from '../../data/dataTypes.ts';\nimport {\n type ResolvedSnippet,\n snip,\n type Snippet,\n} from '../../data/snippet.ts';\nimport {\n isWgslData,\n isWgslStruct,\n Void,\n type WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport { MissingLinksError } from '../../errors.ts';\nimport { getMetaData, getName, setName } from '../../shared/meta.ts';\nimport type { ResolutionCtx } from '../../types.ts';\nimport {\n applyExternals,\n type ExternalMap,\n replaceExternalsInWgsl,\n} from '../resolve/externals.ts';\nimport { extractArgs } from './extractArgs.ts';\nimport type { Implementation } from './fnTypes.ts';\n\nexport interface FnCore {\n applyExternals(newExternals: ExternalMap): void;\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n /**\n * The return type of the function. If undefined, the type should be inferred\n * from the implementation (relevant for shellless functions).\n */\n returnType: AnyData | undefined,\n ): ResolvedSnippet;\n}\n\nexport function createFnCore(\n implementation: Implementation,\n fnAttribute = '',\n): FnCore {\n /**\n * External application has to be deferred until resolution because\n * some externals can reference the owner function which has not been\n * initialized yet (like when accessing the Output struct of a vertex\n * entry fn).\n */\n const externalsToApply: ExternalMap[] = [];\n\n const core = {\n applyExternals(newExternals: ExternalMap): void {\n externalsToApply.push(newExternals);\n },\n\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n returnType: AnyData | undefined,\n ): ResolvedSnippet {\n const externalMap: ExternalMap = {};\n\n for (const externals of externalsToApply) {\n applyExternals(externalMap, externals);\n }\n\n const id = ctx.getUniqueName(this);\n\n if (typeof implementation === 'string') {\n if (!returnType) {\n throw new Error(\n 'Explicit return type is required for string implementation',\n );\n }\n\n const replacedImpl = replaceExternalsInWgsl(\n ctx,\n externalMap,\n implementation,\n );\n\n let header = '';\n let body = '';\n\n if (fnAttribute !== '') {\n const input = isWgslStruct(argTypes[0])\n ? `(in: ${ctx.resolve(argTypes[0]).value})`\n : '()';\n\n const attributes = isWgslData(returnType)\n ? getAttributesString(returnType)\n : '';\n const output = returnType !== Void\n ? isWgslStruct(returnType)\n ? `-> ${ctx.resolve(returnType).value}`\n : `-> ${attributes !== '' ? attributes : '@location(0)'} ${\n ctx.resolve(returnType).value\n }`\n : '';\n\n header = `${input} ${output} `;\n body = replacedImpl;\n } else {\n const providedArgs = extractArgs(replacedImpl);\n\n if (providedArgs.args.length !== argTypes.length) {\n throw new Error(\n `WGSL implementation has ${providedArgs.args.length} arguments, while the shell has ${argTypes.length} arguments.`,\n );\n }\n\n const input = providedArgs.args.map((argInfo, i) =>\n `${argInfo.identifier}: ${\n checkAndReturnType(\n ctx,\n `parameter ${argInfo.identifier}`,\n argInfo.type,\n argTypes[i],\n )\n }`\n ).join(', ');\n\n const output = returnType === Void ? '' : `-> ${\n checkAndReturnType(\n ctx,\n 'return type',\n providedArgs.ret?.type,\n returnType,\n )\n }`;\n\n header = `(${input}) ${output}`;\n\n body = replacedImpl.slice(providedArgs.range.end);\n }\n\n ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body}`);\n return snip(id, returnType);\n }\n\n // get data generated by the plugin\n const pluginData = getMetaData(implementation);\n\n if (pluginData?.externals) {\n const missing = Object.fromEntries(\n Object.entries(pluginData.externals).filter(\n ([name]) => !(name in externalMap),\n ),\n );\n\n applyExternals(externalMap, missing);\n }\n\n const ast = pluginData?.ast;\n if (!ast) {\n throw new Error(\n \"Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)\",\n );\n }\n\n // verify all required externals are present\n const missingExternals = ast.externalNames.filter(\n (name) => !(name in externalMap),\n );\n if (missingExternals.length > 0) {\n throw new MissingLinksError(getName(this), missingExternals);\n }\n\n // If an entrypoint implementation has a second argument, it represents the output schema.\n // We look at the identifier chosen by the user and add it to externals.\n const maybeSecondArg = ast.params[1];\n if (\n maybeSecondArg && maybeSecondArg.type === 'i' && fnAttribute !== ''\n ) {\n applyExternals(\n externalMap,\n {\n // biome-ignore lint/style/noNonNullAssertion: entry functions cannot be shellless\n [maybeSecondArg.name]: undecorate(returnType!),\n },\n );\n }\n\n // generate wgsl string\n\n const args: Snippet[] = [];\n const argAliases: [string, Snippet][] = [];\n\n for (const [i, argType] of argTypes.entries()) {\n const astParam = ast.params[i];\n\n switch (astParam?.type) {\n case FuncParameterType.identifier: {\n const rawName = astParam.name;\n const snippet = snip(ctx.makeNameValid(rawName), argType);\n args.push(snippet);\n if (snippet.value !== rawName) {\n argAliases.push([rawName, snippet]);\n }\n break;\n }\n case FuncParameterType.destructuredObject: {\n args.push(snip(`_arg_${i}`, argType));\n argAliases.push(...astParam.props.map(({ name, alias }) =>\n [\n alias,\n snip(\n `_arg_${i}.${name}`,\n (argTypes[i] as WgslStruct)\n .propTypes[name],\n ),\n ] as [string, Snippet]\n ));\n break;\n }\n case undefined:\n args.push(snip(`_arg_${i}`, argType));\n }\n }\n\n const { head, body, returnType: actualReturnType } = ctx.fnToWgsl({\n args,\n argAliases: Object.fromEntries(argAliases),\n returnType,\n body: ast.body,\n externalMap,\n });\n\n ctx.addDeclaration(\n `${fnAttribute}fn ${id}${ctx.resolve(head).value}${\n ctx.resolve(body).value\n }`,\n );\n\n return snip(id, actualReturnType);\n },\n };\n\n // The implementation could have been given a name by a bundler plugin,\n // so we try to transfer it to the core.\n const maybeName = getName(implementation);\n if (maybeName !== undefined) {\n setName(core, maybeName);\n }\n\n return core;\n}\n\nfunction checkAndReturnType(\n ctx: ResolutionCtx,\n name: string,\n wgslType: string | undefined,\n jsType: unknown,\n) {\n const resolvedJsType = ctx.resolve(jsType).value.replace(/\\s/g, '');\n\n if (!wgslType) {\n return resolvedJsType;\n }\n\n const resolvedWgslType = wgslType.replace(/\\s/g, '');\n\n if (resolvedWgslType !== resolvedJsType) {\n throw new Error(\n `Type mismatch between TGPU shell and WGSL code string: ${name}, JS type \"${resolvedJsType}\", WGSL type \"${resolvedWgslType}\".`,\n );\n }\n\n return wgslType;\n}\n","import { isLooseData } from '../../data/dataTypes.ts';\nimport { isWgslStruct } from '../../data/wgslTypes.ts';\nimport { getName, hasTinyestMetadata, setName } from '../../shared/meta.ts';\nimport { isWgsl, type ResolutionCtx } from '../../types.ts';\n\n/**\n * A key-value mapping where keys represent identifiers within shader code,\n * and values can be any type that can be resolved to a code string.\n */\nexport type ExternalMap = Record<string, unknown>;\n\n/**\n * Merges two external maps into one. If a key is present in both maps, the value from the new map is used.\n * If the external value is a namable object, it is given a name if it does not already have one.\n * @param existing - The existing external map.\n * @param newExternals - The new external map.\n */\nexport function applyExternals(\n existing: ExternalMap,\n newExternals: ExternalMap,\n) {\n for (const [key, value] of Object.entries(newExternals)) {\n existing[key] = value;\n\n // Giving name to external value, if it does not already have one.\n if (\n value && (typeof value === 'object' || typeof value === 'function') &&\n getName(value) === undefined\n ) {\n setName(value, key);\n }\n }\n}\n\nexport function addArgTypesToExternals(\n implementation: string,\n argTypes: unknown[],\n applyExternals: (externals: ExternalMap) => void,\n) {\n const argTypeNames = [\n ...implementation.matchAll(/:\\s*(?<arg>.*?)\\s*[,)]/g),\n ].map((found) => (found ? found[1] : undefined));\n\n applyExternals(\n Object.fromEntries(\n argTypes.flatMap((argType, i) => {\n const argTypeName = argTypeNames ? argTypeNames[i] : undefined;\n return isWgslStruct(argType) && argTypeName !== undefined\n ? [[argTypeName, argType]]\n : [];\n }),\n ),\n );\n}\n\nexport function addReturnTypeToExternals(\n implementation: string,\n returnType: unknown,\n applyExternals: (externals: ExternalMap) => void,\n) {\n const matched = implementation.match(/->\\s(?<output>[\\w\\d_]+)\\s{/);\n const outputName = matched ? matched[1]?.trim() : undefined;\n\n if (isWgslStruct(returnType) && outputName && !/\\s/g.test(outputName)) {\n applyExternals({ [outputName]: returnType });\n }\n}\n\nfunction identifierRegex(name: string) {\n return new RegExp(\n `(?<![\\\\w\\\\$_.])${\n name.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }(?![\\\\w\\\\$_])`,\n 'g',\n );\n}\n\n/**\n * Replaces all occurrences of external names in WGSL code with their resolved values.\n * It adds all necessary definitions to the resolution context.\n * @param ctx - The resolution context.\n * @param externalMap - The external map.\n * @param wgsl - The WGSL code.\n *\n * @returns The WGSL code with all external names replaced with their resolved values.\n */\nexport function replaceExternalsInWgsl(\n ctx: ResolutionCtx,\n externalMap: ExternalMap,\n wgsl: string,\n): string {\n return Object.entries(externalMap).reduce((acc, [externalName, external]) => {\n const externalRegex = identifierRegex(externalName);\n if (\n wgsl &&\n externalName !== 'Out' &&\n externalName !== 'In' &&\n !externalRegex.test(wgsl)\n ) {\n console.warn(\n `The external '${externalName}' wasn't used in the resolved template.`,\n );\n // continue anyway, we still might need to resolve the external\n }\n\n if (\n isWgsl(external) || isLooseData(external) || hasTinyestMetadata(external)\n ) {\n return acc.replaceAll(externalRegex, ctx.resolve(external).value);\n }\n\n if (external !== null && typeof external === 'object') {\n const foundProperties = [\n ...wgsl.matchAll(\n new RegExp(\n `${\n externalName.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }\\\\.(?<prop>.*?)(?![\\\\w\\\\$_])`,\n 'g',\n ),\n ),\n ].map((found) => found[1]);\n const uniqueProperties = [...new Set(foundProperties)];\n\n return uniqueProperties.reduce(\n (innerAcc: string, prop) =>\n prop && prop in external\n ? replaceExternalsInWgsl(\n ctx,\n {\n [`${externalName}.${prop}`]:\n external[prop as keyof typeof external],\n },\n innerAcc,\n )\n : innerAcc,\n acc,\n );\n }\n\n console.warn(\n `During resolution, the external '${externalName}' has been omitted. Only primitives, TGPU resources and plain JS objects can be used as externals.`,\n );\n\n return acc;\n }, wgsl);\n}\n"]}
@@ -1,2 +0,0 @@
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 _chunkZYGTVBDHcjs = require('./chunk-ZYGTVBDH.cjs');var _chunkTRE7NUKEcjs = require('./chunk-TRE7NUKE.cjs');function E(t){return u("function",t,"read-write")}function V(t){return u("private",t,"read-write")}function U(t){return u("workgroup",t,"read-write")}function $(t,e="read"){return u("storage",t,e)}function C(t){return u("uniform",t,"read")}function L(t){return u("handle",t,"read")}function u(t,e,r){return{[_chunkTRE7NUKEcjs.a]:!0,type:"ptr",addressSpace:t,inner:e,access:r}}var k=_chunkTRE7NUKEcjs.La.call(void 0, ((t,e)=>e===void 0?r=>b(t,r):b(t,e)),(t,e)=>{if(e===void 0||e.value===void 0){let r=a=>k[_chunkTRE7NUKEcjs.a].gpuImpl(t,a);return r[_chunkTRE7NUKEcjs.a]=!0,_chunkTRE7NUKEcjs.aa.call(void 0, r,_chunkTRE7NUKEcjs.W)}if(typeof e.value!="number")throw new Error(`Cannot create disarray schema with count unknown at compile-time: '${e.value}'`);return _chunkTRE7NUKEcjs.aa.call(void 0, b(t.value,e.value),t.value)},"disarrayOf");function b(t,e){let r=a=>{if(a&&a.length!==e)throw new Error(`Disarray schema of ${e} elements of type ${t.type} called with ${a.length} argument(s).`);return Array.from({length:e},(s,n)=>_chunkTRE7NUKEcjs.qc.call(void 0, t,_optionalChain([a, 'optionalAccess', _ => _[n]])))};if(Object.setPrototypeOf(r,M),r.elementType=t,!Number.isInteger(e)||e<0)throw new Error(`Cannot create disarray schema with invalid element count: ${e}.`);return r.elementCount=e,r}var M={[_chunkTRE7NUKEcjs.a]:!0,type:"disarray",toString(){return`disarrayOf(${this.elementType}, ${this.elementCount})`}};function j(t){let e=r=>Object.fromEntries(Object.entries(t).map(([a,s])=>[a,_chunkTRE7NUKEcjs.qc.call(void 0, s,_optionalChain([r, 'optionalAccess', _2 => _2[a]]))]));return Object.setPrototypeOf(e,F),e.propTypes=t,e}var F={[_chunkTRE7NUKEcjs.a]:!0,type:"unstruct",$name(t){return _chunkTRE7NUKEcjs.k.call(void 0, this,t),this},toString(){return`unstruct:${_nullishCoalesce(_chunkTRE7NUKEcjs.j.call(void 0, this), () => ("<unnamed>"))}`}};function c(t,e){if(t===e)return!0;if(t.type!==e.type)return!1;if(_chunkTRE7NUKEcjs.D.call(void 0, t)&&_chunkTRE7NUKEcjs.D.call(void 0, e)||_chunkTRE7NUKEcjs.S.call(void 0, t)&&_chunkTRE7NUKEcjs.S.call(void 0, e)){let r=t.propTypes,a=e.propTypes,s=Object.keys(r),n=Object.keys(a);if(s.length!==n.length)return!1;for(let i=0;i<s.length;i++){let S=s[i],v=n[i];if(S!==v||!S||!v||!c(r[S],a[v]))return!1}return!0}if(_chunkTRE7NUKEcjs.C.call(void 0, t)&&_chunkTRE7NUKEcjs.C.call(void 0, e)||_chunkTRE7NUKEcjs.R.call(void 0, t)&&_chunkTRE7NUKEcjs.R.call(void 0, e))return t.elementCount===e.elementCount&&c(t.elementType,e.elementType);if(_chunkTRE7NUKEcjs.E.call(void 0, t)&&_chunkTRE7NUKEcjs.E.call(void 0, e))return t.addressSpace===e.addressSpace&&t.access===e.access&&c(t.inner,e.inner);if(_chunkTRE7NUKEcjs.F.call(void 0, t)&&_chunkTRE7NUKEcjs.F.call(void 0, e))return c(t.inner,e.inner);if(_chunkTRE7NUKEcjs.L.call(void 0, t)&&_chunkTRE7NUKEcjs.L.call(void 0, e)||_chunkTRE7NUKEcjs.T.call(void 0, t)&&_chunkTRE7NUKEcjs.T.call(void 0, e)){if(!c(t.inner,e.inner)||t.attribs.length!==e.attribs.length)return!1;let r=n=>{let i=n;return`${i.type}(${(_nullishCoalesce(i.params, () => ([]))).join(",")})`},a=t.attribs.map(r),s=e.attribs.map(r);for(let n=0;n<a.length;n++)if(a[n]!==s[n])return!1}return!0}function p(t,e){let r=t.prototype,a=_chunkZYGTVBDHcjs.ib[e][_chunkTRE7NUKEcjs.a].jsImpl;r[e]=function(s){return a(this,s)}}p(_chunkTRE7NUKEcjs.Wa,"add");p(_chunkTRE7NUKEcjs.Wa,"sub");p(_chunkTRE7NUKEcjs.Wa,"mul");p(_chunkTRE7NUKEcjs.Wa,"div");p(_chunkZYGTVBDHcjs.a,"add");p(_chunkZYGTVBDHcjs.a,"sub");p(_chunkZYGTVBDHcjs.a,"mul");exports.a = E; exports.b = V; exports.c = U; exports.d = $; exports.e = C; exports.f = L; exports.g = k; exports.h = j; exports.i = c;
2
- //# sourceMappingURL=chunk-PRMFGUQT.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-PRMFGUQT.cjs","../src/data/ptr.ts","../src/data/disarray.ts","../src/data/unstruct.ts"],"names":["ptrFn","inner","INTERNAL_createPtr","ptrPrivate","ptrWorkgroup","ptrStorage","access","ptrUniform","ptrHandle","addressSpace","$internal","disarrayOf","createDualImpl","elementType","elementCount","count","cpu_disarrayOf","partial","snip","UnknownData","disarraySchema","elements","_","i","schemaCallWrapper","DisarrayImpl","unstruct","properties","unstructSchema","instanceProps","key","schema","UnstructImpl","label","setName","getName"],"mappings":"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","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-PRMFGUQT.cjs","sourcesContent":[null,"import { $internal } from '../shared/symbols.ts';\nimport type { Access, AddressSpace, Ptr, StorableData } from './wgslTypes.ts';\n\nexport function ptrFn<T extends StorableData>(\n inner: T,\n): Ptr<'function', T, 'read-write'> {\n return INTERNAL_createPtr('function', inner, 'read-write');\n}\n\nexport function ptrPrivate<T extends StorableData>(\n inner: T,\n): Ptr<'private', T, 'read-write'> {\n return INTERNAL_createPtr('private', inner, 'read-write');\n}\n\nexport function ptrWorkgroup<T extends StorableData>(\n inner: T,\n): Ptr<'workgroup', T, 'read-write'> {\n return INTERNAL_createPtr('workgroup', inner, 'read-write');\n}\n\nexport function ptrStorage<\n T extends StorableData,\n TAccess extends 'read' | 'read-write' = 'read',\n>(inner: T, access: TAccess = 'read' as TAccess): Ptr<'storage', T, TAccess> {\n return INTERNAL_createPtr('storage', inner, access);\n}\n\nexport function ptrUniform<T extends StorableData>(\n inner: T,\n): Ptr<'uniform', T, 'read'> {\n return INTERNAL_createPtr('uniform', inner, 'read');\n}\n\nexport function ptrHandle<T extends StorableData>(\n inner: T,\n): Ptr<'handle', T, 'read'> {\n return INTERNAL_createPtr('handle', inner, 'read');\n}\n\nfunction INTERNAL_createPtr<\n TAddressSpace extends AddressSpace,\n TInner extends StorableData,\n TAccess extends Access,\n>(\n addressSpace: TAddressSpace,\n inner: TInner,\n access: TAccess,\n): Ptr<TAddressSpace, TInner, TAccess> {\n return {\n [$internal]: true,\n type: 'ptr',\n addressSpace,\n inner,\n access,\n } as Ptr<TAddressSpace, TInner, TAccess>;\n}\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { UnknownData } from './dataTypes.ts';\nimport { snip, type Snippet } from './snippet.ts';\nimport type { AnyData, Disarray } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { AnyWgslData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\ninterface DisarrayConstructor {\n <TElement extends AnyData>(\n elementType: TElement,\n ): (elementCount: number) => Disarray<TElement>;\n\n <TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n ): Disarray<TElement>;\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 const disarrayOf = createDualImpl(\n // JS implementation\n ((elementType, elementCount) => {\n if (elementCount === undefined) {\n return (count: number) => cpu_disarrayOf(elementType, count);\n }\n return cpu_disarrayOf(elementType, elementCount);\n }) as DisarrayConstructor,\n // CODEGEN implementation\n (elementType, elementCount) => {\n if (elementCount === undefined || elementCount.value === undefined) {\n const partial = (count: Snippet) =>\n disarrayOf[$internal].gpuImpl(elementType, count);\n // Marking so the WGSL generator lets this function through\n partial[$internal] = true;\n\n return snip(partial, UnknownData);\n }\n\n if (typeof elementCount.value !== 'number') {\n throw new Error(\n `Cannot create disarray schema with count unknown at compile-time: '${elementCount.value}'`,\n );\n }\n\n return snip(\n cpu_disarrayOf(elementType.value as AnyWgslData, elementCount.value),\n elementType.value as AnyWgslData,\n );\n },\n 'disarrayOf',\n);\n\nexport function cpu_disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n): Disarray<TElement> {\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","import { getName, setName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Unstruct } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { BaseData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates a loose struct schema that can be used to construct vertex buffers.\n * Describes structs with members of both loose and non-loose types.\n *\n * The order of members matches the passed in properties object.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });\n *\n * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,\n * each entry describing one struct member.\n */\nexport function unstruct<TProps extends Record<string, BaseData>>(\n properties: TProps,\n): Unstruct<TProps> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in corresponding schema calls.\n const unstructSchema = (instanceProps?: TProps) =>\n Object.fromEntries(\n Object.entries(properties).map(([key, schema]) => [\n key,\n schemaCallWrapper(schema as AnyData, instanceProps?.[key]),\n ]),\n );\n Object.setPrototypeOf(unstructSchema, UnstructImpl);\n unstructSchema.propTypes = properties;\n\n return unstructSchema as unknown as Unstruct<TProps>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst UnstructImpl = {\n [$internal]: true,\n type: 'unstruct',\n\n $name(label: string) {\n setName(this, label);\n return this;\n },\n\n toString(): string {\n return `unstruct:${getName(this) ?? '<unnamed>'}`;\n },\n};\n"]}
@@ -1,10 +0,0 @@
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 m="0.8.1";var o=Symbol(`typegpu:${m}:$internal`),kn= exports.b =Symbol(`typegpu:${m}:$gpuValueOf`),me= exports.c =Symbol(`typegpu:${m}:$getNameForward`),He= exports.d =Symbol(`typegpu:${m}:$providing`),qe= exports.e =Symbol(`typegpu:${m}:$ownSnippet`),oe= exports.f =Symbol(`typegpu:${m}:$resolve`),Je= exports.g =Symbol(`typegpu:${m}:$repr`),Fn=Symbol(`typegpu:${m}:$gpuRepr`),Pn=Symbol(`typegpu:${m}:$reprPartial`),Bn=Symbol(`typegpu:${m}:$memIdent`),En=Symbol(`typegpu:${m}:$invalidStorageSchema`),Un=Symbol(`typegpu:${m}:$validUniformSchema`),Nn=Symbol(`typegpu:${m}:$validVertexSchema`),Rn=Symbol(`typegpu:${m}:$invalidSchemaReason`);function u(e){return!!_optionalChain([e, 'optionalAccess', _2 => _2[o]])}var Mn={[o]:!0,type:"void",toString(){return"void"}},Wt=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void","texture_1d","texture_storage_1d","texture_2d","texture_storage_2d","texture_multisampled_2d","texture_depth_2d","texture_depth_multisampled_2d","texture_2d_array","texture_storage_2d_array","texture_depth_2d_array","texture_cube","texture_depth_cube","texture_cube_array","texture_depth_cube_array","texture_3d","texture_storage_3d","texture_external","sampler","sampler_comparison"];function Ee(e){let t=e;return u(t)&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function Ct(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec2")}function Ot(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec3")}function Mt(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec4")}function ae(e){return Ct(e)||Ot(e)||Mt(e)}function Xe(e){let t=e;return u(t)&&typeof _optionalChain([t, 'access', _3 => _3.kind, 'optionalAccess', _4 => _4.startsWith])=="function"&&t.kind.startsWith("mat")}function Lt(e){return u(e)&&_optionalChain([e, 'optionalAccess', _5 => _5.type])==="mat2x2f"}function jt(e){return u(e)&&_optionalChain([e, 'optionalAccess', _6 => _6.type])==="mat3x3f"}function Gt(e){return u(e)&&_optionalChain([e, 'optionalAccess', _7 => _7.type])==="mat4x4f"}function Ue(e){return Lt(e)||jt(e)||Gt(e)}function Ln(e){return Ee(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function C(e){return u(e)&&Wt.includes(_optionalChain([e, 'optionalAccess', _8 => _8.type]))}function fe(e){return u(e)&&_optionalChain([e, 'optionalAccess', _9 => _9.type])==="array"}function we(e){return u(e)&&_optionalChain([e, 'optionalAccess', _10 => _10.type])==="struct"}function jn(e){return u(e)&&_optionalChain([e, 'optionalAccess', _11 => _11.type])==="ptr"}function Gn(e){return u(e)&&_optionalChain([e, 'optionalAccess', _12 => _12.type])==="atomic"}function Te(e){return u(e)&&_optionalChain([e, 'optionalAccess', _13 => _13.type])==="@align"}function ge(e){return u(e)&&_optionalChain([e, 'optionalAccess', _14 => _14.type])==="@size"}function Ze(e){return u(e)&&_optionalChain([e, 'optionalAccess', _15 => _15.type])==="@location"}function Kn(e){return u(e)&&_optionalChain([e, 'optionalAccess', _16 => _16.type])==="@interpolate"}function Ne(e){return u(e)&&_optionalChain([e, 'optionalAccess', _17 => _17.type])==="@builtin"}function _(e){return u(e)&&_optionalChain([e, 'optionalAccess', _18 => _18.type])==="decorated"}function Yn(e){return u(e)&&e.type==="void"}function Qe(e){let t=_optionalChain([e, 'optionalAccess', _19 => _19.type]);return u(e)&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}function Hn(e){let t=_optionalChain([e, 'optionalAccess', _20 => _20.type]);return u(e)&&(t==="f16"||t==="vec2h"||t==="vec3h"||t==="vec4h")}var A=process.env.NODE_ENV==="development",ve=process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>(Yt(e)&&u(e)&&!D(e)&&e.$name(t),e)});var ue=globalThis,Zn= exports.i =(A||ve)&&{get enabled(){return!!ue.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=ue.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function et(e){return!!_optionalChain([e, 'optionalAccess', _21 => _21[me]])}function D(e){return et(e)?D(e[me]):_optionalChain([nt, 'call', _22 => _22(e), 'optionalAccess', _23 => _23.name])}function k(e,t){et(e)&&k(e[me],t),Ht(e,{name:t})}function Yt(e){return!!_optionalChain([e, 'optionalAccess', _24 => _24.$name])}function tt(e){return!!_optionalChain([nt, 'call', _25 => _25(e), 'optionalAccess', _26 => _26.ast])}function nt(e){return ue.__TYPEGPU_META__.get(e)}function Ht(e,t){ue.__TYPEGPU_META__??=new WeakMap;let n=ue.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var rt=["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"],er= exports.p ={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"};function S(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}var qt=["unstruct","disarray","loose-decorated",...rt];function Re(e){return u(e)&&qt.includes(_optionalChain([e, 'optionalAccess', _27 => _27.type]))}function ce(e){return u(e)&&_optionalChain([e, 'optionalAccess', _28 => _28.type])==="disarray"}function ye(e){return u(e)&&_optionalChain([e, 'optionalAccess', _29 => _29.type])==="unstruct"}function I(e){return u(e)&&_optionalChain([e, 'optionalAccess', _30 => _30.type])==="loose-decorated"}function O(e){return _optionalChain([e, 'access', _31 => _31.attribs, 'optionalAccess', _32 => _32.find, 'call', _33 => _33(Te), 'optionalAccess', _34 => _34.params, 'access', _35 => _35[0]])}function at(e){return _optionalChain([e, 'access', _36 => _36.attribs, 'optionalAccess', _37 => _37.find, 'call', _38 => _38(ge), 'optionalAccess', _39 => _39.params, 'access', _40 => _40[0]])}function or(e){return _optionalChain([e, 'access', _41 => _41.attribs, 'optionalAccess', _42 => _42.find, 'call', _43 => _43(Ze), 'optionalAccess', _44 => _44.params, 'access', _45 => _45[0]])}function ar(e){return C(e)||Re(e)}var ut={type:"unknown",toString(){return"unknown"}},it= exports.X =class{constructor(t,n,r){this.name=t;this.lhs=n;this.operator=r}},st= exports.Y =class{constructor(t){this.matrix=t}},ot= exports.Z = (_class =class{constructor(t){;_class.prototype.__init.call(this);this.op=t;k(this,"consoleLog")}__init() {this[o]=!0}}, _class);var We="Invariant failed";function Ve(e,t){if(e)return;if(!A)throw new Error(We);let n=typeof t=="function"?t():t,r=n?`${We}: ${n}`:We;throw new Error(r)}var ct=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${tt(s)?`fn*:${D(s)}`:s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Resolution of the following tree failed:
2
- ${i.join(`
3
- `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},yt= exports.da =class e extends Error{constructor(n,r){let i=r.map(s=>`- ${s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Execution of the following tree failed:
4
- ${i.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)}},lt= exports.ea =class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},pt= exports.fa =class e extends Error{constructor(t){super(`Buffer '${_nullishCoalesce(D(t), () => ("<unnamed>"))}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},ht= exports.ga =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)}},xt= exports.ha =class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>_nullishCoalesce(D(n), () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},dt= exports.ia =class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>_nullishCoalesce(D(n), () => ("<unnamed>"))).join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},mt= exports.ja =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},ft= exports.ka =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},be= exports.la =class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function wt(e){return _optionalChain([e, 'optionalAccess', _46 => _46.resourceType])==="slot"}function Tt(e){return _optionalChain([e, 'optionalAccess', _47 => _47.resourceType])==="derived"}function gt(e){return _optionalChain([e, 'optionalAccess', _48 => _48[He]])!==void 0}function dr(e){return _optionalChain([e, 'optionalAccess', _49 => _49.resourceType])==="accessor"}var ze=class{constructor(t,n){this.value=t;this.dataType=n}};function Ce(e){return e instanceof ze}function gr(e){return Qe(e.dataType)}function x(e,t){if(A&&Ce(e))throw new Error("Cannot nest snippets");return new ze(e,S(t))}var Se= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.type="normal"}}, _class2),vt= exports.ra = (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this.type="codegen"}}, _class3),bt= exports.sa = (_class4 =class{constructor(t,n){;_class4.prototype.__init4.call(this);this.buffers=t;this.vars=n}__init4() {this.type="simulate"}}, _class4);function Jt(e){return!!_optionalChain([e, 'optionalAccess', _50 => _50[oe]])}function Vt(e){return _optionalChain([e, 'optionalAccess', _51 => _51[qe]])}function _r(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Jt(e)||C(e)||wt(e)||Tt(e)||gt(e)}function Ar(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}var Ie=!1;function Fr(e){if(Ie)return e();try{return Ie=!0,e()}finally{Ie=!1}}function Pr(){return Ie}var F;function Br(e,t){if(Ve(F===void 0||F===e,"Cannot nest context providers"),F===e)return t();F=e;try{return t()}finally{F=void 0}}function zt(){return F}var Xt=new Se;function Er(){return _nullishCoalesce(_optionalChain([F, 'optionalAccess', _52 => _52.mode]), () => (Xt))}function Oe(){return _optionalChain([F, 'optionalAccess', _53 => _53.mode, 'access', _54 => _54.type])==="codegen"}function d(e,...t){let n=zt();function r(s){return Ce(s)?n.resolve(s.value,s.dataType).value:s}let i="";for(let s=0;s<e.length;++s){i+=e[s];let p=t[s];Array.isArray(p)?i+=p.filter(y=>y!==void 0).map(r).join(", "):p&&(i+=r(p))}return i}function St(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var Me={rank:Number.POSITIVE_INFINITY,action:"none"};function _e(e,t){let n=S(e),r=S(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"}}return ae(n)&&ae(r)?_e(n.primitive,r.primitive):Ue(n)&&Ue(r)?{rank:0,action:"none"}:Me}function Zt(e,t){let n=S(e),r=S(t);if(n.type==="ptr"&&_e(n.inner,r).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(r.type==="ptr"&&_e(n,r.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let i={f32:0,f16:1,i32:2,u32:3,bool:4};if(n.type in i&&r.type in i){let s=n.type,p=r.type;if(s!==p){let y=i[s];return{rank:i[p]<y?10:20,action:"cast",targetType:r}}}if(n.type==="abstractFloat"){if(r.type==="u32")return{rank:2,action:"cast",targetType:r};if(r.type==="i32")return{rank:1,action:"cast",targetType:r}}return Me}function Qt(e,t,n){let r=_e(e,t);return r.rank<Number.POSITIVE_INFINITY?r:n?Zt(e,t):Me}function It(e,t,n){let r;for(let s of t){let p=[],y=0;for(let l of e){let g=Qt(l,s,n);if(y+=g.rank,g.rank===Number.POSITIVE_INFINITY)break;p.push(g)}y<(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _55 => _55.sum]), () => (Number.POSITIVE_INFINITY)))&&(r={type:s,details:p,sum:y})}if(!r)return;let i=r.details.map((s,p)=>({sourceIndex:p,action:s.action,...s.action==="cast"&&{targetType:s.targetType}}));return{targetType:r.type,actions:i,hasImplicitConversions:i.some(s=>s.action==="cast")}}function _t(e,t){if(e.length===0)return;let n=[...new Set((t||e).map(S))],r=It(e,n,!1);if(r)return r;let i=It(e,n,!0);if(i)return i}function en(e,t,n){if(t.action==="none")return x(e.value,n);switch(t.action){case"ref":return x(d`&${e}`,n);case"deref":return x(d`*${e}`,n);case"cast":return n(e);default:St(t.action,"applyActionToSnippet")}}function Hr(e,t){if(e.some(r=>r.type==="unknown"))return;let n=_t(e,t);if(n)return e.map(()=>n.targetType)}function At(e,t,n=!0){let r=e.map(s=>s.dataType);if(r.some(s=>s.type==="unknown"))return;A&&Array.isArray(t)&&t.length===0&&console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");let i=_t(r,t);if(i)return(ve||A)&&n&&i.hasImplicitConversions&&console.warn(`Implicit conversions from [
6
- ${e.map(s=>` ${s.value}: ${s.dataType.type}`).join(`,
7
- `)}
8
- ] to ${i.targetType.type} are supported, but not recommended.
9
- Consider using explicit conversions instead.`),e.map((s,p)=>{let y=i.actions[p];return Ve(y,"Action should not be undefined"),en(s,y,i.targetType)})}function Dt(e,t,n=!0){if(t===e.dataType)return x(e.value,t);if(e.dataType.type==="unknown")return x(d`${x(e.value,t)}`,t);let r=At([e],[t],n);if(!r)throw new be(`Cannot convert value of type '${e.dataType.type}' to type '${t.type}'`);return r[0]}function qr(e,t){return Object.keys(e.propTypes).map(r=>{let i=t[r];if(!i)throw new Error(`Missing property ${r}`);let s=e.propTypes[r];return _nullishCoalesce(_optionalChain([At, 'call', _56 => _56([i],[s]), 'optionalAccess', _57 => _57[0]]), () => (i))})}function tn(e){return typeof e!="string"&&Vt(e)===void 0}function $t(e,t,n,r="keep"){let i=((...s)=>Oe()?t(...s):e(...s));return k(i,n),i.toString=()=>n,Object.defineProperty(i,o,{value:{jsImpl:e,gpuImpl:t,argConversionHint:r}}),i}var Ae=class extends Error{constructor(t){super(t),this.name=this.constructor.name}};function P(e){let t=(...r)=>{let{argTypes:i,returnType:s}=typeof e.signature=="function"?e.signature(...r.map(l=>l.dataType)):e.signature,y=r.map((l,g)=>Dt(l,i[g],!e.ignoreImplicitCastWarning));if(y.every(l=>tn(l.value))&&typeof e.normalImpl=="function")try{return x(e.normalImpl(...y.map(l=>l.value)),s)}catch(l){if(!(l instanceof Ae))throw l}return x(e.codegenImpl(...y),s)},n=((...r)=>{if(Oe())return t(...r);if(typeof e.normalImpl=="string")throw new Ae(e.normalImpl);return e.normalImpl(...r)});return k(n,e.name),n.toString=()=>e.name,Object.defineProperty(n,o,{value:{jsImpl:e.normalImpl,gpuImpl:t,argConversionHint:"keep"}}),n}var ai={[o]:!0,type:"abstractInt",toString(){return"abstractInt"}},ui= exports.Pa ={[o]:!0,type:"abstractFloat",toString(){return"abstractFloat"}},nn=P({name:"bool",signature:e=>({argTypes:e?[e]:[],returnType:b}),normalImpl(e){return e===void 0?!1:typeof e=="boolean"?e:!!e},codegenImpl:e=>e.dataType.type==="bool"?d`${e}`:d`bool(${e})`}),b= exports.Qa =Object.assign(nn,{type:"bool"}),rn=P({name:"u32",signature:e=>({argTypes:e?[e]:[],returnType:c}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0},codegenImpl:e=>e.dataType.type==="u32"?d`${e}`:d`u32(${e})`}),c= exports.Ra =Object.assign(rn,{type:"u32"}),sn=P({name:"i32",signature:e=>({argTypes:e?[e]:[],returnType:T}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:e|0},codegenImpl:e=>e.dataType.type==="i32"?d`${e}`:d`i32(${e})`}),ci= exports.Sa ={[o]:!0,type:"u16"},T= exports.Ta =Object.assign(sn,{type:"i32"}),on=P({name:"f32",signature:e=>({argTypes:e?[e]:[],returnType:h}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e)},codegenImpl:e=>e.dataType.type==="f32"?d`${e}`:d`f32(${e})`}),h= exports.Ua =Object.assign(on,{type:"f32"}),kt=new ArrayBuffer(4),an=new Float32Array(kt),un=new Uint32Array(kt);function cn(e){an[0]=e;let t=un[0],n=t>>>31&1,r=t>>>23&255,i=t&8388607;return r===255?n<<15|31744|(i?512:0):(r=r-127+15,r<=0?r<-10?n<<15:(i=(i|8388608)>>1-r,i=i+4096>>13,n<<15|i):r>=31||(i=i+4096,i&8388608&&(i=0,++r,r>=31))?n<<15|31744:n<<15|r<<10|i>>13)}function yn(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 ln(e){return yn(cn(e))}var pn=P({name:"f16",signature:e=>({argTypes:e?[e]:[],returnType:$}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:ln(e)},codegenImpl:e=>e.dataType.type==="f16"?d`${e}`:d`f16(${e})`}),$= exports.Va =Object.assign(pn,{type:"f16"});var le=class extends Array{castElement(){return this[o].elementSchema[o].jsImpl}[oe](){let t=this[o].elementSchema;return this.every(n=>!n)?x(`${this.kind}()`,t):this.every(n=>this[0]===n)?x(`${this.kind}(${this[0]})`,t):x(`${this.kind}(${this.join(", ")})`,t)}toString(){return this[oe]().value}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])}},U=class extends le{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)}},N=class extends le{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)}},R=class extends le{constructor(t,n,r,i){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(i, () => (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}},M=class e extends U{get[o](){return{elementSchema:h}}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return Y}get _Vec4(){return Z}},L=class e extends U{get[o](){return{elementSchema:$}}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return H}get _Vec4(){return Q}},j=class e extends U{get[o](){return{elementSchema:T}}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return q}get _Vec4(){return ee}},G=class e extends U{get[o](){return{elementSchema:c}}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return J}get _Vec4(){return te}},K=class e extends U{get[o](){return{elementSchema:b}}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return X}get _Vec4(){return ne}},Y=class e extends N{get[o](){return{elementSchema:h}}get kind(){return"vec3f"}get _Vec2(){return M}get _Vec3(){return e}get _Vec4(){return Z}},H=class e extends N{get[o](){return{elementSchema:$}}get kind(){return"vec3h"}get _Vec2(){return L}get _Vec3(){return e}get _Vec4(){return Q}},q=class e extends N{get[o](){return{elementSchema:T}}get kind(){return"vec3i"}get _Vec2(){return j}get _Vec3(){return e}get _Vec4(){return ee}},J=class e extends N{get[o](){return{elementSchema:c}}get kind(){return"vec3u"}get _Vec2(){return G}get _Vec3(){return e}get _Vec4(){return te}},X=class e extends N{get[o](){return{elementSchema:b}}get kind(){return"vec3<bool>"}get _Vec2(){return K}get _Vec3(){return e}get _Vec4(){return ne}},Z=class e extends R{get[o](){return{elementSchema:h}}get kind(){return"vec4f"}get _Vec2(){return M}get _Vec3(){return Y}get _Vec4(){return e}},Q=class e extends R{get[o](){return{elementSchema:$}}get kind(){return"vec4h"}get _Vec2(){return L}get _Vec3(){return H}get _Vec4(){return e}},ee=class e extends R{get[o](){return{elementSchema:T}}get kind(){return"vec4i"}get _Vec2(){return j}get _Vec3(){return q}get _Vec4(){return e}},te=class e extends R{get[o](){return{elementSchema:c}}get kind(){return"vec4u"}get _Vec2(){return G}get _Vec3(){return J}get _Vec4(){return e}},ne=class e extends R{get[o](){return{elementSchema:b}}get kind(){return"vec4<bool>"}get _Vec2(){return K}get _Vec3(){return X}get _Vec4(){return e}};var B=f(M,h),hn= exports.Ya =f(L,$),pe= exports.Za =f(j,T),he= exports._a =f(G,c),xn= exports.$a =f(K,b),Le= exports.ab =f(Y,h),dn= exports.bb =f(H,$),je= exports.cb =f(q,T),E= exports.db =f(J,c),mn= exports.eb =f(X,b),v= exports.fb =f(Z,h),fn= exports.gb =f(Q,$),xe= exports.hb =f(ee,T),de= exports.ib =f(te,c),wn= exports.jb =f(ne,b),bi= exports.kb ={vec2f:B,vec2h:hn,vec2i:pe,vec2u:he,"vec2<bool>":xn,vec3f:Le,vec3h:dn,vec3i:je,vec3u:E,"vec3<bool>":mn,vec4f:v,vec4h:fn,vec4i:xe,vec4u:de,"vec4<bool>":wn};function f(e,t){let{kind:n,length:r}=new e,s=P({name:n,signature:(...y)=>({argTypes:y.map(l=>{let g=S(l);return ae(g)?g:t}),returnType:p}),normalImpl:(...y)=>{let l=new Array(y.length),g=0;for(let se of y)if(typeof se=="number"||typeof se=="boolean")l[g++]=se;else for(let Be=0;Be<se.length;++Be)l[g++]=se[Be];if(l.length<=1||l.length===r)return new e(...l);throw new Error(`'${n}' constructor called with invalid number of arguments.`)},ignoreImplicitCastWarning:!0,codegenImpl:(...y)=>d`${n}(${y})`}),p=Object.assign(s,{type:n,primitive:t,[Je]:void 0});return p}var a= (_class5 =class{constructor(t){;_class5.prototype.__init5.call(this);this.type=t}__init5() {this[o]=!0}}, _class5),De= exports.nb ={uint8:c,uint8x2:he,uint8x4:de,sint8:T,sint8x2:pe,sint8x4:xe,unorm8:h,unorm8x2:B,unorm8x4:v,snorm8:h,snorm8x2:B,snorm8x4:v,uint16:c,uint16x2:he,uint16x4:de,sint16:T,sint16x2:pe,sint16x4:xe,unorm16:h,unorm16x2:B,unorm16x4:v,snorm16:h,snorm16x2:B,snorm16x4:v,float16:h,float16x2:B,float16x4:v,float32:h,float32x2:B,float32x3:Le,float32x4:v,uint32:c,uint32x2:he,uint32x3:E,uint32x4:de,sint32:T,sint32x2:pe,sint32x3:je,sint32x4:xe,"unorm10-10-10-2":v,"unorm8x4-bgra":v},Ge= exports.ob =new Set(Object.keys(De)),Ai= exports.pb =new a("uint8"),Di= exports.qb =new a("uint8x2"),$i= exports.rb =new a("uint8x4"),ki= exports.sb =new a("sint8"),Fi= exports.tb =new a("sint8x2"),Pi= exports.ub =new a("sint8x4"),Bi= exports.vb =new a("unorm8"),Ei= exports.wb =new a("unorm8x2"),Ui= exports.xb =new a("unorm8x4"),Ni= exports.yb =new a("snorm8"),Ri= exports.zb =new a("snorm8x2"),Wi= exports.Ab =new a("snorm8x4"),Ci= exports.Bb =new a("uint16"),Oi= exports.Cb =new a("uint16x2"),Mi= exports.Db =new a("uint16x4"),Li= exports.Eb =new a("sint16"),ji= exports.Fb =new a("sint16x2"),Gi= exports.Gb =new a("sint16x4"),Ki= exports.Hb =new a("unorm16"),Yi= exports.Ib =new a("unorm16x2"),Hi= exports.Jb =new a("unorm16x4"),qi= exports.Kb =new a("snorm16"),Ji= exports.Lb =new a("snorm16x2"),Xi= exports.Mb =new a("snorm16x4"),Zi= exports.Nb =new a("float16"),Qi= exports.Ob =new a("float16x2"),es= exports.Pb =new a("float16x4"),ts= exports.Qb =new a("float32"),ns= exports.Rb =new a("float32x2"),rs= exports.Sb =new a("float32x3"),is= exports.Tb =new a("float32x4"),ss= exports.Ub =new a("uint32"),os= exports.Vb =new a("uint32x2"),as= exports.Wb =new a("uint32x3"),us= exports.Xb =new a("uint32x4"),cs= exports.Yb =new a("sint32"),ys= exports.Zb =new a("sint32x2"),ls= exports._b =new a("sint32x3"),ps= exports.$b =new a("sint32x4"),hs= exports.ac =new a("unorm10-10-10-2"),xs= exports.bc =new a("unorm8x4-bgra");function ds(e){return u(e)&&Ge.has(_optionalChain([e, 'optionalAccess', _58 => _58.type]))}function Pt(e){let t=String(e);if(t!=="[object Object]")return t;try{return JSON.stringify(e)}catch(n){return console.error("Error parsing JSON:",n),"<invalid json>"}}function Ft(e){return Ee(e)||Xe(e)?e.toString():Array.isArray(e)?`[${e.map(Ft).join(", ")}]`:e&&typeof e=="object"?`{ ${Object.entries(e).map(([t,n])=>`${t}: ${Ft(n)}`).join(", ")} }`:String(e)}var Tn={f32:4,f16:2,i32:4,u32:4,bool:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec2b:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec3b:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,vec4b:16,mat2x2f:8,mat3x3f:16,mat4x4f:16,atomic:4};function gn(e){let t=_optionalChain([e, 'optionalAccess', _59 => _59.type]),n=Tn[t];if(n!==void 0)return n;if(we(e))return Object.values(e.propTypes).map(V).reduce((r,i)=>r>i?r:i);if(fe(e))return V(e.elementType);if(ye(e)){let r=Object.values(e.propTypes)[0];return r?_nullishCoalesce(O(r), () => (1)):1}if(ce(e))return _nullishCoalesce(O(e.elementType), () => (1));if(_(e)||I(e))return _nullishCoalesce(O(e), () => (V(e.inner)));if(Ge.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${Pt(e)}`)}function vn(e){if(ye(e)){let t=Object.values(e.propTypes)[0];return t?re(t):1}return ce(e)?re(e.elementType):I(e)?_nullishCoalesce(O(e), () => (re(e.inner))):_nullishCoalesce(O(e), () => (1))}var Bt=new WeakMap,Et=new WeakMap;function V(e){let t=Bt.get(e);return t===void 0&&(t=gn(e),Bt.set(e,t)),t}function re(e){let t=Et.get(e);return t===void 0&&(t=vn(e),Et.set(e,t)),t}function Vs(e){return V(e)}var ie=(e,t)=>{let n=t-1,r=~n;return(e&n)===0?e:(e&r)+t};var bn={bool:4,f32:4,f16:2,i32:4,u32:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,"vec2<bool>":8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,"vec3<bool>":12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,"vec4<bool>":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 Vn(e){let t=0,n=e.propTypes;for(let r of Object.values(n)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=ie(t,V(r)),t+=z(r),Number.isNaN(t)&&r.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return ie(t,V(e))}function zn(e){let t=0,n=e.propTypes;for(let r of Object.values(n)){let i=re(r);t=ie(t,i),t+=z(r)}return t}function Sn(e){let t=bn[_optionalChain([e, 'optionalAccess', _60 => _60.type])];if(t!==void 0)return t;if(we(e))return Vn(e);if(ye(e))return zn(e);if(fe(e)){if(e.elementCount===0)return Number.NaN;let n=V(e.elementType);return ie(z(e.elementType),n)*e.elementCount}if(ce(e)){let n=re(e.elementType);return ie(z(e.elementType),n)*e.elementCount}if(_(e)||I(e))return _nullishCoalesce(at(e), () => (z(e.inner)));throw new Error(`Cannot determine size of data: ${e}`)}var Ut=new WeakMap;function z(e){let t=Ut.get(e);return t===void 0&&(t=Sn(e),Ut.set(e,t)),t}function $s(e){return z(e)}function W(e,t){return _(e)?new ke(e.inner,[t,...e.attribs]):I(e)?new Fe(e.inner,[t,...e.attribs]):Re(e)?new Fe(e,[t]):new ke(e,[t])}function Ns(e,t){return W(t,{[o]:!0,type:"@align",params:[e]})}function Rs(e,t){return W(t,{[o]:!0,type:"@size",params:[e]})}function Ws(e,t){return W(t,{[o]:!0,type:"@location",params:[e]})}function Cs(e,t){return W(t,{[o]:!0,type:"@interpolate",params:[e]})}function Os(e){if(!In(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=_(e)||I(e)?e.attribs.find(Ne):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 W(e,{[o]:!0,type:"@invariant",params:[]})}function In(e){return(_(e)||I(e))&&e.attribs.find(Ne)!==void 0}function Ms(e){return!_(e)&&!I(e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var $e= (_class6 =class{constructor(t,n){;_class6.prototype.__init6.call(this);this.inner=t;this.attribs=n;let r=_optionalChain([n, 'access', _61 => _61.find, 'call', _62 => _62(Te), 'optionalAccess', _63 => _63.params, 'access', _64 => _64[0]]),i=_optionalChain([n, 'access', _65 => _65.find, 'call', _66 => _66(ge), 'optionalAccess', _67 => _67.params, 'access', _68 => _68[0]]);if(r!==void 0){if(r<=0)throw new Error(`Custom data alignment must be a positive number, got: ${r}.`);if(Math.log2(r)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${r}.`);if(C(this.inner)&&r%V(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${r}, expected multiple of: ${V(this.inner)}.`)}if(i!==void 0){if(i<z(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${i}, expected at least: ${z(this.inner)}.`);if(i<=0)throw new Error(`Custom data size must be a positive number. Got: ${i}.`)}}__init6() {this[o]=!0}}, _class6),ke= (_class7 =class extends $e{constructor(...args) { super(...args); _class7.prototype.__init7.call(this);_class7.prototype.__init8.call(this); }__init7() {this[o]=!0}__init8() {this.type="decorated"}}, _class7),Fe= (_class8 =class extends $e{constructor(...args2) { super(...args2); _class8.prototype.__init9.call(this);_class8.prototype.__init10.call(this); }__init9() {this[o]=!0}__init10() {this.type="loose-decorated"}}, _class8);function Pe(e,t){let n=_optionalChain([e, 'optionalAccess', _69 => _69.type]),r=n in De?De[n]:e;return typeof r!="function"?t:t===void 0?r():r(t)}function qs(e){return Nt(e,!1)}function Js(e){return Nt(e,!0)}function Nt(e,t){let n=r=>Object.fromEntries(Object.entries(e).map(([i,s])=>[i,Pe(s,_optionalChain([r, 'optionalAccess', _70 => _70[i]]))]));return Object.setPrototypeOf(n,_n),n.propTypes=e,Object.defineProperty(n,o,{value:{isAbstruct:t}}),n}var _n={type:"struct",$name(e){return k(this,e),this},toString(){return`struct:${_nullishCoalesce(D(this), () => ("<unnamed>"))}`}};var Ye=$t(((e,t)=>t===void 0?n=>Ke(e,n):Ke(e,t)),(e,t)=>{if(_optionalChain([t, 'optionalAccess', _71 => _71.value])===void 0){let n=r=>Ye[o].gpuImpl(e,r);return n[o]=!0,x(n,ut)}if(typeof t.value!="number")throw new Error(`Cannot create array schema with count unknown at compile-time: '${t.value}'`);return x(Ke(e.value,t.value),e.value)},"arrayOf");function Ke(e,t){let n=r=>{if(r&&r.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${r.length} argument(s).`);return Array.from({length:t},(i,s)=>Pe(e,_optionalChain([r, 'optionalAccess', _72 => _72[s]])))};if(Object.setPrototypeOf(n,An),Number.isNaN(z(e)))throw new Error("Cannot nest runtime sized arrays.");if(n.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return n.elementCount=t,n}var An={[o]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};function w(e,t){return W(e,{[o]:!0,type:"@builtin",params:[t]})}var yo={vertexIndex:w(c,"vertex_index"),instanceIndex:w(c,"instance_index"),position:w(v,"position"),clipDistances:w(Ye(c,8),"clip_distances"),frontFacing:w(b,"front_facing"),fragDepth:w(h,"frag_depth"),sampleIndex:w(c,"sample_index"),sampleMask:w(c,"sample_mask"),localInvocationId:w(E,"local_invocation_id"),localInvocationIndex:w(c,"local_invocation_index"),globalInvocationId:w(E,"global_invocation_id"),workgroupId:w(E,"workgroup_id"),numWorkgroups:w(E,"num_workgroups"),subgroupInvocationId:w(c,"subgroup_invocation_id"),subgroupSize:w(c,"subgroup_size")};exports.a = o; exports.b = kn; exports.c = me; exports.d = He; exports.e = qe; exports.f = oe; exports.g = Je; exports.h = u; exports.i = Zn; exports.j = D; exports.k = k; exports.l = Yt; exports.m = tt; exports.n = nt; exports.o = rt; exports.p = er; exports.q = Mn; exports.r = Ee; exports.s = Ct; exports.t = Ot; exports.u = Mt; exports.v = ae; exports.w = Xe; exports.x = Lt; exports.y = jt; exports.z = Ue; exports.A = Ln; exports.B = C; exports.C = fe; exports.D = we; exports.E = jn; exports.F = Gn; exports.G = Te; exports.H = ge; exports.I = Ze; exports.J = Kn; exports.K = Ne; exports.L = _; exports.M = Yn; exports.N = Qe; exports.O = Hn; exports.P = S; exports.Q = Re; exports.R = ce; exports.S = ye; exports.T = I; exports.U = or; exports.V = ar; exports.W = ut; exports.X = it; exports.Y = st; exports.Z = ot; exports._ = Ce; exports.$ = gr; exports.aa = x; exports.ba = Ve; exports.ca = ct; exports.da = yt; exports.ea = lt; exports.fa = pt; exports.ga = ht; exports.ha = xt; exports.ia = dt; exports.ja = mt; exports.ka = ft; exports.la = be; exports.ma = wt; exports.na = Tt; exports.oa = gt; exports.pa = dr; exports.qa = Se; exports.ra = vt; exports.sa = bt; exports.ta = Jt; exports.ua = Vt; exports.va = _r; exports.wa = Ar; exports.xa = Fr; exports.ya = Pr; exports.za = Br; exports.Aa = zt; exports.Ba = Xt; exports.Ca = Er; exports.Da = Oe; exports.Ea = d; exports.Fa = St; exports.Ga = _t; exports.Ha = Hr; exports.Ia = At; exports.Ja = Dt; exports.Ka = qr; exports.La = $t; exports.Ma = Ae; exports.Na = P; exports.Oa = ai; exports.Pa = ui; exports.Qa = b; exports.Ra = c; exports.Sa = ci; exports.Ta = T; exports.Ua = h; exports.Va = $; exports.Wa = le; exports.Xa = B; exports.Ya = hn; exports.Za = pe; exports._a = he; exports.$a = xn; exports.ab = Le; exports.bb = dn; exports.cb = je; exports.db = E; exports.eb = mn; exports.fb = v; exports.gb = fn; exports.hb = xe; exports.ib = de; exports.jb = wn; exports.kb = bi; exports.lb = Pt; exports.mb = Ft; exports.nb = De; exports.ob = Ge; exports.pb = Ai; exports.qb = Di; exports.rb = $i; exports.sb = ki; exports.tb = Fi; exports.ub = Pi; exports.vb = Bi; exports.wb = Ei; exports.xb = Ui; exports.yb = Ni; exports.zb = Ri; exports.Ab = Wi; exports.Bb = Ci; exports.Cb = Oi; exports.Db = Mi; exports.Eb = Li; exports.Fb = ji; exports.Gb = Gi; exports.Hb = Ki; exports.Ib = Yi; exports.Jb = Hi; exports.Kb = qi; exports.Lb = Ji; exports.Mb = Xi; exports.Nb = Zi; exports.Ob = Qi; exports.Pb = es; exports.Qb = ts; exports.Rb = ns; exports.Sb = rs; exports.Tb = is; exports.Ub = ss; exports.Vb = os; exports.Wb = as; exports.Xb = us; exports.Yb = cs; exports.Zb = ys; exports._b = ls; exports.$b = ps; exports.ac = hs; exports.bc = xs; exports.cc = ds; exports.dc = V; exports.ec = re; exports.fc = Vs; exports.gc = ie; exports.hc = z; exports.ic = $s; exports.jc = Ns; exports.kc = Rs; exports.lc = Ws; exports.mc = Cs; exports.nc = Os; exports.oc = In; exports.pc = Ms; exports.qc = Pe; exports.rc = qs; exports.sc = Js; exports.tc = Ye; exports.uc = yo;
10
- //# sourceMappingURL=chunk-TRE7NUKE.cjs.map