typegpu 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tgsl/wgslGenerator.ts","../src/mathUtils.ts","../src/data/alignmentOf.ts","../src/data/sizeOf.ts","../src/data/array.ts","../src/data/disarray.ts","../src/data/unstruct.ts","../src/data/atomic.ts","../src/data/attributes.ts","../src/builtin.ts","../src/data/index.ts"],"sourcesContent":["import * as tinyest from 'tinyest';\nimport { arrayOf } from '../data/array.ts';\nimport {\n type AnyData,\n InfixDispatch,\n isData,\n isLooseData,\n UnknownData,\n} from '../data/dataTypes.ts';\nimport { isSnippet, snip, type Snippet } from '../data/snippet.ts';\nimport { abstractInt, bool, u32 } from '../data/numeric.ts';\nimport * as wgsl from '../data/wgslTypes.ts';\nimport { ResolutionError, WgslTypeError } from '../errors.ts';\nimport { getName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { type FnArgsConversionHint, isMarkedInternal } from '../types.ts';\nimport {\n coerceToSnippet,\n concretize,\n convertStructValues,\n convertToCommonType,\n type GenerationCtx,\n getTypeForIndexAccess,\n getTypeForPropAccess,\n numericLiteralToSnippet,\n parseNumericString,\n tryConvertSnippet,\n} from './generationHelpers.ts';\nimport { add, div, mul, sub } from '../std/operators.ts';\n\nconst { NodeTypeCatalog: NODE } = tinyest;\n\nconst parenthesizedOps = [\n '==',\n '!=',\n '<',\n '<=',\n '>',\n '>=',\n '<<',\n '>>',\n '+',\n '-',\n '*',\n '/',\n '%',\n '|',\n '^',\n '&',\n '&&',\n '||',\n];\n\nconst binaryLogicalOps = ['&&', '||', '==', '!=', '<', '<=', '>', '>='];\n\nconst infixKinds = [\n 'vec2f',\n 'vec3f',\n 'vec4f',\n 'vec2h',\n 'vec3h',\n 'vec4h',\n 'vec2i',\n 'vec3i',\n 'vec4i',\n 'vec2u',\n 'vec3u',\n 'vec4u',\n 'mat2x2f',\n 'mat3x3f',\n 'mat4x4f',\n];\n\nexport const infixOperators = {\n add,\n sub,\n mul,\n div,\n} as const;\n\nexport type InfixOperator = keyof typeof infixOperators;\n\ntype Operator =\n | tinyest.BinaryOperator\n | tinyest.AssignmentOperator\n | tinyest.LogicalOperator\n | tinyest.UnaryOperator;\n\nfunction operatorToType<\n TL extends AnyData | UnknownData,\n TR extends AnyData | UnknownData,\n>(lhs: TL, op: Operator, rhs?: TR): TL | TR | wgsl.Bool {\n if (!rhs) {\n if (op === '!' || op === '~') {\n return bool;\n }\n\n return lhs;\n }\n\n if (binaryLogicalOps.includes(op)) {\n return bool;\n }\n\n if (op === '=') {\n return rhs;\n }\n\n return lhs;\n}\n\nfunction assertExhaustive(value: never): never {\n throw new Error(\n `'${JSON.stringify(value)}' was not handled by the WGSL generator.`,\n );\n}\n\nexport function generateBlock(\n ctx: GenerationCtx,\n [_, statements]: tinyest.Block,\n): string {\n ctx.pushBlockScope();\n try {\n ctx.indent();\n const body = statements.map((statement) =>\n generateStatement(ctx, statement)\n ).join('\\n');\n ctx.dedent();\n return `{\n${body}\n${ctx.pre}}`;\n } finally {\n ctx.popBlockScope();\n }\n}\n\nexport function registerBlockVariable(\n ctx: GenerationCtx,\n id: string,\n dataType: wgsl.AnyWgslData | UnknownData,\n): Snippet {\n return ctx.defineVariable(id, dataType);\n}\n\nexport function generateIdentifier(ctx: GenerationCtx, id: string): Snippet {\n const res = ctx.getById(id);\n if (!res) {\n throw new Error(`Identifier ${id} not found`);\n }\n\n return res;\n}\n\n/**\n * A wrapper for `generateExpression` that updates `ctx.expectedType`\n * and tries to convert the result when it does not match the expected type.\n */\nexport function generateTypedExpression(\n ctx: GenerationCtx,\n expression: tinyest.Expression,\n expectedType: AnyData,\n) {\n const prevExpectedType = ctx.expectedType;\n ctx.expectedType = expectedType;\n\n try {\n const result = generateExpression(ctx, expression);\n return tryConvertSnippet(ctx, result, expectedType);\n } finally {\n ctx.expectedType = prevExpectedType;\n }\n}\n\nconst opCodeToCodegen = {\n '+': add[$internal].gpuImpl,\n '-': sub[$internal].gpuImpl,\n '*': mul[$internal].gpuImpl,\n '/': div[$internal].gpuImpl,\n} satisfies Partial<\n Record<tinyest.BinaryOperator, (...args: never[]) => unknown>\n>;\n\nexport function generateExpression(\n ctx: GenerationCtx,\n expression: tinyest.Expression,\n): Snippet {\n if (typeof expression === 'string') {\n return generateIdentifier(ctx, expression);\n }\n\n if (typeof expression === 'boolean') {\n return snip(expression ? 'true' : 'false', bool);\n }\n\n if (\n expression[0] === NODE.logicalExpr ||\n expression[0] === NODE.binaryExpr ||\n expression[0] === NODE.assignmentExpr\n ) {\n // Logical/Binary/Assignment Expression\n const [_, lhs, op, rhs] = expression;\n const lhsExpr = generateExpression(ctx, lhs);\n const rhsExpr = generateExpression(ctx, rhs);\n\n const codegen = opCodeToCodegen[op as keyof typeof opCodeToCodegen];\n if (codegen) {\n return codegen(lhsExpr, rhsExpr);\n }\n\n const forcedType = expression[0] === NODE.assignmentExpr\n ? lhsExpr.dataType.type === 'ptr'\n ? [lhsExpr.dataType.inner as AnyData]\n : [lhsExpr.dataType as AnyData]\n : undefined;\n\n const converted = convertToCommonType({\n ctx,\n values: [lhsExpr, rhsExpr] as const,\n restrictTo: forcedType,\n });\n const [convLhs, convRhs] = converted || [lhsExpr, rhsExpr];\n\n const lhsStr = ctx.resolve(convLhs.value);\n const rhsStr = ctx.resolve(convRhs.value);\n const type = operatorToType(convLhs.dataType, op, convRhs.dataType);\n\n return snip(\n parenthesizedOps.includes(op)\n ? `(${lhsStr} ${op} ${rhsStr})`\n : `${lhsStr} ${op} ${rhsStr}`,\n type,\n );\n }\n\n if (expression[0] === NODE.postUpdate) {\n // Post-Update Expression\n const [_, op, arg] = expression;\n const argExpr = generateExpression(ctx, arg);\n const argStr = ctx.resolve(argExpr.value);\n\n return snip(`${argStr}${op}`, argExpr.dataType);\n }\n\n if (expression[0] === NODE.unaryExpr) {\n // Unary Expression\n const [_, op, arg] = expression;\n const argExpr = generateExpression(ctx, arg);\n const argStr = ctx.resolve(argExpr.value);\n\n const type = operatorToType(argExpr.dataType, op);\n return snip(`${op}${argStr}`, type);\n }\n\n if (expression[0] === NODE.memberAccess) {\n // Member Access\n const [_, targetNode, property] = expression;\n const target = generateExpression(ctx, targetNode);\n\n if (\n infixKinds.includes(target.dataType.type) &&\n property in infixOperators\n ) {\n return {\n value: new InfixDispatch(\n property,\n target,\n infixOperators[property as InfixOperator][$internal].gpuImpl,\n ),\n dataType: UnknownData,\n };\n }\n\n if (target.dataType.type === 'unknown') {\n // No idea what the type is, so we act on the snippet's value and try to guess\n\n // biome-ignore lint/suspicious/noExplicitAny: we're inspecting the value, and it could be any value\n const propValue = (target.value as any)[property];\n\n // We try to extract any type information based on the prop's value\n return coerceToSnippet(propValue);\n }\n\n if (wgsl.isPtr(target.dataType)) {\n return snip(\n `(*${ctx.resolve(target.value)}).${property}`,\n getTypeForPropAccess(target.dataType.inner as AnyData, property),\n );\n }\n\n if (wgsl.isWgslArray(target.dataType) && property === 'length') {\n if (target.dataType.elementCount === 0) {\n // Dynamically-sized array\n return snip(`arrayLength(&${ctx.resolve(target.value)})`, u32);\n }\n\n return snip(String(target.dataType.elementCount), abstractInt);\n }\n\n if (wgsl.isMat(target.dataType) && property === 'columns') {\n return snip(target.value, target.dataType);\n }\n\n if (\n wgsl.isVec(target.dataType) && wgsl.isVecInstance(target.value)\n ) {\n // We're operating on a vector that's known at resolution time\n // biome-ignore lint/suspicious/noExplicitAny: it's probably a swizzle\n return coerceToSnippet((target.value as any)[property]);\n }\n\n return snip(\n `${ctx.resolve(target.value)}.${property}`,\n getTypeForPropAccess(target.dataType, property),\n );\n }\n\n if (expression[0] === NODE.indexAccess) {\n // Index Access\n const [_, targetNode, propertyNode] = expression;\n const target = generateExpression(ctx, targetNode);\n const property = generateExpression(ctx, propertyNode);\n const targetStr = ctx.resolve(target.value);\n const propertyStr = ctx.resolve(property.value);\n\n if (target.dataType.type === 'unknown') {\n // No idea what the type is, so we act on the snippet's value and try to guess\n\n if (\n Array.isArray(propertyNode) && propertyNode[0] === NODE.numericLiteral\n ) {\n return coerceToSnippet(\n // biome-ignore lint/suspicious/noExplicitAny: we're inspecting the value, and it could be any value\n (target.value as any)[propertyNode[1] as number],\n );\n }\n\n throw new Error(\n `Cannot index value ${targetStr} of unknown type with index ${propertyStr}`,\n );\n }\n\n if (wgsl.isPtr(target.dataType)) {\n return snip(\n `(*${targetStr})[${propertyStr}]`,\n getTypeForIndexAccess(target.dataType.inner as AnyData),\n );\n }\n\n return snip(\n `${targetStr}[${propertyStr}]`,\n isData(target.dataType)\n ? getTypeForIndexAccess(target.dataType)\n : UnknownData,\n );\n }\n\n if (expression[0] === NODE.numericLiteral) {\n // Numeric Literal\n const type = typeof expression[1] === 'string'\n ? numericLiteralToSnippet(parseNumericString(expression[1]))\n : numericLiteralToSnippet(expression[1]);\n if (!type) {\n throw new Error(`Invalid numeric literal ${expression[1]}`);\n }\n return type;\n }\n\n if (expression[0] === NODE.call) {\n // Function Call\n const [_, calleeNode, argNodes] = expression;\n const callee = generateExpression(ctx, calleeNode);\n\n if (wgsl.isWgslStruct(callee.value) || wgsl.isWgslArray(callee.value)) {\n // Struct/array schema call.\n if (argNodes.length > 1) {\n throw new WgslTypeError(\n 'Array and struct schemas should always be called with at most 1 argument',\n );\n }\n\n // No arguments `Struct()`, resolve struct name and return.\n if (!argNodes[0]) {\n return snip(\n `${ctx.resolve(callee.value)}()`,\n /* the schema becomes the data type */ callee.value,\n );\n }\n\n const arg = generateTypedExpression(ctx, argNodes[0], callee.value);\n\n // Either `Struct({ x: 1, y: 2 })`, or `Struct(otherStruct)`.\n // In both cases, we just let the argument resolve everything.\n return snip(ctx.resolve(arg.value, callee.value), callee.value);\n }\n\n if (callee.value instanceof InfixDispatch) {\n // Infix operator dispatch.\n if (!argNodes[0]) {\n throw new WgslTypeError(\n `An infix operator '${callee.value.name}' was called without any arguments`,\n );\n }\n const rhs = generateExpression(ctx, argNodes[0]);\n return callee.value.operator(callee.value.lhs, rhs);\n }\n\n if (!isMarkedInternal(callee.value)) {\n throw new Error(\n `Function ${String(callee.value)} ${\n getName(callee.value)\n } has not been created using TypeGPU APIs. Did you mean to wrap the function with tgpu.fn(args, return)(...) ?`,\n );\n }\n\n // Other, including tgsl functions, std and vector/matrix schema calls.\n\n const argConversionHint = callee.value[$internal]\n ?.argConversionHint as FnArgsConversionHint ?? 'keep';\n try {\n let convertedArguments: Snippet[];\n\n if (Array.isArray(argConversionHint)) {\n // The hint is an array of schemas.\n convertedArguments = argNodes.map((arg, i) => {\n const argType = argConversionHint[i];\n if (!argType) {\n throw new WgslTypeError(\n `Function '${\n getName(callee.value)\n }' was called with too many arguments`,\n );\n }\n return generateTypedExpression(ctx, arg, argType);\n });\n } else {\n const snippets = argNodes.map((arg) => generateExpression(ctx, arg));\n\n if (argConversionHint === 'keep') {\n // The hint tells us to do nothing.\n convertedArguments = snippets;\n } else if (argConversionHint === 'unify') {\n // The hint tells us to unify the types.\n convertedArguments = convertToCommonType({ ctx, values: snippets }) ??\n snippets;\n } else {\n // The hint is a function that converts the arguments.\n convertedArguments = argConversionHint(...snippets)\n .map((type, i) => [type, snippets[i] as Snippet] as const)\n .map(([type, sn]) => tryConvertSnippet(ctx, sn, type));\n }\n }\n // Assuming that `callee` is callable\n const fnRes =\n (callee.value as unknown as (...args: unknown[]) => unknown)(\n ...convertedArguments,\n );\n\n if (!isSnippet(fnRes)) {\n throw new Error(\n 'Functions running in codegen mode must return snippets',\n );\n }\n return fnRes;\n } catch (error) {\n throw new ResolutionError(error, [{\n toString: () => getName(callee.value),\n }]);\n }\n }\n\n if (expression[0] === NODE.objectExpr) {\n // Object Literal\n const obj = expression[1];\n\n const structType = ctx.expectedType;\n\n if (!structType || !wgsl.isWgslStruct(structType)) {\n throw new WgslTypeError(\n `No target type could be inferred for object with keys [${\n Object.keys(obj).join(', ')\n }], please wrap the object in the corresponding schema.`,\n );\n }\n\n const entries = Object.fromEntries(\n Object.entries(structType.propTypes).map(([key, value]) => {\n const val = obj[key];\n if (val === undefined) {\n throw new WgslTypeError(\n `Missing property ${key} in object literal for struct ${structType}`,\n );\n }\n const result = generateTypedExpression(ctx, val, value as AnyData);\n return [key, result];\n }),\n );\n\n const convertedValues = convertStructValues(ctx, structType, entries);\n\n return snip(\n `${ctx.resolve(structType)}(${\n convertedValues.map((v) => ctx.resolve(v.value)).join(', ')\n })`,\n structType,\n );\n }\n\n if (expression[0] === NODE.arrayExpr) {\n const [_, valueNodes] = expression;\n // Array Expression\n const arrType = ctx.expectedType;\n let elemType: AnyData;\n let values: Snippet[];\n\n if (wgsl.isWgslArray(arrType)) {\n elemType = arrType.elementType as AnyData;\n // The array is typed, so its elements should be as well.\n values = valueNodes.map((value) =>\n generateTypedExpression(ctx, value, elemType)\n );\n // Since it's an expected type, we enforce the length\n if (values.length !== arrType.elementCount) {\n throw new WgslTypeError(\n `Cannot create value of type '${arrType}' from an array of length: ${values.length}`,\n );\n }\n } else {\n // The array is not typed, so we try to guess the types.\n const valuesSnippets = valueNodes.map((value) =>\n generateExpression(ctx, value as tinyest.Expression)\n );\n\n if (valuesSnippets.length === 0) {\n throw new WgslTypeError(\n 'Cannot infer the type of an empty array literal.',\n );\n }\n\n const maybeValues = convertToCommonType({ ctx, values: valuesSnippets });\n if (!maybeValues) {\n throw new WgslTypeError(\n 'The given values cannot be automatically converted to a common type. Consider wrapping the array in an appropriate schema',\n );\n }\n\n values = maybeValues;\n elemType = concretize(values[0]?.dataType as wgsl.AnyWgslData);\n }\n\n const arrayType = `array<${ctx.resolve(elemType)}, ${values.length}>`;\n const arrayValues = values.map((sn) => ctx.resolve(sn.value));\n\n return snip(\n `${arrayType}(${arrayValues.join(', ')})`,\n arrayOf(\n elemType as wgsl.AnyWgslData,\n values.length,\n ) as wgsl.AnyWgslData,\n );\n }\n\n if (expression[0] === NODE.stringLiteral) {\n throw new Error('Cannot use string literals in TGSL.');\n }\n\n if (expression[0] === NODE.preUpdate) {\n throw new Error('Cannot use pre-updates in TGSL.');\n }\n\n assertExhaustive(expression);\n}\n\nfunction blockifySingleStatement(statement: tinyest.Statement): tinyest.Block {\n return typeof statement !== 'object' ||\n statement[0] !== NODE.block\n ? [NODE.block, [statement]]\n : statement;\n}\n\nexport function generateStatement(\n ctx: GenerationCtx,\n statement: tinyest.Statement,\n): string {\n if (typeof statement === 'string') {\n return `${ctx.pre}${\n ctx.resolve(generateIdentifier(ctx, statement).value)\n };`;\n }\n\n if (typeof statement === 'boolean') {\n return `${ctx.pre}${statement ? 'true' : 'false'};`;\n }\n\n if (statement[0] === NODE.return) {\n const returnNode = statement[1];\n\n const returnValue = returnNode !== undefined\n ? ctx.resolve(\n generateTypedExpression(\n ctx,\n returnNode,\n ctx.topFunctionReturnType,\n ).value,\n )\n : undefined;\n\n return returnValue\n ? `${ctx.pre}return ${returnValue};`\n : `${ctx.pre}return;`;\n }\n\n if (statement[0] === NODE.if) {\n const [_, cond, cons, alt] = statement;\n const condition = ctx.resolve(\n generateTypedExpression(ctx, cond, bool).value,\n );\n\n const consequent = generateBlock(ctx, blockifySingleStatement(cons));\n const alternate = alt\n ? generateBlock(ctx, blockifySingleStatement(alt))\n : undefined;\n\n if (!alternate) {\n return `${ctx.pre}if (${condition}) ${consequent}`;\n }\n\n return `\\\n${ctx.pre}if (${condition}) ${consequent}\n${ctx.pre}else ${alternate}`;\n }\n\n if (statement[0] === NODE.let || statement[0] === NODE.const) {\n const [_, rawId, rawValue] = statement;\n const eq = rawValue !== undefined\n ? generateExpression(ctx, rawValue)\n : undefined;\n\n if (!eq) {\n throw new Error(\n `Cannot create variable '${rawId}' without an initial value.`,\n );\n }\n\n if (isLooseData(eq.dataType)) {\n throw new Error(\n `Cannot create variable '${rawId}' with loose data type.`,\n );\n }\n\n registerBlockVariable(\n ctx,\n rawId,\n concretize(eq.dataType as wgsl.AnyWgslData),\n );\n const id = ctx.resolve(generateIdentifier(ctx, rawId).value);\n\n return `${ctx.pre}var ${id} = ${ctx.resolve(eq.value)};`;\n }\n\n if (statement[0] === NODE.block) {\n return generateBlock(ctx, statement);\n }\n\n if (statement[0] === NODE.for) {\n const [_, init, condition, update, body] = statement;\n\n const [initStatement, conditionExpr, updateStatement] = ctx\n .withResetIndentLevel(\n () => [\n init ? generateStatement(ctx, init) : undefined,\n condition ? generateExpression(ctx, condition) : undefined,\n update ? generateStatement(ctx, update) : undefined,\n ],\n );\n\n const initStr = initStatement ? initStatement.slice(0, -1) : '';\n\n const condSnippet = condition\n ? generateTypedExpression(ctx, condition, bool)\n : undefined;\n const conditionStr = condSnippet ? ctx.resolve(condSnippet.value) : '';\n\n const updateStr = updateStatement ? updateStatement.slice(0, -1) : '';\n\n const bodyStr = generateBlock(ctx, blockifySingleStatement(body));\n return `${ctx.pre}for (${initStr}; ${conditionStr}; ${updateStr}) ${bodyStr}`;\n }\n\n if (statement[0] === NODE.while) {\n const [_, condition, body] = statement;\n const condSnippet = generateTypedExpression(ctx, condition, bool);\n const conditionStr = ctx.resolve(condSnippet.value);\n\n const bodyStr = generateBlock(ctx, blockifySingleStatement(body));\n return `${ctx.pre}while (${conditionStr}) ${bodyStr}`;\n }\n\n if (statement[0] === NODE.continue) {\n return `${ctx.pre}continue;`;\n }\n\n if (statement[0] === NODE.break) {\n return `${ctx.pre}break;`;\n }\n\n return `${ctx.pre}${ctx.resolve(generateExpression(ctx, statement).value)};`;\n}\n\nexport function generateFunction(\n ctx: GenerationCtx,\n body: tinyest.Block,\n): string {\n return generateBlock(ctx, body);\n}\n","/**\n * @param value\n * @param modulo has to be power of 2\n */\nexport const roundUp = (value: number, modulo: number) => {\n const bitMask = modulo - 1;\n const invBitMask = ~bitMask;\n return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;\n};\n","import {\n type AnyData,\n getCustomAlignment,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nimport { packedFormats } from './vertexFormatData.ts';\nimport {\n type BaseData,\n isDecorated,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes.ts';\n\nconst knownAlignmentMap: Record<string, number> = {\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n u16: 2,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n vec3f: 16,\n vec3h: 8,\n vec3i: 16,\n vec3u: 16,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n mat2x2f: 8,\n mat3x3f: 16,\n mat4x4f: 16,\n atomic: 4,\n};\n\nfunction computeAlignment(data: object): number {\n const dataType = (data as BaseData)?.type;\n const knownAlignment = knownAlignmentMap[dataType];\n if (knownAlignment !== undefined) {\n return knownAlignment;\n }\n\n if (isWgslStruct(data)) {\n return Object.values(data.propTypes as Record<string, BaseData>)\n .map(alignmentOf)\n .reduce((a, b) => (a > b ? a : b));\n }\n\n if (isWgslArray(data)) {\n return alignmentOf(data.elementType);\n }\n\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp =\n Object.values(data.propTypes as Record<string, BaseData>)[0];\n return firstProp ? (getCustomAlignment(firstProp) ?? 1) : 1;\n }\n\n if (isDisarray(data)) {\n return getCustomAlignment(data.elementType) ?? 1;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? alignmentOf(data.inner);\n }\n\n if (packedFormats.has(dataType)) {\n return 1;\n }\n\n throw new Error(\n `Cannot determine alignment of data: ${JSON.stringify(data)}`,\n );\n}\n\nfunction computeCustomAlignment(data: BaseData): number {\n if (isUnstruct(data)) {\n // A loose struct is aligned to its first property.\n const firstProp =\n Object.values(data.propTypes as Record<string, BaseData>)[0];\n return firstProp ? customAlignmentOf(firstProp) : 1;\n }\n\n if (isDisarray(data)) {\n return customAlignmentOf(data.elementType);\n }\n\n if (isLooseDecorated(data)) {\n return getCustomAlignment(data) ?? customAlignmentOf(data.inner);\n }\n\n return getCustomAlignment(data) ?? 1;\n}\n\n/**\n * Since alignments can be inferred from data types, they are not stored on them.\n * Instead, this weak map acts as an extended property of those data types.\n */\nconst cachedAlignments = new WeakMap<object, number>();\n\nconst cachedCustomAlignments = new WeakMap<object, number>();\n\nexport function alignmentOf(data: BaseData): number {\n let alignment = cachedAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeAlignment(data);\n cachedAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\nexport function customAlignmentOf(data: BaseData): number {\n let alignment = cachedCustomAlignments.get(data);\n if (alignment === undefined) {\n alignment = computeCustomAlignment(data);\n cachedCustomAlignments.set(data, alignment);\n }\n\n return alignment;\n}\n\n/**\n * Returns the alignment (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_alignmentOf(schema: AnyData): number {\n return alignmentOf(schema);\n}\n","import { roundUp } from '../mathUtils.ts';\nimport { alignmentOf, customAlignmentOf } from './alignmentOf.ts';\nimport type { AnyData, LooseTypeLiteral, Unstruct } from './dataTypes.ts';\nimport {\n getCustomSize,\n isDisarray,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nimport type { BaseData, WgslStruct, WgslTypeLiteral } from './wgslTypes.ts';\nimport { isDecorated, isWgslArray, isWgslStruct } from './wgslTypes.ts';\n\nconst knownSizesMap: Record<string, number> = {\n f32: 4,\n f16: 2,\n i32: 4,\n u32: 4,\n u16: 2,\n vec2f: 8,\n vec2h: 4,\n vec2i: 8,\n vec2u: 8,\n vec3f: 12,\n vec3h: 6,\n vec3i: 12,\n vec3u: 12,\n vec4f: 16,\n vec4h: 8,\n vec4i: 16,\n vec4u: 16,\n mat2x2f: 16,\n mat3x3f: 48,\n mat4x4f: 64,\n uint8: 1,\n uint8x2: 2,\n uint8x4: 4,\n sint8: 1,\n sint8x2: 2,\n sint8x4: 4,\n unorm8: 1,\n unorm8x2: 2,\n unorm8x4: 4,\n snorm8: 1,\n snorm8x2: 2,\n snorm8x4: 4,\n uint16: 2,\n uint16x2: 4,\n uint16x4: 8,\n sint16: 2,\n sint16x2: 4,\n sint16x4: 8,\n unorm16: 2,\n unorm16x2: 4,\n unorm16x4: 8,\n snorm16: 2,\n snorm16x2: 4,\n snorm16x4: 8,\n float16: 2,\n float16x2: 4,\n float16x4: 8,\n float32: 4,\n float32x2: 8,\n float32x3: 12,\n float32x4: 16,\n uint32: 4,\n uint32x2: 8,\n uint32x3: 12,\n uint32x4: 16,\n sint32: 4,\n sint32x2: 8,\n sint32x3: 12,\n sint32x4: 16,\n 'unorm10-10-10-2': 4,\n 'unorm8x4-bgra': 4,\n atomic: 4,\n} satisfies Partial<Record<WgslTypeLiteral | LooseTypeLiteral, number>>;\n\nfunction sizeOfStruct(struct: WgslStruct) {\n let size = 0;\n const propTypes = struct.propTypes as Record<string, BaseData>;\n for (const property of Object.values(propTypes)) {\n if (Number.isNaN(size)) {\n throw new Error('Only the last property of a struct can be unbounded');\n }\n\n size = roundUp(size, alignmentOf(property));\n size += sizeOf(property);\n\n if (Number.isNaN(size) && property.type !== 'array') {\n throw new Error('Cannot nest unbounded struct within another struct');\n }\n }\n\n return roundUp(size, alignmentOf(struct));\n}\n\nfunction sizeOfUnstruct(data: Unstruct) {\n let size = 0;\n\n const propTypes = data.propTypes as Record<string, BaseData>;\n for (const property of Object.values(propTypes)) {\n const alignment = customAlignmentOf(property);\n size = roundUp(size, alignment);\n size += sizeOf(property);\n }\n\n return size;\n}\n\nfunction computeSize(data: object): number {\n const knownSize = knownSizesMap[(data as BaseData)?.type];\n\n if (knownSize !== undefined) {\n return knownSize;\n }\n\n if (isWgslStruct(data)) {\n return sizeOfStruct(data);\n }\n\n if (isUnstruct(data)) {\n return sizeOfUnstruct(data);\n }\n\n if (isWgslArray(data)) {\n if (data.elementCount === 0) {\n return Number.NaN;\n }\n\n const alignment = alignmentOf(data.elementType);\n const stride = roundUp(sizeOf(data.elementType), alignment);\n return stride * data.elementCount;\n }\n\n if (isDisarray(data)) {\n const alignment = customAlignmentOf(data.elementType);\n const stride = roundUp(sizeOf(data.elementType), alignment);\n return stride * data.elementCount;\n }\n\n if (isDecorated(data) || isLooseDecorated(data)) {\n return getCustomSize(data) ?? sizeOf(data.inner);\n }\n\n throw new Error(`Cannot determine size of data: ${data}`);\n}\n\n/**\n * Since sizes can be inferred from data types, they are not stored on them.\n * Instead, this weak map acts as an extended property of those data types.\n */\nconst cachedSizes = new WeakMap<BaseData, number>();\n\nexport function sizeOf(schema: BaseData): number {\n let size = cachedSizes.get(schema);\n\n if (size === undefined) {\n size = computeSize(schema);\n cachedSizes.set(schema, size);\n }\n\n return size;\n}\n\n/**\n * Returns the size (in bytes) of data represented by the `schema`.\n */\nexport function PUBLIC_sizeOf(schema: AnyData): number {\n return sizeOf(schema);\n}\n","import { $internal } from '../shared/symbols.ts';\nimport { sizeOf } from './sizeOf.ts';\nimport { schemaCallWrapper } from './utils.ts';\nimport type { AnyWgslData, WgslArray } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates an array schema that can be used to construct gpu buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * @example\n * const LENGTH = 3;\n * const array = d.arrayOf(d.u32, LENGTH);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const array = d.arrayOf(d.vec3f);\n * // ^? (n: number) => WgslArray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport function arrayOf<TElement extends AnyWgslData>(\n elementType: TElement,\n elementCount: number,\n): WgslArray<TElement>;\n\nexport function arrayOf<TElement extends AnyWgslData>(\n elementType: TElement,\n elementCount?: undefined,\n): (elementCount: number) => WgslArray<TElement>;\n\nexport function arrayOf<TElement extends AnyWgslData>(\n elementType: TElement,\n elementCount?: number | undefined,\n): WgslArray<TElement> | ((elementCount: number) => WgslArray<TElement>) {\n if (elementCount === undefined) {\n return (n: number) => arrayOf(elementType, n);\n }\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const arraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Array 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(arraySchema, WgslArrayImpl);\n\n if (Number.isNaN(sizeOf(elementType))) {\n throw new Error('Cannot nest runtime sized arrays.');\n }\n arraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create array schema with invalid element count: ${elementCount}.`,\n );\n }\n arraySchema.elementCount = elementCount;\n\n return arraySchema as unknown as WgslArray<TElement>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst WgslArrayImpl = {\n [$internal]: true,\n type: 'array',\n\n toString(this: WgslArray): string {\n return `arrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n","import { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Disarray } from './dataTypes.ts';\nimport { schemaCallWrapper } from './utils.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates an array schema that can be used to construct vertex buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f\n *\n * @example\n * const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const disarray = d.disarrayOf(d.vec3f);\n * // ^? (n: number) => Disarray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport function disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n): Disarray<TElement>;\n\nexport function disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount?: undefined,\n): (elementCount: number) => Disarray<TElement>;\n\nexport function disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount?: number | undefined,\n): Disarray<TElement> | ((elementCount: number) => Disarray<TElement>) {\n if (elementCount === undefined) {\n return (n: number) => disarrayOf(elementType, n);\n }\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const disarraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Disarray schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`,\n );\n }\n\n return Array.from(\n { length: elementCount },\n (_, i) => schemaCallWrapper(elementType, elements?.[i]),\n );\n };\n Object.setPrototypeOf(disarraySchema, DisarrayImpl);\n\n disarraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create disarray schema with invalid element count: ${elementCount}.`,\n );\n }\n disarraySchema.elementCount = elementCount;\n\n return disarraySchema as unknown as Disarray<TElement>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst DisarrayImpl = {\n [$internal]: true,\n type: 'disarray',\n\n toString(this: Disarray): string {\n return `disarrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n","import { getName, setName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Unstruct } from './dataTypes.ts';\nimport { schemaCallWrapper } from './utils.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","import type { Infer, MemIdentity } from '../shared/repr.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type {\n $gpuRepr,\n $memIdent,\n $repr,\n $validStorageSchema,\n $validUniformSchema,\n $validVertexSchema,\n} from '../shared/symbols.ts';\nimport type { Atomic, atomicI32, atomicU32, I32, U32 } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.\n *\n * @example\n * const atomicU32 = d.atomic(d.u32);\n * const atomicI32 = d.atomic(d.i32);\n *\n * @param data Underlying type schema.\n */\nexport function atomic<TSchema extends U32 | I32>(\n data: TSchema,\n): Atomic<TSchema> {\n return new AtomicImpl(data);\n}\n\n// --------------\n// Implementation\n// --------------\n\nclass AtomicImpl<TSchema extends U32 | I32> implements Atomic<TSchema> {\n public readonly [$internal] = true;\n public readonly type = 'atomic';\n\n // Type-tokens, not available at runtime\n declare readonly [$repr]: Infer<TSchema>;\n declare readonly [$memIdent]: MemIdentity<TSchema>;\n declare readonly [$gpuRepr]: TSchema extends U32 ? atomicU32 : atomicI32;\n declare readonly [$validStorageSchema]: true;\n declare readonly [$validUniformSchema]: true;\n declare readonly [$validVertexSchema]: true;\n // ---\n\n constructor(public readonly inner: TSchema) {}\n}\n","import type {\n Infer,\n InferGPU,\n InferPartial,\n IsValidStorageSchema,\n IsValidUniformSchema,\n IsValidVertexSchema,\n MemIdentity,\n} from '../shared/repr.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type {\n $gpuRepr,\n $invalidSchemaReason,\n $memIdent,\n $repr,\n $reprPartial,\n $validStorageSchema,\n $validUniformSchema,\n $validVertexSchema,\n} from '../shared/symbols.ts';\nimport { alignmentOf } from './alignmentOf.ts';\nimport {\n type AnyData,\n type AnyLooseData,\n isLooseData,\n isLooseDecorated,\n type LooseDecorated,\n type LooseTypeLiteral,\n} from './dataTypes.ts';\nimport type { Undecorate } from './decorateUtils.ts';\nimport { sizeOf } from './sizeOf.ts';\nimport {\n type Align,\n type AnyWgslData,\n type BaseData,\n type Builtin,\n type Decorated,\n type FlatInterpolatableData,\n type FlatInterpolationType,\n type Interpolate,\n type InterpolationType,\n type Invariant,\n isAlignAttrib,\n isBuiltinAttrib,\n isDecorated,\n isSizeAttrib,\n isWgslData,\n type Location,\n type PerspectiveOrLinearInterpolatableData,\n type PerspectiveOrLinearInterpolationType,\n type Size,\n type Vec4f,\n type WgslTypeLiteral,\n} from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport const builtinNames = [\n 'vertex_index',\n 'instance_index',\n 'position',\n 'clip_distances',\n 'front_facing',\n 'frag_depth',\n 'sample_index',\n 'sample_mask',\n 'fragment',\n 'local_invocation_id',\n 'local_invocation_index',\n 'global_invocation_id',\n 'workgroup_id',\n 'num_workgroups',\n 'subgroup_invocation_id',\n 'subgroup_size',\n] as const;\n\nexport type BuiltinName = (typeof builtinNames)[number];\n\nexport type AnyAttribute<\n AllowedBuiltins extends Builtin<BuiltinName> = Builtin<BuiltinName>,\n> =\n | Align<number>\n | Size<number>\n | Location<number>\n | Interpolate<InterpolationType>\n | Invariant\n | AllowedBuiltins;\n\nexport type ExtractAttributes<T> = T extends {\n readonly attribs: unknown[];\n} ? T['attribs']\n : [];\n\n/**\n * Decorates a data-type `TData` with an attribute `TAttrib`.\n *\n * - if `TData` is loose\n * - if `TData` is already `LooseDecorated`\n * - Prepend `TAttrib` to the existing attribute tuple.\n * - else\n * - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`\n * - else\n * - if `TData` is already `Decorated`\n * - Prepend `TAttrib` to the existing attribute tuple.\n * - else\n * - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`\n */\nexport type Decorate<\n TData extends BaseData,\n TAttrib extends AnyAttribute,\n> = TData['type'] extends WgslTypeLiteral\n ? Decorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]>\n : TData['type'] extends LooseTypeLiteral\n ? LooseDecorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]>\n : never;\n\nexport type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false\n : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true\n : false;\n\nexport type HasCustomLocation<T> = ExtractAttributes<T>[number] extends []\n ? false\n : ExtractAttributes<T>[number] extends Location ? true\n : false;\n\nexport function attribute<TData extends BaseData, TAttrib extends AnyAttribute>(\n data: TData,\n attrib: TAttrib,\n): Decorated | LooseDecorated {\n if (isDecorated(data)) {\n return new DecoratedImpl(data.inner, [\n attrib,\n ...data.attribs,\n ]) as Decorated;\n }\n\n if (isLooseDecorated(data)) {\n return new LooseDecoratedImpl(data.inner, [\n attrib,\n ...data.attribs,\n ]) as LooseDecorated;\n }\n\n if (isLooseData(data)) {\n return new LooseDecoratedImpl(data, [attrib]) as unknown as LooseDecorated;\n }\n\n return new DecoratedImpl(data, [attrib]) as unknown as Decorated;\n}\n\n/**\n * Gives the wrapped data-type a custom byte alignment. Useful in order to\n * fulfill uniform alignment requirements.\n *\n * @example\n * const Data = d.struct({\n * a: u32, // takes up 4 bytes\n * // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes\n * b: d.align(16, u32),\n * });\n *\n * @param alignment The multiple of bytes this data should align itself to.\n * @param data The data-type to align.\n */\nexport function align<TAlign extends number, TData extends AnyData>(\n alignment: TAlign,\n data: TData,\n): Decorate<TData, Align<TAlign>> {\n return attribute(data, {\n [$internal]: true,\n type: '@align',\n params: [alignment],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.\n *\n * @example\n * const Data = d.struct({\n * a: d.size(16, u32), // takes up 16 bytes, instead of 4\n * b: u32, // starts at byte 16, because `a` has a custom size\n * });\n *\n * @param size The amount of bytes that should be reserved for this data-type.\n * @param data The data-type to wrap.\n */\nexport function size<TSize extends number, TData extends AnyData>(\n size: TSize,\n data: TData,\n): Decorate<TData, Size<TSize>> {\n return attribute(data, {\n [$internal]: true,\n type: '@size',\n params: [size],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Assigns an explicit numeric location to a struct member or a parameter that has this type.\n *\n * @example\n * const VertexOutput = {\n * a: d.u32, // has implicit location 0\n * b: d.location(5, d.u32),\n * c: d.u32, // has implicit location 6\n * };\n *\n * @param location The explicit numeric location.\n * @param data The data-type to wrap.\n */\nexport function location<TLocation extends number, TData extends AnyData>(\n location: TLocation,\n data: TData,\n): Decorate<TData, Location<TLocation>> {\n return attribute(data, {\n [$internal]: true,\n type: '@location',\n params: [location],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Specifies how user-defined vertex shader output (fragment shader input)\n * must be interpolated.\n *\n * Tip: Integer outputs cannot be interpolated.\n *\n * @example\n * const VertexOutput = {\n * a: d.f32, // has implicit 'perspective, center' interpolation\n * b: d.interpolate('linear, sample', d.f32),\n * };\n *\n * @param interpolationType How data should be interpolated.\n * @param data The data-type to wrap.\n */\nexport function interpolate<\n TInterpolation extends PerspectiveOrLinearInterpolationType,\n TData extends PerspectiveOrLinearInterpolatableData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<TData, Interpolate<TInterpolation>>;\n\n/**\n * Specifies how user-defined vertex shader output (fragment shader input)\n * must be interpolated.\n *\n * Tip: Default sampling method of `flat` is `first`. Unless you specifically\n * need deterministic behavior provided by `'flat, first'`, prefer explicit\n * `'flat, either'` as it could be slightly faster in hardware.\n *\n * @example\n * const VertexOutput = {\n * a: d.f32, // has implicit 'perspective, center' interpolation\n * b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate\n * };\n *\n * @param interpolationType How data should be interpolated.\n * @param data The data-type to wrap.\n */\nexport function interpolate<\n TInterpolation extends FlatInterpolationType,\n TData extends FlatInterpolatableData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<TData, Interpolate<TInterpolation>>;\n\nexport function interpolate<\n TInterpolation extends InterpolationType,\n TData extends AnyData,\n>(\n interpolationType: TInterpolation,\n data: TData,\n): Decorate<TData, Interpolate<TInterpolation>> {\n return attribute(data, {\n [$internal]: true,\n type: '@interpolate',\n params: [interpolationType],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\n/**\n * Marks a position built-in output value as invariant in vertex shaders.\n * If the data and control flow match for two position outputs in different\n * entry points, then the result values are guaranteed to be the same.\n *\n * Must only be applied to the position built-in value.\n *\n * @example\n * const VertexOutput = {\n * pos: d.invariant(d.builtin.position),\n * };\n *\n * @param data The position built-in data-type to mark as invariant.\n */\nexport function invariant(\n data: Decorated<Vec4f, [Builtin<'position'>]>,\n): Decorated<Vec4f, [Builtin<'position'>, Invariant]> {\n // Validate that invariant is only applied to position built-in\n if (!isBuiltin(data)) {\n throw new Error(\n 'The @invariant attribute must only be applied to the position built-in value.',\n );\n }\n\n // Find the builtin attribute to check if it's position\n const builtinAttrib = (isDecorated(data) || isLooseDecorated(data))\n ? data.attribs.find(isBuiltinAttrib)\n : undefined;\n\n if (!builtinAttrib || builtinAttrib.params[0] !== 'position') {\n throw new Error(\n 'The @invariant attribute must only be applied to the position built-in value.',\n );\n }\n\n return attribute(data, {\n [$internal]: true,\n type: '@invariant',\n params: [],\n // biome-ignore lint/suspicious/noExplicitAny: <tired of lying to types>\n }) as any;\n}\n\nexport function isBuiltin<\n T extends\n | Decorated<AnyWgslData, AnyAttribute[]>\n | LooseDecorated<AnyLooseData, AnyAttribute[]>,\n>(value: T | unknown): value is T {\n return (\n (isDecorated(value) || isLooseDecorated(value)) &&\n value.attribs.find(isBuiltinAttrib) !== undefined\n );\n}\n\nexport function getAttributesString<T extends BaseData>(field: T): string {\n if (!isDecorated(field) && !isLooseDecorated(field)) {\n return '';\n }\n\n return (field.attribs as AnyAttribute[])\n .map((attrib) => {\n if (attrib.params.length === 0) {\n return `${attrib.type} `;\n }\n return `${attrib.type}(${attrib.params.join(', ')}) `;\n })\n .join('');\n}\n\n// --------------\n// Implementation\n// --------------\n\nclass BaseDecoratedImpl<TInner extends BaseData, TAttribs extends unknown[]> {\n public readonly [$internal] = true;\n\n // Type-tokens, not available at runtime\n declare readonly [$repr]: Infer<TInner>;\n declare readonly [$gpuRepr]: InferGPU<TInner>;\n declare readonly [$reprPartial]: InferPartial<TInner>;\n // ---\n\n constructor(\n public readonly inner: TInner,\n public readonly attribs: TAttribs,\n ) {\n const alignAttrib = attribs.find(isAlignAttrib)?.params[0];\n const sizeAttrib = attribs.find(isSizeAttrib)?.params[0];\n\n if (alignAttrib !== undefined) {\n if (alignAttrib <= 0) {\n throw new Error(\n `Custom data alignment must be a positive number, got: ${alignAttrib}.`,\n );\n }\n\n if (Math.log2(alignAttrib) % 1 !== 0) {\n throw new Error(\n `Alignment has to be a power of 2, got: ${alignAttrib}.`,\n );\n }\n\n if (isWgslData(this.inner)) {\n if (alignAttrib % alignmentOf(this.inner) !== 0) {\n throw new Error(\n `Custom alignment has to be a multiple of the standard data alignment. Got: ${alignAttrib}, expected multiple of: ${\n alignmentOf(this.inner)\n }.`,\n );\n }\n }\n }\n\n if (sizeAttrib !== undefined) {\n if (sizeAttrib < sizeOf(this.inner)) {\n throw new Error(\n `Custom data size cannot be smaller then the standard data size. Got: ${sizeAttrib}, expected at least: ${\n sizeOf(this.inner)\n }.`,\n );\n }\n\n if (sizeAttrib <= 0) {\n throw new Error(\n `Custom data size must be a positive number. Got: ${sizeAttrib}.`,\n );\n }\n }\n }\n}\n\nclass DecoratedImpl<TInner extends BaseData, TAttribs extends unknown[]>\n extends BaseDecoratedImpl<TInner, TAttribs>\n implements Decorated<TInner, TAttribs> {\n public readonly [$internal] = true;\n public readonly type = 'decorated';\n\n // Type-tokens, not available at runtime\n declare readonly [$memIdent]: TAttribs extends Location[]\n ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs>\n : Decorated<MemIdentity<TInner>, TAttribs>;\n declare readonly [$invalidSchemaReason]:\n Decorated[typeof $invalidSchemaReason];\n declare readonly [$validStorageSchema]: IsValidStorageSchema<TInner>;\n declare readonly [$validUniformSchema]: IsValidUniformSchema<TInner>;\n declare readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;\n // ---\n}\n\nclass LooseDecoratedImpl<TInner extends BaseData, TAttribs extends unknown[]>\n extends BaseDecoratedImpl<TInner, TAttribs>\n implements LooseDecorated<TInner, TAttribs> {\n public readonly [$internal] = true;\n public readonly type = 'loose-decorated';\n\n // Type-tokens, not available at runtime\n declare readonly [$invalidSchemaReason]:\n LooseDecorated[typeof $invalidSchemaReason];\n declare readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;\n // ---\n}\n","import { arrayOf } from './data/array.ts';\nimport { attribute } from './data/attributes.ts';\nimport type { LooseDecorated } from './data/dataTypes.ts';\nimport { bool, f32, u32 } from './data/numeric.ts';\nimport { vec3u, vec4f } from './data/vector.ts';\nimport type {\n AnyWgslData,\n BaseData,\n Bool,\n Builtin,\n Decorated,\n F32,\n U32,\n Vec3u,\n Vec4f,\n WgslArray,\n} from './data/wgslTypes.ts';\nimport { $internal } from './shared/symbols.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;\nexport type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;\nexport type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;\nexport type BuiltinClipDistances = Decorated<\n WgslArray<U32>,\n [Builtin<'clip_distances'>]\n>;\nexport type BuiltinFrontFacing = Decorated<Bool, [Builtin<'front_facing'>]>;\nexport type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;\nexport type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;\nexport type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;\nexport type BuiltinLocalInvocationId = Decorated<\n Vec3u,\n [Builtin<'local_invocation_id'>]\n>;\nexport type BuiltinLocalInvocationIndex = Decorated<\n U32,\n [Builtin<'local_invocation_index'>]\n>;\nexport type BuiltinGlobalInvocationId = Decorated<\n Vec3u,\n [Builtin<'global_invocation_id'>]\n>;\nexport type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;\nexport type BuiltinNumWorkgroups = Decorated<\n Vec3u,\n [Builtin<'num_workgroups'>]\n>;\nexport type BuiltinSubgroupInvocationId = Decorated<\n U32,\n [Builtin<'subgroup_invocation_id'>]\n>;\nexport type BuiltinSubgroupSize = Decorated<U32, [Builtin<'subgroup_size'>]>;\n\nfunction defineBuiltin<T extends Decorated | LooseDecorated>(\n dataType: AnyWgslData,\n value: T['attribs'][0] extends { params: [infer TValue] } ? TValue : never,\n): T {\n return attribute(dataType, {\n [$internal]: true,\n type: '@builtin',\n // biome-ignore lint/suspicious/noExplicitAny: it's fine\n params: [value as any],\n }) as T;\n}\n\nexport const builtin = {\n vertexIndex: defineBuiltin<BuiltinVertexIndex>(u32, 'vertex_index'),\n instanceIndex: defineBuiltin<BuiltinInstanceIndex>(u32, 'instance_index'),\n position: defineBuiltin<BuiltinPosition>(vec4f, 'position'),\n clipDistances: defineBuiltin<BuiltinClipDistances>(\n arrayOf(u32, 8),\n 'clip_distances',\n ),\n frontFacing: defineBuiltin<BuiltinFrontFacing>(bool, 'front_facing'),\n fragDepth: defineBuiltin<BuiltinFragDepth>(f32, 'frag_depth'),\n sampleIndex: defineBuiltin<BuiltinSampleIndex>(u32, 'sample_index'),\n sampleMask: defineBuiltin<BuiltinSampleMask>(u32, 'sample_mask'),\n localInvocationId: defineBuiltin<BuiltinLocalInvocationId>(\n vec3u,\n 'local_invocation_id',\n ),\n localInvocationIndex: defineBuiltin<BuiltinLocalInvocationIndex>(\n u32,\n 'local_invocation_index',\n ),\n globalInvocationId: defineBuiltin<BuiltinGlobalInvocationId>(\n vec3u,\n 'global_invocation_id',\n ),\n workgroupId: defineBuiltin<BuiltinWorkgroupId>(vec3u, 'workgroup_id'),\n numWorkgroups: defineBuiltin<BuiltinNumWorkgroups>(vec3u, 'num_workgroups'),\n subgroupInvocationId: defineBuiltin<BuiltinSubgroupInvocationId>(\n u32,\n 'subgroup_invocation_id',\n ),\n subgroupSize: defineBuiltin<BuiltinSubgroupSize>(u32, 'subgroup_size'),\n} as const;\n\nexport type AnyBuiltin = (typeof builtin)[keyof typeof builtin];\nexport type AnyComputeBuiltin =\n | BuiltinLocalInvocationId\n | BuiltinLocalInvocationIndex\n | BuiltinGlobalInvocationId\n | BuiltinWorkgroupId\n | BuiltinNumWorkgroups\n | BuiltinSubgroupInvocationId\n | BuiltinSubgroupSize;\nexport type AnyVertexInputBuiltin = BuiltinVertexIndex | BuiltinInstanceIndex;\nexport type AnyVertexOutputBuiltin = BuiltinClipDistances | BuiltinPosition;\nexport type AnyFragmentInputBuiltin =\n | BuiltinPosition\n | BuiltinFrontFacing\n | BuiltinSampleIndex\n | BuiltinSampleMask\n | BuiltinSubgroupInvocationId\n | BuiltinSubgroupSize;\nexport type AnyFragmentOutputBuiltin = BuiltinFragDepth | BuiltinSampleMask;\n\nexport type OmitBuiltins<S> = S extends AnyBuiltin ? never\n : S extends BaseData ? S\n : {\n [Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];\n };\n","/**\n * @module typegpu/data\n */\n\nimport { type InfixOperator, infixOperators } from '../tgsl/wgslGenerator.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { MatBase } from './matrix.ts';\nimport { VecBase } from './vectorImpl.ts';\n\nfunction assignInfixOperator<T extends typeof VecBase | typeof MatBase>(\n object: T,\n operator: InfixOperator,\n) {\n type Instance = InstanceType<T>;\n\n const proto = object.prototype as {\n [K in InfixOperator]?: (this: Instance, other: unknown) => unknown;\n };\n const opImpl = infixOperators[operator][$internal].jsImpl as (\n lhs: Instance,\n rhs: unknown,\n ) => unknown;\n\n proto[operator] = function (this: Instance, other: unknown): unknown {\n return opImpl(this, other);\n };\n}\n\nassignInfixOperator(VecBase, 'add');\nassignInfixOperator(VecBase, 'sub');\nassignInfixOperator(VecBase, 'mul');\nassignInfixOperator(VecBase, 'div');\nassignInfixOperator(MatBase, 'add');\nassignInfixOperator(MatBase, 'sub');\nassignInfixOperator(MatBase, 'mul');\n\nexport { bool, f16, f32, i32, u16, u32 } from './numeric.ts';\nexport {\n isAlignAttrib,\n isAtomic,\n isBuiltinAttrib,\n isDecorated,\n isInterpolateAttrib,\n isLocationAttrib,\n isPtr,\n isSizeAttrib,\n isWgslArray,\n isWgslData,\n isWgslStruct,\n Void,\n} from './wgslTypes.ts';\nexport type {\n Align,\n AnyVecInstance,\n AnyWgslData,\n AnyWgslStruct,\n Atomic,\n BaseData,\n BaseData as BaseWgslData,\n Bool,\n Builtin,\n Decorated,\n F16,\n F32,\n I32,\n Interpolate,\n Location,\n m2x2f,\n m3x3f,\n m4x4f,\n Mat2x2f,\n Mat3x3f,\n Mat4x4f,\n Ptr,\n Size,\n U16,\n U32,\n v2b,\n v2f,\n v2i,\n v2u,\n v3b,\n v3f,\n v3i,\n v3u,\n v4b,\n v4f,\n v4i,\n v4u,\n Vec2b,\n Vec2f,\n Vec2h,\n Vec2i,\n Vec2u,\n Vec3b,\n Vec3f,\n Vec3h,\n Vec3i,\n Vec3u,\n Vec4b,\n Vec4f,\n Vec4h,\n Vec4i,\n Vec4u,\n WgslArray,\n WgslStruct,\n} from './wgslTypes.ts';\nexport { struct } from './struct.ts';\nexport { arrayOf } from './array.ts';\nexport {\n ptrFn,\n ptrHandle,\n ptrPrivate,\n ptrStorage,\n ptrUniform,\n ptrWorkgroup,\n} from './ptr.ts';\nexport type {\n AnyData,\n AnyLooseData,\n Disarray,\n LooseDecorated,\n Unstruct,\n} from './dataTypes.ts';\nexport {\n vec2b,\n vec2f,\n vec2h,\n vec2i,\n vec2u,\n vec3b,\n vec3f,\n vec3h,\n vec3i,\n vec3u,\n vec4b,\n vec4f,\n vec4h,\n vec4i,\n vec4u,\n} from './vector.ts';\nexport { disarrayOf } from './disarray.ts';\nexport { unstruct } from './unstruct.ts';\nexport { mat2x2f, mat3x3f, mat4x4f, matToArray } from './matrix.ts';\nexport * from './vertexFormatData.ts';\nexport { atomic } from './atomic.ts';\nexport {\n align,\n type AnyAttribute,\n type HasCustomLocation,\n interpolate,\n invariant,\n type IsBuiltin,\n isBuiltin,\n location,\n size,\n} from './attributes.ts';\nexport {\n isData,\n isDisarray,\n isLooseData,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nexport { PUBLIC_sizeOf as sizeOf } from './sizeOf.ts';\nexport { PUBLIC_alignmentOf as alignmentOf } from './alignmentOf.ts';\nexport { builtin } from '../builtin.ts';\nexport type {\n AnyBuiltin,\n BuiltinClipDistances,\n BuiltinFragDepth,\n BuiltinFrontFacing,\n BuiltinGlobalInvocationId,\n BuiltinInstanceIndex,\n BuiltinLocalInvocationId,\n BuiltinLocalInvocationIndex,\n BuiltinNumWorkgroups,\n BuiltinPosition,\n BuiltinSampleIndex,\n BuiltinSampleMask,\n BuiltinVertexIndex,\n BuiltinWorkgroupId,\n} from '../builtin.ts';\nexport type { Infer, InferGPU, InferPartial } from '../shared/repr.ts';\n"],"mappings":"qcAAA,UAAYA,OAAa,UCIlB,IAAMC,EAAU,CAACC,EAAeC,IAAmB,CACxD,IAAMC,EAAUD,EAAS,EACnBE,EAAa,CAACD,E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,CACzB,CAACG,CAAS,EAAG,GACb,KAAM,WAEN,OAAQ,CAACF,CAAY,CACvB,CAAC,CACH,CAEO,IAAMG,GAAU,CACrB,YAAaL,EAAkCM,EAAK,cAAc,EAClE,cAAeN,EAAoCM,EAAK,gBAAgB,EACxE,SAAUN,EAA+BO,GAAO,UAAU,EAC1D,cAAeP,EACbQ,EAAQF,EAAK,CAAC,EACd,gBACF,EACA,YAAaN,EAAkCS,EAAM,cAAc,EACnE,UAAWT,EAAgCU,GAAK,YAAY,EAC5D,YAAaV,EAAkCM,EAAK,cAAc,EAClE,WAAYN,EAAiCM,EAAK,aAAa,EAC/D,kBAAmBN,EACjBW,EACA,qBACF,EACA,qBAAsBX,EACpBM,EACA,wBACF,EACA,mBAAoBN,EAClBW,EACA,sBACF,EACA,YAAaX,EAAkCW,EAAO,cAAc,EACpE,cAAeX,EAAoCW,EAAO,gBAAgB,EAC1E,qBAAsBX,EACpBM,EACA,wBACF,EACA,aAAcN,EAAmCM,EAAK,eAAe,CACvE,EC3FA,SAASM,EACPC,EACAC,EACA,CAGA,IAAMC,EAAQF,EAAO,UAGfG,EAASC,EAAeH,CAAQ,EAAEI,CAAS,EAAE,OAKnDH,EAAMD,CAAQ,EAAI,SAA0BK,EAAyB,CACnE,OAAOH,EAAO,KAAMG,CAAK,CAC3B,CACF,CAEAP,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBQ,EAAS,KAAK,EAClCR,EAAoBS,EAAS,KAAK,EAClCT,EAAoBS,EAAS,KAAK,EAClCT,EAAoBS,EAAS,KAAK","names":["tinyest","roundUp","value","modulo","bitMask","invBitMask","knownAlignmentMap","computeAlignment","data","dataType","knownAlignment","isWgslStruct","alignmentOf","a","b","isWgslArray","isUnstruct","firstProp","getCustomAlignment","isDisarray","isDecorated","isLooseDecorated","packedFormats","computeCustomAlignment","customAlignmentOf","cachedAlignments","cachedCustomAlignments","alignment","PUBLIC_alignmentOf","schema","knownSizesMap","sizeOfStruct","struct","size","propTypes","property","roundUp","alignmentOf","sizeOf","sizeOfUnstruct","data","alignment","customAlignmentOf","computeSize","knownSize","isWgslStruct","isUnstruct","isWgslArray","isDisarray","isDecorated","isLooseDecorated","getCustomSize","cachedSizes","schema","PUBLIC_sizeOf","arrayOf","elementType","elementCount","arraySchema","elements","_","i","schemaCallWrapper","WgslArrayImpl","sizeOf","$internal","NODE","tinyest","parenthesizedOps","binaryLogicalOps","infixKinds","infixOperators","add","sub","mul","div","operatorToType","lhs","op","rhs","bool","assertExhaustive","value","generateBlock","ctx","_","statements","body","statement","generateStatement","registerBlockVariable","id","dataType","generateIdentifier","res","generateTypedExpression","expression","expectedType","prevExpectedType","result","generateExpression","tryConvertSnippet","opCodeToCodegen","$internal","snip","lhsExpr","rhsExpr","codegen","forcedType","converted","convertToCommonType","convLhs","convRhs","lhsStr","rhsStr","type","arg","argExpr","argStr","targetNode","property","target","InfixDispatch","UnknownData","propValue","coerceToSnippet","isPtr","getTypeForPropAccess","isWgslArray","u32","abstractInt","isMat","isVec","isVecInstance","propertyNode","targetStr","propertyStr","getTypeForIndexAccess","isData","numericLiteralToSnippet","parseNumericString","calleeNode","argNodes","callee","isWgslStruct","WgslTypeError","isMarkedInternal","getName","argConversionHint","convertedArguments","i","argType","snippets","sn","fnRes","isSnippet","error","ResolutionError","obj","structType","entries","key","val","convertedValues","convertStructValues","v","valueNodes","arrType","elemType","values","valuesSnippets","maybeValues","concretize","arrayType","arrayValues","arrayOf","blockifySingleStatement","returnNode","returnValue","cond","cons","alt","condition","consequent","alternate","rawId","rawValue","eq","isLooseData","init","update","initStatement","conditionExpr","updateStatement","initStr","condSnippet","conditionStr","updateStr","bodyStr","generateFunction","disarrayOf","elementType","elementCount","disarraySchema","elements","_","i","schemaCallWrapper","DisarrayImpl","$internal","unstruct","properties","unstructSchema","instanceProps","key","schema","schemaCallWrapper","UnstructImpl","$internal","label","setName","getName","atomic","data","AtomicImpl","inner","$internal","attribute","data","attrib","isDecorated","DecoratedImpl","isLooseDecorated","LooseDecoratedImpl","isLooseData","align","alignment","$internal","size","location","interpolate","interpolationType","invariant","isBuiltin","builtinAttrib","isBuiltinAttrib","value","getAttributesString","field","BaseDecoratedImpl","inner","attribs","alignAttrib","isAlignAttrib","sizeAttrib","isSizeAttrib","isWgslData","alignmentOf","sizeOf","defineBuiltin","dataType","value","attribute","$internal","builtin","u32","vec4f","arrayOf","bool","f32","vec3u","assignInfixOperator","object","operator","proto","opImpl","infixOperators","$internal","other","VecBase","MatBase"]}
@@ -0,0 +1,10 @@
1
+ var C="0.7.1";var i=Symbol(`typegpu:${C}:$internal`),lt=Symbol(`typegpu:${C}:$wgslDataType`),Wr=Symbol(`typegpu:${C}:$gpuValueOf`),At=Symbol(`typegpu:${C}:$getNameForward`),Gt=Symbol(`typegpu:${C}:$providing`),Yt=Symbol(`typegpu:${C}:$repr`),Lr=Symbol(`typegpu:${C}:$gpuRepr`),jr=Symbol(`typegpu:${C}:$reprPartial`),Kr=Symbol(`typegpu:${C}:$memIdent`),Gr=Symbol(`typegpu:${C}:$invalidStorageSchema`),Yr=Symbol(`typegpu:${C}:$validUniformSchema`),qr=Symbol(`typegpu:${C}:$validVertexSchema`),Hr=Symbol(`typegpu:${C}:$invalidSchemaReason`);var X=globalThis.process.env.NODE_ENV==="development",qt=globalThis.process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>En(e)&&e?.[i]&&!te(e)?e.$name(t):e});var Ze=globalThis,es=(X||qt)&&{get enabled(){return!!Ze.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=Ze.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function Un(e){return!!e?.[At]}function te(e){return Un(e)?te(e[At]):On(e)?.name}function ht(e,t){Wn(e,{name:t})}function En(e){return!!e?.$name}function On(e){return Ze.__TYPEGPU_META__.get(e)}function Wn(e,t){Ze.__TYPEGPU_META__??=new WeakMap;let n=Ze.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var Mt="Invariant failed";function pt(e,t){if(e)return;if(!X)throw new Error(Mt);let n=typeof t=="function"?t():t,r=n?`${Mt}: ${n}`:Mt;throw new Error(r)}var Ht=class e extends Error{constructor(n,r){let s=r.map(a=>`- ${a}`);s.length>20&&(s=[...s.slice(0,11),"...",...s.slice(-10)]);super(`Resolution of the following tree failed:
2
+ ${s.join(`
3
+ `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},Xt=class e extends Error{constructor(n,r){let s=r.map(a=>`- ${a}`);s.length>20&&(s=[...s.slice(0,11),"...",...s.slice(-10)]);super(`Execution of the following tree failed:
4
+ ${s.join(`
5
+ `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},Zt=class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},Jt=class e extends Error{constructor(t){super(`Buffer '${te(t)??"<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},Qt=class e extends Error{constructor(t,n){super(`The function '${t??"<unnamed>"}' is missing links to the following external values: ${n}.`),Object.setPrototypeOf(this,e.prototype)}},en=class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>te(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(layout, bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},tn=class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>te(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},nn=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},rn=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},xt=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function sn(e){return e?.resourceType==="slot"}function an(e){return e?.resourceType==="derived"}function on(e){return e?.[Gt]!==void 0}function cs(e){return e?.resourceType==="accessor"}function cn(e){return!!e?.[lt]}var ls={[i]:!0,type:"void"},Ln=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void"];function y(e){let t=e;return!!t?.[i]&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function jn(e){let t=e;return!!t?.[i]&&typeof t.type=="string"&&t.type.startsWith("vec2")}function Kn(e){let t=e;return!!t?.[i]&&typeof t.type=="string"&&t.type.startsWith("vec3")}function Gn(e){let t=e;return!!t?.[i]&&typeof t.type=="string"&&t.type.startsWith("vec4")}function ce(e){return jn(e)||Kn(e)||Gn(e)}function A(e){let t=e;return!!t?.[i]&&typeof t.kind?.startsWith=="function"&&t.kind.startsWith("mat")}function Yn(e){return e?.[i]&&e?.type==="mat2x2f"}function qn(e){return e?.[i]&&e?.type==="mat3x3f"}function Hn(e){return e?.[i]&&e?.type==="mat4x4f"}function $t(e){return Yn(e)||qn(e)||Hn(e)}function Dt(e){return y(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function mt(e){return e?.[i]&&Ln.includes(e?.type)}function un(e){return e?.[i]&&e?.type==="array"}function yn(e){return e?.[i]&&e?.type==="struct"}function hs(e){return e?.[i]&&e?.type==="ptr"}function xs(e){return e?.[i]&&e?.type==="atomic"}function ln(e){return e?.[i]&&e?.type==="@align"}function hn(e){return e?.[i]&&e?.type==="@size"}function xn(e){return e?.[i]&&e?.type==="@location"}function ps(e){return e?.[i]&&e?.type==="@interpolate"}function ms(e){return e?.[i]&&e?.type==="@builtin"}function pn(e){return e?.[i]&&e?.type==="decorated"}function ds(e){return e?.[i]&&e.type==="void"}function dt(e){let t=e?.type;return!!e?.[i]&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}var mn=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],ws={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};var Zn=["unstruct","disarray","loose-decorated",...mn];function Jn(e){return e?.[i]&&Zn.includes(e?.type)}function wn(e){return e?.[i]&&e?.type==="disarray"}function fn(e){return e?.[i]&&e?.type==="unstruct"}function Ts(e){return e?.[i]&&e?.type==="loose-decorated"}function bs(e){return e.attribs?.find(ln)?.params[0]}function zs(e){return e.attribs?.find(hn)?.params[0]}function Vs(e){return e.attribs?.find(xn)?.params[0]}function Ss(e){return mt(e)||Jn(e)}var ne={type:"unknown",toString(){return"unknown"}},dn=class{constructor(t,n,r){this.name=t;this.lhs=n;this.operator=r}};var wt=class{type="normal"},vn=class{type="codegen"},gn=class{constructor(t,n){this.buffers=t;this.vars=n}type="simulate"};function Qn(e){return er(e)&&typeof e?.["~resolve"]=="function"}function $s(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Qn(e)||mt(e)||sn(e)||an(e)||on(e)}function Ds(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function ks(e){return e?.resourceType==="buffer-usage"}function er(e){return!!e?.[i]}var ft=!1;function Rs(e){if(ft)return e();try{return ft=!0,e()}finally{ft=!1}}function Ns(){return ft}var re;function Bs(e,t){if(pt(re===void 0||re===e,"Cannot nest context providers"),re===e)return t();re=e;try{return t()}finally{re=void 0}}function vt(){return re}var tr=new wt;function Us(){return re?.mode??tr}function Tn(){return re?.mode.type==="codegen"}function m(e,...t){let n=vt();function r(a){return typeof a=="string"?a:n.resolve(a.value,a.dataType)}let s="";for(let a=0;a<e.length;++a){s+=e[a];let l=t[a];Array.isArray(l)?s+=l.filter(x=>x!==void 0).map(r).join(", "):l&&(s+=r(l))}return s}function w(e,t,n,r="keep"){let s=(...a)=>Tn()?t(...a):e(...a);return ht(s,n),s.toString=()=>n,Object.defineProperty(s,i,{value:{jsImpl:e,gpuImpl:t,argConversionHint:r}}),s}function Z(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}var gt=class{constructor(t,n){this.value=t;this.dataType=n}};function kt(e){return e instanceof gt}function we(e){return dt(e.dataType)}function o(e,t){if(X&&kt(e))throw new Error("Cannot nest snippets");return new gt(e,Z(t))}var bn={[i]:!0,type:"abstractInt"},zn={[i]:!0,type:"abstractFloat"},nr=w(e=>e===void 0?!1:typeof e=="boolean"?e:!!e,e=>o(m`bool(${e})`,$),"boolCast"),$=Object.assign(nr,{type:"bool"}),rr=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0,e=>o(m`u32(${e})`,V),"u32Cast"),V=Object.assign(rr,{type:"u32"}),sr=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:e|0,e=>o(m`i32(${e})`,z),"i32Cast"),ni={[i]:!0,type:"u16"},z=Object.assign(sr,{type:"i32"}),ir=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e),e=>o(m`f32(${e})`,v),"f32Cast"),v=Object.assign(ir,{type:"f32"}),Vn=new ArrayBuffer(4),ar=new Float32Array(Vn),or=new Uint32Array(Vn);function cr(e){ar[0]=e;let t=or[0],n=t>>>31&1,r=t>>>23&255,s=t&8388607;return r===255?n<<15|31744|(s?512:0):(r=r-127+15,r<=0?r<-10?n<<15:(s=(s|8388608)>>1-r,s=s+4096>>13,n<<15|s):r>=31||(s=s+4096,s&8388608&&(s=0,++r,r>=31))?n<<15|31744:n<<15|r<<10|s>>13)}function ur(e){let t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?r?t*r*2**-24:t*0:n===31?r?Number.NaN:t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t*(1+r/1024)*2**(n-15)}function yr(e){return ur(cr(e))}var lr=w(e=>e===void 0?0:typeof e=="boolean"?e?1:0:yr(e),e=>o(m`f16(${e})`,D),"f16Cast"),D=Object.assign(lr,{type:"f16"});var Je=class extends Array{[i]=!0;"~resolve"(){return this.every(t=>!t)?`${this.kind}()`:this.every(t=>this[0]===t)?`${this.kind}(${this[0]})`:`${this.kind}(${this.join(", ")})`}toString(){return this["~resolve"]()}get xx(){return new this._Vec2(this[0],this[0])}get xy(){return new this._Vec2(this[0],this[1])}get xz(){return new this._Vec2(this[0],this[2])}get xw(){return new this._Vec2(this[0],this[3])}get yx(){return new this._Vec2(this[1],this[0])}get yy(){return new this._Vec2(this[1],this[1])}get yz(){return new this._Vec2(this[1],this[2])}get yw(){return new this._Vec2(this[1],this[3])}get zx(){return new this._Vec2(this[2],this[0])}get zy(){return new this._Vec2(this[2],this[1])}get zz(){return new this._Vec2(this[2],this[2])}get zw(){return new this._Vec2(this[2],this[3])}get wx(){return new this._Vec2(this[3],this[0])}get wy(){return new this._Vec2(this[3],this[1])}get wz(){return new this._Vec2(this[3],this[2])}get ww(){return new this._Vec2(this[3],this[3])}get xxx(){return new this._Vec3(this[0],this[0],this[0])}get xxy(){return new this._Vec3(this[0],this[0],this[1])}get xxz(){return new this._Vec3(this[0],this[0],this[2])}get xxw(){return new this._Vec3(this[0],this[0],this[3])}get xyx(){return new this._Vec3(this[0],this[1],this[0])}get xyy(){return new this._Vec3(this[0],this[1],this[1])}get xyz(){return new this._Vec3(this[0],this[1],this[2])}get xyw(){return new this._Vec3(this[0],this[1],this[3])}get xzx(){return new this._Vec3(this[0],this[2],this[0])}get xzy(){return new this._Vec3(this[0],this[2],this[1])}get xzz(){return new this._Vec3(this[0],this[2],this[2])}get xzw(){return new this._Vec3(this[0],this[2],this[3])}get xwx(){return new this._Vec3(this[0],this[3],this[0])}get xwy(){return new this._Vec3(this[0],this[3],this[1])}get xwz(){return new this._Vec3(this[0],this[3],this[2])}get xww(){return new this._Vec3(this[0],this[3],this[3])}get yxx(){return new this._Vec3(this[1],this[0],this[0])}get yxy(){return new this._Vec3(this[1],this[0],this[1])}get yxz(){return new this._Vec3(this[1],this[0],this[2])}get yxw(){return new this._Vec3(this[1],this[0],this[3])}get yyx(){return new this._Vec3(this[1],this[1],this[0])}get yyy(){return new this._Vec3(this[1],this[1],this[1])}get yyz(){return new this._Vec3(this[1],this[1],this[2])}get yyw(){return new this._Vec3(this[1],this[1],this[3])}get yzx(){return new this._Vec3(this[1],this[2],this[0])}get yzy(){return new this._Vec3(this[1],this[2],this[1])}get yzz(){return new this._Vec3(this[1],this[2],this[2])}get yzw(){return new this._Vec3(this[1],this[2],this[3])}get ywx(){return new this._Vec3(this[1],this[3],this[0])}get ywy(){return new this._Vec3(this[1],this[3],this[1])}get ywz(){return new this._Vec3(this[1],this[3],this[2])}get yww(){return new this._Vec3(this[1],this[3],this[3])}get zxx(){return new this._Vec3(this[2],this[0],this[0])}get zxy(){return new this._Vec3(this[2],this[0],this[1])}get zxz(){return new this._Vec3(this[2],this[0],this[2])}get zxw(){return new this._Vec3(this[2],this[0],this[3])}get zyx(){return new this._Vec3(this[2],this[1],this[0])}get zyy(){return new this._Vec3(this[2],this[1],this[1])}get zyz(){return new this._Vec3(this[2],this[1],this[2])}get zyw(){return new this._Vec3(this[2],this[1],this[3])}get zzx(){return new this._Vec3(this[2],this[2],this[0])}get zzy(){return new this._Vec3(this[2],this[2],this[1])}get zzz(){return new this._Vec3(this[2],this[2],this[2])}get zzw(){return new this._Vec3(this[2],this[2],this[3])}get zwx(){return new this._Vec3(this[2],this[3],this[0])}get zwy(){return new this._Vec3(this[2],this[3],this[1])}get zwz(){return new this._Vec3(this[2],this[3],this[2])}get zww(){return new this._Vec3(this[2],this[3],this[3])}get wxx(){return new this._Vec3(this[3],this[0],this[0])}get wxy(){return new this._Vec3(this[3],this[0],this[1])}get wxz(){return new this._Vec3(this[3],this[0],this[2])}get wxw(){return new this._Vec3(this[3],this[0],this[3])}get wyx(){return new this._Vec3(this[3],this[1],this[0])}get wyy(){return new this._Vec3(this[3],this[1],this[1])}get wyz(){return new this._Vec3(this[3],this[1],this[2])}get wyw(){return new this._Vec3(this[3],this[1],this[3])}get wzx(){return new this._Vec3(this[3],this[2],this[0])}get wzy(){return new this._Vec3(this[3],this[2],this[1])}get wzz(){return new this._Vec3(this[3],this[2],this[2])}get wzw(){return new this._Vec3(this[3],this[2],this[3])}get wwx(){return new this._Vec3(this[3],this[3],this[0])}get wwy(){return new this._Vec3(this[3],this[3],this[1])}get wwz(){return new this._Vec3(this[3],this[3],this[2])}get www(){return new this._Vec3(this[3],this[3],this[3])}get xxxx(){return new this._Vec4(this[0],this[0],this[0],this[0])}get xxxy(){return new this._Vec4(this[0],this[0],this[0],this[1])}get xxxz(){return new this._Vec4(this[0],this[0],this[0],this[2])}get xxxw(){return new this._Vec4(this[0],this[0],this[0],this[3])}get xxyx(){return new this._Vec4(this[0],this[0],this[1],this[0])}get xxyy(){return new this._Vec4(this[0],this[0],this[1],this[1])}get xxyz(){return new this._Vec4(this[0],this[0],this[1],this[2])}get xxyw(){return new this._Vec4(this[0],this[0],this[1],this[3])}get xxzx(){return new this._Vec4(this[0],this[0],this[2],this[0])}get xxzy(){return new this._Vec4(this[0],this[0],this[2],this[1])}get xxzz(){return new this._Vec4(this[0],this[0],this[2],this[2])}get xxzw(){return new this._Vec4(this[0],this[0],this[2],this[3])}get xxwx(){return new this._Vec4(this[0],this[0],this[3],this[0])}get xxwy(){return new this._Vec4(this[0],this[0],this[3],this[1])}get xxwz(){return new this._Vec4(this[0],this[0],this[3],this[2])}get xxww(){return new this._Vec4(this[0],this[0],this[3],this[3])}get xyxx(){return new this._Vec4(this[0],this[1],this[0],this[0])}get xyxy(){return new this._Vec4(this[0],this[1],this[0],this[1])}get xyxz(){return new this._Vec4(this[0],this[1],this[0],this[2])}get xyxw(){return new this._Vec4(this[0],this[1],this[0],this[3])}get xyyx(){return new this._Vec4(this[0],this[1],this[1],this[0])}get xyyy(){return new this._Vec4(this[0],this[1],this[1],this[1])}get xyyz(){return new this._Vec4(this[0],this[1],this[1],this[2])}get xyyw(){return new this._Vec4(this[0],this[1],this[1],this[3])}get xyzx(){return new this._Vec4(this[0],this[1],this[2],this[0])}get xyzy(){return new this._Vec4(this[0],this[1],this[2],this[1])}get xyzz(){return new this._Vec4(this[0],this[1],this[2],this[2])}get xyzw(){return new this._Vec4(this[0],this[1],this[2],this[3])}get xywx(){return new this._Vec4(this[0],this[1],this[3],this[0])}get xywy(){return new this._Vec4(this[0],this[1],this[3],this[1])}get xywz(){return new this._Vec4(this[0],this[1],this[3],this[2])}get xyww(){return new this._Vec4(this[0],this[1],this[3],this[3])}get xzxx(){return new this._Vec4(this[0],this[2],this[0],this[0])}get xzxy(){return new this._Vec4(this[0],this[2],this[0],this[1])}get xzxz(){return new this._Vec4(this[0],this[2],this[0],this[2])}get xzxw(){return new this._Vec4(this[0],this[2],this[0],this[3])}get xzyx(){return new this._Vec4(this[0],this[2],this[1],this[0])}get xzyy(){return new this._Vec4(this[0],this[2],this[1],this[1])}get xzyz(){return new this._Vec4(this[0],this[2],this[1],this[2])}get xzyw(){return new this._Vec4(this[0],this[2],this[1],this[3])}get xzzx(){return new this._Vec4(this[0],this[2],this[2],this[0])}get xzzy(){return new this._Vec4(this[0],this[2],this[2],this[1])}get xzzz(){return new this._Vec4(this[0],this[2],this[2],this[2])}get xzzw(){return new this._Vec4(this[0],this[2],this[2],this[3])}get xzwx(){return new this._Vec4(this[0],this[2],this[3],this[0])}get xzwy(){return new this._Vec4(this[0],this[2],this[3],this[1])}get xzwz(){return new this._Vec4(this[0],this[2],this[3],this[2])}get xzww(){return new this._Vec4(this[0],this[2],this[3],this[3])}get xwxx(){return new this._Vec4(this[0],this[3],this[0],this[0])}get xwxy(){return new this._Vec4(this[0],this[3],this[0],this[1])}get xwxz(){return new this._Vec4(this[0],this[3],this[0],this[2])}get xwxw(){return new this._Vec4(this[0],this[3],this[0],this[3])}get xwyx(){return new this._Vec4(this[0],this[3],this[1],this[0])}get xwyy(){return new this._Vec4(this[0],this[3],this[1],this[1])}get xwyz(){return new this._Vec4(this[0],this[3],this[1],this[2])}get xwyw(){return new this._Vec4(this[0],this[3],this[1],this[3])}get xwzx(){return new this._Vec4(this[0],this[3],this[2],this[0])}get xwzy(){return new this._Vec4(this[0],this[3],this[2],this[1])}get xwzz(){return new this._Vec4(this[0],this[3],this[2],this[2])}get xwzw(){return new this._Vec4(this[0],this[3],this[2],this[3])}get xwwx(){return new this._Vec4(this[0],this[3],this[3],this[0])}get xwwy(){return new this._Vec4(this[0],this[3],this[3],this[1])}get xwwz(){return new this._Vec4(this[0],this[3],this[3],this[2])}get xwww(){return new this._Vec4(this[0],this[3],this[3],this[3])}get yxxx(){return new this._Vec4(this[1],this[0],this[0],this[0])}get yxxy(){return new this._Vec4(this[1],this[0],this[0],this[1])}get yxxz(){return new this._Vec4(this[1],this[0],this[0],this[2])}get yxxw(){return new this._Vec4(this[1],this[0],this[0],this[3])}get yxyx(){return new this._Vec4(this[1],this[0],this[1],this[0])}get yxyy(){return new this._Vec4(this[1],this[0],this[1],this[1])}get yxyz(){return new this._Vec4(this[1],this[0],this[1],this[2])}get yxyw(){return new this._Vec4(this[1],this[0],this[1],this[3])}get yxzx(){return new this._Vec4(this[1],this[0],this[2],this[0])}get yxzy(){return new this._Vec4(this[1],this[0],this[2],this[1])}get yxzz(){return new this._Vec4(this[1],this[0],this[2],this[2])}get yxzw(){return new this._Vec4(this[1],this[0],this[2],this[3])}get yxwx(){return new this._Vec4(this[1],this[0],this[3],this[0])}get yxwy(){return new this._Vec4(this[1],this[0],this[3],this[1])}get yxwz(){return new this._Vec4(this[1],this[0],this[3],this[2])}get yxww(){return new this._Vec4(this[1],this[0],this[3],this[3])}get yyxx(){return new this._Vec4(this[1],this[1],this[0],this[0])}get yyxy(){return new this._Vec4(this[1],this[1],this[0],this[1])}get yyxz(){return new this._Vec4(this[1],this[1],this[0],this[2])}get yyxw(){return new this._Vec4(this[1],this[1],this[0],this[3])}get yyyx(){return new this._Vec4(this[1],this[1],this[1],this[0])}get yyyy(){return new this._Vec4(this[1],this[1],this[1],this[1])}get yyyz(){return new this._Vec4(this[1],this[1],this[1],this[2])}get yyyw(){return new this._Vec4(this[1],this[1],this[1],this[3])}get yyzx(){return new this._Vec4(this[1],this[1],this[2],this[0])}get yyzy(){return new this._Vec4(this[1],this[1],this[2],this[1])}get yyzz(){return new this._Vec4(this[1],this[1],this[2],this[2])}get yyzw(){return new this._Vec4(this[1],this[1],this[2],this[3])}get yywx(){return new this._Vec4(this[1],this[1],this[3],this[0])}get yywy(){return new this._Vec4(this[1],this[1],this[3],this[1])}get yywz(){return new this._Vec4(this[1],this[1],this[3],this[2])}get yyww(){return new this._Vec4(this[1],this[1],this[3],this[3])}get yzxx(){return new this._Vec4(this[1],this[2],this[0],this[0])}get yzxy(){return new this._Vec4(this[1],this[2],this[0],this[1])}get yzxz(){return new this._Vec4(this[1],this[2],this[0],this[2])}get yzxw(){return new this._Vec4(this[1],this[2],this[0],this[3])}get yzyx(){return new this._Vec4(this[1],this[2],this[1],this[0])}get yzyy(){return new this._Vec4(this[1],this[2],this[1],this[1])}get yzyz(){return new this._Vec4(this[1],this[2],this[1],this[2])}get yzyw(){return new this._Vec4(this[1],this[2],this[1],this[3])}get yzzx(){return new this._Vec4(this[1],this[2],this[2],this[0])}get yzzy(){return new this._Vec4(this[1],this[2],this[2],this[1])}get yzzz(){return new this._Vec4(this[1],this[2],this[2],this[2])}get yzzw(){return new this._Vec4(this[1],this[2],this[2],this[3])}get yzwx(){return new this._Vec4(this[1],this[2],this[3],this[0])}get yzwy(){return new this._Vec4(this[1],this[2],this[3],this[1])}get yzwz(){return new this._Vec4(this[1],this[2],this[3],this[2])}get yzww(){return new this._Vec4(this[1],this[2],this[3],this[3])}get ywxx(){return new this._Vec4(this[1],this[3],this[0],this[0])}get ywxy(){return new this._Vec4(this[1],this[3],this[0],this[1])}get ywxz(){return new this._Vec4(this[1],this[3],this[0],this[2])}get ywxw(){return new this._Vec4(this[1],this[3],this[0],this[3])}get ywyx(){return new this._Vec4(this[1],this[3],this[1],this[0])}get ywyy(){return new this._Vec4(this[1],this[3],this[1],this[1])}get ywyz(){return new this._Vec4(this[1],this[3],this[1],this[2])}get ywyw(){return new this._Vec4(this[1],this[3],this[1],this[3])}get ywzx(){return new this._Vec4(this[1],this[3],this[2],this[0])}get ywzy(){return new this._Vec4(this[1],this[3],this[2],this[1])}get ywzz(){return new this._Vec4(this[1],this[3],this[2],this[2])}get ywzw(){return new this._Vec4(this[1],this[3],this[2],this[3])}get ywwx(){return new this._Vec4(this[1],this[3],this[3],this[0])}get ywwy(){return new this._Vec4(this[1],this[3],this[3],this[1])}get ywwz(){return new this._Vec4(this[1],this[3],this[3],this[2])}get ywww(){return new this._Vec4(this[1],this[3],this[3],this[3])}get zxxx(){return new this._Vec4(this[2],this[0],this[0],this[0])}get zxxy(){return new this._Vec4(this[2],this[0],this[0],this[1])}get zxxz(){return new this._Vec4(this[2],this[0],this[0],this[2])}get zxxw(){return new this._Vec4(this[2],this[0],this[0],this[3])}get zxyx(){return new this._Vec4(this[2],this[0],this[1],this[0])}get zxyy(){return new this._Vec4(this[2],this[0],this[1],this[1])}get zxyz(){return new this._Vec4(this[2],this[0],this[1],this[2])}get zxyw(){return new this._Vec4(this[2],this[0],this[1],this[3])}get zxzx(){return new this._Vec4(this[2],this[0],this[2],this[0])}get zxzy(){return new this._Vec4(this[2],this[0],this[2],this[1])}get zxzz(){return new this._Vec4(this[2],this[0],this[2],this[2])}get zxzw(){return new this._Vec4(this[2],this[0],this[2],this[3])}get zxwx(){return new this._Vec4(this[2],this[0],this[3],this[0])}get zxwy(){return new this._Vec4(this[2],this[0],this[3],this[1])}get zxwz(){return new this._Vec4(this[2],this[0],this[3],this[2])}get zxww(){return new this._Vec4(this[2],this[0],this[3],this[3])}get zyxx(){return new this._Vec4(this[2],this[1],this[0],this[0])}get zyxy(){return new this._Vec4(this[2],this[1],this[0],this[1])}get zyxz(){return new this._Vec4(this[2],this[1],this[0],this[2])}get zyxw(){return new this._Vec4(this[2],this[1],this[0],this[3])}get zyyx(){return new this._Vec4(this[2],this[1],this[1],this[0])}get zyyy(){return new this._Vec4(this[2],this[1],this[1],this[1])}get zyyz(){return new this._Vec4(this[2],this[1],this[1],this[2])}get zyyw(){return new this._Vec4(this[2],this[1],this[1],this[3])}get zyzx(){return new this._Vec4(this[2],this[1],this[2],this[0])}get zyzy(){return new this._Vec4(this[2],this[1],this[2],this[1])}get zyzz(){return new this._Vec4(this[2],this[1],this[2],this[2])}get zyzw(){return new this._Vec4(this[2],this[1],this[2],this[3])}get zywx(){return new this._Vec4(this[2],this[1],this[3],this[0])}get zywy(){return new this._Vec4(this[2],this[1],this[3],this[1])}get zywz(){return new this._Vec4(this[2],this[1],this[3],this[2])}get zyww(){return new this._Vec4(this[2],this[1],this[3],this[3])}get zzxx(){return new this._Vec4(this[2],this[2],this[0],this[0])}get zzxy(){return new this._Vec4(this[2],this[2],this[0],this[1])}get zzxz(){return new this._Vec4(this[2],this[2],this[0],this[2])}get zzxw(){return new this._Vec4(this[2],this[2],this[0],this[3])}get zzyx(){return new this._Vec4(this[2],this[2],this[1],this[0])}get zzyy(){return new this._Vec4(this[2],this[2],this[1],this[1])}get zzyz(){return new this._Vec4(this[2],this[2],this[1],this[2])}get zzyw(){return new this._Vec4(this[2],this[2],this[1],this[3])}get zzzx(){return new this._Vec4(this[2],this[2],this[2],this[0])}get zzzy(){return new this._Vec4(this[2],this[2],this[2],this[1])}get zzzz(){return new this._Vec4(this[2],this[2],this[2],this[2])}get zzzw(){return new this._Vec4(this[2],this[2],this[2],this[3])}get zzwx(){return new this._Vec4(this[2],this[2],this[3],this[0])}get zzwy(){return new this._Vec4(this[2],this[2],this[3],this[1])}get zzwz(){return new this._Vec4(this[2],this[2],this[3],this[2])}get zzww(){return new this._Vec4(this[2],this[2],this[3],this[3])}get zwxx(){return new this._Vec4(this[2],this[3],this[0],this[0])}get zwxy(){return new this._Vec4(this[2],this[3],this[0],this[1])}get zwxz(){return new this._Vec4(this[2],this[3],this[0],this[2])}get zwxw(){return new this._Vec4(this[2],this[3],this[0],this[3])}get zwyx(){return new this._Vec4(this[2],this[3],this[1],this[0])}get zwyy(){return new this._Vec4(this[2],this[3],this[1],this[1])}get zwyz(){return new this._Vec4(this[2],this[3],this[1],this[2])}get zwyw(){return new this._Vec4(this[2],this[3],this[1],this[3])}get zwzx(){return new this._Vec4(this[2],this[3],this[2],this[0])}get zwzy(){return new this._Vec4(this[2],this[3],this[2],this[1])}get zwzz(){return new this._Vec4(this[2],this[3],this[2],this[2])}get zwzw(){return new this._Vec4(this[2],this[3],this[2],this[3])}get zwwx(){return new this._Vec4(this[2],this[3],this[3],this[0])}get zwwy(){return new this._Vec4(this[2],this[3],this[3],this[1])}get zwwz(){return new this._Vec4(this[2],this[3],this[3],this[2])}get zwww(){return new this._Vec4(this[2],this[3],this[3],this[3])}get wxxx(){return new this._Vec4(this[3],this[0],this[0],this[0])}get wxxy(){return new this._Vec4(this[3],this[0],this[0],this[1])}get wxxz(){return new this._Vec4(this[3],this[0],this[0],this[2])}get wxxw(){return new this._Vec4(this[3],this[0],this[0],this[3])}get wxyx(){return new this._Vec4(this[3],this[0],this[1],this[0])}get wxyy(){return new this._Vec4(this[3],this[0],this[1],this[1])}get wxyz(){return new this._Vec4(this[3],this[0],this[1],this[2])}get wxyw(){return new this._Vec4(this[3],this[0],this[1],this[3])}get wxzx(){return new this._Vec4(this[3],this[0],this[2],this[0])}get wxzy(){return new this._Vec4(this[3],this[0],this[2],this[1])}get wxzz(){return new this._Vec4(this[3],this[0],this[2],this[2])}get wxzw(){return new this._Vec4(this[3],this[0],this[2],this[3])}get wxwx(){return new this._Vec4(this[3],this[0],this[3],this[0])}get wxwy(){return new this._Vec4(this[3],this[0],this[3],this[1])}get wxwz(){return new this._Vec4(this[3],this[0],this[3],this[2])}get wxww(){return new this._Vec4(this[3],this[0],this[3],this[3])}get wyxx(){return new this._Vec4(this[3],this[1],this[0],this[0])}get wyxy(){return new this._Vec4(this[3],this[1],this[0],this[1])}get wyxz(){return new this._Vec4(this[3],this[1],this[0],this[2])}get wyxw(){return new this._Vec4(this[3],this[1],this[0],this[3])}get wyyx(){return new this._Vec4(this[3],this[1],this[1],this[0])}get wyyy(){return new this._Vec4(this[3],this[1],this[1],this[1])}get wyyz(){return new this._Vec4(this[3],this[1],this[1],this[2])}get wyyw(){return new this._Vec4(this[3],this[1],this[1],this[3])}get wyzx(){return new this._Vec4(this[3],this[1],this[2],this[0])}get wyzy(){return new this._Vec4(this[3],this[1],this[2],this[1])}get wyzz(){return new this._Vec4(this[3],this[1],this[2],this[2])}get wyzw(){return new this._Vec4(this[3],this[1],this[2],this[3])}get wywx(){return new this._Vec4(this[3],this[1],this[3],this[0])}get wywy(){return new this._Vec4(this[3],this[1],this[3],this[1])}get wywz(){return new this._Vec4(this[3],this[1],this[3],this[2])}get wyww(){return new this._Vec4(this[3],this[1],this[3],this[3])}get wzxx(){return new this._Vec4(this[3],this[2],this[0],this[0])}get wzxy(){return new this._Vec4(this[3],this[2],this[0],this[1])}get wzxz(){return new this._Vec4(this[3],this[2],this[0],this[2])}get wzxw(){return new this._Vec4(this[3],this[2],this[0],this[3])}get wzyx(){return new this._Vec4(this[3],this[2],this[1],this[0])}get wzyy(){return new this._Vec4(this[3],this[2],this[1],this[1])}get wzyz(){return new this._Vec4(this[3],this[2],this[1],this[2])}get wzyw(){return new this._Vec4(this[3],this[2],this[1],this[3])}get wzzx(){return new this._Vec4(this[3],this[2],this[2],this[0])}get wzzy(){return new this._Vec4(this[3],this[2],this[2],this[1])}get wzzz(){return new this._Vec4(this[3],this[2],this[2],this[2])}get wzzw(){return new this._Vec4(this[3],this[2],this[2],this[3])}get wzwx(){return new this._Vec4(this[3],this[2],this[3],this[0])}get wzwy(){return new this._Vec4(this[3],this[2],this[3],this[1])}get wzwz(){return new this._Vec4(this[3],this[2],this[3],this[2])}get wzww(){return new this._Vec4(this[3],this[2],this[3],this[3])}get wwxx(){return new this._Vec4(this[3],this[3],this[0],this[0])}get wwxy(){return new this._Vec4(this[3],this[3],this[0],this[1])}get wwxz(){return new this._Vec4(this[3],this[3],this[0],this[2])}get wwxw(){return new this._Vec4(this[3],this[3],this[0],this[3])}get wwyx(){return new this._Vec4(this[3],this[3],this[1],this[0])}get wwyy(){return new this._Vec4(this[3],this[3],this[1],this[1])}get wwyz(){return new this._Vec4(this[3],this[3],this[1],this[2])}get wwyw(){return new this._Vec4(this[3],this[3],this[1],this[3])}get wwzx(){return new this._Vec4(this[3],this[3],this[2],this[0])}get wwzy(){return new this._Vec4(this[3],this[3],this[2],this[1])}get wwzz(){return new this._Vec4(this[3],this[3],this[2],this[2])}get wwzw(){return new this._Vec4(this[3],this[3],this[2],this[3])}get wwwx(){return new this._Vec4(this[3],this[3],this[3],this[0])}get wwwy(){return new this._Vec4(this[3],this[3],this[3],this[1])}get wwwz(){return new this._Vec4(this[3],this[3],this[3],this[2])}get wwww(){return new this._Vec4(this[3],this[3],this[3],this[3])}},ue=class extends Je{e0;e1;constructor(t,n){super(2),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t)}get 0(){return this.e0}get 1(){return this.e1}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}},ye=class extends Je{e0;e1;e2;constructor(t,n,r){super(3),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}set z(t){this[2]=this.castElement()(t)}},le=class extends Je{e0;e1;e2;e3;constructor(t,n,r,s){super(4),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t),this.e3=this.castElement()(s??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}get 3(){return this.e3}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}set 3(t){this.e3=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set w(t){this[3]=t}},fe=class e extends ue{castElement(){return v[i].jsImpl}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return ze}get _Vec4(){return Ae}},ve=class e extends ue{castElement(){return D[i].jsImpl}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return Ve}get _Vec4(){return Me}},ge=class e extends ue{castElement(){return z[i].jsImpl}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return Se}get _Vec4(){return $e}},Te=class e extends ue{castElement(){return V[i].jsImpl}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return _e}get _Vec4(){return De}},be=class e extends ue{castElement(){return $[i].jsImpl}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return Ie}get _Vec4(){return ke}},ze=class e extends ye{castElement(){return v[i].jsImpl}get kind(){return"vec3f"}get _Vec2(){return fe}get _Vec3(){return e}get _Vec4(){return Ae}},Ve=class e extends ye{castElement(){return D[i].jsImpl}get kind(){return"vec3h"}get _Vec2(){return ve}get _Vec3(){return e}get _Vec4(){return Me}},Se=class e extends ye{castElement(){return z[i].jsImpl}get kind(){return"vec3i"}get _Vec2(){return ge}get _Vec3(){return e}get _Vec4(){return $e}},_e=class e extends ye{castElement(){return V[i].jsImpl}get kind(){return"vec3u"}get _Vec2(){return Te}get _Vec3(){return e}get _Vec4(){return De}},Ie=class e extends ye{castElement(){return $[i].jsImpl}get kind(){return"vec3<bool>"}get _Vec2(){return be}get _Vec3(){return e}get _Vec4(){return ke}},Ae=class e extends le{castElement(){return v[i].jsImpl}get kind(){return"vec4f"}get _Vec2(){return fe}get _Vec3(){return ze}get _Vec4(){return e}},Me=class e extends le{castElement(){return D[i].jsImpl}get kind(){return"vec4h"}get _Vec2(){return ve}get _Vec3(){return Ve}get _Vec4(){return e}},$e=class e extends le{castElement(){return z[i].jsImpl}get kind(){return"vec4i"}get _Vec2(){return ge}get _Vec3(){return Se}get _Vec4(){return e}},De=class e extends le{castElement(){return V[i].jsImpl}get kind(){return"vec4u"}get _Vec2(){return Te}get _Vec3(){return _e}get _Vec4(){return e}},ke=class e extends le{castElement(){return $[i].jsImpl}get kind(){return"vec4<bool>"}get _Vec2(){return be}get _Vec3(){return Ie}get _Vec4(){return e}};var k=F(fe),Fe=F(ve),j=F(ge),K=F(Te),Ce=F(be),E=F(ze),Pe=F(Ve),se=F(Se),ie=F(_e),Re=F(Ie),S=F(Ae),Ne=F(Me),G=F($e),Y=F(De),Be=F(ke),Qe={vec2f:k,vec2h:Fe,vec2i:j,vec2u:K,"vec2<bool>":Ce,vec3f:E,vec3h:Pe,vec3i:se,vec3u:ie,"vec3<bool>":Re,vec4f:S,vec4h:Ne,vec4i:G,vec4u:Y,"vec4<bool>":Be},Ft={vec2f:v,vec2h:D,vec2i:z,vec2u:V,"vec2<bool>":$,vec3f:v,vec3h:D,vec3i:z,vec3u:V,"vec3<bool>":$,vec4f:v,vec4h:D,vec4i:z,vec4u:V,"vec4<bool>":$};function F(e){let{kind:t,length:n}=new e,r=(...l)=>{let x=new Array(l.length),p=0;for(let I of l)if(typeof I=="number"||typeof I=="boolean")x[p++]=I;else for(let P=0;P<I.length;++P)x[p++]=I[P];if(x.length<=1||x.length===n)return new e(...x);throw new Error(`'${t}' constructor called with invalid number of arguments.`)},s=w(r,(...l)=>{if(l.every(x=>typeof x.value=="number"||y(x.value))){let x=l.map(p=>p.value);return o(r(...x),a)}return o(m`${t}(${l})`,a)},t,(...l)=>l.map(x=>{let p=x.dataType;return pn(p)&&(p=p.inner),ce(p)?p:Ft[t]})),a=Object.assign(s,{type:t,[Yt]:void 0});return a}var et=class{};function Et(e){let t=w((...r)=>{let s=[];for(let a of r)if(typeof a=="number")s.push(a);else for(let l=0;l<a.length;++l)s.push(a[l]);if(s.length!==0&&s.length!==e.columns*e.rows)throw new Error(`'${e.type}' constructor called with invalid number of arguments.`);for(let a=s.length;a<e.columns*e.rows;++a)s.push(0);return new e.MatImpl(...s)},(...r)=>o(m`${e.type}(${r})`,n),e.type),n=Object.assign(t,{type:e.type,identity:dr[e.columns],translation:e.columns===4?wr:void 0,scaling:e.columns===4?fr:void 0,rotationX:e.columns===4?vr:void 0,rotationY:e.columns===4?gr:void 0,rotationZ:e.columns===4?Tr:void 0});return n}var Ct=class extends et{[i]=!0;columns;length=4;constructor(...t){super(),this.columns=[this.makeColumn(t[0],t[1]),this.makeColumn(t[2],t[3])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[1].x}get 3(){return this.columns[1].y}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[1].x=t}set 3(t){this.columns[1].y=t}*[Symbol.iterator](){yield this[0],yield this[1],yield this[2],yield this[3]}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}},Pt=class extends Ct{kind="mat2x2f";makeColumn(t,n){return k(t,n)}},Rt=class extends et{[i]=!0;columns;length=12;constructor(...t){super(),this.columns=[this.makeColumn(t[0],t[1],t[2]),this.makeColumn(t[3],t[4],t[5]),this.makeColumn(t[6],t[7],t[8])]}get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return 0}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return 0}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return 0}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){}*[Symbol.iterator](){for(let t=0;t<12;t++)yield this[t]}"~resolve"(){return`${this.kind}(${this[0]}, ${this[1]}, ${this[2]}, ${this[4]}, ${this[5]}, ${this[6]}, ${this[8]}, ${this[9]}, ${this[10]})`}},Nt=class extends Rt{kind="mat3x3f";makeColumn(t,n,r){return E(t,n,r)}},Bt=class extends et{[i]=!0;columns;constructor(...t){super(),this.columns=[this.makeColumn(t[0],t[1],t[2],t[3]),this.makeColumn(t[4],t[5],t[6],t[7]),this.makeColumn(t[8],t[9],t[10],t[11]),this.makeColumn(t[12],t[13],t[14],t[15])]}length=16;get 0(){return this.columns[0].x}get 1(){return this.columns[0].y}get 2(){return this.columns[0].z}get 3(){return this.columns[0].w}get 4(){return this.columns[1].x}get 5(){return this.columns[1].y}get 6(){return this.columns[1].z}get 7(){return this.columns[1].w}get 8(){return this.columns[2].x}get 9(){return this.columns[2].y}get 10(){return this.columns[2].z}get 11(){return this.columns[2].w}get 12(){return this.columns[3].x}get 13(){return this.columns[3].y}get 14(){return this.columns[3].z}get 15(){return this.columns[3].w}set 0(t){this.columns[0].x=t}set 1(t){this.columns[0].y=t}set 2(t){this.columns[0].z=t}set 3(t){this.columns[0].w=t}set 4(t){this.columns[1].x=t}set 5(t){this.columns[1].y=t}set 6(t){this.columns[1].z=t}set 7(t){this.columns[1].w=t}set 8(t){this.columns[2].x=t}set 9(t){this.columns[2].y=t}set 10(t){this.columns[2].z=t}set 11(t){this.columns[2].w=t}set 12(t){this.columns[3].x=t}set 13(t){this.columns[3].y=t}set 14(t){this.columns[3].z=t}set 15(t){this.columns[3].w=t}*[Symbol.iterator](){for(let t=0;t<16;t++)yield this[t]}"~resolve"(){return`${this.kind}(${Array.from({length:this.length}).map((t,n)=>this[n]).join(", ")})`}},Ut=class extends Bt{kind="mat4x4f";makeColumn(t,n,r,s){return S(t,n,r,s)}},xr=w(()=>ae(1,0,0,1),()=>o("mat2x2f(1, 0, 0, 1)",ae),"identity2"),pr=w(()=>oe(1,0,0,0,1,0,0,0,1),()=>o("mat3x3f(1, 0, 0, 0, 1, 0, 0, 0, 1)",oe),"identity3"),mr=w(()=>_(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),()=>o("mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)",_),"identity4"),dr={2:xr,3:pr,4:mr},wr=w(e=>_(1,0,0,0,0,1,0,0,0,0,1,0,e.x,e.y,e.z,1),e=>o(m`mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, ${e}.x, ${e}.y, ${e}.z, 1)`,_),"translation4"),fr=w(e=>_(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),e=>o(m`mat4x4f(${e}.x, 0, 0, 0, 0, ${e}.y, 0, 0, 0, 0, ${e}.z, 0, 0, 0, 0, 1)`,_),"scaling4"),vr=w(e=>_(1,0,0,0,0,Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1),e=>o(m`mat4x4f(1, 0, 0, 0, 0, cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1)`,_),"rotationX4"),gr=w(e=>_(Math.cos(e),0,-Math.sin(e),0,0,1,0,0,Math.sin(e),0,Math.cos(e),0,0,0,0,1),e=>o(m`mat4x4f(cos(${e}), 0, -sin(${e}), 0, 0, 1, 0, 0, sin(${e}), 0, cos(${e}), 0, 0, 0, 0, 1)`,_),"rotationY4"),Tr=w(e=>_(Math.cos(e),Math.sin(e),0,0,-Math.sin(e),Math.cos(e),0,0,0,0,1,0,0,0,0,1),e=>o(m`mat4x4f(cos(${e}), sin(${e}), 0, 0, -sin(${e}), cos(${e}), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)`,_),"rotationZ4"),ae=Et({type:"mat2x2f",rows:2,columns:2,MatImpl:Pt}),oe=Et({type:"mat3x3f",rows:3,columns:3,MatImpl:Nt}),_=Et({type:"mat4x4f",rows:4,columns:4,MatImpl:Ut});function vi(e){return e.kind==="mat3x3f"?[e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10]]:Array.from({length:e.length}).map((t,n)=>e[n])}var c=class{constructor(t){this.type=t}[i]=!0},Tt={uint8:V,uint8x2:K,uint8x4:Y,sint8:z,sint8x2:j,sint8x4:G,unorm8:v,unorm8x2:k,unorm8x4:S,snorm8:v,snorm8x2:k,snorm8x4:S,uint16:V,uint16x2:K,uint16x4:Y,sint16:z,sint16x2:j,sint16x4:G,unorm16:v,unorm16x2:k,unorm16x4:S,snorm16:v,snorm16x2:k,snorm16x4:S,float16:v,float16x2:k,float16x4:S,float32:v,float32x2:k,float32x3:E,float32x4:S,uint32:V,uint32x2:K,uint32x3:ie,uint32x4:Y,sint32:z,sint32x2:j,sint32x3:se,sint32x4:G,"unorm10-10-10-2":S,"unorm8x4-bgra":S},br=new Set(Object.keys(Tt)),Vi=new c("uint8"),Si=new c("uint8x2"),_i=new c("uint8x4"),Ii=new c("sint8"),Ai=new c("sint8x2"),Mi=new c("sint8x4"),$i=new c("unorm8"),Di=new c("unorm8x2"),ki=new c("unorm8x4"),Fi=new c("snorm8"),Ci=new c("snorm8x2"),Pi=new c("snorm8x4"),Ri=new c("uint16"),Ni=new c("uint16x2"),Bi=new c("uint16x4"),Ui=new c("sint16"),Ei=new c("sint16x2"),Oi=new c("sint16x4"),Wi=new c("unorm16"),Li=new c("unorm16x2"),ji=new c("unorm16x4"),Ki=new c("snorm16"),Gi=new c("snorm16x2"),Yi=new c("snorm16x4"),qi=new c("float16"),Hi=new c("float16x2"),Xi=new c("float16x4"),Zi=new c("float32"),Ji=new c("float32x2"),Qi=new c("float32x3"),ea=new c("float32x4"),ta=new c("uint32"),na=new c("uint32x2"),ra=new c("uint32x3"),sa=new c("uint32x4"),ia=new c("sint32"),aa=new c("sint32x2"),oa=new c("sint32x3"),ca=new c("sint32x4"),ua=new c("unorm10-10-10-2"),ya=new c("unorm8x4-bgra");function la(e){return e?.[i]&&br.has(e?.type)}function Sn(e,t){let n=e?.type;try{let r=n in Tt?Tt[n]:e;return t===void 0?r():r(t)}catch{throw new Error(`Schema of type ${n??"<unknown>"} is not callable or was called with invalid arguments.`)}}function fa(e){return _n(e,!1)}function va(e){return _n(e,!0)}function _n(e,t){let n=r=>Object.fromEntries(Object.entries(e).map(([s,a])=>[s,Sn(a,r?.[s])]));return Object.setPrototypeOf(n,zr),n.propTypes=e,Object.defineProperty(n,i,{value:{isAbstruct:t}}),n}var zr={type:"struct",$name(e){return ht(this,e),this},toString(){return`struct:${te(this)??"<unnamed>"}`}};var he=(e,t,n)=>{if(e===t)return 0;let r=u((n-e)/(t-e),0,1);return r*r*(3-2*r)},u=(e,t,n)=>Math.min(Math.max(t,e),n),xe=(e,t)=>t===0?e:Math.trunc(e/t);var R=Ce[i].jsImpl,O=k[i].jsImpl,Q=Fe[i].jsImpl,st=j[i].jsImpl,it=K[i].jsImpl,N=Re[i].jsImpl,U=E[i].jsImpl,q=Pe[i].jsImpl,at=se[i].jsImpl,ot=ie[i].jsImpl,B=Be[i].jsImpl,W=S[i].jsImpl,ee=Ne[i].jsImpl,ct=G[i].jsImpl,ut=Y[i].jsImpl,Ue=e=>Math.sqrt(e.x**2+e.y**2),Ee=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),Oe=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),bt=(e,t)=>e.x*t.x+e.y*t.y,zt=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z,Vt=(e,t)=>e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,f=e=>t=>O(e(t.x),e(t.y)),g=e=>t=>Q(e(t.x),e(t.y)),We=e=>t=>st(e(t.x),e(t.y)),tt=e=>t=>it(e(t.x),e(t.y)),d=e=>t=>U(e(t.x),e(t.y),e(t.z)),T=e=>t=>q(e(t.x),e(t.y),e(t.z)),Le=e=>t=>at(e(t.x),e(t.y),e(t.z)),nt=e=>t=>ot(e(t.x),e(t.y),e(t.z)),h=e=>t=>W(e(t.x),e(t.y),e(t.z),e(t.w)),b=e=>t=>ee(e(t.x),e(t.y),e(t.z),e(t.w)),je=e=>t=>ct(e(t.x),e(t.y),e(t.z),e(t.w)),rt=e=>t=>ut(e(t.x),e(t.y),e(t.z),e(t.w)),In=e=>t=>{let n=t.columns;return ae(f(e)(n[0]),f(e)(n[1]))},An=e=>t=>{let n=t.columns;return oe(d(e)(n[0]),d(e)(n[1]),d(e)(n[2]))},Mn=e=>t=>{let n=t.columns;return _(h(e)(n[0]),h(e)(n[1]),h(e)(n[2]),h(e)(n[3]))},J=e=>(t,n)=>O(e(t.x,n.x),e(t.y,n.y)),pe=e=>(t,n)=>Q(e(t.x,n.x),e(t.y,n.y)),Ke=e=>(t,n)=>st(e(t.x,n.x),e(t.y,n.y)),Ge=e=>(t,n)=>it(e(t.x,n.x),e(t.y,n.y)),H=e=>(t,n)=>U(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),me=e=>(t,n)=>q(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),Ye=e=>(t,n)=>at(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),qe=e=>(t,n)=>ot(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z)),L=e=>(t,n)=>W(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),de=e=>(t,n)=>ee(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),He=e=>(t,n)=>ct(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Xe=e=>(t,n)=>ut(e(t.x,n.x),e(t.y,n.y),e(t.z,n.z),e(t.w,n.w)),Vr=e=>(t,n)=>{let r=t.columns,s=n.columns;return ae(J(e)(r[0],s[0]),J(e)(r[1],s[1]))},Sr=e=>(t,n)=>{let r=t.columns,s=n.columns;return oe(H(e)(r[0],s[0]),H(e)(r[1],s[1]),H(e)(r[2],s[2]))},_r=e=>(t,n)=>{let r=t.columns,s=n.columns;return _(L(e)(r[0],s[0]),L(e)(r[1],s[1]),L(e)(r[2],s[2]),L(e)(r[3],s[3]))},Ir=e=>(t,n,r)=>O(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),Ar=e=>(t,n,r)=>Q(e(t.x,n.x,r.x),e(t.y,n.y,r.y)),Mr=e=>(t,n,r)=>U(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),$r=e=>(t,n,r)=>q(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z)),Dr=e=>(t,n,r)=>W(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z),e(t.w,n.w,r.w)),kr=e=>(t,n,r)=>ee(e(t.x,n.x,r.x),e(t.y,n.y,r.y),e(t.z,n.z,r.z),e(t.w,n.w,r.w)),M={eq:{vec2f:(e,t)=>R(e.x===t.x,e.y===t.y),vec2h:(e,t)=>R(e.x===t.x,e.y===t.y),vec2i:(e,t)=>R(e.x===t.x,e.y===t.y),vec2u:(e,t)=>R(e.x===t.x,e.y===t.y),"vec2<bool>":(e,t)=>R(e.x===t.x,e.y===t.y),vec3f:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec3h:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec3i:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec3u:(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),"vec3<bool>":(e,t)=>N(e.x===t.x,e.y===t.y,e.z===t.z),vec4f:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4h:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4i:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),vec4u:(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w),"vec4<bool>":(e,t)=>B(e.x===t.x,e.y===t.y,e.z===t.z,e.w===t.w)},lt:{vec2f:(e,t)=>R(e.x<t.x,e.y<t.y),vec2h:(e,t)=>R(e.x<t.x,e.y<t.y),vec2i:(e,t)=>R(e.x<t.x,e.y<t.y),vec2u:(e,t)=>R(e.x<t.x,e.y<t.y),vec3f:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec3h:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec3i:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec3u:(e,t)=>N(e.x<t.x,e.y<t.y,e.z<t.z),vec4f:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4h:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4i:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w),vec4u:(e,t)=>B(e.x<t.x,e.y<t.y,e.z<t.z,e.w<t.w)},or:{"vec2<bool>":(e,t)=>R(e.x||t.x,e.y||t.y),"vec3<bool>":(e,t)=>N(e.x||t.x,e.y||t.y,e.z||t.z),"vec4<bool>":(e,t)=>B(e.x||t.x,e.y||t.y,e.z||t.z,e.w||t.w)},all:{"vec2<bool>":e=>e.x&&e.y,"vec3<bool>":e=>e.x&&e.y&&e.z,"vec4<bool>":e=>e.x&&e.y&&e.z&&e.w},abs:{vec2f:f(Math.abs),vec2h:g(Math.abs),vec2i:We(Math.abs),vec2u:tt(Math.abs),vec3f:d(Math.abs),vec3h:T(Math.abs),vec3i:Le(Math.abs),vec3u:nt(Math.abs),vec4f:h(Math.abs),vec4h:b(Math.abs),vec4i:je(Math.abs),vec4u:rt(Math.abs)},atan2:{vec2f:J(Math.atan2),vec2h:pe(Math.atan2),vec3f:H(Math.atan2),vec3h:me(Math.atan2),vec4f:L(Math.atan2),vec4h:de(Math.atan2)},acos:{vec2f:f(Math.acos),vec2h:g(Math.acos),vec2i:We(Math.acos),vec2u:tt(Math.acos),vec3f:d(Math.acos),vec3h:T(Math.acos),vec3i:Le(Math.acos),vec3u:nt(Math.acos),vec4f:h(Math.acos),vec4h:b(Math.acos),vec4i:je(Math.acos),vec4u:rt(Math.acos)},acosh:{vec2f:f(Math.acosh),vec2h:g(Math.acosh),vec3f:d(Math.acosh),vec3h:T(Math.acosh),vec4f:h(Math.acosh),vec4h:b(Math.acosh)},asin:{vec2f:f(Math.asin),vec2h:g(Math.asin),vec3f:d(Math.asin),vec3h:T(Math.asin),vec4f:h(Math.asin),vec4h:b(Math.asin)},asinh:{vec2f:f(Math.asinh),vec2h:g(Math.asinh),vec3f:d(Math.asinh),vec3h:T(Math.asinh),vec4f:h(Math.asinh),vec4h:b(Math.asinh)},atan:{vec2f:f(Math.atan),vec2h:g(Math.atan),vec3f:d(Math.atan),vec3h:T(Math.atan),vec4f:h(Math.atan),vec4h:b(Math.atan)},atanh:{vec2f:f(Math.atanh),vec2h:g(Math.atanh),vec3f:d(Math.atanh),vec3h:T(Math.atanh),vec4f:h(Math.atanh),vec4h:b(Math.atanh)},ceil:{vec2f:f(Math.ceil),vec2h:g(Math.ceil),vec3f:d(Math.ceil),vec3h:T(Math.ceil),vec4f:h(Math.ceil),vec4h:b(Math.ceil)},clamp:{vec2f:(e,t,n)=>O(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2h:(e,t,n)=>Q(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2i:(e,t,n)=>st(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec2u:(e,t,n)=>it(u(e.x,t.x,n.x),u(e.y,t.y,n.y)),vec3f:(e,t,n)=>U(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec3h:(e,t,n)=>q(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec3i:(e,t,n)=>at(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec3u:(e,t,n)=>ot(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z)),vec4f:(e,t,n)=>W(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w)),vec4h:(e,t,n)=>ee(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w)),vec4i:(e,t,n)=>ct(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w)),vec4u:(e,t,n)=>ut(u(e.x,t.x,n.x),u(e.y,t.y,n.y),u(e.z,t.z,n.z),u(e.w,t.w,n.w))},length:{vec2f:Ue,vec2h:Ue,vec3f:Ee,vec3h:Ee,vec4f:Oe,vec4h:Oe},add:{vec2f:J((e,t)=>e+t),vec2h:pe((e,t)=>e+t),vec2i:Ke((e,t)=>e+t),vec2u:Ge((e,t)=>e+t),vec3f:H((e,t)=>e+t),vec3h:me((e,t)=>e+t),vec3i:Ye((e,t)=>e+t),vec3u:qe((e,t)=>e+t),vec4f:L((e,t)=>e+t),vec4h:de((e,t)=>e+t),vec4i:He((e,t)=>e+t),vec4u:Xe((e,t)=>e+t),mat2x2f:Vr((e,t)=>e+t),mat3x3f:Sr((e,t)=>e+t),mat4x4f:_r((e,t)=>e+t)},smoothstep:{vec2f:Ir(he),vec2h:Ar(he),vec3f:Mr(he),vec3h:$r(he),vec4f:Dr(he),vec4h:kr(he)},addMixed:{vec2f:(e,t)=>f(n=>n+t)(e),vec2h:(e,t)=>g(n=>n+t)(e),vec2i:(e,t)=>We(n=>n+t)(e),vec2u:(e,t)=>tt(n=>n+t)(e),vec3f:(e,t)=>d(n=>n+t)(e),vec3h:(e,t)=>T(n=>n+t)(e),vec3i:(e,t)=>Le(n=>n+t)(e),vec3u:(e,t)=>nt(n=>n+t)(e),vec4f:(e,t)=>h(n=>n+t)(e),vec4h:(e,t)=>b(n=>n+t)(e),vec4i:(e,t)=>je(n=>n+t)(e),vec4u:(e,t)=>rt(n=>n+t)(e),mat2x2f:(e,t)=>In(n=>n+t)(e),mat3x3f:(e,t)=>An(n=>n+t)(e),mat4x4f:(e,t)=>Mn(n=>n+t)(e)},mulSxV:{vec2f:(e,t)=>f(n=>e*n)(t),vec2h:(e,t)=>g(n=>e*n)(t),vec2i:(e,t)=>We(n=>e*n)(t),vec2u:(e,t)=>tt(n=>e*n)(t),vec3f:(e,t)=>d(n=>e*n)(t),vec3h:(e,t)=>T(n=>e*n)(t),vec3i:(e,t)=>Le(n=>e*n)(t),vec3u:(e,t)=>nt(n=>e*n)(t),vec4f:(e,t)=>h(n=>e*n)(t),vec4h:(e,t)=>b(n=>e*n)(t),vec4i:(e,t)=>je(n=>e*n)(t),vec4u:(e,t)=>rt(n=>e*n)(t),mat2x2f:(e,t)=>In(n=>e*n)(t),mat3x3f:(e,t)=>An(n=>e*n)(t),mat4x4f:(e,t)=>Mn(n=>e*n)(t)},mulVxV:{vec2f:J((e,t)=>e*t),vec2h:pe((e,t)=>e*t),vec2i:Ke((e,t)=>e*t),vec2u:Ge((e,t)=>e*t),vec3f:H((e,t)=>e*t),vec3h:me((e,t)=>e*t),vec3i:Ye((e,t)=>e*t),vec3u:qe((e,t)=>e*t),vec4f:L((e,t)=>e*t),vec4h:de((e,t)=>e*t),vec4i:He((e,t)=>e*t),vec4u:Xe((e,t)=>e*t),mat2x2f:(e,t)=>{let n=e.columns,r=t.columns;return ae(n[0].x*r[0].x+n[1].x*r[0].y,n[0].y*r[0].x+n[1].y*r[0].y,n[0].x*r[1].x+n[1].x*r[1].y,n[0].y*r[1].x+n[1].y*r[1].y)},mat3x3f:(e,t)=>{let n=e.columns,r=t.columns;return oe(n[0].x*r[0].x+n[1].x*r[0].y+n[2].x*r[0].z,n[0].y*r[0].x+n[1].y*r[0].y+n[2].y*r[0].z,n[0].z*r[0].x+n[1].z*r[0].y+n[2].z*r[0].z,n[0].x*r[1].x+n[1].x*r[1].y+n[2].x*r[1].z,n[0].y*r[1].x+n[1].y*r[1].y+n[2].y*r[1].z,n[0].z*r[1].x+n[1].z*r[1].y+n[2].z*r[1].z,n[0].x*r[2].x+n[1].x*r[2].y+n[2].x*r[2].z,n[0].y*r[2].x+n[1].y*r[2].y+n[2].y*r[2].z,n[0].z*r[2].x+n[1].z*r[2].y+n[2].z*r[2].z)},mat4x4f:(e,t)=>{let n=e.columns,r=t.columns;return _(n[0].x*r[0].x+n[1].x*r[0].y+n[2].x*r[0].z+n[3].x*r[0].w,n[0].y*r[0].x+n[1].y*r[0].y+n[2].y*r[0].z+n[3].y*r[0].w,n[0].z*r[0].x+n[1].z*r[0].y+n[2].z*r[0].z+n[3].z*r[0].w,n[0].w*r[0].x+n[1].w*r[0].y+n[2].w*r[0].z+n[3].w*r[0].w,n[0].x*r[1].x+n[1].x*r[1].y+n[2].x*r[1].z+n[3].x*r[1].w,n[0].y*r[1].x+n[1].y*r[1].y+n[2].y*r[1].z+n[3].y*r[1].w,n[0].z*r[1].x+n[1].z*r[1].y+n[2].z*r[1].z+n[3].z*r[1].w,n[0].w*r[1].x+n[1].w*r[1].y+n[2].w*r[1].z+n[3].w*r[1].w,n[0].x*r[2].x+n[1].x*r[2].y+n[2].x*r[2].z+n[3].x*r[2].w,n[0].y*r[2].x+n[1].y*r[2].y+n[2].y*r[2].z+n[3].y*r[2].w,n[0].z*r[2].x+n[1].z*r[2].y+n[2].z*r[2].z+n[3].z*r[2].w,n[0].w*r[2].x+n[1].w*r[2].y+n[2].w*r[2].z+n[3].w*r[2].w,n[0].x*r[3].x+n[1].x*r[3].y+n[2].x*r[3].z+n[3].x*r[3].w,n[0].y*r[3].x+n[1].y*r[3].y+n[2].y*r[3].z+n[3].y*r[3].w,n[0].z*r[3].x+n[1].z*r[3].y+n[2].z*r[3].z+n[3].z*r[3].w,n[0].w*r[3].x+n[1].w*r[3].y+n[2].w*r[3].z+n[3].w*r[3].w)}},mulMxV:{mat2x2f:(e,t)=>{let n=e.columns;return O(n[0].x*t.x+n[1].x*t.y,n[0].y*t.x+n[1].y*t.y)},mat3x3f:(e,t)=>{let n=e.columns;return U(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z)},mat4x4f:(e,t)=>{let n=e.columns;return W(n[0].x*t.x+n[1].x*t.y+n[2].x*t.z+n[3].x*t.w,n[0].y*t.x+n[1].y*t.y+n[2].y*t.z+n[3].y*t.w,n[0].z*t.x+n[1].z*t.y+n[2].z*t.z+n[3].z*t.w,n[0].w*t.x+n[1].w*t.y+n[2].w*t.z+n[3].w*t.w)}},mulVxM:{mat2x2f:(e,t)=>{let n=t.columns;return O(e.x*n[0].x+e.y*n[0].y,e.x*n[1].x+e.y*n[1].y)},mat3x3f:(e,t)=>{let n=t.columns;return U(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z)},mat4x4f:(e,t)=>{let n=t.columns;return W(e.x*n[0].x+e.y*n[0].y+e.z*n[0].z+e.w*n[0].w,e.x*n[1].x+e.y*n[1].y+e.z*n[1].z+e.w*n[1].w,e.x*n[2].x+e.y*n[2].y+e.z*n[2].z+e.w*n[2].w,e.x*n[3].x+e.y*n[3].y+e.z*n[3].z+e.w*n[3].w)}},div:{vec2f:J((e,t)=>e/t),vec2h:pe((e,t)=>e/t),vec2i:Ke(xe),vec2u:Ge(xe),vec3f:H((e,t)=>e/t),vec3h:me((e,t)=>e/t),vec3i:Ye(xe),vec3u:qe(xe),vec4f:L((e,t)=>e/t),vec4h:de((e,t)=>e/t),vec4i:He(xe),vec4u:Xe(xe)},dot:{vec2f:bt,vec2h:bt,vec2i:bt,vec2u:bt,vec3f:zt,vec3h:zt,vec3i:zt,vec3u:zt,vec4f:Vt,vec4h:Vt,vec4i:Vt,vec4u:Vt},normalize:{vec2f:e=>{let t=Ue(e);return O(e.x/t,e.y/t)},vec2h:e=>{let t=Ue(e);return Q(e.x/t,e.y/t)},vec2i:e=>{let t=Ue(e);return st(e.x/t,e.y/t)},vec2u:e=>{let t=Ue(e);return it(e.x/t,e.y/t)},vec3f:e=>{let t=Ee(e);return U(e.x/t,e.y/t,e.z/t)},vec3h:e=>{let t=Ee(e);return q(e.x/t,e.y/t,e.z/t)},vec3i:e=>{let t=Ee(e);return at(e.x/t,e.y/t,e.z/t)},vec3u:e=>{let t=Ee(e);return ot(e.x/t,e.y/t,e.z/t)},vec4f:e=>{let t=Oe(e);return W(e.x/t,e.y/t,e.z/t,e.w/t)},vec4h:e=>{let t=Oe(e);return ee(e.x/t,e.y/t,e.z/t,e.w/t)},vec4i:e=>{let t=Oe(e);return ct(e.x/t,e.y/t,e.z/t,e.w/t)},vec4u:e=>{let t=Oe(e);return ut(e.x/t,e.y/t,e.z/t,e.w/t)}},cross:{vec3f:(e,t)=>U(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x),vec3h:(e,t)=>q(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x)},mod:{vec2f:J((e,t)=>e%t),vec2h:pe((e,t)=>e%t),vec2i:Ke((e,t)=>e%t),vec2u:Ge((e,t)=>e%t),vec3f:H((e,t)=>e%t),vec3h:me((e,t)=>e%t),vec3i:Ye((e,t)=>e%t),vec3u:qe((e,t)=>e%t),vec4f:L((e,t)=>e%t),vec4h:de((e,t)=>e%t),vec4i:He((e,t)=>e%t),vec4u:Xe((e,t)=>e%t)},floor:{vec2f:f(Math.floor),vec2h:g(Math.floor),vec3f:d(Math.floor),vec3h:T(Math.floor),vec4f:h(Math.floor),vec4h:b(Math.floor)},max:{vec2f:J(Math.max),vec2h:pe(Math.max),vec2i:Ke(Math.max),vec2u:Ge(Math.max),vec3f:H(Math.max),vec3h:me(Math.max),vec3i:Ye(Math.max),vec3u:qe(Math.max),vec4f:L(Math.max),vec4h:de(Math.max),vec4i:He(Math.max),vec4u:Xe(Math.max)},min:{vec2f:J(Math.min),vec2h:pe(Math.min),vec2i:Ke(Math.min),vec2u:Ge(Math.min),vec3f:H(Math.min),vec3h:me(Math.min),vec3i:Ye(Math.min),vec3u:qe(Math.min),vec4f:L(Math.min),vec4h:de(Math.min),vec4i:He(Math.min),vec4u:Xe(Math.min)},pow:{vec2f:(e,t)=>O(e.x**t.x,e.y**t.y),vec2h:(e,t)=>Q(e.x**t.x,e.y**t.y),vec3f:(e,t)=>U(e.x**t.x,e.y**t.y,e.z**t.z),vec3h:(e,t)=>q(e.x**t.x,e.y**t.y,e.z**t.z),vec4f:(e,t)=>W(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w),vec4h:(e,t)=>ee(e.x**t.x,e.y**t.y,e.z**t.z,e.w**t.w)},sign:{vec2f:f(Math.sign),vec2h:g(Math.sign),vec2i:We(Math.sign),vec3f:d(Math.sign),vec3h:T(Math.sign),vec3i:Le(Math.sign),vec4f:h(Math.sign),vec4h:b(Math.sign),vec4i:je(Math.sign)},sqrt:{vec2f:f(Math.sqrt),vec2h:g(Math.sqrt),vec3f:d(Math.sqrt),vec3h:T(Math.sqrt),vec4f:h(Math.sqrt),vec4h:b(Math.sqrt)},mix:{vec2f:(e,t,n)=>typeof n=="number"?O(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):O(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec2h:(e,t,n)=>typeof n=="number"?Q(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n):Q(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y),vec3f:(e,t,n)=>typeof n=="number"?U(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):U(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec3h:(e,t,n)=>typeof n=="number"?q(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n):q(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z),vec4f:(e,t,n)=>typeof n=="number"?W(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):W(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w),vec4h:(e,t,n)=>typeof n=="number"?ee(e.x*(1-n)+t.x*n,e.y*(1-n)+t.y*n,e.z*(1-n)+t.z*n,e.w*(1-n)+t.w*n):ee(e.x*(1-n.x)+t.x*n.x,e.y*(1-n.y)+t.y*n.y,e.z*(1-n.z)+t.z*n.z,e.w*(1-n.w)+t.w*n.w)},sin:{vec2f:f(Math.sin),vec2h:g(Math.sin),vec3f:d(Math.sin),vec3h:T(Math.sin),vec4f:h(Math.sin),vec4h:b(Math.sin)},cos:{vec2f:f(Math.cos),vec2h:g(Math.cos),vec3f:d(Math.cos),vec3h:T(Math.cos),vec4f:h(Math.cos),vec4h:b(Math.cos)},cosh:{vec2f:f(Math.cosh),vec2h:g(Math.cosh),vec3f:d(Math.cosh),vec3h:T(Math.cosh),vec4f:h(Math.cosh),vec4h:b(Math.cosh)},exp:{vec2f:f(Math.exp),vec2h:g(Math.exp),vec3f:d(Math.exp),vec3h:T(Math.exp),vec4f:h(Math.exp),vec4h:b(Math.exp)},exp2:{vec2f:f(e=>2**e),vec2h:g(e=>2**e),vec3f:d(e=>2**e),vec3h:T(e=>2**e),vec4f:h(e=>2**e),vec4h:b(e=>2**e)},log:{vec2f:f(Math.log),vec2h:g(Math.log),vec3f:d(Math.log),vec3h:T(Math.log),vec4f:h(Math.log),vec4h:b(Math.log)},log2:{vec2f:f(Math.log2),vec2h:g(Math.log2),vec3f:d(Math.log2),vec3h:T(Math.log2),vec4f:h(Math.log2),vec4h:b(Math.log2)},fract:{vec2f:f(e=>e-Math.floor(e)),vec2h:g(e=>e-Math.floor(e)),vec3f:d(e=>e-Math.floor(e)),vec3h:T(e=>e-Math.floor(e)),vec4f:h(e=>e-Math.floor(e)),vec4h:b(e=>e-Math.floor(e))},isCloseToZero:{vec2f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec2h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t,vec3f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec3h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t,vec4f:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t,vec4h:(e,t)=>Math.abs(e.x)<=t&&Math.abs(e.y)<=t&&Math.abs(e.z)<=t&&Math.abs(e.w)<=t},neg:{vec2f:f(e=>-e),vec2h:g(e=>-e),vec2i:We(e=>-e),vec2u:tt(e=>-e),"vec2<bool>":e=>R(!e.x,!e.y),vec3f:d(e=>-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4f:h(Math.tanh),vec4h:b(Math.tanh)}};function $n(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var Fr={f:{1:v,2:k,3:E,4:S},h:{1:D,2:Fe,3:Pe,4:Ne},i:{1:z,2:j,3:se,4:G},u:{1:V,2:K,3:ie,4:Y},b:{1:$,2:Ce,3:Re,4:Be}},Cr={vec2f:k,vec2h:Fe,vec2i:j,vec2u:K,"vec2<bool>":Ce,vec3f:E,vec3h:Pe,vec3i:se,vec3u:ie,"vec3<bool>":Re,vec4f:S,vec4h:Ne,vec4i:G,vec4u:Y,"vec4<bool>":Be,mat2x2f:ae,mat3x3f:oe,mat4x4f:_},Dn={vec2f:v,vec2h:D,vec2i:z,vec2u:V,"vec2<bool>":$,vec3f:v,vec3h:D,vec3i:z,vec3u:V,"vec3<bool>":$,vec4f:v,vec4h:D,vec4i:z,vec4u:V,"vec4<bool>":$,mat2x2f:k,mat3x3f:E,mat4x4f:S};function Wa(e,t){if(yn(e)||fn(e))return e.propTypes[t]??ne;if(e===$||dt(e))return ne;let n=t.length;if(ce(e)&&n>=1&&n<=4){let r=e.type.includes("bool")?"b":e.type[4],s=Fr[r][n];if(s)return s}return ne}function La(e){return un(e)||wn(e)?e.elementType:e.type in Dn?Dn[e.type]:ne}function ja(e){return/^0x[0-9a-f]+$/i.test(e)?Number.parseInt(e):/^0b[01]+$/i.test(e)?Number.parseInt(e.slice(2),2):Number.parseFloat(e)}function Pr(e){return Number.isInteger(e)&&e>=-2147483648&&e<=2147483647?o(e,bn):o(e,zn)}var Ot={rank:Number.POSITIVE_INFINITY,action:"none"};function kn(e){return ce(e)?Ft[e.type]:void 0}function St(e,t){let n=Z(e),r=Z(t);if(n.type===r.type)return{rank:0,action:"none"};if(n.type==="abstractFloat"){if(r.type==="f32")return{rank:1,action:"none"};if(r.type==="f16")return{rank:2,action:"none"}}if(n.type==="abstractInt"){if(r.type==="i32")return{rank:3,action:"none"};if(r.type==="u32")return{rank:4,action:"none"};if(r.type==="abstractFloat")return{rank:5,action:"none"};if(r.type==="f32")return{rank:6,action:"none"};if(r.type==="f16")return{rank:7,action:"none"}}if(ce(n)&&ce(r)){let s=kn(n),a=kn(r);if(s&&a)return St(s,a)}return $t(n)&&$t(r)?{rank:0,action:"none"}:Ot}function Rr(e,t){let n=Z(e),r=Z(t);if(n.type==="ptr"&&St(n.inner,r).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(r.type==="ptr"&&St(n,r.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let s={f32:0,f16:1,i32:2,u32:3,bool:4};if(n.type in s&&r.type in s){let a=n.type,l=r.type;if(a!==l){let x=s[a];return{rank:s[l]<x?10:20,action:"cast",targetType:r}}}return Ot}function Nr(e,t,n){let r=St(e,t);return r.rank<Number.POSITIVE_INFINITY?r:n?Rr(e,t):Ot}function Fn(e,t,n){let r,s=Number.POSITIVE_INFINITY,a=new Map;for(let I of t){let P=0,jt=[],Kt=!0;for(let Nn of e){let It=Nr(Nn,I,n);if(It.rank===Number.POSITIVE_INFINITY){Kt=!1;break}P+=It.rank,jt.push(It)}Kt&&P<s&&(s=P,r=I,a.set(r,jt))}if(!r)return;let x=a.get(r).map((I,P)=>({sourceIndex:P,action:I.action,...I.action==="cast"&&{targetType:I.targetType}})),p=x.some(I=>I.action==="cast");return{targetType:r,actions:x,hasImplicitConversions:p}}function Cn(e){return e.type==="abstractFloat"?v:e.type==="abstractInt"?z:e}function Br(e,t){if(e.length===0)return;let n=[...new Set(e.map(Z))],r=t?[...new Set(t.map(Z))]:n,s=Fn(e,r,!1);if(s)return s;let a=Fn(e,r,!0);if(a)return a.hasImplicitConversions=a.actions.some(l=>l.action==="cast"),a}function Ur(e,t,n,r){if(n.action==="none")return o(t.value,r);switch(n.action){case"ref":return o(m`&${t}`,r);case"deref":return o(m`*${t}`,r);case"cast":return o(m`${e.resolve(r)}(${t})`,r);default:$n(n.action,"applyActionToSnippet")}}function _t({ctx:e,values:t,restrictTo:n,concretizeTypes:r=!1,verbose:s=!0}){let a=r&&!t.some(p=>Cn(p.dataType)===p.dataType),l=t.map(p=>a?Cn(p.dataType):p.dataType);if(l.some(p=>p===ne))return;X&&s&&Array.isArray(n)&&n.length===0&&console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");let x=Br(l,n);if(x)return X&&s&&x.hasImplicitConversions&&console.warn(`Implicit conversions from [
6
+ ${t.map(p=>` ${p.value}: ${p.dataType.type}`).join(`,
7
+ `)}
8
+ ] to ${x.targetType.type} are supported, but not recommended.
9
+ Consider using explicit conversions instead.`),t.map((p,I)=>{let P=x.actions[I];return pt(P,"Action should not be undefined"),Ur(e,p,P,x.targetType)})}function Ka(e,t,n){if(n===t.dataType)return t;if(t.dataType.type==="unknown")return o(e.resolve(t.value,n),n);let r=_t({ctx:e,values:[t],restrictTo:[n]});if(!r)throw new xt(`Cannot convert value of type '${t.dataType.type}' to type '${n.type}'`);return r[0]}function Ga(e,t,n){return Object.keys(t.propTypes).map(s=>{let a=n[s];if(!a)throw new Error(`Missing property ${s}`);let l=t.propTypes[s];return _t({ctx:e,values:[a],restrictTo:[l]})?.[0]??a})}function Ya(e){return kt(e)?e:cn(e)?o(e,e[lt]):y(e)||A(e)?o(e,Cr[e.kind]):typeof e=="string"||typeof e=="function"||typeof e=="object"||typeof e=="symbol"||typeof e>"u"||e===null?o(e,ne):typeof e=="number"?Pr(e):typeof e=="boolean"?o(e,$):o(e,ne)}function yt(e,t,n=!1,r=!0){let s=vt();return _t({ctx:s,values:e,restrictTo:t,concretizeTypes:n,verbose:r})??e}function Wt(e,t){if(typeof e=="number"&&typeof t=="number")return e+t;if(typeof e=="number"&&y(t))return M.addMixed[t.kind](t,e);if(y(e)&&typeof t=="number")return M.addMixed[e.kind](e,t);if(y(e)&&y(t)||A(e)&&A(t))return M.add[e.kind](e,t);throw new Error("Add/Sub called with invalid arguments.")}var io=w(Wt,(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:n.dataType;return(typeof e.value=="number"||y(e.value)||A(e.value))&&(typeof t.value=="number"||y(t.value)||A(t.value))?o(Wt(e.value,t.value),s):o(m`(${n} + ${r})`,s)},"add");function Pn(e,t){return Wt(e,Lt(-1,t))}var ao=w(Pn,(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:n.dataType;return(typeof e.value=="number"||y(e.value)||A(e.value))&&(typeof t.value=="number"||y(t.value)||A(t.value))?o(Pn(e.value,t.value),s):o(m`(${n} - ${r})`,s)},"sub");function Lt(e,t){if(typeof e=="number"&&typeof t=="number")return e*t;if(typeof e=="number"&&(y(t)||A(t)))return M.mulSxV[t.kind](e,t);if((y(e)||A(e))&&typeof t=="number")return M.mulSxV[e.kind](t,e);if(y(e)&&y(t))return M.mulVxV[e.kind](e,t);if(Dt(e)&&A(t))return M.mulVxM[t.kind](e,t);if(A(e)&&Dt(t))return M.mulMxV[e.kind](e,t);if(A(e)&&A(t))return M.mulVxV[e.kind](e,t);throw new Error("Mul called with invalid arguments.")}var oo=w(Lt,(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:we(r)||n.dataType.type.startsWith("vec")?n.dataType:r.dataType.type.startsWith("vec")?r.dataType:n.dataType;return(typeof e.value=="number"||y(e.value)||A(e.value))&&(typeof t.value=="number"||y(t.value)||A(t.value))?o(Lt(e.value,t.value),s):o(m`(${n} * ${r})`,s)},"mul");function Rn(e,t){if(typeof e=="number"&&typeof t=="number")return e/t;if(typeof e=="number"&&y(t)){let n=Qe[t.kind][i].jsImpl;return M.div[t.kind](n(e),t)}if(y(e)&&typeof t=="number"){let n=Qe[e.kind][i].jsImpl;return M.div[e.kind](e,n(t))}if(y(e)&&y(t))return M.div[e.kind](e,t);throw new Error("Div called with invalid arguments.")}var co=w(Rn,(e,t)=>{let[n,r]=yt([e,t],[v,D],!0,!1);return(typeof e.value=="number"||y(e.value))&&(typeof t.value=="number"||y(t.value))?o(Rn(e.value,t.value),n.dataType):o(m`(${n} / ${r})`,n.dataType)},"div"),uo=w((e,t)=>{if(typeof e=="number"&&typeof t=="number")return e%t;if(typeof e=="number"&&y(t)){let n=Qe[t.kind];return M.mod[t.kind](n(e),t)}if(y(e)&&typeof t=="number"){let n=Qe[e.kind];return M.mod[e.kind](e,n(t))}if(y(e)&&y(t))return M.mod[e.kind](e,t);throw new Error("Mod called with invalid arguments, expected types: number or vector.")},(e,t)=>{let[n,r]=yt([e,t]),s=we(n)?r.dataType:n.dataType;return o(m`(${n} % ${r})`,s)},"mod"),yo=w(e=>typeof e=="number"?-e:M.neg[e.kind](e),e=>o(m`-(${e})`,e.dataType),"neg");function xo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"function",access:"read-write"}}function po(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"private",access:"read-write"}}function mo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"workgroup",access:"read-write"}}function wo(e,t="read"){return{[i]:!0,type:"ptr",inner:e,addressSpace:"storage",access:t}}function fo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"uniform",access:"read"}}function vo(e){return{[i]:!0,type:"ptr",inner:e,addressSpace:"handle",access:"read"}}export{i as a,lt as b,Wr as c,At as d,Gt as e,es as f,te as g,ht as h,En as i,On as j,pt as k,Ht as l,Xt as m,Zt as n,Jt as o,Qt as p,en as q,tn as r,nn as s,rn as t,xt as u,sn as v,an as w,on as x,cs as y,ls as z,y as A,jn as B,Kn as C,Gn as D,ce as E,Yn as F,qn as G,$t as H,mt as I,un as J,yn as K,hs as L,xs as M,ln as N,hn as O,xn as P,ps as Q,ms as R,pn as S,ds as T,wt as U,vn as V,gn as W,Qn as X,$s as Y,Ds as Z,ks as _,er as $,Rs as aa,Ns as ba,Bs as ca,vt as da,tr as ea,Us as fa,Tn as ga,mn as ha,ws as ia,Jn as ja,wn as ka,fn as la,Ts as ma,bs as na,zs as oa,Vs as pa,Ss as qa,ne as ra,dn as sa,Z as ta,kt as ua,we as va,o as wa,m as xa,w as ya,bn as za,zn as Aa,$ as Ba,V as Ca,ni as Da,z as Ea,v as Fa,D as Ga,Je as Ha,k as Ia,Fe as Ja,j as Ka,K as La,Ce as Ma,E as Na,Pe as Oa,se as Pa,ie as Qa,Re as Ra,S as Sa,Ne as Ta,G as Ua,Y as Va,Be as Wa,et as Xa,xr as Ya,pr as Za,mr as _a,wr as $a,fr as ab,vr as bb,gr as cb,Tr as db,ae as eb,oe as fb,_ as gb,vi as hb,$n as ib,Wa as jb,La as kb,ja as lb,Pr as mb,Cn as nb,_t as ob,Ka as pb,Ga as qb,Ya as rb,Tt as sb,br as tb,Vi as ub,Si as vb,_i as wb,Ii as xb,Ai as yb,Mi as zb,$i as Ab,Di as Bb,ki as Cb,Fi as Db,Ci as Eb,Pi as Fb,Ri as Gb,Ni as Hb,Bi as Ib,Ui as Jb,Ei as Kb,Oi as Lb,Wi as Mb,Li as Nb,ji as Ob,Ki as Pb,Gi as Qb,Yi as Rb,qi as Sb,Hi as Tb,Xi as Ub,Zi as Vb,Ji as Wb,Qi as Xb,ea as Yb,ta as Zb,na as _b,ra as $b,sa as ac,ia as bc,aa as cc,oa as dc,ca as ec,ua as fc,ya as gc,la as hc,Sn as ic,fa as jc,va as kc,he as lc,M as mc,io as nc,ao as oc,oo as pc,co as qc,uo as rc,yo as sc,xo as tc,po as uc,mo as vc,wo as wc,fo as xc,vo as yc};
10
+ //# sourceMappingURL=chunk-WP6W72RY.js.map