typegpu 0.4.3 → 0.4.4
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.
- package/{attributes--1y4Kirx.d.cts → attributes-B5bhZAAK.d.cts} +1 -1
- package/{attributes-Dri8dk1v.d.ts → attributes-Cfiq6vud.d.ts} +1 -1
- package/chunk-C6C35PDM.cjs +2 -0
- package/{chunk-O7JKWPDH.cjs.map → chunk-C6C35PDM.cjs.map} +1 -1
- package/chunk-ZJMGYM7L.js +2 -0
- package/chunk-ZJMGYM7L.js.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.d.cts +3 -3
- package/data/index.d.ts +3 -3
- package/data/index.js +1 -1
- package/index.cjs +9 -9
- package/index.d.cts +99 -97
- package/index.d.ts +99 -97
- package/index.js +8 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/std/index.d.cts +1 -1
- package/std/index.d.ts +1 -1
- package/{wgslTypes-D0JqCGnw.d.cts → wgslTypes-DgaoTc4M.d.cts} +22 -22
- package/{wgslTypes-D0JqCGnw.d.ts → wgslTypes-DgaoTc4M.d.ts} +22 -22
- package/chunk-O7JKWPDH.cjs +0 -2
- package/chunk-OERXDFXG.js +0 -2
- package/chunk-OERXDFXG.js.map +0 -1
package/data/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { G as Bool, F as F32, a as F16, b as I32, U as U32, A as AnyWgslData, q as WgslArray, w as AnyData, H as PtrFn, V as Vec2f, e as Vec2h, h as Vec2i, k as Vec2u, c as Vec3f, f as Vec3h, i as Vec3i, l as Vec3u, d as Vec4f, g as Vec4h, j as Vec4i, m as Vec4u, r as Disarray, B as BaseData, s as Unstruct, J as Mat2x2f, N as Mat3x3f, Q as Mat4x4f, R as m2x2f, S as m3x3f, X as m4x4f, Y as Atomic } from '../wgslTypes-
|
2
|
-
export { a9 as Align, an as AnyLooseData, aa as Builtin, D as Decorated, at as FormatToWGSLType, I as Infer, ab as Interpolate, L as Location, am as LooseDecorated, ba as PackedData, a8 as Size, au as TgpuVertexFormatData, W as WgslStruct, aV as float16, aW as float16x2, aX as float16x4, aY as float32, aZ as float32x2, a_ as float32x3, a$ as float32x4, av as formatToWGSLType, a3 as isAlignAttrib, a1 as isAtomic, a4 as isBuiltinAttrib, ar as isData, a2 as isDecorated, ao as isDisarray, a6 as isInterpolateAttrib, a5 as isLocationAttrib, as as isLooseData, aq as isLooseDecorated, a0 as isPtrFn, a7 as isSizeAttrib, ap as isUnstruct, _ as isWgslArray, Z as isWgslData, $ as isWgslStruct, aw as packedFormats, aM as sint16, aN as sint16x2, aO as sint16x4, b4 as sint32, b5 as sint32x2, b6 as sint32x3, b7 as sint32x4, aA as sint8, aB as sint8x2, aC as sint8x4, aS as snorm16, aT as snorm16x2, aU as snorm16x4, aG as snorm8, aH as snorm8x2, aI as snorm8x4, al as struct, aJ as uint16, aK as uint16x2, aL as uint16x4, b0 as uint32, b1 as uint32x2, b2 as uint32x3, b3 as uint32x4, ax as uint8, ay as uint8x2, az as uint8x4, b8 as unorm10_10_10_2, aP as unorm16, aQ as unorm16x2, aR as unorm16x4, aD as unorm8, aE as unorm8x2, aF as unorm8x4, b9 as unorm8x4_bgra, ac as v2f, ad as v2i, ae as v2u, af as v3f, ag as v3i, ah as v3u, ai as v4f, aj as v4i, ak as v4u } from '../wgslTypes-
|
3
|
-
export { A as AnyAttribute, v as AnyBuiltin, j as BuiltinClipDistances, m as BuiltinFragDepth, k as BuiltinFrontFacing, r as BuiltinGlobalInvocationId, g as BuiltinInstanceIndex, p as BuiltinLocalInvocationId, q as BuiltinLocalInvocationIndex, u as BuiltinNumWorkgroups, h as BuiltinPosition, n as BuiltinSampleIndex, o as BuiltinSampleMask, B as BuiltinVertexIndex, t as BuiltinWorkgroupId, H as HasCustomLocation, I as IsBuiltin, d as align, f as builtin, i as interpolate, e as isBuiltin, l as location, s as size } from '../attributes-
|
1
|
+
import { G as Bool, F as F32, a as F16, b as I32, U as U32, A as AnyWgslData, q as WgslArray, w as AnyData, H as PtrFn, V as Vec2f, e as Vec2h, h as Vec2i, k as Vec2u, c as Vec3f, f as Vec3h, i as Vec3i, l as Vec3u, d as Vec4f, g as Vec4h, j as Vec4i, m as Vec4u, r as Disarray, B as BaseData, s as Unstruct, J as Mat2x2f, N as Mat3x3f, Q as Mat4x4f, R as m2x2f, S as m3x3f, X as m4x4f, Y as Atomic } from '../wgslTypes-DgaoTc4M.js';
|
2
|
+
export { a9 as Align, an as AnyLooseData, aa as Builtin, D as Decorated, at as FormatToWGSLType, I as Infer, ab as Interpolate, L as Location, am as LooseDecorated, ba as PackedData, a8 as Size, au as TgpuVertexFormatData, W as WgslStruct, aV as float16, aW as float16x2, aX as float16x4, aY as float32, aZ as float32x2, a_ as float32x3, a$ as float32x4, av as formatToWGSLType, a3 as isAlignAttrib, a1 as isAtomic, a4 as isBuiltinAttrib, ar as isData, a2 as isDecorated, ao as isDisarray, a6 as isInterpolateAttrib, a5 as isLocationAttrib, as as isLooseData, aq as isLooseDecorated, a0 as isPtrFn, a7 as isSizeAttrib, ap as isUnstruct, _ as isWgslArray, Z as isWgslData, $ as isWgslStruct, aw as packedFormats, aM as sint16, aN as sint16x2, aO as sint16x4, b4 as sint32, b5 as sint32x2, b6 as sint32x3, b7 as sint32x4, aA as sint8, aB as sint8x2, aC as sint8x4, aS as snorm16, aT as snorm16x2, aU as snorm16x4, aG as snorm8, aH as snorm8x2, aI as snorm8x4, al as struct, aJ as uint16, aK as uint16x2, aL as uint16x4, b0 as uint32, b1 as uint32x2, b2 as uint32x3, b3 as uint32x4, ax as uint8, ay as uint8x2, az as uint8x4, b8 as unorm10_10_10_2, aP as unorm16, aQ as unorm16x2, aR as unorm16x4, aD as unorm8, aE as unorm8x2, aF as unorm8x4, b9 as unorm8x4_bgra, ac as v2f, ad as v2i, ae as v2u, af as v3f, ag as v3i, ah as v3u, ai as v4f, aj as v4i, ak as v4u } from '../wgslTypes-DgaoTc4M.js';
|
3
|
+
export { A as AnyAttribute, v as AnyBuiltin, j as BuiltinClipDistances, m as BuiltinFragDepth, k as BuiltinFrontFacing, r as BuiltinGlobalInvocationId, g as BuiltinInstanceIndex, p as BuiltinLocalInvocationId, q as BuiltinLocalInvocationIndex, u as BuiltinNumWorkgroups, h as BuiltinPosition, n as BuiltinSampleIndex, o as BuiltinSampleMask, B as BuiltinVertexIndex, t as BuiltinWorkgroupId, H as HasCustomLocation, I as IsBuiltin, d as align, f as builtin, i as interpolate, e as isBuiltin, l as location, s as size } from '../attributes-Cfiq6vud.js';
|
4
4
|
|
5
5
|
/**
|
6
6
|
* A schema that represents a boolean value. (equivalent to `bool` in WGSL)
|
package/data/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{$ as ha,A as I,Aa as Ia,B as J,Ba as Ja,C as K,Ca as Ka,D as L,Da as La,E as M,Ea as Ma,F as N,G as O,Ga as Na,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a,aa as ia,b,ba as ja,c,ca as ka,d,da as la,e,ea as ma,f,fa as na,g,ga as oa,h,ha as pa,i,ia as qa,j,ja as ra,k,ka as sa,la as ta,ma as ua,n as l,na as va,o as m,oa as wa,p as n,q as o,ra as xa,s as p,t as q,ta as ya,u as r,ua as za,v as s,va as Aa,w as t,wa as Ba,x as u,xa as Ca,y as v,ya as Ha}from"../chunk-
|
1
|
+
import{$ as ha,A as I,Aa as Ia,B as J,Ba as Ja,C as K,Ca as Ka,D as L,Da as La,E as M,Ea as Ma,F as N,G as O,Ga as Na,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a,aa as ia,b,ba as ja,c,ca as ka,d,da as la,e,ea as ma,f,fa as na,g,ga as oa,h,ha as pa,i,ia as qa,j,ja as ra,k,ka as sa,la as ta,ma as ua,n as l,na as va,o as m,oa as wa,p as n,q as o,ra as xa,s as p,t as q,ta as ya,u as r,ua as za,v as s,va as Aa,w as t,wa as Ba,x as u,xa as Ca,y as v,ya as Ha}from"../chunk-ZJMGYM7L.js";import{A as Ea,B as Fa,C as Ga,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as Da}from"../chunk-ZHXAQ2YE.js";export{Ia as align,xa as alignmentOf,za as arrayOf,Ha as atomic,q as bool,Na as builtin,Ba as disarrayOf,u as f16,t as f32,ga as float16,ha as float16x2,ia as float16x4,ja as float32,ka as float32x2,la as float32x3,ma as float32x4,I as formatToWGSLType,s as i32,La as interpolate,f as isAlignAttrib,e as isAtomic,Ma as isBuiltin,j as isBuiltinAttrib,p as isData,k as isDecorated,m as isDisarray,i as isInterpolateAttrib,h as isLocationAttrib,l as isLooseData,o as isLooseDecorated,d as isPtrFn,g as isSizeAttrib,n as isUnstruct,b as isWgslArray,a as isWgslData,c as isWgslStruct,Ka as location,Da as mat2x2f,Ea as mat3x3f,Fa as mat4x4f,Ga as matToArray,J as packedFormats,Aa as ptrFn,Z as sint16,_ as sint16x2,$ as sint16x4,ra as sint32,sa as sint32x2,ta as sint32x3,ua as sint32x4,N as sint8,O as sint8x2,P as sint8x4,Ja as size,ya as sizeOf,da as snorm16,ea as snorm16x2,fa as snorm16x4,T as snorm8,U as snorm8x2,V as snorm8x4,v as struct,r as u32,W as uint16,X as uint16x2,Y as uint16x4,na as uint32,oa as uint32x2,pa as uint32x3,qa as uint32x4,K as uint8,L as uint8x2,M as uint8x4,va as unorm10_10_10_2,aa as unorm16,ba as unorm16x2,ca as unorm16x4,Q as unorm8,R as unorm8x2,S as unorm8x4,wa as unorm8x4_bgra,Ca as unstruct,w as vec2f,x as vec2h,y as vec2i,z as vec2u,A as vec3f,B as vec3h,C as vec3i,D as vec3u,E as vec4f,F as vec4h,G as vec4i,H as vec4u};
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.cjs
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkO7JKWPDHcjs = require('./chunk-O7JKWPDH.cjs');var _chunk7X4KDNDZcjs = require('./chunk-7X4KDNDZ.cjs');function q(e){return(e==null?void 0:e.resourceType)==="slot"}function J(e){return(e==null?void 0:e.resourceType)==="derived"}function Se(e){return(e==null?void 0:e["~providing"])!==void 0}function re(e){return(e==null?void 0:e.resourceType)==="accessor"}var v=Symbol("Unknown data type");function st(e){return typeof(e==null?void 0:e["~resolve"])=="function"}function ne(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||st(e)||_chunkO7JKWPDHcjs.a.call(void 0, e)||q(e)||J(e)||Se(e)}function lr(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function Le(e){return(e==null?void 0:e.resourceType)==="buffer-usage"}var k={get(e,t){if(t in e)return Reflect.get(e,t);if(t!=="~providing")return new Proxy({"~resolve":r=>`${r.resolve(e)}.${String(t)}`,toString:()=>{var r;return`.value(...).${String(t)}:${(r=e.label)!=null?r:"<unnamed>"}`}},k)}};function Fe(e){let t=e;for(;q(t)||J(t)||re(t)||Le(t);)t=t.value;return t}function dr(e,t){return new ut(e,t)}var ut=class{constructor(t,r){this.dataType=t;this._value=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"_label")}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),n=t.resolveValue(this._value,this.dataType);return t.addDeclaration(`const ${r} = ${n};`),r}toString(){var t;return`const:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){return _chunk7X4KDNDZcjs.m.call(void 0, )?new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k):this._value}};function $(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function ae(e,t){for(let[r,n]of Object.entries(t))e[r]=n,$(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function mr(e,t,r){let n=[...e.matchAll(new RegExp(":\\s*(?<arg>.*?)\\s*[,)]","g"))].map(a=>a?a[1]:void 0);r(Object.fromEntries(t.flatMap((a,o)=>{let i=n?n[o]:void 0;return _chunkO7JKWPDHcjs.c.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function ge(e,t,r){var o;let n=e.match(new RegExp("->(?<output>.*?){","s")),a=n?(o=n[1])==null?void 0:o.trim():void 0;_chunkO7JKWPDHcjs.c.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function sn(e){return new RegExp(`(?<![\\w_.])${e.replaceAll(".","\\.")}(?![\\w_])`,"g")}function oe(e,t,r){return Object.entries(t).reduce((n,[a,o])=>{var i;return ne(o)||_chunkO7JKWPDHcjs.n.call(void 0, o)?n.replaceAll(sn(a),e.resolve(o)):o!==null&&typeof o=="object"?((i=[...r.matchAll(new RegExp(`${a.replaceAll(".","\\.")}\\.(?<prop>.*?)(?![\\w_])`,"g"))].map(l=>l[1]))!=null?i:[]).reduce((l,s)=>s&&s in o?oe(e,{[`${a}.${s}`]:o[s]},l):l,n):n},r)}function gr(e){return new pt(e)}var pt=class{constructor(t){this.declaration=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"externalsToApply",[])}$uses(t){return this.externalsToApply.push(t),this}"~resolve"(t){let r={};for(let a of this.externalsToApply)ae(r,a);let n=oe(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}};var fr=new WeakMap;function Tr(e){return fr.get(e)}function yr(e,t,r){return fr.set(e,{ast:t,externals:r}),e}function H(e,t){let r=[];return typeof t=="string"&&(mr(t,e.argTypes,n=>r.push(n)),ge(t,e.returnType,n=>r.push(n))),{label:void 0,applyExternals(n){r.push(n)},resolve(n,a=""){var u;let o={};for(let l of r)ae(o,l);let i=n.names.makeUnique(this.label);if(typeof t=="string"){let l=oe(n,o,t.trim());n.addDeclaration(`${a}fn ${i}${l}`)}else{let l=Tr(t);if(l!=null&&l.externals){let c=Object.fromEntries(Object.entries(l.externals).filter(([T])=>!(T in o)));ae(o,c)}let s=(u=l==null?void 0:l.ast)!=null?u:n.transpileFn(String(t)),m=s.externalNames.filter(c=>!(c in o));if(m.length>0)throw new (0, _chunk7X4KDNDZcjs.h)(this.label,m);let g=s.argNames.map((c,T)=>({value:c,dataType:e.argTypes[T]})),{head:f,body:w}=n.fnToWgsl({args:g,returnType:e.returnType,body:s.body,externalMap:o});n.addDeclaration(`${a}fn ${i}${n.resolve(f)}${n.resolve(w)}`)}return i}}}function cr(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunkO7JKWPDHcjs.Ea.call(void 0, n))return[r,n];let a=_chunkO7JKWPDHcjs.r.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunkO7JKWPDHcjs.za.call(void 0, n,{type:"@location",value:t++})]}))}function Ce(e){return _chunkO7JKWPDHcjs.s.call(void 0, e)?_chunkO7JKWPDHcjs.r.call(void 0, e)!==void 0?e:_chunkO7JKWPDHcjs.Ca.call(void 0, 0,e):_chunkO7JKWPDHcjs.y.call(void 0, cr(e))}function fe(e){return _chunkO7JKWPDHcjs.y.call(void 0, cr(e))}function xr(e){var t,r,n,a;return{argTypes:[fe((t=e.in)!=null?t:{})],returnType:void 0,workgroupSize:[(r=e.workgroupSize[0])!=null?r:1,(n=e.workgroupSize[1])!=null?n:1,(a=e.workgroupSize[2])!=null?a:1],does(o){return un(this,e.workgroupSize,o)}}}function un(e,t,r){let n=H(e,r),a=e.argTypes[0];return{shell:e,get label(){return n.label},$uses(o){return n.applyExternals(o),this},$name(o){return n.label=o,$(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){return n.resolve(o,`@compute @workgroup_size(${t.join(", ")}) `)},toString(){var o;return`computeFn:${(o=this.label)!=null?o:"<unnamed>"}`}}}function br(e,t){return{argTypes:e,returnType:t,does(r){return ln(this,r)}}}function lt(e){return(e==null?void 0:e.resourceType)==="function"}function pn([e,t]){var r;return`${(r=e.label)!=null?r:"<unnamed>"}=${t}`}function ln(e,t){let r=H(e,t),o=Object.assign((...i)=>{if(_chunk7X4KDNDZcjs.m.call(void 0, ))return new Ve(o,i);if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");return t(...i)},{shell:e,resourceType:"function",$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,this},with(i,u){return hr(o,[[re(i)?i.slot:i,u]])},"~resolve"(i){return r.resolve(i)}});return Object.defineProperty(o,"label",{get:()=>r.label}),Object.defineProperty(o,"toString",{value:()=>{var i;return`fn:${(i=r.label)!=null?i:"<unnamed>"}`}}),o}function hr(e,t){let r={resourceType:"function",shell:e.shell,"~providing":{inner:e,pairs:t},$uses(o){return e.$uses(o),this},$name(o){return e.$name(o),this},with(o,i){return hr(a,[...t,[re(o)?o.slot:o,i]])}},a=Object.assign((...o)=>_chunk7X4KDNDZcjs.m.call(void 0, )?new Ve(a,o):e(...o),r);return Object.defineProperty(a,"label",{get:()=>e.label}),Object.defineProperty(a,"toString",{value(){var i;return`fn:${(i=e.label)!=null?i:"<unnamed>"}[${t.map(pn).join(", ")}]`}}),a}var Ve=class{constructor(t,r){this._fn=t;this._params=r}get label(){return this._fn.label}"~resolve"(t){return t.resolve(`${t.resolve(this._fn)}(${this._params.map(r=>t.resolve(r)).join(", ")})`)}toString(){var t;return`call:${(t=this.label)!=null?t:"<unnamed>"}`}};function wr(e){var t;return{argTypes:[fe((t=e.in)!=null?t:{})],targets:e.out,returnType:Ce(e.out),does(r){return dn(this,r)}}}function dn(e,t){let r=H(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&ge(t,n,i=>r.applyExternals(i)),{shell:e,outputType:n,get label(){return r.label},$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,$(n)&&n.$name(`${i}_Output`),$(a)&&a.$name(`${i}_Input`),this},"~resolve"(i){if(typeof t=="string")return r.resolve(i,"@fragment ");let u=i;if(u.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return u.callStack.push(n),r.resolve(i,"@fragment ")}finally{u.callStack.pop()}},toString(){var i;return`fragmentFn:${(i=this.label)!=null?i:"<unnamed>"}`}}}function Sr(e){var t,r;return{attributes:[(t=e.in)!=null?t:{}],returnType:Ce(e.out),argTypes:[fe((r=e.in)!=null?r:{})],does(n){return mn(this,n)}}}function mn(e,t){let r=H(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&ge(t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,inputType:a,get label(){return r.label},$uses(o){return r.applyExternals(o),this},$name(o){return r.label=o,$(n)&&n.$name(`${o}_Output`),$(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){if(typeof t=="string")return r.resolve(o,"@vertex ");let i=o;if(i.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return i.callStack.push(n),r.resolve(o,"@vertex ")}finally{i.callStack.pop()}},toString(){var o;return`vertexFn:${(o=this.label)!=null?o:"<unnamed>"}`}}}var Y=class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"lastUniqueId",0)}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}},Q= exports.StrictNameRegistry =class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"_usedNames",new Set)}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}};function Fr(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}function De(e){return typeof(e==null?void 0:e.format)=="string"}function Dr(e,t){var i,u;let r=[];if(_chunkO7JKWPDHcjs.s.call(void 0, e)){if(!De(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:(i=_chunkO7JKWPDHcjs.r.call(void 0, e))!=null?i:0}]}]}}let n=[],a=new WeakMap,o=0;for(let[l,s]of Object.entries(e)){if(_chunkO7JKWPDHcjs.Ea.call(void 0, s))continue;let m=t[l];if(!m)throw new Error(`An attribute by the name of '${l}' was not provided to the shader.`);let g=m._layout,f=a.get(g);f||(r.push(g),f=[],n.push({arrayStride:g.stride,stepMode:g.stepMode,attributes:f}),a.set(g,f)),o=(u=_chunkO7JKWPDHcjs.r.call(void 0, s))!=null?u:o,f.push({format:m.format,offset:m.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var gn=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"];function fn(e){return gn.includes(e.type)}function dt(e,[t,r]){return` ${_chunkO7JKWPDHcjs.Fa.call(void 0, r)}${t}: ${e.resolve(r)},
|
2
|
-
`}function
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkC6C35PDMcjs = require('./chunk-C6C35PDM.cjs');var _chunk7X4KDNDZcjs = require('./chunk-7X4KDNDZ.cjs');function q(e){return(e==null?void 0:e.resourceType)==="slot"}function J(e){return(e==null?void 0:e.resourceType)==="derived"}function Se(e){return(e==null?void 0:e["~providing"])!==void 0}function re(e){return(e==null?void 0:e.resourceType)==="accessor"}var A=Symbol("Unknown data type");function st(e){return typeof(e==null?void 0:e["~resolve"])=="function"}function ne(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||st(e)||_chunkC6C35PDMcjs.a.call(void 0, e)||q(e)||J(e)||Se(e)}function mr(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}function Le(e){return(e==null?void 0:e.resourceType)==="buffer-usage"}var k={get(e,t){if(t in e)return Reflect.get(e,t);if(t!=="~providing")return new Proxy({"~resolve":r=>`${r.resolve(e)}.${String(t)}`,toString:()=>{var r;return`.value(...).${String(t)}:${(r=e.label)!=null?r:"<unnamed>"}`}},k)}};function Fe(e){let t=e;for(;q(t)||J(t)||re(t)||Le(t);)t=t.value;return t}function gr(e,t){return new ut(e,t)}var ut=class{constructor(t,r){this.dataType=t;this._value=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"_label")}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),n=t.resolveValue(this._value,this.dataType);return t.addDeclaration(`const ${r} = ${n};`),r}toString(){var t;return`const:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){return _chunk7X4KDNDZcjs.m.call(void 0, )?new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k):this._value}};function $(e){return!!e&&(typeof e=="object"||typeof e=="function")&&"$name"in e}function ae(e,t){for(let[r,n]of Object.entries(t))e[r]=n,$(n)&&(!("label"in n)||n.label===void 0)&&n.$name(r)}function fr(e,t,r){let n=[...e.matchAll(new RegExp(":\\s*(?<arg>.*?)\\s*[,)]","g"))].map(a=>a?a[1]:void 0);r(Object.fromEntries(t.flatMap((a,o)=>{let i=n?n[o]:void 0;return _chunkC6C35PDMcjs.c.call(void 0, a)&&i!==void 0?[[i,a]]:[]})))}function ge(e,t,r){var o;let n=e.match(new RegExp("->(?<output>.*?){","s")),a=n?(o=n[1])==null?void 0:o.trim():void 0;_chunkC6C35PDMcjs.c.call(void 0, t)&&a&&!/\s/g.test(a)&&r({[a]:t})}function pn(e){return new RegExp(`(?<![\\w_.])${e.replaceAll(".","\\.")}(?![\\w_])`,"g")}function oe(e,t,r){return Object.entries(t).reduce((n,[a,o])=>{var i;return ne(o)||_chunkC6C35PDMcjs.n.call(void 0, o)?n.replaceAll(pn(a),e.resolve(o)):o!==null&&typeof o=="object"?((i=[...r.matchAll(new RegExp(`${a.replaceAll(".","\\.")}\\.(?<prop>.*?)(?![\\w_])`,"g"))].map(l=>l[1]))!=null?i:[]).reduce((l,s)=>s&&s in o?oe(e,{[`${a}.${s}`]:o[s]},l):l,n):n},r)}function Tr(e){return new pt(e)}var pt=class{constructor(t){this.declaration=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"externalsToApply",[])}$uses(t){return this.externalsToApply.push(t),this}"~resolve"(t){let r={};for(let a of this.externalsToApply)ae(r,a);let n=oe(t,r,this.declaration);return t.addDeclaration(n),""}toString(){return`declare: ${this.declaration}`}};var yr=new WeakMap;function cr(e){return yr.get(e)}function xr(e,t,r){return yr.set(e,{ast:t,externals:r}),e}function H(e,t){let r=[];return typeof t=="string"&&(fr(t,e.argTypes,n=>r.push(n)),ge(t,e.returnType,n=>r.push(n))),{label:void 0,applyExternals(n){r.push(n)},resolve(n,a=""){var p;let o={};for(let l of r)ae(o,l);let i=n.names.makeUnique(this.label);if(typeof t=="string"){let l=oe(n,o,t.trim());n.addDeclaration(`${a}fn ${i}${l}`)}else{let l=cr(t);if(l!=null&&l.externals){let c=Object.fromEntries(Object.entries(l.externals).filter(([T])=>!(T in o)));ae(o,c)}let s=(p=l==null?void 0:l.ast)!=null?p:n.transpileFn(String(t)),m=s.externalNames.filter(c=>!(c in o));if(m.length>0)throw new (0, _chunk7X4KDNDZcjs.h)(this.label,m);let g=s.argNames.map((c,T)=>({value:c,dataType:e.argTypes[T]})),{head:f,body:w}=n.fnToWgsl({args:g,returnType:e.returnType,body:s.body,externalMap:o});n.addDeclaration(`${a}fn ${i}${n.resolve(f)}${n.resolve(w)}`)}return i}}}function br(e){let t=0;return Object.fromEntries(Object.entries(e).map(([r,n])=>{if(_chunkC6C35PDMcjs.Ea.call(void 0, n))return[r,n];let a=_chunkC6C35PDMcjs.r.call(void 0, n);return a!==void 0?(t=a+1,[r,n]):[r,_chunkC6C35PDMcjs.za.call(void 0, n,{type:"@location",value:t++})]}))}function Ce(e){return _chunkC6C35PDMcjs.s.call(void 0, e)?_chunkC6C35PDMcjs.r.call(void 0, e)!==void 0?e:_chunkC6C35PDMcjs.Ca.call(void 0, 0,e):_chunkC6C35PDMcjs.y.call(void 0, br(e))}function fe(e){return _chunkC6C35PDMcjs.y.call(void 0, br(e))}function hr(e){var t,r,n,a;return{argTypes:[fe((t=e.in)!=null?t:{})],returnType:void 0,workgroupSize:[(r=e.workgroupSize[0])!=null?r:1,(n=e.workgroupSize[1])!=null?n:1,(a=e.workgroupSize[2])!=null?a:1],does(o){return ln(this,e.workgroupSize,o)}}}function ln(e,t,r){let n=H(e,r),a=e.argTypes[0];return{shell:e,get label(){return n.label},$uses(o){return n.applyExternals(o),this},$name(o){return n.label=o,$(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){return n.resolve(o,`@compute @workgroup_size(${t.join(", ")}) `)},toString(){var o;return`computeFn:${(o=this.label)!=null?o:"<unnamed>"}`}}}function wr(e,t){return{argTypes:e,returnType:t,does(r){return mn(this,r)}}}function lt(e){return(e==null?void 0:e.resourceType)==="function"}function dn([e,t]){var r;return`${(r=e.label)!=null?r:"<unnamed>"}=${t}`}function mn(e,t){let r=H(e,t),o=Object.assign((...i)=>{if(_chunk7X4KDNDZcjs.m.call(void 0, ))return new Ve(o,i);if(typeof t=="string")throw new Error("Cannot execute on the CPU functions constructed with raw WGSL");return t(...i)},{shell:e,resourceType:"function",$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,this},with(i,p){return Sr(o,[[re(i)?i.slot:i,p]])},"~resolve"(i){return r.resolve(i)}});return Object.defineProperty(o,"label",{get:()=>r.label}),Object.defineProperty(o,"toString",{value:()=>{var i;return`fn:${(i=r.label)!=null?i:"<unnamed>"}`}}),o}function Sr(e,t){let r={resourceType:"function",shell:e.shell,"~providing":{inner:e,pairs:t},$uses(o){return e.$uses(o),this},$name(o){return e.$name(o),this},with(o,i){return Sr(a,[...t,[re(o)?o.slot:o,i]])}},a=Object.assign((...o)=>_chunk7X4KDNDZcjs.m.call(void 0, )?new Ve(a,o):e(...o),r);return Object.defineProperty(a,"label",{get:()=>e.label}),Object.defineProperty(a,"toString",{value(){var i;return`fn:${(i=e.label)!=null?i:"<unnamed>"}[${t.map(dn).join(", ")}]`}}),a}var Ve=class{constructor(t,r){this._fn=t;this._params=r}get label(){return this._fn.label}"~resolve"(t){return t.resolve(`${t.resolve(this._fn)}(${this._params.map(r=>t.resolve(r)).join(", ")})`)}toString(){var t;return`call:${(t=this.label)!=null?t:"<unnamed>"}`}};function Fr(e){var t;return{argTypes:[fe((t=e.in)!=null?t:{})],targets:e.out,returnType:Ce(e.out),does(r){return gn(this,r)}}}function gn(e,t){let r=H(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&ge(t,n,i=>r.applyExternals(i)),{shell:e,outputType:n,get label(){return r.label},$uses(i){return r.applyExternals(i),this},$name(i){return r.label=i,$(n)&&n.$name(`${i}_Output`),$(a)&&a.$name(`${i}_Input`),this},"~resolve"(i){if(typeof t=="string")return r.resolve(i,"@fragment ");let p=i;if(p.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return p.callStack.push(n),r.resolve(i,"@fragment ")}finally{p.callStack.pop()}},toString(){var i;return`fragmentFn:${(i=this.label)!=null?i:"<unnamed>"}`}}}function Dr(e){var t,r;return{attributes:[(t=e.in)!=null?t:{}],returnType:Ce(e.out),argTypes:[fe((r=e.in)!=null?r:{})],does(n){return fn(this,n)}}}function fn(e,t){let r=H(e,t),n=e.returnType,a=e.argTypes[0];return typeof t=="string"&&ge(t,n,o=>r.applyExternals(o)),{shell:e,outputType:n,inputType:a,get label(){return r.label},$uses(o){return r.applyExternals(o),this},$name(o){return r.label=o,$(n)&&n.$name(`${o}_Output`),$(a)&&a.$name(`${o}_Input`),this},"~resolve"(o){if(typeof t=="string")return r.resolve(o,"@vertex ");let i=o;if(i.callStack===void 0)throw new Error("Cannot resolve a TGSL function outside of a generation context");try{return i.callStack.push(n),r.resolve(o,"@vertex ")}finally{i.callStack.pop()}},toString(){var o;return`vertexFn:${(o=this.label)!=null?o:"<unnamed>"}`}}}var Y=class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"lastUniqueId",0)}makeUnique(t){let r;return t?(r=t.replaceAll(/\s/g,"_"),r=r.replaceAll(/[^\w\d]/g,"")):r="item",`${r}_${this.lastUniqueId++}`}},Q= exports.StrictNameRegistry =class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"_usedNames",new Set)}makeUnique(t){if(t===void 0)throw new Error("Unnamed item found when using a strict name registry");let r=0,n=t;for(;this._usedNames.has(n);)r++,n=`${t}_${r}`;return this._usedNames.add(n),n}};function Ur(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}function De(e){return typeof(e==null?void 0:e.format)=="string"}function vr(e,t){var i,p;let r=[];if(_chunkC6C35PDMcjs.s.call(void 0, e)){if(!De(t))throw new Error("Shader expected a single attribute, not a record of attributes to be passed in.");return r.push(t._layout),{usedVertexLayouts:r,bufferDefinitions:[{arrayStride:t._layout.stride,stepMode:t._layout.stepMode,attributes:[{format:t.format,offset:t.offset,shaderLocation:(i=_chunkC6C35PDMcjs.r.call(void 0, e))!=null?i:0}]}]}}let n=[],a=new WeakMap,o=0;for(let[l,s]of Object.entries(e)){if(_chunkC6C35PDMcjs.Ea.call(void 0, s))continue;let m=t[l];if(!m)throw new Error(`An attribute by the name of '${l}' was not provided to the shader.`);let g=m._layout,f=a.get(g);f||(r.push(g),f=[],n.push({arrayStride:g.stride,stepMode:g.stepMode,attributes:f}),a.set(g,f)),o=(p=_chunkC6C35PDMcjs.r.call(void 0, s))!=null?p:o,f.push({format:m.format,offset:m.offset,shaderLocation:o++})}return{usedVertexLayouts:r,bufferDefinitions:n}}var Tn=["bool","f32","f16","i32","u32","vec2f","vec3f","vec4f","vec2h","vec3h","vec4h","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","mat2x2f","mat3x3f","mat4x4f"];function yn(e){return Tn.includes(e.type)}function dt(e,[t,r]){return` ${_chunkC6C35PDMcjs.Fa.call(void 0, r)}${t}: ${e.resolve(r)},
|
2
|
+
`}function cn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
|
3
3
|
struct ${r} {
|
4
4
|
${Object.entries(t.propTypes).map(n=>dt(e,n)).join("")}}
|
5
|
-
`),r}function
|
5
|
+
`),r}function xn(e,t){let r=e.names.makeUnique(t.label);return e.addDeclaration(`
|
6
6
|
struct ${r} {
|
7
|
-
${Object.entries(t.propTypes).map(n=>De(n[1])?dt(e,[n[0],
|
7
|
+
${Object.entries(t.propTypes).map(n=>De(n[1])?dt(e,[n[0],_chunkC6C35PDMcjs.A[n[1].format]]):dt(e,n)).join("")}
|
8
8
|
}
|
9
|
-
`),r}function
|
9
|
+
`),r}function bn(e,t){let r=e.resolve(t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function hn(e,t){let r=e.resolve(De(t.elementType)?_chunkC6C35PDMcjs.A[t.elementType.format]:t.elementType);return t.elementCount===0?`array<${r}>`:`array<${r}, ${t.elementCount}>`}function mt(e,t){if(_chunkC6C35PDMcjs.n.call(void 0, t))return t.type==="unstruct"?xn(e,t):t.type==="disarray"?hn(e,t):t.type==="loose-decorated"?e.resolve(De(t.inner)?_chunkC6C35PDMcjs.A[t.inner.format]:t.inner):e.resolve(_chunkC6C35PDMcjs.A[t.type]);if(yn(t))return t.type;if(t.type==="struct")return cn(e,t);if(t.type==="array")return bn(e,t);if(t.type==="atomic")return`atomic<${mt(e,t.inner)}>`;if(t.type==="decorated")return e.resolve(t.inner);if(t.type==="ptrFn")return`ptr<function, ${e.resolve(t.inner)}>`;Ur(t,"resolveData")}function*Ar(e){let t=0;for(;;)e.has(t)||(yield t),t++}var wn=["==","!=","<","<=",">",">=","<<",">>","+","-","*","/","%","|","^","&","&&","||"];function U(e,t){return ne(t.value)||_chunkC6C35PDMcjs.a.call(void 0, t.value)?e.resolve(t.value):String(t.value)}function Sn(e){throw new Error(`'${JSON.stringify(e)}' was not handled by the WGSL generator.`)}function Ir(e,t){return t?{value:"true",dataType:_chunkC6C35PDMcjs.t}:{value:"false",dataType:_chunkC6C35PDMcjs.t}}function Rr(e,t){return`${e.indent()}{
|
10
10
|
${t.b.map(r=>ft(e,r)).join(`
|
11
11
|
`)}
|
12
|
-
${e.dedent()}}`}function gt(e,t){return e.getById(t)}function
|
12
|
+
${e.dedent()}}`}function gt(e,t){return e.getById(t)}function I(e,t){if(typeof t=="string")return gt(e,t);if(typeof t=="boolean")return Ir(e,t);if("x"in t){let[r,n,a]=t.x,o=U(e,I(e,r)),i=U(e,I(e,a));return{value:wn.includes(n)?`(${o} ${n} ${i})`:`${o} ${n} ${i}`,dataType:A}}if("u"in t){let[r,n]=t.u,a=U(e,I(e,n));return{value:`${r}${a}`,dataType:A}}if("a"in t){let[r,n]=t.a,a=I(e,r),o=U(e,I(e,n));if(typeof a.value=="string")return{value:`${a.value}.${o}`,dataType:A};if(ne(a.value))return{value:a.value[o],dataType:A};if(typeof a.value=="object")return{value:a.value[o],dataType:A};throw new Error(`Cannot access member ${o} of ${a.value}`)}if("i"in t){let[r,n]=t.i,a=U(e,I(e,r)),o=U(e,I(e,n));return{value:`${a}[${o}]`,dataType:A}}if("n"in t)return{value:t.n,dataType:A};if("f"in t){let[r,n]=t.f,o=I(e,r).value;e.callStack.push(o);let p=n.map(s=>I(e,s)).map(s=>U(e,s));return e.callStack.pop(),typeof o=="string"?{value:`${o}(${p.join(", ")})`,dataType:A}:_chunkC6C35PDMcjs.c.call(void 0, o)?{value:`${e.resolve(o)}(${p.join(", ")})`,dataType:A}:{value:o(...p),dataType:A}}if("o"in t){let r=t.o,n=e.callStack[e.callStack.length-1],a=o=>o.map(i=>{let p=I(e,i);return U(e,p)}).join(", ");if(_chunkC6C35PDMcjs.c.call(void 0, n)){let i=Object.keys(n.propTypes).map(p=>{let l=r[p];if(l===void 0)throw new Error(`Missing property ${p} in object literal for struct ${n}`);return l});return{value:a(i),dataType:n}}return{value:a(Object.values(r)),dataType:A}}Sn(t)}function ft(e,t){if(typeof t=="string")return`${e.pre}${U(e,gt(e,t))};`;if(typeof t=="boolean")return`${e.pre}${U(e,Ir(e,t))};`;if("r"in t){if(_chunkC6C35PDMcjs.c.call(void 0, e.callStack[e.callStack.length-1])&&t.r!==null&&typeof t.r=="object"&&"o"in t.r){let r=U(e,I(e,t.r)),n=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}return ${n}(${r});`}return t.r===null?`${e.pre}return;`:`${e.pre}return ${U(e,I(e,t.r))};`}if("q"in t){let[r,n,a]=t.q,o=U(e,I(e,r));e.indent();let i=ft(e,n);e.dedent(),e.indent();let p=a?ft(e,a):void 0;return e.dedent(),p?`${e.pre}if (${o})
|
13
13
|
${i}
|
14
14
|
${e.pre}else
|
15
|
-
${
|
16
|
-
${i}`}if("l"in t||"c"in t){let[r,n]="l"in t?t.l:t.c,a=U(e,gt(e,r)),o=n?A(e,n):void 0;if(!o||!n)throw new Error("Cannot create variable without an initial value.");if(typeof n=="object"&&"o"in n&&_chunkO7JKWPDHcjs.c.call(void 0, e.callStack[e.callStack.length-1])){let i=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}var ${a} = ${i}(${U(e,o)});`}return`${e.pre}var ${a} = ${U(e,o)};`}return"b"in t?Ar(e,t):`${e.pre}${U(e,A(e,t))};`}function Tt(e,t){return Ar(e,t)}var _typedbinary = require('typed-binary');function wn(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var h=wn;var R={bool(e,t,r){e.writeBool(r)},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkO7JKWPDHcjs.pa.call(void 0, t);h(e,n);for(let[a,o]of Object.entries(t.propTypes))h(e,_chunkO7JKWPDHcjs.pa.call(void 0, o)),X(e,o,r[a]);h(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkO7JKWPDHcjs.pa.call(void 0, t);h(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)h(e,n),X(e,t.elementType,r[o]);e.seekTo(a+_chunkO7JKWPDHcjs.sa.call(void 0, t))},ptrFn(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){var n;(n=R[t.inner.type])==null||n.call(R,e,t,r)},decorated(e,t,r){var o,i;let n=_chunkO7JKWPDHcjs.qa.call(void 0, t);h(e,n);let a=e.currentByteOffset;(i=R[(o=t.inner)==null?void 0:o.type])==null||i.call(R,e,t.inner,r),e.seekTo(a+_chunkO7JKWPDHcjs.sa.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(r*255)},unorm8x2(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255)},unorm8x4(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255),e.writeUint8(r.z*255),e.writeUint8(r.w*255)},snorm8(e,t,r){e.writeUint8(r*127+128)},snorm8x2(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128)},snorm8x4(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128),e.writeUint8(r.z*127+128),e.writeUint8(r.w*127+128)},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeUint16(r*32767+32768)},snorm16x2(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768)},snorm16x4(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768),e.writeUint16(r.z*32767+32768),e.writeUint16(r.w*32767+32768)},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.x*1023&1023)<<12,n|=(r.y*1023&1023)<<2,n|=r.z*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){var o,i;let n=_chunkO7JKWPDHcjs.pa.call(void 0, t);h(e,n);let a=e.currentByteOffset;for(let u=0;u<Math.min(t.elementCount,r.length);u++)h(e,n),(i=R[(o=t.elementType)==null?void 0:o.type])==null||i.call(R,e,t.elementType,r[u]);e.seekTo(a+_chunkO7JKWPDHcjs.sa.call(void 0, t))},unstruct(e,t,r){var n;for(let[a,o]of Object.entries(t.propTypes))(n=R[o.type])==null||n.call(R,e,o,r[a])},"loose-decorated"(e,t,r){var i;let n=_chunkO7JKWPDHcjs.qa.call(void 0, t);h(e,n);let a=e.currentByteOffset,o=R[(i=t.inner)==null?void 0:i.type];return o==null||o(e,t.inner,r),e.seekTo(a+_chunkO7JKWPDHcjs.sa.call(void 0, t)),r}};function X(e,t,r){let n=R[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var ie={bool(e){return e.readBool()},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunk7X4KDNDZcjs.n.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunk7X4KDNDZcjs.r.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunk7X4KDNDZcjs.v.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunk7X4KDNDZcjs.o.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunk7X4KDNDZcjs.s.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunk7X4KDNDZcjs.w.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunk7X4KDNDZcjs.p.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunk7X4KDNDZcjs.t.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunk7X4KDNDZcjs.x.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunk7X4KDNDZcjs.q.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunk7X4KDNDZcjs.u.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunk7X4KDNDZcjs.y.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},mat2x2f(e){return _chunk7X4KDNDZcjs.z.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunk7X4KDNDZcjs.A.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunk7X4KDNDZcjs.B.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunkO7JKWPDHcjs.pa.call(void 0, t);h(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))h(e,_chunkO7JKWPDHcjs.pa.call(void 0, o)),n[a]=E(e,o);return h(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkO7JKWPDHcjs.pa.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){h(e,r);let o=t.elementType,i=E(e,o);n.push(i)}return h(e,r),n},ptrFn(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return E(e,t.inner)},decorated(e,t){let r=_chunkO7JKWPDHcjs.qa.call(void 0, t);h(e,r);let n=e.currentByteOffset,a=E(e,t.inner);return e.seekTo(n+_chunkO7JKWPDHcjs.sa.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunk7X4KDNDZcjs.q.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunk7X4KDNDZcjs.y.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunk7X4KDNDZcjs.p.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunk7X4KDNDZcjs.x.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunk7X4KDNDZcjs.q.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunk7X4KDNDZcjs.y.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunk7X4KDNDZcjs.p.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunk7X4KDNDZcjs.x.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, ie.snorm16(e),ie.snorm16(e)),snorm16x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, ie.snorm16(e),ie.snorm16(e),ie.snorm16(e),ie.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunk7X4KDNDZcjs.r.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunk7X4KDNDZcjs.q.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunk7X4KDNDZcjs.u.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunk7X4KDNDZcjs.y.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunk7X4KDNDZcjs.p.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunk7X4KDNDZcjs.t.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunk7X4KDNDZcjs.x.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunk7X4KDNDZcjs.v.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunk7X4KDNDZcjs.v.call(void 0, n,r,t,a)},unstruct(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=E(e,a);return r},disarray(e,t){let r=_chunkO7JKWPDHcjs.pa.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)h(e,r),n.push(E(e,t.elementType));return h(e,r),n},"loose-decorated"(e,t){h(e,_chunkO7JKWPDHcjs.qa.call(void 0, t));let r=e.currentByteOffset,n=E(e,t.inner);return e.seekTo(r+_chunkO7JKWPDHcjs.sa.call(void 0, t)),n}};function E(e,t){let r=ie[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}var Ir=new WeakMap;function Rr(e){let t=Ir.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let i=e.propTypes[o];if(i===void 0)throw new Error(`Property ${o} is undefined in struct`);let u=r.size;h(r,_chunkO7JKWPDHcjs.p.call(void 0, e)?_chunkO7JKWPDHcjs.qa.call(void 0, i):_chunkO7JKWPDHcjs.pa.call(void 0, i)),a&&(a.padding=r.size-u);let l=_chunkO7JKWPDHcjs.sa.call(void 0, i);n[o]={offset:r.size,size:l},a=n[o],r.add(l)}return a&&(a.padding=_chunkO7JKWPDHcjs.z.call(void 0, _chunkO7JKWPDHcjs.sa.call(void 0, e),_chunkO7JKWPDHcjs.pa.call(void 0, e))-r.size),Ir.set(e,n),n}function Br(e,t){var s;let r=_chunkO7JKWPDHcjs.sa.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function i(m,g,f,w){var c;if(g!=null)if(_chunkO7JKWPDHcjs.c.call(void 0, m)||_chunkO7JKWPDHcjs.p.call(void 0, m)){let T=Rr(m);for(let[b,y]of Object.entries(T)){let S=m.propTypes[b];if(!S)continue;let pe=g[b];pe!==void 0&&i(S,pe,f+y.offset,(c=y.padding)!=null?c:w)}}else if(_chunkO7JKWPDHcjs.b.call(void 0, m)||_chunkO7JKWPDHcjs.o.call(void 0, m)){let T=m,b=_chunkO7JKWPDHcjs.z.call(void 0, _chunkO7JKWPDHcjs.sa.call(void 0, T.elementType),_chunkO7JKWPDHcjs.pa.call(void 0, T.elementType));if(!Array.isArray(g))throw new Error("Partial value for array must be an array");let y=g;y.sort((S,pe)=>S.idx-pe.idx);for(let{idx:S,value:pe}of y)i(T.elementType,pe,f+S*b,b-_chunkO7JKWPDHcjs.sa.call(void 0, T.elementType))}else{let T=_chunkO7JKWPDHcjs.sa.call(void 0, m);a.seekTo(f),X(a,m,g),o.push({start:f,end:f+T,padding:w})}}if(i(e,t,0),o.length===0)return[];let u=[],l=o[0];for(let m=1;m<o.length;m++){let g=o[m];if(!g||!l)throw new Error("Internal error: missing segment");g.start===l.end+((s=l.padding)!=null?s:0)?(l.end=g.end,l.padding=g.padding):(u.push({data:new Uint8Array(n,l.start,l.end-l.start)}),l=g)}if(!l)throw new Error("Internal error: missing segment");return u.push({data:new Uint8Array(n,l.start,l.end-l.start)}),u}function se(e){return!!(e!=null&&e.usableAsStorage)}var Ue=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function Ee(e){return!!e.usableAsUniform}var Cr={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},ve=class{constructor(t,r){this.usage=t;this.buffer=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr");_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","buffer-usage")}get label(){return this.buffer.label}$name(t){return this.buffer.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:this.buffer.dataType}:{storage:this.buffer.dataType,access:this.usage},this.buffer),o=Cr[this.usage];return t.addDeclaration(`@group(${n}) @binding(${a}) var<${o}> ${r}: ${t.resolve(this.buffer.dataType)};`),r}write(t){this.buffer.write(t)}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.m.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k)}},Ae=class{constructor(t,r,n){this.usage=t;this.dataType=r;this._membership=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr");_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","buffer-usage")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=Cr[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.m.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k)}},Pr=new WeakMap;function yt(e){if(!se(e))throw new Error(`Cannot pass ${e} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=Pr.get(e);return t||(t=new ve("mutable",e),Pr.set(e,t)),t}var _r=new WeakMap;function ct(e){if(!se(e))throw new Error(`Cannot pass ${e} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=_r.get(e);return t||(t=new ve("readonly",e),_r.set(e,t)),t}var Lr=new WeakMap;function xt(e){if(!Ee(e))throw new Error(`Cannot pass ${e} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);let t=Lr.get(e);return t||(t=new ve("uniform",e),Lr.set(e,t)),t}var wt={uniform:xt,mutable:yt,readonly:ct};function Vr(e,t,r){return _chunkO7JKWPDHcjs.a.call(void 0, t)?new Ge(e,t,r):new Ge(e,t,r,["storage","uniform"])}function Z(e){return e.resourceType==="buffer"}function Dn(e){return!!e.usableAsVertex}var Ge=class{constructor(t,r,n,a){this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","buffer");_chunk7X4KDNDZcjs.c.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunk7X4KDNDZcjs.c.call(void 0, this,"_buffer",null);_chunk7X4KDNDZcjs.c.call(void 0, this,"_ownBuffer");_chunk7X4KDNDZcjs.c.call(void 0, this,"_destroyed",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"initial");_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsUniform",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsStorage",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsVertex",!1);lr(n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}get label(){return this._label}get buffer(){var r;let t=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=t.createBuffer({size:_chunkO7JKWPDHcjs.sa.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:(r=this.label)!=null?r:"<unnamed>"}),this.initial)){let n=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());X(n,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get destroyed(){return this._destroyed}$name(t){return this._label=t,this._buffer&&(this._buffer.label=t),this}$usage(...t){var r;for(let n of t){if((r=this._disallowedUsages)!=null&&r.includes(n))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${n}`);this.flags|=n==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=n==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=n==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||n==="uniform",this.usableAsStorage=this.usableAsStorage||n==="storage",this.usableAsVertex=this.usableAsVertex||n==="vertex"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}write(t){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let i=r.getMappedRange();X(new (0, _typedbinary.BufferWriter)(i),this.dataType,t);return}let a=_chunkO7JKWPDHcjs.sa.call(void 0, this.dataType);this._group.flush();let o=new ArrayBuffer(a);X(new (0, _typedbinary.BufferWriter)(o),this.dataType,t),n.queue.writeBuffer(r,0,o,0,a)}writePartial(t){let r=this.buffer,n=this._group.device,a=Br(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),i=new Uint8Array(o);for(let u of a)i.set(u.data,u.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunkO7JKWPDHcjs.sa.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(t.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let t=this.buffer,r=this._group.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return E(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),u=E(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),u}let n=r.createBuffer({size:_chunkO7JKWPDHcjs.sa.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkO7JKWPDHcjs.sa.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkO7JKWPDHcjs.sa.call(void 0, this.dataType));let o=E(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){var r;return(r=wt[t])==null?void 0:r.call(wt,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,this._ownBuffer&&((t=this._buffer)==null||t.destroy()))}toString(){var t;return`buffer:${(t=this._label)!=null?t:"<unnamed>"}`}};function Er(e){return new St(e)}function Gr(e){return new Ft(e)}function Un(e){return(e==null?void 0:e.resourceType)==="sampler"}function vn(e){return(e==null?void 0:e.resourceType)==="sampler-comparison"}var Oe=class{constructor(t){this._membership=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},ke=class{constructor(t){this._membership=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler-comparison")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},St=class{constructor(t){this._props=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler");_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_filtering");this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),{group:n,binding:a}=t.allocateFixedEntry({sampler:this._filtering?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},Ft=class{constructor(t){this._props=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler-comparison");_chunk7X4KDNDZcjs.c.call(void 0, this,"_label")}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({sampler:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};var $e=class{constructor(t){this._membership=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","external-texture")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};var Or={r8unorm:_chunkO7JKWPDHcjs.w,r8snorm:_chunkO7JKWPDHcjs.w,r8uint:_chunkO7JKWPDHcjs.u,r8sint:_chunkO7JKWPDHcjs.v,r16uint:_chunkO7JKWPDHcjs.u,r16sint:_chunkO7JKWPDHcjs.v,r16float:_chunkO7JKWPDHcjs.w,rg8unorm:_chunkO7JKWPDHcjs.w,rg8snorm:_chunkO7JKWPDHcjs.w,rg8uint:_chunkO7JKWPDHcjs.u,rg8sint:_chunkO7JKWPDHcjs.v,r32uint:_chunkO7JKWPDHcjs.u,r32sint:_chunkO7JKWPDHcjs.v,r32float:_chunkO7JKWPDHcjs.w,rg16uint:_chunkO7JKWPDHcjs.u,rg16sint:_chunkO7JKWPDHcjs.v,rg16float:_chunkO7JKWPDHcjs.w,rgba8unorm:_chunkO7JKWPDHcjs.w,"rgba8unorm-srgb":_chunkO7JKWPDHcjs.w,rgba8snorm:_chunkO7JKWPDHcjs.w,rgba8uint:_chunkO7JKWPDHcjs.u,rgba8sint:_chunkO7JKWPDHcjs.v,bgra8unorm:_chunkO7JKWPDHcjs.w,"bgra8unorm-srgb":_chunkO7JKWPDHcjs.w,rgb9e5ufloat:_chunkO7JKWPDHcjs.w,rgb10a2uint:_chunkO7JKWPDHcjs.u,rgb10a2unorm:_chunkO7JKWPDHcjs.w,rg11b10ufloat:_chunkO7JKWPDHcjs.w,rg32uint:_chunkO7JKWPDHcjs.u,rg32sint:_chunkO7JKWPDHcjs.v,rg32float:_chunkO7JKWPDHcjs.w,rgba16uint:_chunkO7JKWPDHcjs.u,rgba16sint:_chunkO7JKWPDHcjs.v,rgba16float:_chunkO7JKWPDHcjs.w,rgba32uint:_chunkO7JKWPDHcjs.u,rgba32sint:_chunkO7JKWPDHcjs.v,rgba32float:_chunkO7JKWPDHcjs.w,stencil8:_chunkO7JKWPDHcjs.w,depth16unorm:_chunkO7JKWPDHcjs.w,depth24plus:_chunkO7JKWPDHcjs.w,"depth24plus-stencil8":_chunkO7JKWPDHcjs.w,depth32float:_chunkO7JKWPDHcjs.w,"depth32float-stencil8":_chunkO7JKWPDHcjs.w,"bc1-rgba-unorm":_chunkO7JKWPDHcjs.w,"bc1-rgba-unorm-srgb":_chunkO7JKWPDHcjs.w,"bc2-rgba-unorm":_chunkO7JKWPDHcjs.w,"bc2-rgba-unorm-srgb":_chunkO7JKWPDHcjs.w,"bc3-rgba-unorm":_chunkO7JKWPDHcjs.w,"bc3-rgba-unorm-srgb":_chunkO7JKWPDHcjs.w,"bc4-r-unorm":_chunkO7JKWPDHcjs.w,"bc4-r-snorm":_chunkO7JKWPDHcjs.w,"bc5-rg-unorm":_chunkO7JKWPDHcjs.w,"bc5-rg-snorm":_chunkO7JKWPDHcjs.w,"bc6h-rgb-ufloat":_chunkO7JKWPDHcjs.w,"bc6h-rgb-float":_chunkO7JKWPDHcjs.w,"bc7-rgba-unorm":_chunkO7JKWPDHcjs.w,"bc7-rgba-unorm-srgb":_chunkO7JKWPDHcjs.w,"etc2-rgb8unorm":_chunkO7JKWPDHcjs.w,"etc2-rgb8unorm-srgb":_chunkO7JKWPDHcjs.w,"etc2-rgb8a1unorm":_chunkO7JKWPDHcjs.w,"etc2-rgb8a1unorm-srgb":_chunkO7JKWPDHcjs.w,"etc2-rgba8unorm":_chunkO7JKWPDHcjs.w,"etc2-rgba8unorm-srgb":_chunkO7JKWPDHcjs.w,"eac-r11unorm":_chunkO7JKWPDHcjs.w,"eac-r11snorm":_chunkO7JKWPDHcjs.w,"eac-rg11unorm":_chunkO7JKWPDHcjs.w,"eac-rg11snorm":_chunkO7JKWPDHcjs.w,"astc-4x4-unorm":_chunkO7JKWPDHcjs.w,"astc-4x4-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-5x4-unorm":_chunkO7JKWPDHcjs.w,"astc-5x4-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-5x5-unorm":_chunkO7JKWPDHcjs.w,"astc-5x5-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-6x5-unorm":_chunkO7JKWPDHcjs.w,"astc-6x5-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-6x6-unorm":_chunkO7JKWPDHcjs.w,"astc-6x6-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-8x5-unorm":_chunkO7JKWPDHcjs.w,"astc-8x5-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-8x6-unorm":_chunkO7JKWPDHcjs.w,"astc-8x6-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-8x8-unorm":_chunkO7JKWPDHcjs.w,"astc-8x8-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-10x5-unorm":_chunkO7JKWPDHcjs.w,"astc-10x5-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-10x6-unorm":_chunkO7JKWPDHcjs.w,"astc-10x6-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-10x8-unorm":_chunkO7JKWPDHcjs.w,"astc-10x8-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-10x10-unorm":_chunkO7JKWPDHcjs.w,"astc-10x10-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-12x10-unorm":_chunkO7JKWPDHcjs.w,"astc-12x10-unorm-srgb":_chunkO7JKWPDHcjs.w,"astc-12x12-unorm":_chunkO7JKWPDHcjs.w,"astc-12x12-unorm-srgb":_chunkO7JKWPDHcjs.w},Ie={rgba8unorm:_chunk7X4KDNDZcjs.v,rgba8snorm:_chunk7X4KDNDZcjs.v,rgba8uint:_chunk7X4KDNDZcjs.y,rgba8sint:_chunk7X4KDNDZcjs.x,rgba16uint:_chunk7X4KDNDZcjs.y,rgba16sint:_chunk7X4KDNDZcjs.x,rgba16float:_chunk7X4KDNDZcjs.v,r32uint:_chunk7X4KDNDZcjs.y,r32sint:_chunk7X4KDNDZcjs.x,r32float:_chunk7X4KDNDZcjs.v,rg32uint:_chunk7X4KDNDZcjs.y,rg32sint:_chunk7X4KDNDZcjs.x,rg32float:_chunk7X4KDNDZcjs.v,rgba32uint:_chunk7X4KDNDZcjs.y,rgba32sint:_chunk7X4KDNDZcjs.x,rgba32float:_chunk7X4KDNDZcjs.v,bgra8unorm:_chunk7X4KDNDZcjs.v},kr={f32:"float",u32:"uint",i32:"sint"},$r={float:_chunkO7JKWPDHcjs.w,"unfilterable-float":_chunkO7JKWPDHcjs.w,uint:_chunkO7JKWPDHcjs.u,sint:_chunkO7JKWPDHcjs.v,depth:_chunkO7JKWPDHcjs.w};function Mr(e,t){return new Dt(e,t)}function W(e){return(e==null?void 0:e.resourceType)==="texture"}function At(e){return(e==null?void 0:e.resourceType)==="texture-storage-view"}function It(e){return(e==null?void 0:e.resourceType)==="texture-sampled-view"}var Wr={mutable:"read_write",readonly:"read",writeonly:"write"},Dt=class{constructor(t,r){this.props=t;this._branch=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture");_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsSampled",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsStorage",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsRender",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"_destroyed",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_flags",GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC);_chunk7X4KDNDZcjs.c.call(void 0, this,"_texture",null)}get label(){return this._label}$name(t){return this._label=t,this}unwrap(){var t,r,n,a,o;if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:(t=this._label)!=null?t:"<unnamed>",format:this.props.format,size:this.props.size,usage:this._flags,dimension:(r=this.props.dimension)!=null?r:"2d",viewFormats:(n=this.props.viewFormats)!=null?n:[],mipLevelCount:(a=this.props.mipLevelCount)!=null?a:1,sampleCount:(o=this.props.sampleCount)!=null?o:1})),this._texture}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||(this.usableAsStorage=r),this.usableAsSampled||(this.usableAsSampled=n),this.usableAsRender||(this.usableAsRender=a),this}createView(t,r){if(t==="sampled")return this._asSampled(r);let n=r;switch(t){case"mutable":return this._asMutable(n);case"readonly":return this._asReadonly(n);case"writeonly":return this._asWriteonly(n)}}_asStorage(t,r){var o;if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=(o=t==null?void 0:t.format)!=null?o:this.props.format,a=Ie[n];return _chunk7X4KDNDZcjs.d.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new Ut(t!=null?t:{},r,this)}_asReadonly(t){return this._asStorage(t,"readonly")}_asWriteonly(t){return this._asStorage(t,"writeonly")}_asMutable(t){return this._asStorage(t,"mutable")}_asSampled(t){var a;if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=(a=t==null?void 0:t.format)!=null?a:this.props.format;if(!Ie[r])throw new Error(`Unsupported storage texture format: ${r}`);return new vt(t,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._texture)==null||t.destroy())}},Ne={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},Ut=class{constructor(t,r,n){this.access=r;this._texture=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"texelDataType");_chunk7X4KDNDZcjs.c.call(void 0, this,"dimension");_chunk7X4KDNDZcjs.c.call(void 0, this,"_view");_chunk7X4KDNDZcjs.c.call(void 0, this,"_format");var a,o,i;this.dimension=(o=(a=t==null?void 0:t.dimension)!=null?a:n.props.dimension)!=null?o:"2d",this._format=(i=t==null?void 0:t.format)!=null?i:n.props.format,this.texelDataType=Ie[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView({label:`${(t=this.label)!=null?t:"<unnamed>"} - View`,format:this._format,dimension:this.dimension})),this._view}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${Wr[this.access]}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},Me=class{constructor(t,r,n,a){this._format=t;this.dimension=r;this.access=n;this._membership=a;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"texelDataType");this.texelDataType=Ie[this._format]}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${Wr[this.access]}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},vt=class{constructor(t,r){this._props=t;this._texture=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"channelDataType");_chunk7X4KDNDZcjs.c.call(void 0, this,"dimension");_chunk7X4KDNDZcjs.c.call(void 0, this,"_format");_chunk7X4KDNDZcjs.c.call(void 0, this,"_view");var n,a,o;this.dimension=(a=(n=t==null?void 0:t.dimension)!=null?n:r.props.dimension)!=null?a:"2d",this._format=(o=t==null?void 0:t.format)!=null?o:r.props.format,this.channelDataType=Or[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView(_chunk7X4KDNDZcjs.a.call(void 0, {label:`${(t=this.label)!=null?t:"<unnamed>"} - View`},this._props))),this._view}"~resolve"(t){var u;let r=t.names.makeUnique(this.label),n=((u=this._texture.props.sampleCount)!=null?u:1)>1,{group:a,binding:o}=t.allocateFixedEntry({texture:kr[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},We=class{constructor(t,r,n,a){this.dimension=r;this._multisampled=n;this._membership=a;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"channelDataType");this.channelDataType=$r[t]}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};function Rt(e){return!!(e!=null&&e.usableAsSampled)}function An(e){return!!(e!=null&&e.usableAsRender)}var je=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function ze(e){return new Pt(e)}function Ke(e){return!!e&&e.resourceType==="bind-group-layout"}function _t(e){return!!e&&e.resourceType==="bind-group"}var Bt=class e extends Error{constructor(t,r){super(`Bind group '${t!=null?t:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},Nr=["compute"],Te=["compute","vertex","fragment"],Pt=class{constructor(t){this.entries=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_index");_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","bind-group-layout");_chunk7X4KDNDZcjs.c.call(void 0, this,"bound",{});var n,a,o,i,u;let r=0;for(let[l,s]of Object.entries(t)){if(s===null){r++;continue}let m={idx:r,key:l,layout:this};if("uniform"in s&&(this.bound[l]=new Ae("uniform",s.uniform,m)),"storage"in s){let g="type"in s.storage?s.storage:s.storage(0);this.bound[l]=new Ae((n=s.access)!=null?n:"readonly",g,m)}"texture"in s&&(this.bound[l]=new We(s.texture,(a=s.viewDimension)!=null?a:"2d",(o=s.multisampled)!=null?o:!1,m)),"storageTexture"in s&&(this.bound[l]=new Me(s.storageTexture,(i=s.viewDimension)!=null?i:"2d",(u=s.access)!=null?u:"writeonly",m)),"externalTexture"in s&&(this.bound[l]=new $e(m)),"sampler"in s&&(s.sampler==="comparison"?this.bound[l]=new ke(m):this.bound[l]=new Oe(m)),r++}}get label(){return this._label}get index(){return this._index}$name(t){return this._label=t,this}$idx(t){return this._index=t,this}unwrap(t){var n;return t.device.createBindGroupLayout({label:(n=this.label)!=null?n:"<unnamed>",entries:Object.values(this.entries).map((a,o)=>{var l,s,m,g;if(a===null)return null;let i=a.visibility,u={binding:o,visibility:0};if("uniform"in a)i=i!=null?i:Te,u.buffer={type:"uniform"};else if("storage"in a)i=i!=null?i:a.access==="mutable"?Nr:Te,u.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)i=i!=null?i:Te,u.sampler={type:a.sampler};else if("texture"in a)i=i!=null?i:Te,u.texture={sampleType:a.texture,viewDimension:(l=a.viewDimension)!=null?l:"2d",multisampled:(s=a.multisampled)!=null?s:!1};else if("storageTexture"in a){let f=(m=a.access)!=null?m:"writeonly";i=i!=null?i:f==="readonly"?Te:Nr,u.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[f],viewDimension:(g=a.viewDimension)!=null?g:"2d"}}else"externalTexture"in a&&(i=i!=null?i:Te,u.externalTexture={});return i!=null&&i.includes("compute")&&(u.visibility|=GPUShaderStage.COMPUTE),i!=null&&i.includes("vertex")&&(u.visibility|=GPUShaderStage.VERTEX),i!=null&&i.includes("fragment")&&(u.visibility|=GPUShaderStage.FRAGMENT),u}).filter(a=>a!==null)})}populate(t){return new ue(this,t)}},ue=class{constructor(t,r){this.layout=t;this.entries=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new Bt(t.label,n)}unwrap(t){var n;return t.device.createBindGroup({label:(n=this.layout.label)!=null?n:"<unnamed>",layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,o],i)=>{var l;if(o===null)return null;let u=this.entries[a];if(u===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(l=this.layout.label)!=null?l:"<unnamed>"}'.`);if("uniform"in o){let s;if(Z(u)){if(!Ee(u))throw new (0, _chunk7X4KDNDZcjs.g)(u);s={buffer:t.unwrap(u)}}else s={buffer:u};return{binding:i,resource:s}}if("storage"in o){let s;if(Z(u)){if(!se(u))throw new Ue(u);s={buffer:t.unwrap(u)}}else s={buffer:u};return{binding:i,resource:s}}if("texture"in o){let s;if(W(u)){if(!Rt(u))throw new je(u);s=t.unwrap(u.createView("sampled"))}else s=u;return{binding:i,resource:s}}if("storageTexture"in o){let s;if(W(u)){if(!se(u))throw new Ue(u);o.access==="readonly"?s=t.unwrap(u.createView("readonly")):o.access==="mutable"?s=t.unwrap(u.createView("mutable")):s=t.unwrap(u.createView("writeonly"))}else s=u;return{binding:i,resource:s}}if("externalTexture"in o||"sampler"in o)return{binding:i,resource:u};throw new Error(`Malformed bind group entry: ${u} (${JSON.stringify(u)})`)}).filter(a=>a!==null)})}};var jr="#CATCHALL#",Ct=class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"_stack",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"_itemDepth",0)}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}pushFunctionScope(t,r,n){this._stack.push({type:"functionScope",args:t,returnType:r,externalMap:n})}pop(){let t=this._stack.pop();(t==null?void 0:t.type)==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="item")n.usedSlots.add(t);else if((n==null?void 0:n.type)==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!((n==null?void 0:n.type)==="functionScope"||(n==null?void 0:n.type)==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getResourceById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:v}:void 0}if((n==null?void 0:n.type)==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return{value:t,dataType:a}}}}},qe=[""," "," "," "," "," "," "," "," "],Lt=qe.length-1,Vt=class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"identLevel",0)}get pre(){var t;return(t=qe[this.identLevel])!=null?t:qe[Lt].repeat(this.identLevel/Lt)+qe[this.identLevel%Lt]}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}},Et=class{constructor(t){_chunk7X4KDNDZcjs.c.call(void 0, this,"_memoizedResolves",new WeakMap);_chunk7X4KDNDZcjs.c.call(void 0, this,"_memoizedDerived",new WeakMap);_chunk7X4KDNDZcjs.c.call(void 0, this,"_indentController",new Vt);_chunk7X4KDNDZcjs.c.call(void 0, this,"_jitTranspiler");_chunk7X4KDNDZcjs.c.call(void 0, this,"_itemStateStack",new Ct);_chunk7X4KDNDZcjs.c.call(void 0, this,"_declarations",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"bindGroupLayoutsToPlaceholderMap",new Map);_chunk7X4KDNDZcjs.c.call(void 0, this,"_nextFreeLayoutPlaceholderIdx",0);_chunk7X4KDNDZcjs.c.call(void 0, this,"fixedBindings",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"callStack",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"names");this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){var r;return(r=this._itemStateStack.getResourceById(t))!=null?r:{value:t,dataType:v}}transpileFn(t){if(!this._jitTranspiler)throw new Error("Tried to execute a tgpu.fn function without providing a JIT transpiler, or transpiling at build time.");return this._jitTranspiler.transpileFn(t)}fnToWgsl(t){this._itemStateStack.pushFunctionScope(t.args,t.returnType,t.externalMap);let r=Tt(this,t.body);this._itemStateStack.pop();let n=t.args.map(a=>`${a.value}: ${this.resolve(a.dataType)}`).join(", ");return{head:t.returnType!==void 0?`(${n}) -> ${_chunkO7JKWPDHcjs.Fa.call(void 0, t.returnType)} ${this.resolve(t.returnType)}`:`(${n})`,body:r}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:jr,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunk7X4KDNDZcjs.f)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.pop()}}unwrap(t){if(Se(t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if(q(r))r=this.readSlot(r);else if(J(r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){var n;let r=(n=this._memoizedDerived.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([l,s])=>l.areEqual(this._itemStateStack.readSlot(l),s)))return i.result;let a=t["~compute"](),o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedDerived.set(t,r),a}catch(a){throw a instanceof _chunk7X4KDNDZcjs.e?a.appendToTrace(t):new (0, _chunk7X4KDNDZcjs.e)(a,[t])}finally{this._itemStateStack.pop()}}_getOrInstantiate(t){var n;let r=(n=this._memoizedResolves.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([l,s])=>l.areEqual(this._itemStateStack.readSlot(l),s)))return i.result;let a;_chunkO7JKWPDHcjs.a.call(void 0, t)||_chunkO7JKWPDHcjs.n.call(void 0, t)?a=mt(this,t):J(t)||q(t)?a=this.resolve(this.unwrap(t)):st(t)?a=t["~resolve"](this):a=this.resolveValue(t);let o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedResolves.set(t,r),a}catch(a){throw a instanceof _chunk7X4KDNDZcjs.e?a.appendToTrace(t):new (0, _chunk7X4KDNDZcjs.e)(a,[t])}finally{this._itemStateStack.pop()}}resolve(t){if(Se(t))return this.withSlots(t["~providing"].pairs,()=>this.resolve(t["~providing"].inner));if(t&&typeof t=="object"||typeof t=="function"){if(this._itemStateStack.itemDepth===0){let r=_chunk7X4KDNDZcjs.k.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
|
15
|
+
${p}`:`${e.pre}if (${o})
|
16
|
+
${i}`}if("l"in t||"c"in t){let[r,n]="l"in t?t.l:t.c,a=U(e,gt(e,r)),o=n?I(e,n):void 0;if(!o||!n)throw new Error("Cannot create variable without an initial value.");if(typeof n=="object"&&"o"in n&&_chunkC6C35PDMcjs.c.call(void 0, e.callStack[e.callStack.length-1])){let i=e.resolve(e.callStack[e.callStack.length-1]);return`${e.pre}var ${a} = ${i}(${U(e,o)});`}return`${e.pre}var ${a} = ${U(e,o)};`}return"b"in t?Rr(e,t):`${e.pre}${U(e,I(e,t))};`}function Tt(e,t){return Rr(e,t)}var _typedbinary = require('typed-binary');function Fn(e,t){let r="size"in e?e.size:e.currentByteOffset,n=t-1,a=r&n;"skipBytes"in e?e.skipBytes(t-a&n):e.add(t-a&n)}var h=Fn;var P={bool(e,t,r){e.writeBool(r)},f32(e,t,r){e.writeFloat32(r)},f16(e,t,r){e.writeFloat16(r)},i32(e,t,r){e.writeInt32(r)},u32(e,t,r){e.writeUint32(r)},vec2f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},vec2h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},vec2i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},vec2u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},vec3f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},vec3h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z)},vec3i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},vec3u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},vec4f(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},vec4h(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},vec4i(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},vec4u(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},mat2x2f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat3x3f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},mat4x4f(e,t,r){for(let n=0;n<r.length;++n)e.writeFloat32(r[n])},struct(e,t,r){let n=_chunkC6C35PDMcjs.pa.call(void 0, t);h(e,n);for(let[a,o]of Object.entries(t.propTypes))h(e,_chunkC6C35PDMcjs.pa.call(void 0, o)),X(e,o,r[a]);h(e,n)},array(e,t,r){if(t.elementCount===0)throw new Error("Cannot write using a runtime-sized schema.");let n=_chunkC6C35PDMcjs.pa.call(void 0, t);h(e,n);let a=e.currentByteOffset;for(let o=0;o<Math.min(t.elementCount,r.length);o++)h(e,n),X(e,t.elementType,r[o]);e.seekTo(a+_chunkC6C35PDMcjs.sa.call(void 0, t))},ptrFn(){throw new Error("Pointers are not host-shareable")},atomic(e,t,r){var n;(n=P[t.inner.type])==null||n.call(P,e,t,r)},decorated(e,t,r){var o,i;let n=_chunkC6C35PDMcjs.qa.call(void 0, t);h(e,n);let a=e.currentByteOffset;(i=P[(o=t.inner)==null?void 0:o.type])==null||i.call(P,e,t.inner,r),e.seekTo(a+_chunkC6C35PDMcjs.sa.call(void 0, t))},uint8(e,t,r){e.writeUint8(r)},uint8x2(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y)},uint8x4(e,t,r){e.writeUint8(r.x),e.writeUint8(r.y),e.writeUint8(r.z),e.writeUint8(r.w)},sint8(e,t,r){e.writeInt8(r)},sint8x2(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y)},sint8x4(e,t,r){e.writeInt8(r.x),e.writeInt8(r.y),e.writeInt8(r.z),e.writeInt8(r.w)},unorm8(e,t,r){e.writeUint8(r*255)},unorm8x2(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255)},unorm8x4(e,t,r){e.writeUint8(r.x*255),e.writeUint8(r.y*255),e.writeUint8(r.z*255),e.writeUint8(r.w*255)},snorm8(e,t,r){e.writeUint8(r*127+128)},snorm8x2(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128)},snorm8x4(e,t,r){e.writeUint8(r.x*127+128),e.writeUint8(r.y*127+128),e.writeUint8(r.z*127+128),e.writeUint8(r.w*127+128)},uint16(e,t,r){e.writeUint16(r)},uint16x2(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y)},uint16x4(e,t,r){e.writeUint16(r.x),e.writeUint16(r.y),e.writeUint16(r.z),e.writeUint16(r.w)},sint16(e,t,r){e.writeInt16(r)},sint16x2(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y)},sint16x4(e,t,r){e.writeInt16(r.x),e.writeInt16(r.y),e.writeInt16(r.z),e.writeInt16(r.w)},unorm16(e,t,r){e.writeUint16(r*65535)},unorm16x2(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535)},unorm16x4(e,t,r){e.writeUint16(r.x*65535),e.writeUint16(r.y*65535),e.writeUint16(r.z*65535),e.writeUint16(r.w*65535)},snorm16(e,t,r){e.writeUint16(r*32767+32768)},snorm16x2(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768)},snorm16x4(e,t,r){e.writeUint16(r.x*32767+32768),e.writeUint16(r.y*32767+32768),e.writeUint16(r.z*32767+32768),e.writeUint16(r.w*32767+32768)},float16(e,t,r){e.writeFloat16(r)},float16x2(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y)},float16x4(e,t,r){e.writeFloat16(r.x),e.writeFloat16(r.y),e.writeFloat16(r.z),e.writeFloat16(r.w)},float32(e,t,r){e.writeFloat32(r)},float32x2(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y)},float32x3(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z)},float32x4(e,t,r){e.writeFloat32(r.x),e.writeFloat32(r.y),e.writeFloat32(r.z),e.writeFloat32(r.w)},uint32(e,t,r){e.writeUint32(r)},uint32x2(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y)},uint32x3(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z)},uint32x4(e,t,r){e.writeUint32(r.x),e.writeUint32(r.y),e.writeUint32(r.z),e.writeUint32(r.w)},sint32(e,t,r){e.writeInt32(r)},sint32x2(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y)},sint32x3(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z)},sint32x4(e,t,r){e.writeInt32(r.x),e.writeInt32(r.y),e.writeInt32(r.z),e.writeInt32(r.w)},"unorm10-10-10-2"(e,t,r){let n=0;n|=(r.x*1023&1023)<<22,n|=(r.x*1023&1023)<<12,n|=(r.y*1023&1023)<<2,n|=r.z*3&3,e.writeUint32(n)},"unorm8x4-bgra"(e,t,r){e.writeUint8(r.z*255),e.writeUint8(r.y*255),e.writeUint8(r.x*255),e.writeUint8(r.w*255)},disarray(e,t,r){var o,i;let n=_chunkC6C35PDMcjs.pa.call(void 0, t);h(e,n);let a=e.currentByteOffset;for(let p=0;p<Math.min(t.elementCount,r.length);p++)h(e,n),(i=P[(o=t.elementType)==null?void 0:o.type])==null||i.call(P,e,t.elementType,r[p]);e.seekTo(a+_chunkC6C35PDMcjs.sa.call(void 0, t))},unstruct(e,t,r){var n;for(let[a,o]of Object.entries(t.propTypes))(n=P[o.type])==null||n.call(P,e,o,r[a])},"loose-decorated"(e,t,r){var i;let n=_chunkC6C35PDMcjs.qa.call(void 0, t);h(e,n);let a=e.currentByteOffset,o=P[(i=t.inner)==null?void 0:i.type];return o==null||o(e,t.inner,r),e.seekTo(a+_chunkC6C35PDMcjs.sa.call(void 0, t)),r}};function X(e,t,r){let n=P[t.type];if(!n)throw new Error(`Cannot write data of type '${t.type}'.`);n(e,t,r)}var ie={bool(e){return e.readBool()},f32(e){return e.readFloat32()},f16(e){return e.readFloat16()},i32(e){return e.readInt32()},u32(e){return e.readUint32()},vec2f(e){return _chunk7X4KDNDZcjs.n.call(void 0, e.readFloat32(),e.readFloat32())},vec3f(e){return _chunk7X4KDNDZcjs.r.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32())},vec4f(e){return _chunk7X4KDNDZcjs.v.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},vec2h(e){return _chunk7X4KDNDZcjs.o.call(void 0, e.readFloat16(),e.readFloat16())},vec3h(e){return _chunk7X4KDNDZcjs.s.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16())},vec4h(e){return _chunk7X4KDNDZcjs.w.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16())},vec2i(e){return _chunk7X4KDNDZcjs.p.call(void 0, e.readInt32(),e.readInt32())},vec3i(e){return _chunk7X4KDNDZcjs.t.call(void 0, e.readInt32(),e.readInt32(),e.readInt32())},vec4i(e){return _chunk7X4KDNDZcjs.x.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32())},vec2u(e){return _chunk7X4KDNDZcjs.q.call(void 0, e.readUint32(),e.readUint32())},vec3u(e){return _chunk7X4KDNDZcjs.u.call(void 0, e.readUint32(),e.readUint32(),e.readUint32())},vec4u(e){return _chunk7X4KDNDZcjs.y.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32())},mat2x2f(e){return _chunk7X4KDNDZcjs.z.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},mat3x3f(e){let t=()=>{let r=e.readFloat32();return e.readFloat32(),r};return _chunk7X4KDNDZcjs.A.call(void 0, e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t(),e.readFloat32(),e.readFloat32(),t())},mat4x4f(e){return _chunk7X4KDNDZcjs.B.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32())},struct(e,t){let r=_chunkC6C35PDMcjs.pa.call(void 0, t);h(e,r);let n={};for(let[a,o]of Object.entries(t.propTypes))h(e,_chunkC6C35PDMcjs.pa.call(void 0, o)),n[a]=E(e,o);return h(e,r),n},array(e,t){if(t.elementCount===0)throw new Error("Cannot read using a runtime-sized schema.");let r=_chunkC6C35PDMcjs.pa.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++){h(e,r);let o=t.elementType,i=E(e,o);n.push(i)}return h(e,r),n},ptrFn(){throw new Error("Pointers are not host-shareable")},atomic(e,t){return E(e,t.inner)},decorated(e,t){let r=_chunkC6C35PDMcjs.qa.call(void 0, t);h(e,r);let n=e.currentByteOffset,a=E(e,t.inner);return e.seekTo(n+_chunkC6C35PDMcjs.sa.call(void 0, t)),a},uint8:e=>e.readUint8(),uint8x2:e=>_chunk7X4KDNDZcjs.q.call(void 0, e.readUint8(),e.readUint8()),uint8x4:e=>_chunk7X4KDNDZcjs.y.call(void 0, e.readUint8(),e.readUint8(),e.readUint8(),e.readUint8()),sint8:e=>e.readInt8(),sint8x2:e=>_chunk7X4KDNDZcjs.p.call(void 0, e.readInt8(),e.readInt8()),sint8x4:e=>_chunk7X4KDNDZcjs.x.call(void 0, e.readInt8(),e.readInt8(),e.readInt8(),e.readInt8()),unorm8:e=>e.readUint8()/255,unorm8x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readUint8()/255,e.readUint8()/255),unorm8x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readUint8()/255,e.readUint8()/255,e.readUint8()/255,e.readUint8()/255),snorm8:e=>(e.readUint8()-128)/127,snorm8x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127),snorm8x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, (e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127,(e.readUint8()-128)/127),uint16:e=>e.readUint16(),uint16x2:e=>_chunk7X4KDNDZcjs.q.call(void 0, e.readUint16(),e.readUint16()),uint16x4:e=>_chunk7X4KDNDZcjs.y.call(void 0, e.readUint16(),e.readUint16(),e.readUint16(),e.readUint16()),sint16:e=>e.readInt16(),sint16x2:e=>_chunk7X4KDNDZcjs.p.call(void 0, e.readInt16(),e.readInt16()),sint16x4:e=>_chunk7X4KDNDZcjs.x.call(void 0, e.readInt16(),e.readInt16(),e.readInt16(),e.readInt16()),unorm16:e=>e.readUint16()/65535,unorm16x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readUint16()/65535,e.readUint16()/65535),unorm16x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535,e.readUint16()/65535),snorm16:e=>(e.readUint16()-32768)/32767,snorm16x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, ie.snorm16(e),ie.snorm16(e)),snorm16x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, ie.snorm16(e),ie.snorm16(e),ie.snorm16(e),ie.snorm16(e)),float16(e){return e.readFloat16()},float16x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readFloat16(),e.readFloat16()),float16x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readFloat16(),e.readFloat16(),e.readFloat16(),e.readFloat16()),float32:e=>e.readFloat32(),float32x2:e=>_chunk7X4KDNDZcjs.n.call(void 0, e.readFloat32(),e.readFloat32()),float32x3:e=>_chunk7X4KDNDZcjs.r.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32()),float32x4:e=>_chunk7X4KDNDZcjs.v.call(void 0, e.readFloat32(),e.readFloat32(),e.readFloat32(),e.readFloat32()),uint32:e=>e.readUint32(),uint32x2:e=>_chunk7X4KDNDZcjs.q.call(void 0, e.readUint32(),e.readUint32()),uint32x3:e=>_chunk7X4KDNDZcjs.u.call(void 0, e.readUint32(),e.readUint32(),e.readUint32()),uint32x4:e=>_chunk7X4KDNDZcjs.y.call(void 0, e.readUint32(),e.readUint32(),e.readUint32(),e.readUint32()),sint32:e=>e.readInt32(),sint32x2:e=>_chunk7X4KDNDZcjs.p.call(void 0, e.readInt32(),e.readInt32()),sint32x3:e=>_chunk7X4KDNDZcjs.t.call(void 0, e.readInt32(),e.readInt32(),e.readInt32()),sint32x4:e=>_chunk7X4KDNDZcjs.x.call(void 0, e.readInt32(),e.readInt32(),e.readInt32(),e.readInt32()),"unorm10-10-10-2"(e){let t=e.readUint32(),r=(t>>22)/1023,n=(t>>12&1023)/1023,a=(t>>2&1023)/1023,o=(t&3)/3;return _chunk7X4KDNDZcjs.v.call(void 0, r,n,a,o)},"unorm8x4-bgra"(e){let t=e.readByte()/255,r=e.readByte()/255,n=e.readByte()/255,a=e.readByte()/255;return _chunk7X4KDNDZcjs.v.call(void 0, n,r,t,a)},unstruct(e,t){let r={};for(let[n,a]of Object.entries(t.propTypes))r[n]=E(e,a);return r},disarray(e,t){let r=_chunkC6C35PDMcjs.pa.call(void 0, t),n=[];for(let a=0;a<t.elementCount;a++)h(e,r),n.push(E(e,t.elementType));return h(e,r),n},"loose-decorated"(e,t){h(e,_chunkC6C35PDMcjs.qa.call(void 0, t));let r=e.currentByteOffset,n=E(e,t.inner);return e.seekTo(r+_chunkC6C35PDMcjs.sa.call(void 0, t)),n}};function E(e,t){let r=ie[t.type];if(!r)throw new Error(`Cannot read data of type '${t.type}'.`);return r(e,t)}var Br=new WeakMap;function Pr(e){let t=Br.get(e);if(t)return t;let r=new _typedbinary.Measurer,n={},a;for(let o in e.propTypes){let i=e.propTypes[o];if(i===void 0)throw new Error(`Property ${o} is undefined in struct`);let p=r.size;h(r,_chunkC6C35PDMcjs.p.call(void 0, e)?_chunkC6C35PDMcjs.qa.call(void 0, i):_chunkC6C35PDMcjs.pa.call(void 0, i)),a&&(a.padding=r.size-p);let l=_chunkC6C35PDMcjs.sa.call(void 0, i);n[o]={offset:r.size,size:l},a=n[o],r.add(l)}return a&&(a.padding=_chunkC6C35PDMcjs.z.call(void 0, _chunkC6C35PDMcjs.sa.call(void 0, e),_chunkC6C35PDMcjs.pa.call(void 0, e))-r.size),Br.set(e,n),n}function _r(e,t){var s;let r=_chunkC6C35PDMcjs.sa.call(void 0, e);if(r===0||t===void 0||t===null)return[];let n=new ArrayBuffer(r),a=new (0, _typedbinary.BufferWriter)(n),o=[];function i(m,g,f,w){var c;if(g!=null)if(_chunkC6C35PDMcjs.c.call(void 0, m)||_chunkC6C35PDMcjs.p.call(void 0, m)){let T=Pr(m);for(let[b,y]of Object.entries(T)){let S=m.propTypes[b];if(!S)continue;let pe=g[b];pe!==void 0&&i(S,pe,f+y.offset,(c=y.padding)!=null?c:w)}}else if(_chunkC6C35PDMcjs.b.call(void 0, m)||_chunkC6C35PDMcjs.o.call(void 0, m)){let T=m,b=_chunkC6C35PDMcjs.z.call(void 0, _chunkC6C35PDMcjs.sa.call(void 0, T.elementType),_chunkC6C35PDMcjs.pa.call(void 0, T.elementType));if(!Array.isArray(g))throw new Error("Partial value for array must be an array");let y=g;y.sort((S,pe)=>S.idx-pe.idx);for(let{idx:S,value:pe}of y)i(T.elementType,pe,f+S*b,b-_chunkC6C35PDMcjs.sa.call(void 0, T.elementType))}else{let T=_chunkC6C35PDMcjs.sa.call(void 0, m);a.seekTo(f),X(a,m,g),o.push({start:f,end:f+T,padding:w})}}if(i(e,t,0),o.length===0)return[];let p=[],l=o[0];for(let m=1;m<o.length;m++){let g=o[m];if(!g||!l)throw new Error("Internal error: missing segment");g.start===l.end+((s=l.padding)!=null?s:0)?(l.end=g.end,l.padding=g.padding):(p.push({data:new Uint8Array(n,l.start,l.end-l.start)}),l=g)}if(!l)throw new Error("Internal error: missing segment");return p.push({data:new Uint8Array(n,l.start,l.end-l.start)}),p}function se(e){return!!(e!=null&&e.usableAsStorage)}var Ue=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'storage'. Use .$usage('storage') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function Ee(e){return!!e.usableAsUniform}var Er={uniform:"uniform",mutable:"storage, read_write",readonly:"storage, read"},ve=class{constructor(t,r){this.usage=t;this.buffer=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr");_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","buffer-usage")}get label(){return this.buffer.label}$name(t){return this.buffer.$name(t),this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry(this.usage==="uniform"?{uniform:this.buffer.dataType}:{storage:this.buffer.dataType,access:this.usage},this.buffer),o=Er[this.usage];return t.addDeclaration(`@group(${n}) @binding(${a}) var<${o}> ${r}: ${t.resolve(this.buffer.dataType)};`),r}write(t){this.buffer.write(t)}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.m.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k)}},Ae=class{constructor(t,r,n){this.usage=t;this.dataType=r;this._membership=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr");_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","buffer-usage")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=Er[this.usage];return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var<${a}> ${r}: ${t.resolve(this.dataType)};`),r}toString(){var t;return`${this.usage}:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.m.call(void 0, ))throw new Error("Cannot access buffer's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k)}},Lr=new WeakMap;function yt(e){if(!se(e))throw new Error(`Cannot pass ${e} to asMutable, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=Lr.get(e);return t||(t=new ve("mutable",e),Lr.set(e,t)),t}var Cr=new WeakMap;function ct(e){if(!se(e))throw new Error(`Cannot pass ${e} to asReadonly, as it is not allowed to be used as storage. To allow it, call .$usage('storage') when creating the buffer.`);let t=Cr.get(e);return t||(t=new ve("readonly",e),Cr.set(e,t)),t}var Vr=new WeakMap;function xt(e){if(!Ee(e))throw new Error(`Cannot pass ${e} to asUniform, as it is not allowed to be used as a uniform. To allow it, call .$usage('uniform') when creating the buffer.`);let t=Vr.get(e);return t||(t=new ve("uniform",e),Vr.set(e,t)),t}var wt={uniform:xt,mutable:yt,readonly:ct};function Gr(e,t,r){return _chunkC6C35PDMcjs.a.call(void 0, t)?new Ge(e,t,r):new Ge(e,t,r,["storage","uniform"])}function Z(e){return e.resourceType==="buffer"}function vn(e){return!!e.usableAsVertex}var Ge=class{constructor(t,r,n,a){this._group=t;this.dataType=r;this.initialOrBuffer=n;this._disallowedUsages=a;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","buffer");_chunk7X4KDNDZcjs.c.call(void 0, this,"flags",GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC);_chunk7X4KDNDZcjs.c.call(void 0, this,"_buffer",null);_chunk7X4KDNDZcjs.c.call(void 0, this,"_ownBuffer");_chunk7X4KDNDZcjs.c.call(void 0, this,"_destroyed",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"initial");_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsUniform",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsStorage",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsVertex",!1);mr(n)?(this._ownBuffer=!1,this._buffer=n):(this._ownBuffer=!0,this.initial=n)}get label(){return this._label}get buffer(){var r;let t=this._group.device;if(this._destroyed)throw new Error("This buffer has been destroyed");if(!this._buffer&&(this._buffer=t.createBuffer({size:_chunkC6C35PDMcjs.sa.call(void 0, this.dataType),usage:this.flags,mappedAtCreation:!!this.initial,label:(r=this.label)!=null?r:"<unnamed>"}),this.initial)){let n=new (0, _typedbinary.BufferWriter)(this._buffer.getMappedRange());X(n,this.dataType,this.initial),this._buffer.unmap()}return this._buffer}get destroyed(){return this._destroyed}$name(t){return this._label=t,this._buffer&&(this._buffer.label=t),this}$usage(...t){var r;for(let n of t){if((r=this._disallowedUsages)!=null&&r.includes(n))throw new Error(`Buffer of type ${this.dataType.type} cannot be used as ${n}`);this.flags|=n==="uniform"?GPUBufferUsage.UNIFORM:0,this.flags|=n==="storage"?GPUBufferUsage.STORAGE:0,this.flags|=n==="vertex"?GPUBufferUsage.VERTEX:0,this.usableAsUniform=this.usableAsUniform||n==="uniform",this.usableAsStorage=this.usableAsStorage||n==="storage",this.usableAsVertex=this.usableAsVertex||n==="vertex"}return this}$addFlags(t){if(!this._ownBuffer)throw new Error("Cannot add flags to a buffer that is not managed by TypeGPU.");return t&GPUBufferUsage.MAP_READ?(this.flags=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this):t&GPUBufferUsage.MAP_WRITE?(this.flags=GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,this):(this.flags|=t,this)}write(t){let r=this.buffer,n=this._group.device;if(r.mapState==="mapped"){let i=r.getMappedRange();X(new (0, _typedbinary.BufferWriter)(i),this.dataType,t);return}let a=_chunkC6C35PDMcjs.sa.call(void 0, this.dataType);this._group.flush();let o=new ArrayBuffer(a);X(new (0, _typedbinary.BufferWriter)(o),this.dataType,t),n.queue.writeBuffer(r,0,o,0,a)}writePartial(t){let r=this.buffer,n=this._group.device,a=_r(this.dataType,t);if(r.mapState==="mapped"){let o=r.getMappedRange(),i=new Uint8Array(o);for(let p of a)i.set(p.data,p.data.byteOffset)}else for(let o of a)n.queue.writeBuffer(r,o.data.byteOffset,o.data,0,o.data.byteLength)}copyFrom(t){if(this.buffer.mapState==="mapped")throw new Error("Cannot copy to a mapped buffer.");let r=_chunkC6C35PDMcjs.sa.call(void 0, this.dataType);this._group.commandEncoder.copyBufferToBuffer(t.buffer,0,this.buffer,0,r)}async read(){this._group.flush();let t=this.buffer,r=this._group.device;if(t.mapState==="mapped"){let i=t.getMappedRange();return E(new (0, _typedbinary.BufferReader)(i),this.dataType)}if(t.usage&GPUBufferUsage.MAP_READ){await t.mapAsync(GPUMapMode.READ);let i=t.getMappedRange(),p=E(new (0, _typedbinary.BufferReader)(i),this.dataType);return t.unmap(),p}let n=r.createBuffer({size:_chunkC6C35PDMcjs.sa.call(void 0, this.dataType),usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder();a.copyBufferToBuffer(t,0,n,0,_chunkC6C35PDMcjs.sa.call(void 0, this.dataType)),r.queue.submit([a.finish()]),await r.queue.onSubmittedWorkDone(),await n.mapAsync(GPUMapMode.READ,0,_chunkC6C35PDMcjs.sa.call(void 0, this.dataType));let o=E(new (0, _typedbinary.BufferReader)(n.getMappedRange()),this.dataType);return n.unmap(),n.destroy(),o}as(t){var r;return(r=wt[t])==null?void 0:r.call(wt,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,this._ownBuffer&&((t=this._buffer)==null||t.destroy()))}toString(){var t;return`buffer:${(t=this._label)!=null?t:"<unnamed>"}`}};function Or(e){return new St(e)}function kr(e){return new Ft(e)}function Dt(e){return(e==null?void 0:e.resourceType)==="sampler"}function Ut(e){return(e==null?void 0:e.resourceType)==="sampler-comparison"}var Oe=class{constructor(t){this._membership=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},ke=class{constructor(t){this._membership=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler-comparison")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: sampler_comparison;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},St=class{constructor(t){this._props=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler");_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_filtering");_chunk7X4KDNDZcjs.c.call(void 0, this,"_sampler",null);this._filtering=t.minFilter==="linear"||t.magFilter==="linear"||t.mipmapFilter==="linear"}unwrap(t){var r;return this._sampler||(this._sampler=t.device.createSampler(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._props),{label:(r=this._label)!=null?r:"<unnamed>"}))),this._sampler}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label),{group:n,binding:a}=t.allocateFixedEntry({sampler:this._filtering?"filtering":"non-filtering"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},Ft=class{constructor(t){this._props=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","sampler-comparison");_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_sampler",null)}unwrap(t){var r;return this._sampler||(this._sampler=t.device.createSampler(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._props),{label:(r=this._label)!=null?r:"<unnamed>"}))),this._sampler}get label(){return this._label}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({sampler:"comparison"},this);return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: sampler_comparison;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};var $e=class{constructor(t){this._membership=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","external-texture")}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout);return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: texture_external;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};var $r={r8unorm:_chunkC6C35PDMcjs.w,r8snorm:_chunkC6C35PDMcjs.w,r8uint:_chunkC6C35PDMcjs.u,r8sint:_chunkC6C35PDMcjs.v,r16uint:_chunkC6C35PDMcjs.u,r16sint:_chunkC6C35PDMcjs.v,r16float:_chunkC6C35PDMcjs.w,rg8unorm:_chunkC6C35PDMcjs.w,rg8snorm:_chunkC6C35PDMcjs.w,rg8uint:_chunkC6C35PDMcjs.u,rg8sint:_chunkC6C35PDMcjs.v,r32uint:_chunkC6C35PDMcjs.u,r32sint:_chunkC6C35PDMcjs.v,r32float:_chunkC6C35PDMcjs.w,rg16uint:_chunkC6C35PDMcjs.u,rg16sint:_chunkC6C35PDMcjs.v,rg16float:_chunkC6C35PDMcjs.w,rgba8unorm:_chunkC6C35PDMcjs.w,"rgba8unorm-srgb":_chunkC6C35PDMcjs.w,rgba8snorm:_chunkC6C35PDMcjs.w,rgba8uint:_chunkC6C35PDMcjs.u,rgba8sint:_chunkC6C35PDMcjs.v,bgra8unorm:_chunkC6C35PDMcjs.w,"bgra8unorm-srgb":_chunkC6C35PDMcjs.w,rgb9e5ufloat:_chunkC6C35PDMcjs.w,rgb10a2uint:_chunkC6C35PDMcjs.u,rgb10a2unorm:_chunkC6C35PDMcjs.w,rg11b10ufloat:_chunkC6C35PDMcjs.w,rg32uint:_chunkC6C35PDMcjs.u,rg32sint:_chunkC6C35PDMcjs.v,rg32float:_chunkC6C35PDMcjs.w,rgba16uint:_chunkC6C35PDMcjs.u,rgba16sint:_chunkC6C35PDMcjs.v,rgba16float:_chunkC6C35PDMcjs.w,rgba32uint:_chunkC6C35PDMcjs.u,rgba32sint:_chunkC6C35PDMcjs.v,rgba32float:_chunkC6C35PDMcjs.w,stencil8:_chunkC6C35PDMcjs.w,depth16unorm:_chunkC6C35PDMcjs.w,depth24plus:_chunkC6C35PDMcjs.w,"depth24plus-stencil8":_chunkC6C35PDMcjs.w,depth32float:_chunkC6C35PDMcjs.w,"depth32float-stencil8":_chunkC6C35PDMcjs.w,"bc1-rgba-unorm":_chunkC6C35PDMcjs.w,"bc1-rgba-unorm-srgb":_chunkC6C35PDMcjs.w,"bc2-rgba-unorm":_chunkC6C35PDMcjs.w,"bc2-rgba-unorm-srgb":_chunkC6C35PDMcjs.w,"bc3-rgba-unorm":_chunkC6C35PDMcjs.w,"bc3-rgba-unorm-srgb":_chunkC6C35PDMcjs.w,"bc4-r-unorm":_chunkC6C35PDMcjs.w,"bc4-r-snorm":_chunkC6C35PDMcjs.w,"bc5-rg-unorm":_chunkC6C35PDMcjs.w,"bc5-rg-snorm":_chunkC6C35PDMcjs.w,"bc6h-rgb-ufloat":_chunkC6C35PDMcjs.w,"bc6h-rgb-float":_chunkC6C35PDMcjs.w,"bc7-rgba-unorm":_chunkC6C35PDMcjs.w,"bc7-rgba-unorm-srgb":_chunkC6C35PDMcjs.w,"etc2-rgb8unorm":_chunkC6C35PDMcjs.w,"etc2-rgb8unorm-srgb":_chunkC6C35PDMcjs.w,"etc2-rgb8a1unorm":_chunkC6C35PDMcjs.w,"etc2-rgb8a1unorm-srgb":_chunkC6C35PDMcjs.w,"etc2-rgba8unorm":_chunkC6C35PDMcjs.w,"etc2-rgba8unorm-srgb":_chunkC6C35PDMcjs.w,"eac-r11unorm":_chunkC6C35PDMcjs.w,"eac-r11snorm":_chunkC6C35PDMcjs.w,"eac-rg11unorm":_chunkC6C35PDMcjs.w,"eac-rg11snorm":_chunkC6C35PDMcjs.w,"astc-4x4-unorm":_chunkC6C35PDMcjs.w,"astc-4x4-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-5x4-unorm":_chunkC6C35PDMcjs.w,"astc-5x4-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-5x5-unorm":_chunkC6C35PDMcjs.w,"astc-5x5-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-6x5-unorm":_chunkC6C35PDMcjs.w,"astc-6x5-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-6x6-unorm":_chunkC6C35PDMcjs.w,"astc-6x6-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-8x5-unorm":_chunkC6C35PDMcjs.w,"astc-8x5-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-8x6-unorm":_chunkC6C35PDMcjs.w,"astc-8x6-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-8x8-unorm":_chunkC6C35PDMcjs.w,"astc-8x8-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-10x5-unorm":_chunkC6C35PDMcjs.w,"astc-10x5-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-10x6-unorm":_chunkC6C35PDMcjs.w,"astc-10x6-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-10x8-unorm":_chunkC6C35PDMcjs.w,"astc-10x8-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-10x10-unorm":_chunkC6C35PDMcjs.w,"astc-10x10-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-12x10-unorm":_chunkC6C35PDMcjs.w,"astc-12x10-unorm-srgb":_chunkC6C35PDMcjs.w,"astc-12x12-unorm":_chunkC6C35PDMcjs.w,"astc-12x12-unorm-srgb":_chunkC6C35PDMcjs.w},Ie={rgba8unorm:_chunk7X4KDNDZcjs.v,rgba8snorm:_chunk7X4KDNDZcjs.v,rgba8uint:_chunk7X4KDNDZcjs.y,rgba8sint:_chunk7X4KDNDZcjs.x,rgba16uint:_chunk7X4KDNDZcjs.y,rgba16sint:_chunk7X4KDNDZcjs.x,rgba16float:_chunk7X4KDNDZcjs.v,r32uint:_chunk7X4KDNDZcjs.y,r32sint:_chunk7X4KDNDZcjs.x,r32float:_chunk7X4KDNDZcjs.v,rg32uint:_chunk7X4KDNDZcjs.y,rg32sint:_chunk7X4KDNDZcjs.x,rg32float:_chunk7X4KDNDZcjs.v,rgba32uint:_chunk7X4KDNDZcjs.y,rgba32sint:_chunk7X4KDNDZcjs.x,rgba32float:_chunk7X4KDNDZcjs.v,bgra8unorm:_chunk7X4KDNDZcjs.v},Mr={f32:"float",u32:"uint",i32:"sint"},Wr={float:_chunkC6C35PDMcjs.w,"unfilterable-float":_chunkC6C35PDMcjs.w,uint:_chunkC6C35PDMcjs.u,sint:_chunkC6C35PDMcjs.v,depth:_chunkC6C35PDMcjs.w};function Nr(e,t){return new vt(e,t)}function W(e){return(e==null?void 0:e.resourceType)==="texture"}function Rt(e){return(e==null?void 0:e.resourceType)==="texture-storage-view"}function Bt(e){return(e==null?void 0:e.resourceType)==="texture-sampled-view"}var jr={mutable:"read_write",readonly:"read",writeonly:"write"},vt=class{constructor(t,r){this.props=t;this._branch=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture");_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsSampled",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsStorage",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"usableAsRender",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"_destroyed",!1);_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_flags",GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC);_chunk7X4KDNDZcjs.c.call(void 0, this,"_texture",null)}get label(){return this._label}$name(t){return this._label=t,this}unwrap(){var t,r,n,a,o;if(this._destroyed)throw new Error("This texture has been destroyed");return this._texture||(this._texture=this._branch.device.createTexture({label:(t=this._label)!=null?t:"<unnamed>",format:this.props.format,size:this.props.size,usage:this._flags,dimension:(r=this.props.dimension)!=null?r:"2d",viewFormats:(n=this.props.viewFormats)!=null?n:[],mipLevelCount:(a=this.props.mipLevelCount)!=null?a:1,sampleCount:(o=this.props.sampleCount)!=null?o:1})),this._texture}$usage(...t){let r=t.includes("storage"),n=t.includes("sampled"),a=t.includes("render");return this._flags|=n?GPUTextureUsage.TEXTURE_BINDING:0,this._flags|=r?GPUTextureUsage.STORAGE_BINDING:0,this._flags|=a?GPUTextureUsage.RENDER_ATTACHMENT:0,this.usableAsStorage||(this.usableAsStorage=r),this.usableAsSampled||(this.usableAsSampled=n),this.usableAsRender||(this.usableAsRender=a),this}createView(t,r){if(t==="sampled")return this._asSampled(r);let n=r;switch(t){case"mutable":return this._asMutable(n);case"readonly":return this._asReadonly(n);case"writeonly":return this._asWriteonly(n)}}_asStorage(t,r){var o;if(!this.usableAsStorage)throw new Error("Unusable as storage");let n=(o=t==null?void 0:t.format)!=null?o:this.props.format,a=Ie[n];return _chunk7X4KDNDZcjs.d.call(void 0, !!a,`Unsupported storage texture format: ${n}`),new At(t!=null?t:{},r,this)}_asReadonly(t){return this._asStorage(t,"readonly")}_asWriteonly(t){return this._asStorage(t,"writeonly")}_asMutable(t){return this._asStorage(t,"mutable")}_asSampled(t){var a;if(!this.usableAsSampled)throw new Error("Unusable as sampled");let r=(a=t==null?void 0:t.format)!=null?a:this.props.format;if(!Ie[r])throw new Error(`Unsupported storage texture format: ${r}`);return new It(t,this)}destroy(){var t;this._destroyed||(this._destroyed=!0,(t=this._texture)==null||t.destroy())}},Ne={"1d":"1d","2d":"2d","2d-array":"2d_array",cube:"cube","cube-array":"cube_array","3d":"3d"},At=class{constructor(t,r,n){this.access=r;this._texture=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"texelDataType");_chunk7X4KDNDZcjs.c.call(void 0, this,"dimension");_chunk7X4KDNDZcjs.c.call(void 0, this,"_view");_chunk7X4KDNDZcjs.c.call(void 0, this,"_format");var a,o,i;this.dimension=(o=(a=t==null?void 0:t.dimension)!=null?a:n.props.dimension)!=null?o:"2d",this._format=(i=t==null?void 0:t.format)!=null?i:n.props.format,this.texelDataType=Ie[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView({label:`${(t=this.label)!=null?t:"<unnamed>"} - View`,format:this._format,dimension:this.dimension})),this._view}"~resolve"(t){let r=t.names.makeUnique(this.label),{group:n,binding:a}=t.allocateFixedEntry({storageTexture:this._format,access:this.access,viewDimension:this.dimension},this),o=`texture_storage_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${a}) var ${r}: ${o}<${this._format}, ${jr[this.access]}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},Me=class{constructor(t,r,n,a){this._format=t;this.dimension=r;this.access=n;this._membership=a;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-storage-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"texelDataType");this.texelDataType=Ie[this._format]}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=`texture_storage_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${this._format}, ${jr[this.access]}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},It=class{constructor(t,r){this._props=t;this._texture=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"channelDataType");_chunk7X4KDNDZcjs.c.call(void 0, this,"dimension");_chunk7X4KDNDZcjs.c.call(void 0, this,"_format");_chunk7X4KDNDZcjs.c.call(void 0, this,"_view");var n,a,o;this.dimension=(a=(n=t==null?void 0:t.dimension)!=null?n:r.props.dimension)!=null?a:"2d",this._format=(o=t==null?void 0:t.format)!=null?o:r.props.format,this.channelDataType=$r[this._format]}get label(){return this._texture.label}$name(t){return this._texture.$name(t),this}unwrap(){var t;return this._view||(this._view=this._texture.unwrap().createView(_chunk7X4KDNDZcjs.a.call(void 0, {label:`${(t=this.label)!=null?t:"<unnamed>"} - View`},this._props))),this._view}"~resolve"(t){var p;let r=t.names.makeUnique(this.label),n=((p=this._texture.props.sampleCount)!=null?p:1)>1,{group:a,binding:o}=t.allocateFixedEntry({texture:Mr[this.channelDataType.type],viewDimension:this.dimension,multisampled:n},this),i=n?"texture_multisampled_2d":`texture_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${a}) @binding(${o}) var ${r}: ${i}<${t.resolve(this.channelDataType)}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}},We=class{constructor(t,r,n,a){this.dimension=r;this._multisampled=n;this._membership=a;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","texture-sampled-view");_chunk7X4KDNDZcjs.c.call(void 0, this,"channelDataType");this.channelDataType=Wr[t]}get label(){return this._membership.key}"~resolve"(t){let r=t.names.makeUnique(this.label),n=t.allocateLayoutEntry(this._membership.layout),a=this._multisampled?"texture_multisampled_2d":`texture_${Ne[this.dimension]}`;return t.addDeclaration(`@group(${n}) @binding(${this._membership.idx}) var ${r}: ${a}<${t.resolve(this.channelDataType)}>;`),r}toString(){var t;return`${this.resourceType}:${(t=this.label)!=null?t:"<unnamed>"}`}};function Pt(e){return!!(e!=null&&e.usableAsSampled)}function An(e){return!!(e!=null&&e.usableAsRender)}var je=class e extends Error{constructor(t){var r;super(`Resource '${(r=t.label)!=null?r:"<unnamed>"}' cannot be bound as 'sampled'. Use .$usage('sampled') to allow it.`),Object.setPrototypeOf(this,e.prototype)}};function ze(e){return new Lt(e)}function Ke(e){return!!e&&e.resourceType==="bind-group-layout"}function Ct(e){return!!e&&e.resourceType==="bind-group"}var _t=class e extends Error{constructor(t,r){super(`Bind group '${t!=null?t:"<unnamed>"}' is missing a required binding '${r}'`),Object.setPrototypeOf(this,e.prototype)}},zr=["compute"],Te=["compute","vertex","fragment"],Lt=class{constructor(t){this.entries=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_index");_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","bind-group-layout");_chunk7X4KDNDZcjs.c.call(void 0, this,"bound",{});var n,a,o,i,p;let r=0;for(let[l,s]of Object.entries(t)){if(s===null){r++;continue}let m={idx:r,key:l,layout:this};if("uniform"in s&&(this.bound[l]=new Ae("uniform",s.uniform,m)),"storage"in s){let g="type"in s.storage?s.storage:s.storage(0);this.bound[l]=new Ae((n=s.access)!=null?n:"readonly",g,m)}"texture"in s&&(this.bound[l]=new We(s.texture,(a=s.viewDimension)!=null?a:"2d",(o=s.multisampled)!=null?o:!1,m)),"storageTexture"in s&&(this.bound[l]=new Me(s.storageTexture,(i=s.viewDimension)!=null?i:"2d",(p=s.access)!=null?p:"writeonly",m)),"externalTexture"in s&&(this.bound[l]=new $e(m)),"sampler"in s&&(s.sampler==="comparison"?this.bound[l]=new ke(m):this.bound[l]=new Oe(m)),r++}}get label(){return this._label}get index(){return this._index}$name(t){return this._label=t,this}$idx(t){return this._index=t,this}unwrap(t){var n;return t.device.createBindGroupLayout({label:(n=this.label)!=null?n:"<unnamed>",entries:Object.values(this.entries).map((a,o)=>{var l,s,m,g;if(a===null)return null;let i=a.visibility,p={binding:o,visibility:0};if("uniform"in a)i=i!=null?i:Te,p.buffer={type:"uniform"};else if("storage"in a)i=i!=null?i:a.access==="mutable"?zr:Te,p.buffer={type:a.access==="mutable"?"storage":"read-only-storage"};else if("sampler"in a)i=i!=null?i:Te,p.sampler={type:a.sampler};else if("texture"in a)i=i!=null?i:Te,p.texture={sampleType:a.texture,viewDimension:(l=a.viewDimension)!=null?l:"2d",multisampled:(s=a.multisampled)!=null?s:!1};else if("storageTexture"in a){let f=(m=a.access)!=null?m:"writeonly";i=i!=null?i:f==="readonly"?Te:zr,p.storageTexture={format:a.storageTexture,access:{mutable:"read-write",readonly:"read-only",writeonly:"write-only"}[f],viewDimension:(g=a.viewDimension)!=null?g:"2d"}}else"externalTexture"in a&&(i=i!=null?i:Te,p.externalTexture={});return i!=null&&i.includes("compute")&&(p.visibility|=GPUShaderStage.COMPUTE),i!=null&&i.includes("vertex")&&(p.visibility|=GPUShaderStage.VERTEX),i!=null&&i.includes("fragment")&&(p.visibility|=GPUShaderStage.FRAGMENT),p}).filter(a=>a!==null)})}populate(t){return new ue(this,t)}},ue=class{constructor(t,r){this.layout=t;this.entries=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","bind-group");for(let n of Object.keys(t.entries))if(t.entries[n]!==null&&!(n in r))throw new _t(t.label,n)}unwrap(t){var n;return t.device.createBindGroup({label:(n=this.layout.label)!=null?n:"<unnamed>",layout:t.unwrap(this.layout),entries:Object.entries(this.layout.entries).map(([a,o],i)=>{var l;if(o===null)return null;let p=this.entries[a];if(p===void 0)throw new Error(`'${a}' is a resource required to populate bind group layout '${(l=this.layout.label)!=null?l:"<unnamed>"}'.`);if("uniform"in o){let s;if(Z(p)){if(!Ee(p))throw new (0, _chunk7X4KDNDZcjs.g)(p);s={buffer:t.unwrap(p)}}else s={buffer:p};return{binding:i,resource:s}}if("storage"in o){let s;if(Z(p)){if(!se(p))throw new Ue(p);s={buffer:t.unwrap(p)}}else s={buffer:p};return{binding:i,resource:s}}if("texture"in o){let s;if(W(p)){if(!Pt(p))throw new je(p);s=t.unwrap(p.createView("sampled"))}else s=p;return{binding:i,resource:s}}if("storageTexture"in o){let s;if(W(p)){if(!se(p))throw new Ue(p);o.access==="readonly"?s=t.unwrap(p.createView("readonly")):o.access==="mutable"?s=t.unwrap(p.createView("mutable")):s=t.unwrap(p.createView("writeonly"))}else s=p;return{binding:i,resource:s}}if("externalTexture"in o||"sampler"in o)return{binding:i,resource:p};throw new Error(`Malformed bind group entry: ${p} (${JSON.stringify(p)})`)}).filter(a=>a!==null)})}};var Kr="#CATCHALL#",Et=class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"_stack",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"_itemDepth",0)}get itemDepth(){return this._itemDepth}get topItem(){let t=this._stack[this._stack.length-1];if(!t||t.type!=="item")throw new Error("Internal error, expected item layer to be on top.");return t}pushItem(){this._itemDepth++,this._stack.push({type:"item",usedSlots:new Set})}pushSlotBindings(t){this._stack.push({type:"slotBinding",bindingMap:new WeakMap(t)})}pushFunctionScope(t,r,n){this._stack.push({type:"functionScope",args:t,returnType:r,externalMap:n})}pop(){let t=this._stack.pop();(t==null?void 0:t.type)==="item"&&this._itemDepth--}readSlot(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="item")n.usedSlots.add(t);else if((n==null?void 0:n.type)==="slotBinding"){let a=n.bindingMap.get(t);if(a!==void 0)return a}else if(!((n==null?void 0:n.type)==="functionScope"||(n==null?void 0:n.type)==="blockScope"))throw new Error("Unknown layer type.")}return t.defaultValue}getResourceById(t){for(let r=this._stack.length-1;r>=0;--r){let n=this._stack[r];if((n==null?void 0:n.type)==="functionScope"){let a=n.args.find(i=>i.value===t);if(a!==void 0)return a;let o=n.externalMap[t];return o!==void 0?{value:o,dataType:A}:void 0}if((n==null?void 0:n.type)==="blockScope"){let a=n.declarations.get(t);if(a!==void 0)return{value:t,dataType:a}}}}},qe=[""," "," "," "," "," "," "," "," "],Vt=qe.length-1,Gt=class{constructor(){_chunk7X4KDNDZcjs.c.call(void 0, this,"identLevel",0)}get pre(){var t;return(t=qe[this.identLevel])!=null?t:qe[Vt].repeat(this.identLevel/Vt)+qe[this.identLevel%Vt]}indent(){let t=this.pre;return this.identLevel++,t}dedent(){return this.identLevel--,this.pre}},Ot=class{constructor(t){_chunk7X4KDNDZcjs.c.call(void 0, this,"_memoizedResolves",new WeakMap);_chunk7X4KDNDZcjs.c.call(void 0, this,"_memoizedDerived",new WeakMap);_chunk7X4KDNDZcjs.c.call(void 0, this,"_indentController",new Gt);_chunk7X4KDNDZcjs.c.call(void 0, this,"_jitTranspiler");_chunk7X4KDNDZcjs.c.call(void 0, this,"_itemStateStack",new Et);_chunk7X4KDNDZcjs.c.call(void 0, this,"_declarations",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"bindGroupLayoutsToPlaceholderMap",new Map);_chunk7X4KDNDZcjs.c.call(void 0, this,"_nextFreeLayoutPlaceholderIdx",0);_chunk7X4KDNDZcjs.c.call(void 0, this,"fixedBindings",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"callStack",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"names");this.names=t.names,this._jitTranspiler=t.jitTranspiler}get pre(){return this._indentController.pre}indent(){return this._indentController.indent()}dedent(){return this._indentController.dedent()}getById(t){var r;return(r=this._itemStateStack.getResourceById(t))!=null?r:{value:t,dataType:A}}transpileFn(t){if(!this._jitTranspiler)throw new Error("Tried to execute a tgpu.fn function without providing a JIT transpiler, or transpiling at build time.");return this._jitTranspiler.transpileFn(t)}fnToWgsl(t){this._itemStateStack.pushFunctionScope(t.args,t.returnType,t.externalMap);let r=Tt(this,t.body);this._itemStateStack.pop();let n=t.args.map(a=>`${a.value}: ${this.resolve(a.dataType)}`).join(", ");return{head:t.returnType!==void 0?`(${n}) -> ${_chunkC6C35PDMcjs.Fa.call(void 0, t.returnType)} ${this.resolve(t.returnType)}`:`(${n})`,body:r}}addDeclaration(t){this._declarations.push(t)}allocateLayoutEntry(t){let r=this.bindGroupLayoutsToPlaceholderMap,n=r.get(t);return n||(n=`#BIND_GROUP_LAYOUT_${this._nextFreeLayoutPlaceholderIdx++}#`,r.set(t,n)),n}allocateFixedEntry(t,r){let n=this.fixedBindings.length;return this.fixedBindings.push({layoutEntry:t,resource:r}),{group:Kr,binding:n}}readSlot(t){let r=this._itemStateStack.readSlot(t);if(r===void 0)throw new (0, _chunk7X4KDNDZcjs.f)(t);return r}withSlots(t,r){this._itemStateStack.pushSlotBindings(t);try{return r()}finally{this._itemStateStack.pop()}}unwrap(t){if(Se(t))return this.withSlots(t["~providing"].pairs,()=>this.unwrap(t["~providing"].inner));let r=t;for(;;)if(q(r))r=this.readSlot(r);else if(J(r))r=this._getOrCompute(r);else break;return r}_getOrCompute(t){var n;let r=(n=this._memoizedDerived.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([l,s])=>l.areEqual(this._itemStateStack.readSlot(l),s)))return i.result;let a=t["~compute"](),o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedDerived.set(t,r),a}catch(a){throw a instanceof _chunk7X4KDNDZcjs.e?a.appendToTrace(t):new (0, _chunk7X4KDNDZcjs.e)(a,[t])}finally{this._itemStateStack.pop()}}_getOrInstantiate(t){var n;let r=(n=this._memoizedResolves.get(t))!=null?n:[];this._itemStateStack.pushItem();try{for(let i of r)if([...i.slotToValueMap.entries()].every(([l,s])=>l.areEqual(this._itemStateStack.readSlot(l),s)))return i.result;let a;_chunkC6C35PDMcjs.a.call(void 0, t)||_chunkC6C35PDMcjs.n.call(void 0, t)?a=mt(this,t):J(t)||q(t)?a=this.resolve(this.unwrap(t)):st(t)?a=t["~resolve"](this):a=this.resolveValue(t);let o=new Map;for(let i of this._itemStateStack.topItem.usedSlots)o.set(i,this._itemStateStack.readSlot(i));return r.push({slotToValueMap:o,result:a}),this._memoizedResolves.set(t,r),a}catch(a){throw a instanceof _chunk7X4KDNDZcjs.e?a.appendToTrace(t):new (0, _chunk7X4KDNDZcjs.e)(a,[t])}finally{this._itemStateStack.pop()}}resolve(t){if(Se(t))return this.withSlots(t["~providing"].pairs,()=>this.resolve(t["~providing"].inner));if(t&&typeof t=="object"||typeof t=="function"){if(this._itemStateStack.itemDepth===0){let r=_chunk7X4KDNDZcjs.k.call(void 0, this,()=>this._getOrInstantiate(t));return`${[...this._declarations].join(`
|
17
17
|
|
18
|
-
`)}${r}`}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(ne(t))return this.resolve(t);if(r&&_chunkO7JKWPDHcjs.b.call(void 0, r))return`array(${t.map(n=>this.resolveValue(n,r.elementType))})`;if(Array.isArray(t))return`array(${t.map(n=>this.resolveValue(n))})`;if(r&&_chunkO7JKWPDHcjs.c.call(void 0, r))return`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>this.resolveValue(t[n],a))})`;throw new Error(`Value ${t} (as json: ${JSON.stringify(t)}) of schema ${r} is not resolvable to WGSL`)}};function ye(e,t){var g;let r=new Et(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(f=>f.index).filter(f=>f!==void 0)),u=Ur(i),l=r.fixedBindings.map((f,w)=>[String(w),f.layoutEntry]),s=()=>{let f=u.next().value,w=ze(Object.fromEntries(l));return o[f]=w,n=n.replaceAll(jr,String(f)),[f,new ue(w,Object.fromEntries(r.fixedBindings.map((c,T)=>[String(T),c.resource])))]},m=l.length>0?s():null;for(let[f,w]of a.entries()){let c=(g=f.index)!=null?g:u.next().value;o[c]=f,n=n.replaceAll(w,String(c))}return{code:n,bindGroupLayouts:o,catchall:m}}function zr(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};ae(o,t!=null?t:{});let i={"~resolve"(l){return oe(l,o,r!=null?r:"")},toString:()=>"<root>"},{code:u}=ye(i,{names:n==="strict"?new Q:new Y,jitTranspiler:a});return u}var Re=class{constructor(t){this._make=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"_map",new WeakMap)}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}};function Kr(e,t,r){return new Gt(new Ot(e,t,r),{})}function qr(e){return(e==null?void 0:e.resourceType)==="compute-pipeline"}var Gt=class e{constructor(t,r){this._core=t;this._priors=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","compute-pipeline")}get label(){return this._core.label}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){var n;return new e(this._core,{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])})}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o,label:i}=this._core,u=o.commandEncoder.beginComputePass({label:i!=null?i:"<unnamed>"});u.setPipeline(a.pipeline);let l=new Set(a.bindGroupLayouts);if(a.bindGroupLayouts.forEach((s,m)=>{var g;if(a.catchall&&m===a.catchall[0])u.setBindGroup(m,o.unwrap(a.catchall[1])),l.delete(s);else{let f=(g=this._priors.bindGroupLayoutMap)==null?void 0:g.get(s);f!==void 0&&(l.delete(s),u.setBindGroup(m,o.unwrap(f)))}}),l.size>0)throw new (0, _chunk7X4KDNDZcjs.i)(l);u.dispatchWorkgroups(t,r,n),u.end()}$name(t){return this._core.label=t,this}},Ot=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_memo")}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let i=this.branch.device,{code:u,bindGroupLayouts:l,catchall:s}=ye({"~resolve":m=>(m.withSlots(this._slotBindings,()=>{m.resolve(this._entryFn)}),""),toString:()=>{var m;return`computePipeline:${(m=this.label)!=null?m:"<unnamed>"}`}},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});s!==null&&((r=l[s[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`)),this._memo={pipeline:i.createComputePipeline({label:(n=this.label)!=null?n:"<unnamed>",layout:i.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:l.map(m=>this.branch.unwrap(m))}),compute:{module:i.createShaderModule({label:`${(o=this.label)!=null?o:"<unnamed>"} - Shader`,code:u})}}),bindGroupLayouts:l,catchall:s}}return this._memo}};function Mt(e,t="vertex"){return new $t(e,t)}function He(e){return(e==null?void 0:e.resourceType)==="vertex-layout"}var kt=Symbol("defaultAttribEntry");function Je(e,t,r,n,a){if(_chunkO7JKWPDHcjs.k.call(void 0, t)||_chunkO7JKWPDHcjs.q.call(void 0, t)){let o=_chunkO7JKWPDHcjs.r.call(void 0, t);return o!==void 0&&(n[a!=null?a:kt]=o),Je(e,t.inner,_chunkO7JKWPDHcjs.z.call(void 0, r,_chunkO7JKWPDHcjs.qa.call(void 0, t)),n)}if(_chunkO7JKWPDHcjs.c.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,u])=>{o=_chunkO7JKWPDHcjs.z.call(void 0, o,_chunkO7JKWPDHcjs.pa.call(void 0, u));let l=[i,Je(e,u,o,n,i)];return o+=_chunkO7JKWPDHcjs.sa.call(void 0, u),l}))}if(_chunkO7JKWPDHcjs.p.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,u])=>{o=_chunkO7JKWPDHcjs.z.call(void 0, o,_chunkO7JKWPDHcjs.qa.call(void 0, u));let l=[i,Je(e,u,o,n,i)];return o+=_chunkO7JKWPDHcjs.sa.call(void 0, u),l}))}if("type"in t&&typeof t.type=="string"){if(_chunkO7JKWPDHcjs.l.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkO7JKWPDHcjs.m[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var $t=class{constructor(t,r){this.schemaForCount=t;this.stepMode=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","vertex-layout");_chunk7X4KDNDZcjs.c.call(void 0, this,"stride");_chunk7X4KDNDZcjs.c.call(void 0, this,"attrib");_chunk7X4KDNDZcjs.c.call(void 0, this,"_customLocationMap",{});_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");let n=t(0);this.stride=_chunkO7JKWPDHcjs.z.call(void 0, _chunkO7JKWPDHcjs.sa.call(void 0, n.elementType),_chunkO7JKWPDHcjs.pa.call(void 0, n)),this.attrib=Je(this,n.elementType,0,this._customLocationMap)}get label(){return this._label}get vertexLayout(){if(this._customLocationMap[kt]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[kt]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return this._label=t,this}};function In(e){return typeof(e==null?void 0:e.loadOp)=="string"}function Jr(e,t){if(_chunkO7JKWPDHcjs.s.call(void 0, e)){if(!In(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Rn(e){return typeof(e==null?void 0:e.format)=="string"}function Hr(e,t){if(_chunkO7JKWPDHcjs.s.call(void 0, e)){if(!Rn(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Yr(e){return new Wt(new Nt(e),{})}function Qr(e){return(e==null?void 0:e.resourceType)==="render-pipeline"}var Wt=class e{constructor(t,r){this.core=t;this.priors=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","render-pipeline")}get label(){return this.core.label}$name(t){return this.core.label=t,this}with(t,r){var n,a;if(Ke(t))return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{bindGroupLayoutMap:new Map([...(n=this.priors.bindGroupLayoutMap)!=null?n:[],[t,r]])}));if(He(t))return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{vertexLayoutMap:new Map([...(a=this.priors.vertexLayoutMap)!=null?a:[],[t,r]])}));throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{colorAttachment:t}))}withDepthStencilAttachment(t){return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{depthStencilAttachment:t}))}draw(t,r,n,a){var c;let o=this.core.unwrap(),{branch:i,fragmentFn:u}=this.core.options,s={colorAttachments:Jr(u.shell.targets,(c=this.priors.colorAttachment)!=null?c:{}).map(T=>W(T.view)?_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},T),{view:i.unwrap(T.view).createView()}):T)};if(this.core.label!==void 0&&(s.label=this.core.label),this.priors.depthStencilAttachment!==void 0){let T=this.priors.depthStencilAttachment;W(T.view)?s.depthStencilAttachment=_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},T),{view:i.unwrap(T.view).createView()}):s.depthStencilAttachment=T}let m=i.commandEncoder.beginRenderPass(s);m.setPipeline(o.pipeline);let g=new Set(o.bindGroupLayouts);o.bindGroupLayouts.forEach((T,b)=>{var y;if(o.catchall&&b===o.catchall[0])m.setBindGroup(b,i.unwrap(o.catchall[1])),g.delete(T);else{let S=(y=this.priors.bindGroupLayoutMap)==null?void 0:y.get(T);S!==void 0&&(g.delete(T),m.setBindGroup(b,i.unwrap(S)))}});let f=new Set(this.core.usedVertexLayouts);if(this.core.usedVertexLayouts.forEach((T,b)=>{var S;let y=(S=this.priors.vertexLayoutMap)==null?void 0:S.get(T);y&&(f.delete(T),m.setVertexBuffer(b,i.unwrap(y)))}),g.size>0)throw new (0, _chunk7X4KDNDZcjs.i)(g);if(f.size>0)throw new (0, _chunk7X4KDNDZcjs.j)(f);m.draw(t,r,n,a),m.end()}},Nt=class{constructor(t){this.options=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"usedVertexLayouts");_chunk7X4KDNDZcjs.c.call(void 0, this,"_memo");_chunk7X4KDNDZcjs.c.call(void 0, this,"_vertexBufferLayouts");_chunk7X4KDNDZcjs.c.call(void 0, this,"_targets");let r=Dr(t.vertexFn.shell.attributes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=Hr(t.fragmentFn.shell.targets,t.targets)}unwrap(){var t,r,n,a;if(this._memo===void 0){let{branch:o,vertexFn:i,fragmentFn:u,slotBindings:l,primitiveState:s,depthStencilState:m}=this.options,{code:g,bindGroupLayouts:f,catchall:w}=ye({"~resolve":y=>(y.withSlots(l,()=>{y.resolve(i),y.resolve(u)}),""),toString:()=>{var y;return`renderPipeline:${(y=this.label)!=null?y:"<unnamed>"}`}},{names:o.nameRegistry,jitTranspiler:o.jitTranspiler});w!==null&&((r=f[w[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`));let c=o.device,T=c.createShaderModule({label:`${(n=this.label)!=null?n:"<unnamed>"} - Shader`,code:g}),b={layout:c.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:f.map(y=>o.unwrap(y))}),vertex:{module:T,buffers:this._vertexBufferLayouts},fragment:{module:T,targets:this._targets}};this.label!==void 0&&(b.label=this.label),s&&(b.primitive=s),m&&(b.depthStencil=m),this._memo={pipeline:c.createRenderPipeline(b),bindGroupLayouts:f,catchall:w}}return this._memo}};var jt=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[re(t)?t.slot:t,r]])}withCompute(t){return new zt(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new Kt({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r})}},zt=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return Kr(this._root,this._slotBindings,this._entryFn)}},Kt=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunk7X4KDNDZcjs.d.call(void 0, typeof t!="string","Just type mismatch validation"),_chunk7X4KDNDZcjs.d.call(void 0, typeof r!="string","Just type mismatch validation"),new qt(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._options),{fragmentFn:t,targets:r}))}},qt=class e{constructor(t){this._options=t}withPrimitive(t){return new e(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._options),{primitiveState:t}))}withDepthStencil(t){return new e(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._options),{depthStencilState:t}))}createPipeline(){return Yr(this._options)}},Ye=class extends jt{constructor(r,n,a,o){super(()=>this,[]);this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;_chunk7X4KDNDZcjs.c.call(void 0, this,"~unstable");_chunk7X4KDNDZcjs.c.call(void 0, this,"_disposables",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"_unwrappedBindGroupLayouts",new Re(r=>r.unwrap(this)));_chunk7X4KDNDZcjs.c.call(void 0, this,"_unwrappedBindGroups",new Re(r=>r.unwrap(this)));_chunk7X4KDNDZcjs.c.call(void 0, this,"_commandEncoder",null);this["~unstable"]=this}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=Vr(this,r,n);return this._disposables.push(a),a}createUniform(r,n){return this.createBuffer(r,n).$usage("uniform").as("uniform")}createMutable(r,n){return this.createBuffer(r,n).$usage("storage").as("mutable")}createReadonly(r,n){return this.createBuffer(r,n).$usage("storage").as("readonly")}createBindGroup(r,n){return new ue(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=Mr(r,this);return this._disposables.push(n),n}unwrap(r){if(qr(r))return r.rawPipeline;if(Qr(r))return r.core.unwrap().pipeline;if(Ke(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(_t(r))return this._unwrappedBindGroups.getOrMake(r);if(Z(r))return r.buffer;if(W(r)||At(r)||It(r))return r.unwrap();if(He(r))return r.vertexLayout;throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,i=new Map,u,l=()=>{if(!u)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:s,priors:m}=u,g=s.unwrap();a.setPipeline(g.pipeline);let f=new Set(g.bindGroupLayouts);g.bindGroupLayouts.forEach((c,T)=>{var b,y;if(g.catchall&&T===g.catchall[0])a.setBindGroup(T,this.unwrap(g.catchall[1])),f.delete(c);else{let S=(y=(b=m.bindGroupLayoutMap)==null?void 0:b.get(c))!=null?y:o.get(c);S!==void 0&&(f.delete(c),_t(S)?a.setBindGroup(T,this.unwrap(S)):a.setBindGroup(T,S))}});let w=new Set;if(s.usedVertexLayouts.forEach((c,T)=>{var S;let b=(S=m.vertexLayoutMap)==null?void 0:S.get(c),y=b?{buffer:b,offset:void 0,size:void 0}:i.get(c);!y||!y.buffer?w.add(c):Z(y.buffer)?a.setVertexBuffer(T,this.unwrap(y.buffer),y.offset,y.size):a.setVertexBuffer(T,y.buffer,y.offset,y.size)}),f.size>0)throw new (0, _chunk7X4KDNDZcjs.i)(f);if(w.size>0)throw new (0, _chunk7X4KDNDZcjs.j)(w)};n({setViewport(...s){a.setViewport(...s)},setScissorRect(...s){a.setScissorRect(...s)},setBlendConstant(...s){a.setBlendConstant(...s)},setStencilReference(...s){a.setStencilReference(...s)},beginOcclusionQuery(...s){a.beginOcclusionQuery(...s)},endOcclusionQuery(...s){a.endOcclusionQuery(...s)},executeBundles(...s){a.executeBundles(...s)},setPipeline(s){u=s},setIndexBuffer:(s,m,g,f)=>{Z(s)?a.setIndexBuffer(this.unwrap(s),m,g,f):a.setIndexBuffer(s,m,g,f)},setVertexBuffer(s,m,g,f){i.set(s,{buffer:m,offset:g,size:f})},setBindGroup(s,m){o.set(s,m)},draw(s,m,g,f){l(),a.draw(s,m,g,f)},drawIndexed(...s){l(),a.drawIndexed(...s)},drawIndirect(...s){l(),a.drawIndirect(...s)},drawIndexedIndirect(...s){l(),a.drawIndexedIndirect(...s)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}};async function Xr(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=e!=null?e:{};if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new Ye(await o.requestDevice(r),n==="random"?new Y:new Q,a,!0)}function Zr(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=e!=null?e:{};return new Ye(t,r==="random"?new Y:new Q,n,!1)}function Qe(e){return new Jt(e)}var Jt=class{constructor(t=void 0){this.defaultValue=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","slot");_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr")}$name(t){return this.label=t,this}areEqual(t,r){return Object.is(t,r)}toString(){var t;return`slot:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){let t=_chunk7X4KDNDZcjs.l.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return Fe(t.unwrap(this))}};function en(e,t){return new Ht(e,t)}var Ht=class{constructor(t,r=void 0){this.schema=t;this.defaultValue=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","accessor");_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr");_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"slot");this.slot=Qe(r)}$name(t){return this.label=t,this.slot.$name(t),this}toString(){var t;return`accessor:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.l.call(void 0, ))throw new Error("Cannot access tgpu.accessor's value outside of resolution.");return new Proxy({"~resolve":r=>r.resolve(this),toString:()=>{var r;return`.value:${(r=this.label)!=null?r:"<unnamed>"}`}},k)}"~resolve"(t){let r=t.unwrap(this.slot);return Le(r)?t.resolve(r):lt(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}};function tn(e){return Pn(e)}function Bn([e,t]){var r;return`${(r=e.label)!=null?r:"<unnamed>"}=${t}`}function Pn(e){return{resourceType:"derived","~compute":e,"~repr":void 0,get value(){let r=_chunk7X4KDNDZcjs.l.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Fe(r.unwrap(this))},with(r,n){return rn(this,[[r,n]])},toString(){return"derived"}}}function rn(e,t){return{resourceType:"derived","~repr":void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},get value(){let n=_chunk7X4KDNDZcjs.l.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Fe(n.unwrap(this))},with(n,a){return rn(e,[...t,[n,a]])},toString(){return`derived[${t.map(Bn).join(", ")}]`}}}function nn(e,t){return new Xe("private",e,t)}function an(e){return new Xe("workgroup",e)}var Xe=class{constructor(t,r,n){this.scope=t;this._dataType=r;this._initialValue=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"_label")}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label);return this._initialValue?t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)} = ${t.resolveValue(this._initialValue,this._dataType)};`):t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)};`),r}get label(){return this._label}toString(){var t;return`var:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.m.call(void 0, ))throw new Error("Cannot access tgpu.var's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k)}};var on={bindGroupLayout:ze,vertexLayout:Mt,init:Xr,initFromDevice:Zr,resolve:zr,"~unstable":{fn:br,fragmentFn:wr,vertexFn:Sr,computeFn:xr,vertexLayout:Mt,derived:tn,slot:Qe,accessor:en,privateVar:nn,workgroupVar:an,const:dr,declare:gr,sampler:Er,comparisonSampler:Gr}},Vs= exports.default =on;Object.assign(on,{__assignAst:yr});exports.MissingBindGroupsError = _chunk7X4KDNDZcjs.i; exports.MissingLinksError = _chunk7X4KDNDZcjs.h; exports.MissingSlotValueError = _chunk7X4KDNDZcjs.f; exports.MissingVertexBuffersError = _chunk7X4KDNDZcjs.j; exports.NotUniformError = _chunk7X4KDNDZcjs.g; exports.RandomNameRegistry = Y; exports.ResolutionError = _chunk7X4KDNDZcjs.e; exports.StrictNameRegistry = Q; exports.default = Vs; exports.isBuffer = Z; exports.isComparisonSampler = vn; exports.isDerived = J; exports.isSampledTextureView = It; exports.isSampler = Un; exports.isSlot = q; exports.isStorageTextureView = At; exports.isTexture = W; exports.isTgpuFn = lt; exports.isUsableAsRender = An; exports.isUsableAsSampled = Rt; exports.isUsableAsStorage = se; exports.isUsableAsUniform = Ee; exports.isUsableAsVertex = Dn; exports.tgpu = on; exports.unstable_asMutable = yt; exports.unstable_asReadonly = ct; exports.unstable_asUniform = xt;
|
18
|
+
`)}${r}`}return this._getOrInstantiate(t)}return String(t)}resolveValue(t,r){if(ne(t))return this.resolve(t);if(r&&_chunkC6C35PDMcjs.b.call(void 0, r))return`array(${t.map(n=>this.resolveValue(n,r.elementType))})`;if(Array.isArray(t))return`array(${t.map(n=>this.resolveValue(n))})`;if(r&&_chunkC6C35PDMcjs.c.call(void 0, r))return`${this.resolve(r)}(${Object.entries(r.propTypes).map(([n,a])=>this.resolveValue(t[n],a))})`;throw new Error(`Value ${t} (as json: ${JSON.stringify(t)}) of schema ${r} is not resolvable to WGSL`)}};function ye(e,t){var g;let r=new Ot(t),n=r.resolve(e),a=r.bindGroupLayoutsToPlaceholderMap,o=[],i=new Set([...a.keys()].map(f=>f.index).filter(f=>f!==void 0)),p=Ar(i),l=r.fixedBindings.map((f,w)=>[String(w),f.layoutEntry]),s=()=>{let f=p.next().value,w=ze(Object.fromEntries(l));return o[f]=w,n=n.replaceAll(Kr,String(f)),[f,new ue(w,Object.fromEntries(r.fixedBindings.map((c,T)=>[String(T),c.resource])))]},m=l.length>0?s():null;for(let[f,w]of a.entries()){let c=(g=f.index)!=null?g:p.next().value;o[c]=f,n=n.replaceAll(w,String(c))}return{code:n,bindGroupLayouts:o,catchall:m}}function qr(e){let{externals:t,template:r,names:n,unstable_jitTranspiler:a}=e,o={};ae(o,t!=null?t:{});let i={"~resolve"(l){return oe(l,o,r!=null?r:"")},toString:()=>"<root>"},{code:p}=ye(i,{names:n==="strict"?new Q:new Y,jitTranspiler:a});return p}var Re=class{constructor(t){this._make=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"_map",new WeakMap)}getOrMake(t,...r){if(this._map.has(t))return this._map.get(t);let n=this._make(t,...r);return this._map.set(t,n),n}};function Jr(e,t,r){return new kt(new $t(e,t,r),{})}function Hr(e){return(e==null?void 0:e.resourceType)==="compute-pipeline"}var kt=class e{constructor(t,r){this._core=t;this._priors=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","compute-pipeline")}get label(){return this._core.label}get rawPipeline(){return this._core.unwrap().pipeline}with(t,r){var n;return new e(this._core,{bindGroupLayoutMap:new Map([...(n=this._priors.bindGroupLayoutMap)!=null?n:[],[t,r]])})}dispatchWorkgroups(t,r,n){let a=this._core.unwrap(),{branch:o,label:i}=this._core,p=o.commandEncoder.beginComputePass({label:i!=null?i:"<unnamed>"});p.setPipeline(a.pipeline);let l=new Set(a.bindGroupLayouts);if(a.bindGroupLayouts.forEach((s,m)=>{var g;if(a.catchall&&m===a.catchall[0])p.setBindGroup(m,o.unwrap(a.catchall[1])),l.delete(s);else{let f=(g=this._priors.bindGroupLayoutMap)==null?void 0:g.get(s);f!==void 0&&(l.delete(s),p.setBindGroup(m,o.unwrap(f)))}}),l.size>0)throw new (0, _chunk7X4KDNDZcjs.i)(l);p.dispatchWorkgroups(t,r,n),p.end()}$name(t){return this._core.label=t,this}},$t=class{constructor(t,r,n){this.branch=t;this._slotBindings=r;this._entryFn=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"_memo")}unwrap(){var t,r,n,a,o;if(this._memo===void 0){let i=this.branch.device,{code:p,bindGroupLayouts:l,catchall:s}=ye({"~resolve":m=>(m.withSlots(this._slotBindings,()=>{m.resolve(this._entryFn)}),""),toString:()=>{var m;return`computePipeline:${(m=this.label)!=null?m:"<unnamed>"}`}},{names:this.branch.nameRegistry,jitTranspiler:this.branch.jitTranspiler});s!==null&&((r=l[s[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`)),this._memo={pipeline:i.createComputePipeline({label:(n=this.label)!=null?n:"<unnamed>",layout:i.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:l.map(m=>this.branch.unwrap(m))}),compute:{module:i.createShaderModule({label:`${(o=this.label)!=null?o:"<unnamed>"} - Shader`,code:p})}}),bindGroupLayouts:l,catchall:s}}return this._memo}};function Nt(e,t="vertex"){return new Wt(e,t)}function He(e){return(e==null?void 0:e.resourceType)==="vertex-layout"}var Mt=Symbol("defaultAttribEntry");function Je(e,t,r,n,a){if(_chunkC6C35PDMcjs.k.call(void 0, t)||_chunkC6C35PDMcjs.q.call(void 0, t)){let o=_chunkC6C35PDMcjs.r.call(void 0, t);return o!==void 0&&(n[a!=null?a:Mt]=o),Je(e,t.inner,_chunkC6C35PDMcjs.z.call(void 0, r,_chunkC6C35PDMcjs.qa.call(void 0, t)),n)}if(_chunkC6C35PDMcjs.c.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,p])=>{o=_chunkC6C35PDMcjs.z.call(void 0, o,_chunkC6C35PDMcjs.pa.call(void 0, p));let l=[i,Je(e,p,o,n,i)];return o+=_chunkC6C35PDMcjs.sa.call(void 0, p),l}))}if(_chunkC6C35PDMcjs.p.call(void 0, t)){let o=r;return Object.fromEntries(Object.entries(t.propTypes).map(([i,p])=>{o=_chunkC6C35PDMcjs.z.call(void 0, o,_chunkC6C35PDMcjs.qa.call(void 0, p));let l=[i,Je(e,p,o,n,i)];return o+=_chunkC6C35PDMcjs.sa.call(void 0, p),l}))}if("type"in t&&typeof t.type=="string"){if(_chunkC6C35PDMcjs.l.includes(t.type))return{_layout:e,format:t.type,offset:r};let o=_chunkC6C35PDMcjs.m[t.type];if(o)return{_layout:e,format:o,offset:r}}throw new Error(`Unsupported data used in vertex layout: ${String(t)}`)}var Wt=class{constructor(t,r){this.schemaForCount=t;this.stepMode=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","vertex-layout");_chunk7X4KDNDZcjs.c.call(void 0, this,"stride");_chunk7X4KDNDZcjs.c.call(void 0, this,"attrib");_chunk7X4KDNDZcjs.c.call(void 0, this,"_customLocationMap",{});_chunk7X4KDNDZcjs.c.call(void 0, this,"_label");let n=t(0);this.stride=_chunkC6C35PDMcjs.z.call(void 0, _chunkC6C35PDMcjs.sa.call(void 0, n.elementType),_chunkC6C35PDMcjs.pa.call(void 0, n)),this.attrib=Je(this,n.elementType,0,this._customLocationMap)}get label(){return this._label}get vertexLayout(){if(this._customLocationMap[Mt]!==void 0){if(typeof this.attrib.format!="string"||typeof this.attrib.offset!="number")throw new Error("Single attribute vertex layouts must have a format and offset.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[{format:this.attrib.format,offset:this.attrib.offset,shaderLocation:this._customLocationMap[Mt]}]}}if(!Object.keys(this.attrib).every(r=>this._customLocationMap[r]!==void 0))throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");return{arrayStride:this.stride,stepMode:this.stepMode,attributes:[...Object.entries(this.attrib).map(([r,n])=>({format:n.format,offset:n.offset,shaderLocation:this._customLocationMap[r]}))]}}$name(t){return this._label=t,this}};function In(e){return typeof(e==null?void 0:e.loadOp)=="string"}function Yr(e,t){if(_chunkC6C35PDMcjs.s.call(void 0, e)){if(!In(t))throw new Error("Expected a single color attachment, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color attachment by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Rn(e){return typeof(e==null?void 0:e.format)=="string"}function Qr(e,t){if(_chunkC6C35PDMcjs.s.call(void 0, e)){if(!Rn(t))throw new Error("Expected a single color target configuration, not a record.");return[t]}let r=[];for(let n of Object.keys(e)){let a=t[n];if(!a)throw new Error(`A color target by the name of '${n}' was not provided to the shader.`);r.push(a)}return r}function Xr(e){return new jt(new zt(e),{})}function Zr(e){return(e==null?void 0:e.resourceType)==="render-pipeline"}var jt=class e{constructor(t,r){this.core=t;this.priors=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","render-pipeline")}get label(){return this.core.label}$name(t){return this.core.label=t,this}with(t,r){var n,a;if(Ke(t))return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{bindGroupLayoutMap:new Map([...(n=this.priors.bindGroupLayoutMap)!=null?n:[],[t,r]])}));if(He(t))return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{vertexLayoutMap:new Map([...(a=this.priors.vertexLayoutMap)!=null?a:[],[t,r]])}));throw new Error("Unsupported value passed into .with()")}withColorAttachment(t){return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{colorAttachment:t}))}withDepthStencilAttachment(t){return new e(this.core,_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this.priors),{depthStencilAttachment:t}))}draw(t,r,n,a){var c;let o=this.core.unwrap(),{branch:i,fragmentFn:p}=this.core.options,s={colorAttachments:Yr(p.shell.targets,(c=this.priors.colorAttachment)!=null?c:{}).map(T=>W(T.view)?_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},T),{view:i.unwrap(T.view).createView()}):T)};if(this.core.label!==void 0&&(s.label=this.core.label),this.priors.depthStencilAttachment!==void 0){let T=this.priors.depthStencilAttachment;W(T.view)?s.depthStencilAttachment=_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},T),{view:i.unwrap(T.view).createView()}):s.depthStencilAttachment=T}let m=i.commandEncoder.beginRenderPass(s);m.setPipeline(o.pipeline);let g=new Set(o.bindGroupLayouts);o.bindGroupLayouts.forEach((T,b)=>{var y;if(o.catchall&&b===o.catchall[0])m.setBindGroup(b,i.unwrap(o.catchall[1])),g.delete(T);else{let S=(y=this.priors.bindGroupLayoutMap)==null?void 0:y.get(T);S!==void 0&&(g.delete(T),m.setBindGroup(b,i.unwrap(S)))}});let f=new Set(this.core.usedVertexLayouts);if(this.core.usedVertexLayouts.forEach((T,b)=>{var S;let y=(S=this.priors.vertexLayoutMap)==null?void 0:S.get(T);y&&(f.delete(T),m.setVertexBuffer(b,i.unwrap(y)))}),g.size>0)throw new (0, _chunk7X4KDNDZcjs.i)(g);if(f.size>0)throw new (0, _chunk7X4KDNDZcjs.j)(f);m.draw(t,r,n,a),m.end()}},zt=class{constructor(t){this.options=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"usedVertexLayouts");_chunk7X4KDNDZcjs.c.call(void 0, this,"_memo");_chunk7X4KDNDZcjs.c.call(void 0, this,"_vertexBufferLayouts");_chunk7X4KDNDZcjs.c.call(void 0, this,"_targets");let r=vr(t.vertexFn.shell.attributes[0],t.vertexAttribs);this._vertexBufferLayouts=r.bufferDefinitions,this.usedVertexLayouts=r.usedVertexLayouts,this._targets=Qr(t.fragmentFn.shell.targets,t.targets)}unwrap(){var t,r,n,a;if(this._memo===void 0){let{branch:o,vertexFn:i,fragmentFn:p,slotBindings:l,primitiveState:s,depthStencilState:m}=this.options,{code:g,bindGroupLayouts:f,catchall:w}=ye({"~resolve":y=>(y.withSlots(l,()=>{y.resolve(i),y.resolve(p)}),""),toString:()=>{var y;return`renderPipeline:${(y=this.label)!=null?y:"<unnamed>"}`}},{names:o.nameRegistry,jitTranspiler:o.jitTranspiler});w!==null&&((r=f[w[0]])==null||r.$name(`${(t=this.label)!=null?t:"<unnamed>"} - Automatic Bind Group & Layout`));let c=o.device,T=c.createShaderModule({label:`${(n=this.label)!=null?n:"<unnamed>"} - Shader`,code:g}),b={layout:c.createPipelineLayout({label:`${(a=this.label)!=null?a:"<unnamed>"} - Pipeline Layout`,bindGroupLayouts:f.map(y=>o.unwrap(y))}),vertex:{module:T,buffers:this._vertexBufferLayouts},fragment:{module:T,targets:this._targets}};this.label!==void 0&&(b.label=this.label),s&&(b.primitive=s),m&&(b.depthStencil=m),this._memo={pipeline:c.createRenderPipeline(b),bindGroupLayouts:f,catchall:w}}return this._memo}};var Kt=class e{constructor(t,r){this._getRoot=t;this._slotBindings=r}with(t,r){return new e(this._getRoot,[...this._slotBindings,[re(t)?t.slot:t,r]])}withCompute(t){return new qt(this._getRoot(),this._slotBindings,t)}withVertex(t,r){return new Jt({branch:this._getRoot(),primitiveState:void 0,depthStencilState:void 0,slotBindings:this._slotBindings,vertexFn:t,vertexAttribs:r})}},qt=class{constructor(t,r,n){this._root=t;this._slotBindings=r;this._entryFn=n}createPipeline(){return Jr(this._root,this._slotBindings,this._entryFn)}},Jt=class{constructor(t){this._options=t}withFragment(t,r,n){return _chunk7X4KDNDZcjs.d.call(void 0, typeof t!="string","Just type mismatch validation"),_chunk7X4KDNDZcjs.d.call(void 0, typeof r!="string","Just type mismatch validation"),new Ht(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._options),{fragmentFn:t,targets:r}))}},Ht=class e{constructor(t){this._options=t}withPrimitive(t){return new e(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._options),{primitiveState:t}))}withDepthStencil(t){return new e(_chunk7X4KDNDZcjs.b.call(void 0, _chunk7X4KDNDZcjs.a.call(void 0, {},this._options),{depthStencilState:t}))}createPipeline(){return Xr(this._options)}},Ye=class extends Kt{constructor(r,n,a,o){super(()=>this,[]);this.device=r;this.nameRegistry=n;this.jitTranspiler=a;this._ownDevice=o;_chunk7X4KDNDZcjs.c.call(void 0, this,"~unstable");_chunk7X4KDNDZcjs.c.call(void 0, this,"_disposables",[]);_chunk7X4KDNDZcjs.c.call(void 0, this,"_unwrappedBindGroupLayouts",new Re(r=>r.unwrap(this)));_chunk7X4KDNDZcjs.c.call(void 0, this,"_unwrappedBindGroups",new Re(r=>r.unwrap(this)));_chunk7X4KDNDZcjs.c.call(void 0, this,"_commandEncoder",null);this["~unstable"]=this}get commandEncoder(){return this._commandEncoder||(this._commandEncoder=this.device.createCommandEncoder()),this._commandEncoder}createBuffer(r,n){let a=Gr(this,r,n);return this._disposables.push(a),a}createUniform(r,n){return this.createBuffer(r,n).$usage("uniform").as("uniform")}createMutable(r,n){return this.createBuffer(r,n).$usage("storage").as("mutable")}createReadonly(r,n){return this.createBuffer(r,n).$usage("storage").as("readonly")}createBindGroup(r,n){return new ue(r,n)}destroy(){for(let r of this._disposables)r.destroy();this._ownDevice&&this.device.destroy()}createTexture(r){let n=Nr(r,this);return this._disposables.push(n),n}unwrap(r){if(Hr(r))return r.rawPipeline;if(Zr(r))return r.core.unwrap().pipeline;if(Ke(r))return this._unwrappedBindGroupLayouts.getOrMake(r);if(Ct(r))return this._unwrappedBindGroups.getOrMake(r);if(Z(r))return r.buffer;if(W(r)||Rt(r)||Bt(r))return r.unwrap();if(He(r))return r.vertexLayout;if(Dt(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out sampler.")}if(Ut(r)){if("unwrap"in r)return r.unwrap(this);throw new Error("Cannot unwrap laid-out comparison sampler.")}throw new Error(`Unknown resource type: ${r}`)}beginRenderPass(r,n){let a=this.commandEncoder.beginRenderPass(r),o=new Map,i=new Map,p,l=()=>{if(!p)throw new Error("Cannot draw without a call to pass.setPipeline");let{core:s,priors:m}=p,g=s.unwrap();a.setPipeline(g.pipeline);let f=new Set(g.bindGroupLayouts);g.bindGroupLayouts.forEach((c,T)=>{var b,y;if(g.catchall&&T===g.catchall[0])a.setBindGroup(T,this.unwrap(g.catchall[1])),f.delete(c);else{let S=(y=(b=m.bindGroupLayoutMap)==null?void 0:b.get(c))!=null?y:o.get(c);S!==void 0&&(f.delete(c),Ct(S)?a.setBindGroup(T,this.unwrap(S)):a.setBindGroup(T,S))}});let w=new Set;if(s.usedVertexLayouts.forEach((c,T)=>{var S;let b=(S=m.vertexLayoutMap)==null?void 0:S.get(c),y=b?{buffer:b,offset:void 0,size:void 0}:i.get(c);!y||!y.buffer?w.add(c):Z(y.buffer)?a.setVertexBuffer(T,this.unwrap(y.buffer),y.offset,y.size):a.setVertexBuffer(T,y.buffer,y.offset,y.size)}),f.size>0)throw new (0, _chunk7X4KDNDZcjs.i)(f);if(w.size>0)throw new (0, _chunk7X4KDNDZcjs.j)(w)};n({setViewport(...s){a.setViewport(...s)},setScissorRect(...s){a.setScissorRect(...s)},setBlendConstant(...s){a.setBlendConstant(...s)},setStencilReference(...s){a.setStencilReference(...s)},beginOcclusionQuery(...s){a.beginOcclusionQuery(...s)},endOcclusionQuery(...s){a.endOcclusionQuery(...s)},executeBundles(...s){a.executeBundles(...s)},setPipeline(s){p=s},setIndexBuffer:(s,m,g,f)=>{Z(s)?a.setIndexBuffer(this.unwrap(s),m,g,f):a.setIndexBuffer(s,m,g,f)},setVertexBuffer(s,m,g,f){i.set(s,{buffer:m,offset:g,size:f})},setBindGroup(s,m){o.set(s,m)},draw(s,m,g,f){l(),a.draw(s,m,g,f)},drawIndexed(...s){l(),a.drawIndexed(...s)},drawIndirect(...s){l(),a.drawIndirect(...s)},drawIndexedIndirect(...s){l(),a.drawIndexedIndirect(...s)}}),a.end()}flush(){this._commandEncoder&&(this.device.queue.submit([this._commandEncoder.finish()]),this._commandEncoder=null)}};async function en(e){let{adapter:t,device:r,unstable_names:n="random",unstable_jitTranspiler:a}=e!=null?e:{};if(!navigator.gpu)throw new Error("WebGPU is not supported by this browser.");let o=await navigator.gpu.requestAdapter(t);if(!o)throw new Error("Could not find a compatible GPU");return new Ye(await o.requestDevice(r),n==="random"?new Y:new Q,a,!0)}function tn(e){let{device:t,unstable_names:r="random",unstable_jitTranspiler:n}=e!=null?e:{};return new Ye(t,r==="random"?new Y:new Q,n,!1)}function Qe(e){return new Yt(e)}var Yt=class{constructor(t=void 0){this.defaultValue=t;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","slot");_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr")}$name(t){return this.label=t,this}areEqual(t,r){return Object.is(t,r)}toString(){var t;return`slot:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){let t=_chunk7X4KDNDZcjs.l.call(void 0, );if(!t)throw new Error("Cannot access tgpu.slot's value outside of resolution.");return Fe(t.unwrap(this))}};function rn(e,t){return new Qt(e,t)}var Qt=class{constructor(t,r=void 0){this.schema=t;this.defaultValue=r;_chunk7X4KDNDZcjs.c.call(void 0, this,"resourceType","accessor");_chunk7X4KDNDZcjs.c.call(void 0, this,"~repr");_chunk7X4KDNDZcjs.c.call(void 0, this,"label");_chunk7X4KDNDZcjs.c.call(void 0, this,"slot");this.slot=Qe(r)}$name(t){return this.label=t,this.slot.$name(t),this}toString(){var t;return`accessor:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.l.call(void 0, ))throw new Error("Cannot access tgpu.accessor's value outside of resolution.");return new Proxy({"~resolve":r=>r.resolve(this),toString:()=>{var r;return`.value:${(r=this.label)!=null?r:"<unnamed>"}`}},k)}"~resolve"(t){let r=t.unwrap(this.slot);return Le(r)?t.resolve(r):lt(r)?`${t.resolve(r)}()`:t.resolveValue(r,this.schema)}};function nn(e){return Pn(e)}function Bn([e,t]){var r;return`${(r=e.label)!=null?r:"<unnamed>"}=${t}`}function Pn(e){return{resourceType:"derived","~compute":e,"~repr":void 0,get value(){let r=_chunk7X4KDNDZcjs.l.call(void 0, );if(!r)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Fe(r.unwrap(this))},with(r,n){return an(this,[[r,n]])},toString(){return"derived"}}}function an(e,t){return{resourceType:"derived","~repr":void 0,"~compute"(){throw new Error("'~compute' should never be read on bound derived items.")},"~providing":{inner:e,pairs:t},get value(){let n=_chunk7X4KDNDZcjs.l.call(void 0, );if(!n)throw new Error("Cannot access tgpu.derived's value outside of resolution.");return Fe(n.unwrap(this))},with(n,a){return an(e,[...t,[n,a]])},toString(){return`derived[${t.map(Bn).join(", ")}]`}}}function on(e,t){return new Xe("private",e,t)}function sn(e){return new Xe("workgroup",e)}var Xe=class{constructor(t,r,n){this.scope=t;this._dataType=r;this._initialValue=n;_chunk7X4KDNDZcjs.c.call(void 0, this,"_label")}$name(t){return this._label=t,this}"~resolve"(t){let r=t.names.makeUnique(this._label);return this._initialValue?t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)} = ${t.resolveValue(this._initialValue,this._dataType)};`):t.addDeclaration(`var<${this.scope}> ${r}: ${t.resolve(this._dataType)};`),r}get label(){return this._label}toString(){var t;return`var:${(t=this.label)!=null?t:"<unnamed>"}`}get value(){if(!_chunk7X4KDNDZcjs.m.call(void 0, ))throw new Error("Cannot access tgpu.var's value directly in JS.");return new Proxy({"~resolve":t=>t.resolve(this),toString:()=>{var t;return`.value:${(t=this.label)!=null?t:"<unnamed>"}`}},k)}};var un={bindGroupLayout:ze,vertexLayout:Nt,init:en,initFromDevice:tn,resolve:qr,"~unstable":{fn:wr,fragmentFn:Fr,vertexFn:Dr,computeFn:hr,vertexLayout:Nt,derived:nn,slot:Qe,accessor:rn,privateVar:on,workgroupVar:sn,const:gr,declare:Tr,sampler:Or,comparisonSampler:kr}},Es= exports.default =un;Object.assign(un,{__assignAst:xr});exports.MissingBindGroupsError = _chunk7X4KDNDZcjs.i; exports.MissingLinksError = _chunk7X4KDNDZcjs.h; exports.MissingSlotValueError = _chunk7X4KDNDZcjs.f; exports.MissingVertexBuffersError = _chunk7X4KDNDZcjs.j; exports.NotUniformError = _chunk7X4KDNDZcjs.g; exports.RandomNameRegistry = Y; exports.ResolutionError = _chunk7X4KDNDZcjs.e; exports.StrictNameRegistry = Q; exports.default = Es; exports.isBuffer = Z; exports.isComparisonSampler = Ut; exports.isDerived = J; exports.isSampledTextureView = Bt; exports.isSampler = Dt; exports.isSlot = q; exports.isStorageTextureView = Rt; exports.isTexture = W; exports.isTgpuFn = lt; exports.isUsableAsRender = An; exports.isUsableAsSampled = Pt; exports.isUsableAsStorage = se; exports.isUsableAsUniform = Ee; exports.isUsableAsVertex = vn; exports.tgpu = un; exports.unstable_asMutable = yt; exports.unstable_asReadonly = ct; exports.unstable_asUniform = xt;
|
19
19
|
//# sourceMappingURL=index.cjs.map
|