@margoengine/transitions 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/glsl.js ADDED
@@ -0,0 +1,1261 @@
1
+ import { t as e } from "./errors-CsQwshHA.js";
2
+ import { t } from "./custom-CteHwFLg.js";
3
+ import { LiveTransitions as n } from "./live.js";
4
+ //#region ../shader/src/glsl/parser.ts
5
+ var r = /* @__PURE__ */ new Set(/* @__PURE__ */ "void.float.int.uint.bool.vec2.vec3.vec4.ivec2.ivec3.ivec4.uvec2.uvec3.uvec4.bvec2.bvec3.bvec4.mat2.mat3.mat4.mat2x3.mat2x4.mat3x2.mat3x4.mat4x2.mat4x3.sampler2D.samplerCube.sampler3D.sampler2DArray.isampler2D.isampler3D.isamplerCube.isampler2DArray.usampler2D.usampler3D.usamplerCube.usampler2DArray.sampler2DShadow.samplerCubeShadow.sampler2DArrayShadow".split(".")), i = {
6
+ mat2x2: "mat2",
7
+ mat3x3: "mat3",
8
+ mat4x4: "mat4"
9
+ }, a = /* @__PURE__ */ new Set([
10
+ "const",
11
+ "uniform",
12
+ "highp",
13
+ "mediump",
14
+ "lowp",
15
+ "in",
16
+ "out",
17
+ "inout",
18
+ "flat",
19
+ "smooth",
20
+ "centroid",
21
+ "invariant",
22
+ "attribute",
23
+ "varying"
24
+ ]), o = {
25
+ ",": 1,
26
+ "=": 2,
27
+ "+=": 2,
28
+ "-=": 2,
29
+ "*=": 2,
30
+ "/=": 2,
31
+ "%=": 2,
32
+ "<<=": 2,
33
+ ">>=": 2,
34
+ "&=": 2,
35
+ "|=": 2,
36
+ "^=": 2,
37
+ "?": 3,
38
+ "||": 4,
39
+ "^^": 5,
40
+ "&&": 6,
41
+ "|": 7,
42
+ "^": 8,
43
+ "&": 9,
44
+ "==": 10,
45
+ "!=": 10,
46
+ "<": 11,
47
+ "<=": 11,
48
+ ">": 11,
49
+ ">=": 11,
50
+ "<<": 12,
51
+ ">>": 12,
52
+ "+": 13,
53
+ "-": 13,
54
+ "*": 14,
55
+ "/": 14,
56
+ "%": 14
57
+ }, s = (e, t = "", n = []) => ({
58
+ op: e,
59
+ value: t,
60
+ args: n
61
+ });
62
+ function c(t, n = []) {
63
+ let r = [], i = /\s+|\/\/[^\n]*|\/\*[\s\S]*?\*\/|0[xX][\dA-Fa-f]+[uU]?|(?:\d+\.\d*|\.\d+|\d+)(?:[eE][+-]?\d+)?[fFuU]?|[A-Za-z_]\w*|<<=|>>=|&=|\|=|\^=|\+\+|--|\+=|-=|\*=|\/=|%=|==|!=|<=|>=|&&|\|\||\^\^|<<|>>|[{}()[\].,;?:+*/%<>=!&|^~-]/y;
64
+ for (let a = 0; a < t.length;) {
65
+ i.lastIndex = a;
66
+ let o = i.exec(t);
67
+ if (!o) throw e("failed", `GLSL character at ${a} is invalid; correct the transition source`);
68
+ if (a = i.lastIndex, !/^\s|^\/\//.test(o[0]) && !o[0].startsWith("/*") && (r.push(o[0]), n.push(o.index)), r.length > 32768) throw e("failed", "GLSL token limit exceeded; keep source below 32768 tokens");
69
+ }
70
+ return r;
71
+ }
72
+ var l = class {
73
+ constructor(e, t = "transition") {
74
+ this.source = e, this.subject = t, this.offsets = [], this.i = 0, this.depth = 0, this.known = new Set(r), this.globals = [], this.constants = [/* @__PURE__ */ new Map()], this.tokens = c(e, this.offsets);
75
+ }
76
+ peek() {
77
+ return this.tokens[this.i] ?? "";
78
+ }
79
+ take() {
80
+ let e = this.peek();
81
+ return e || this.fail("Unexpected end of source"), this.i++, e;
82
+ }
83
+ match(e) {
84
+ return this.peek() === e && (this.i++, !0);
85
+ }
86
+ expect(e) {
87
+ this.match(e) || this.fail(`Expected ${e}, found ${this.peek() || "end"}`);
88
+ }
89
+ fail(t, n = 0) {
90
+ let r = this.offsets[Math.max(0, Math.min(this.i - n, this.offsets.length - 1))] ?? 0, i = this.source.slice(0, r);
91
+ throw Object.assign(e("failed", `GLSL token ${this.i}: ${t}; correct the ${this.subject} source`), {
92
+ line: i.split("\n").length,
93
+ column: r - i.lastIndexOf("\n")
94
+ });
95
+ }
96
+ identifier() {
97
+ let e = this.take();
98
+ return /^[A-Za-z_]\w*$/.test(e) || this.fail("Expected an identifier", 1), e;
99
+ }
100
+ qualified() {
101
+ let e = [];
102
+ for (;;) if (a.has(this.peek())) e.push(this.take());
103
+ else if (this.match("layout")) for (this.expect("("); !this.match(")");) this.take();
104
+ else break;
105
+ let t = this.identifier(), n = i[t] ?? t;
106
+ return !this.known.has(n) && !i[t] && this.fail(`Unknown type ${n}`), {
107
+ type: this.peek() === "[" ? this.array(n) : n,
108
+ qualifier: e.join(" ")
109
+ };
110
+ }
111
+ array(e) {
112
+ for (; this.match("[");) {
113
+ if (this.match("]")) {
114
+ e += "[]";
115
+ continue;
116
+ }
117
+ let t = this.expression(2);
118
+ this.expect("]");
119
+ let n = this.fold(t);
120
+ n < 1 && this.fail("Array sizes must be positive integer constants"), e += `[${n}]`;
121
+ }
122
+ return e;
123
+ }
124
+ fold(e, t = 0) {
125
+ if (t > 64 && this.fail("Array dimensions must be integer constants"), e.op === "literal" && /^\d+[uU]?$/.test(e.value)) return parseInt(e.value, 10);
126
+ if (e.op === "name") for (let n = this.constants.length - 1; n >= 0; n--) {
127
+ let r = this.constants[n].get(e.value);
128
+ if (r) return this.fold(r, t + 1);
129
+ if (r === null) break;
130
+ }
131
+ if (e.op === "prefix" && e.value === "-" && e.args[0]) return -this.fold(e.args[0], t + 1);
132
+ if (e.op === "prefix" && e.value === "+" && e.args[0]) return this.fold(e.args[0], t + 1);
133
+ if (e.op === "binary" && e.args[0] && e.args[1]) {
134
+ let n = this.fold(e.args[0], t + 1), r = this.fold(e.args[1], t + 1);
135
+ switch (e.value) {
136
+ case "+": return n + r;
137
+ case "-": return n - r;
138
+ case "*": return n * r;
139
+ case "/":
140
+ if (r !== 0) return Math.trunc(n / r);
141
+ break;
142
+ case "%": if (r !== 0) return n % r;
143
+ }
144
+ }
145
+ return this.fail("Array dimensions must be integer constants");
146
+ }
147
+ number(e) {
148
+ if (/[.eE]/.test(e) && !/^0[xX]/.test(e)) return e;
149
+ let t = /[uU]$/.test(e) ? "u" : "", n = t ? e.slice(0, -1) : e;
150
+ return (/^0[xX]/.test(n) ? parseInt(n.slice(2), 16) : /^0[0-7]*$/.test(n) ? parseInt(n, 8) : /^[1-9]\d*$/.test(n) ? Number(n) : this.fail(`Integer literal ${e} is malformed`, 1)) + t;
151
+ }
152
+ declarations(e, t, n, r = !0) {
153
+ let i = [];
154
+ do {
155
+ let a = n ?? this.identifier();
156
+ n = void 0;
157
+ let o = this.array(e), s = this.match("=") ? this.expression(2) : void 0;
158
+ if (o.endsWith("[]")) {
159
+ let e = s?.op === "call" && s.args[0].op === "name" ? s.args[0].value : "";
160
+ (!s || e.replace(/\[\d+\]$/, "[]") !== o) && this.fail(`Unsized array ${a} needs an array constructor of its type`), o = e;
161
+ }
162
+ r && this.constants.at(-1).set(a, /\bconst\b/.test(t) && s ? s : null), i.push({
163
+ name: a,
164
+ type: o,
165
+ qualifier: t,
166
+ init: s
167
+ });
168
+ } while (this.match(","));
169
+ return this.expect(";"), i;
170
+ }
171
+ uniformBlock(e) {
172
+ let t = this.i, n = !1;
173
+ for (;;) {
174
+ let e = this.tokens[t];
175
+ if (e === "layout" && this.tokens[t + 1] === "(") {
176
+ for (; this.tokens[t] && this.tokens[t] !== ")";) t++;
177
+ t++;
178
+ } else if (e && a.has(e)) n ||= e === "uniform", t++;
179
+ else break;
180
+ }
181
+ let r = this.tokens[t] ?? "";
182
+ if (!n || this.tokens[t + 1] !== "{" || !/^[A-Za-z_]\w*$/.test(r) || this.known.has(r)) return !1;
183
+ this.i = t + 2;
184
+ let i = [];
185
+ for (; !this.match("}");) {
186
+ let e = this.qualified();
187
+ /sampler/.test(e.type) && this.fail("A uniform block holds no samplers"), i.push(...this.declarations(e.type, e.qualifier, void 0, !1));
188
+ }
189
+ return this.match(";") ? e.globals.push(...i.map((e) => ({
190
+ ...e,
191
+ qualifier: `uniform ${e.qualifier}`.trim()
192
+ }))) : (this.known.add(r), e.structs.set(r, i), e.globals.push(...this.declarations(r, "uniform"))), !0;
193
+ }
194
+ parse() {
195
+ let e = {
196
+ globals: this.globals,
197
+ functions: [],
198
+ structs: /* @__PURE__ */ new Map()
199
+ };
200
+ for (; this.peek();) {
201
+ if (this.match("precision")) {
202
+ this.take(), this.take(), this.expect(";");
203
+ continue;
204
+ }
205
+ if (this.match(";") || this.uniformBlock(e)) continue;
206
+ if (this.peek() === "invariant" && !this.known.has(this.tokens[this.i + 1]) && !a.has(this.tokens[this.i + 1])) {
207
+ this.take();
208
+ do
209
+ this.identifier();
210
+ while (this.match(","));
211
+ this.expect(";");
212
+ continue;
213
+ }
214
+ if (this.match("struct")) {
215
+ let t = this.identifier();
216
+ this.known.add(t), this.expect("{");
217
+ let n = [];
218
+ for (; !this.match("}");) {
219
+ let e = this.qualified();
220
+ n.push(...this.declarations(e.type, e.qualifier, void 0, !1));
221
+ }
222
+ e.structs.set(t, n), this.match(";") || e.globals.push(...this.declarations(t, ""));
223
+ continue;
224
+ }
225
+ let t = this.qualified(), n = this.identifier();
226
+ if (this.match("(")) {
227
+ let r = [];
228
+ if (this.constants.push(/* @__PURE__ */ new Map()), !this.match(")")) {
229
+ if (this.peek() === "void" && this.tokens[this.i + 1] === ")") this.take(), this.take();
230
+ else {
231
+ do {
232
+ let e = this.qualified(), t = [
233
+ ",",
234
+ ")",
235
+ "["
236
+ ].includes(this.peek()) ? `margo_unnamed${r.length}` : this.identifier();
237
+ r.push({
238
+ name: t,
239
+ type: this.array(e.type),
240
+ qualifier: e.qualifier
241
+ }), this.constants.at(-1).set(t, null);
242
+ } while (this.match(","));
243
+ this.expect(")");
244
+ }
245
+ }
246
+ let i = this.match(";") ? void 0 : this.block();
247
+ this.constants.pop(), e.functions.push({
248
+ name: n,
249
+ type: t.type,
250
+ params: r,
251
+ body: i
252
+ });
253
+ } else e.globals.push(...this.declarations(t.type, t.qualifier, n));
254
+ }
255
+ return e;
256
+ }
257
+ block() {
258
+ this.expect("{");
259
+ let e = [];
260
+ for (this.constants.push(/* @__PURE__ */ new Map()); !this.match("}");) e.push(this.statement());
261
+ return this.constants.pop(), e;
262
+ }
263
+ statement() {
264
+ ++this.depth > 128 && this.fail("Statement nesting exceeds 128");
265
+ try {
266
+ if (this.peek() === "{") return {
267
+ kind: "block",
268
+ body: this.block()
269
+ };
270
+ if (this.match(";")) return {
271
+ kind: "block",
272
+ body: []
273
+ };
274
+ if (this.match("precision")) return this.take(), this.take(), this.expect(";"), {
275
+ kind: "block",
276
+ body: []
277
+ };
278
+ if (this.match("if")) {
279
+ this.expect("(");
280
+ let e = this.expression();
281
+ return this.expect(")"), {
282
+ kind: "if",
283
+ expr: e,
284
+ body: [this.statement()],
285
+ other: this.match("else") ? [this.statement()] : void 0
286
+ };
287
+ }
288
+ if (this.match("for")) {
289
+ this.expect("("), this.constants.push(/* @__PURE__ */ new Map());
290
+ let e = this.match(";") ? void 0 : this.simple(), t = this.match(";") ? void 0 : this.expression();
291
+ t && this.expect(";");
292
+ let n = this.peek() === ")" ? void 0 : this.expression();
293
+ this.expect(")");
294
+ let r = [this.statement()];
295
+ return this.constants.pop(), {
296
+ kind: "for",
297
+ init: e,
298
+ expr: t,
299
+ update: n,
300
+ body: r
301
+ };
302
+ }
303
+ if (this.match("while")) {
304
+ this.expect("(");
305
+ let e = this.expression();
306
+ return this.expect(")"), {
307
+ kind: "while",
308
+ expr: e,
309
+ body: [this.statement()]
310
+ };
311
+ }
312
+ if (this.match("switch")) {
313
+ this.expect("(");
314
+ let e = this.expression();
315
+ this.expect(")"), this.expect("{"), this.constants.push(/* @__PURE__ */ new Map());
316
+ let t = [], n = /* @__PURE__ */ new Set();
317
+ for (; !this.match("}");) {
318
+ let e = this.match("case") ? this.fold(this.expression()) : this.match("default") ? null : void 0;
319
+ if (e === void 0) {
320
+ t.length || this.fail("A switch body starts with a case or default label"), t.at(-1).body.push(this.statement());
321
+ continue;
322
+ }
323
+ this.expect(":"), n.has(e) && this.fail(`Duplicate switch label ${e ?? "default"}`), n.add(e);
324
+ let r = t.at(-1);
325
+ r && !r.body.length ? r.labels.push(e) : t.push({
326
+ labels: [e],
327
+ body: []
328
+ });
329
+ }
330
+ return this.constants.pop(), t.length && !t.at(-1).body.length && this.fail("A switch label needs a statement after it"), {
331
+ kind: "switch",
332
+ expr: e,
333
+ cases: t
334
+ };
335
+ }
336
+ if (this.match("do")) {
337
+ let e = [this.statement()];
338
+ this.expect("while"), this.expect("(");
339
+ let t = this.expression();
340
+ return this.expect(")"), this.expect(";"), {
341
+ kind: "do",
342
+ body: e,
343
+ expr: t
344
+ };
345
+ }
346
+ for (let e of [
347
+ "return",
348
+ "break",
349
+ "continue",
350
+ "discard"
351
+ ]) if (this.match(e)) {
352
+ let t = e === "return" && this.peek() !== ";" ? this.expression() : void 0;
353
+ return this.expect(";"), {
354
+ kind: e,
355
+ expr: t
356
+ };
357
+ }
358
+ return this.simple();
359
+ } finally {
360
+ this.depth--;
361
+ }
362
+ }
363
+ simple() {
364
+ let e = this.peek();
365
+ if (a.has(e) || e === "layout" || (this.known.has(e) || Object.hasOwn(i, e)) && !this.constructs()) {
366
+ let e = this.qualified();
367
+ return {
368
+ kind: "decl",
369
+ decls: this.declarations(e.type, e.qualifier)
370
+ };
371
+ }
372
+ let t = this.expression();
373
+ return this.expect(";"), {
374
+ kind: "expr",
375
+ expr: t
376
+ };
377
+ }
378
+ constructs() {
379
+ if (this.tokens[this.i + 1] !== "[") return !1;
380
+ let e = this.i + 1, t = 0;
381
+ for (; e < this.tokens.length; e++) if (this.tokens[e] === "[") t++;
382
+ else if (this.tokens[e] === "]" && --t === 0) break;
383
+ return this.tokens[e + 1] === "(";
384
+ }
385
+ expression(e = 0) {
386
+ ++this.depth > 128 && this.fail("Expression nesting exceeds 128");
387
+ try {
388
+ let t = this.take(), n;
389
+ if (t === "(") n = this.expression(), this.expect(")");
390
+ else if ([
391
+ "+",
392
+ "-",
393
+ "!",
394
+ "~",
395
+ "++",
396
+ "--"
397
+ ].includes(t)) n = s("prefix", t, [this.expression(15)]);
398
+ else if (/^\.?\d/.test(t)) n = s("literal", this.number(t));
399
+ else if (t === "true" || t === "false") n = s("literal", t);
400
+ else if (this.known.has(t) && this.peek() === "[") {
401
+ let e = this.array(t);
402
+ this.expect("(");
403
+ let r = [];
404
+ if (!this.match(")")) {
405
+ do
406
+ r.push(this.expression(2));
407
+ while (this.match(","));
408
+ this.expect(")");
409
+ }
410
+ e.endsWith("[]") && (e = e.slice(0, -2) + `[${r.length}]`), r.length || this.fail("An array constructor needs its elements"), n = s("call", "", [s("name", e), ...r]);
411
+ } else /^[A-Za-z_]\w*$/.test(t) ? n = s("name", i[t] ?? t) : this.fail(`Unexpected expression token ${t}`, 1);
412
+ for (;;) {
413
+ if (this.match("(")) {
414
+ let e = [];
415
+ if (!this.match(")")) {
416
+ do
417
+ e.push(this.expression(2));
418
+ while (this.match(","));
419
+ this.expect(")");
420
+ }
421
+ n = s("call", "", [n, ...e]);
422
+ continue;
423
+ }
424
+ if (this.match("[")) {
425
+ let e = this.expression();
426
+ this.expect("]"), n = s("index", "", [n, e]);
427
+ continue;
428
+ }
429
+ if (this.match(".")) {
430
+ n = s("member", this.identifier(), [n]);
431
+ continue;
432
+ }
433
+ if (this.peek() === "++" || this.peek() === "--") {
434
+ n = s("postfix", this.take(), [n]);
435
+ continue;
436
+ }
437
+ let t = this.peek(), r = o[t];
438
+ if (r === void 0 || r < e) break;
439
+ if (this.take(), t === "?") {
440
+ let e = this.expression();
441
+ this.expect(":");
442
+ let t = this.expression(2);
443
+ n = s("conditional", "", [
444
+ n,
445
+ e,
446
+ t
447
+ ]);
448
+ continue;
449
+ }
450
+ let i = this.expression(r + (r === 2 ? 0 : 1));
451
+ n = s("binary", t, [n, i]);
452
+ }
453
+ return n;
454
+ } finally {
455
+ this.depth--;
456
+ }
457
+ }
458
+ }, u = (e) => e.startsWith("bvec") ? "bool" : e.startsWith("ivec") ? "int" : e.startsWith("uvec") ? "uint" : e.startsWith("vec") || e.startsWith("mat") ? "float" : e, d = (e) => /vec[234]$/.test(e) ? Number(e.at(-1)) : 1, f = (e, t) => t === 1 ? e : `${e === "float" ? "" : e === "int" ? "i" : e === "uint" ? "u" : "b"}vec${t}`, p = (e) => "user_" + e, m = (e) => {
459
+ let t = /^mat([234])(?:x([234]))?$/.exec(e);
460
+ return t ? [Number(t[1]), Number(t[2] ?? t[1])] : void 0;
461
+ }, h = (e, t) => e === t ? `mat${e}` : `mat${e}x${t}`, g = {
462
+ sampler2D: "texture_2d<f32>",
463
+ samplerCube: "texture_cube<f32>",
464
+ sampler3D: "texture_3d<f32>",
465
+ sampler2DArray: "texture_2d_array<f32>",
466
+ sampler2DShadow: "texture_depth_2d",
467
+ samplerCubeShadow: "texture_depth_cube",
468
+ sampler2DArrayShadow: "texture_depth_2d_array"
469
+ };
470
+ for (let e of ["i", "u"]) for (let [t, n] of [
471
+ ["2D", "2d"],
472
+ ["3D", "3d"],
473
+ ["Cube", "cube"],
474
+ ["2DArray", "2d_array"]
475
+ ]) g[`${e}sampler${t}`] = `texture_${n}<${e}32>`;
476
+ var _ = (e) => e.replace(/^[iu]/, "").replace("Shadow", ""), v = (e) => e.endsWith("Shadow") ? "float" : /^[iu]/.test(e) ? e[0] + "vec4" : "vec4", y = (e) => {
477
+ let t = /^(.*)\[([^\]]+)\]$/.exec(e);
478
+ if (t) return `array<${y(t[1])},${t[2]}>`;
479
+ let n = {
480
+ float: "f32",
481
+ int: "i32",
482
+ uint: "u32",
483
+ bool: "bool",
484
+ void: "void",
485
+ ...g
486
+ };
487
+ if (n[e]) return n[e];
488
+ let r = /^([ibu]?)vec([234])$/.exec(e);
489
+ if (r) return `vec${r[2]}<${r[1] === "i" ? "i32" : r[1] === "u" ? "u32" : r[1] === "b" ? "bool" : "f32"}>`;
490
+ let i = m(e);
491
+ return i ? `mat${i[0]}x${i[1]}<f32>` : p(e);
492
+ }, b = "\n", x = (e, t, n = []) => ({
493
+ code: e,
494
+ type: t,
495
+ before: n
496
+ }), S = class {
497
+ constructor(e, t, n = 100) {
498
+ this.program = e, this.host = t, this.version = n, this.scopes = [/* @__PURE__ */ new Map()], this.serial = 0, this.names = /* @__PURE__ */ new Map(), this.helpers = /* @__PURE__ */ new Set(), this.equalityNames = /* @__PURE__ */ new Map(), this.uniforms = t.uniforms, this.flipY = t.flipY, this.functions = e.functions.filter((e) => e.body), this.functions.forEach((e, t) => this.names.set(e, `user_function_${t}`));
499
+ }
500
+ fail(t) {
501
+ throw e("failed", `GLSL translation: ${t}; correct the source or supplied uniform values`);
502
+ }
503
+ temp() {
504
+ return `temporary_${this.serial++}`;
505
+ }
506
+ equality(e) {
507
+ let t = this.equalityNames.get(e);
508
+ if (t) return t;
509
+ let n = `aggregate_equal_${this.serial++}`;
510
+ this.equalityNames.set(e, n);
511
+ let r = (e, t, n) => [
512
+ "float",
513
+ "int",
514
+ "uint",
515
+ "bool"
516
+ ].includes(e) ? `(${t}==${n})` : `${this.equality(e)}(${t},${n})`, i;
517
+ if (/^[ibu]?vec[234]$/.test(e)) i = "all(a==b)";
518
+ else if (m(e)) i = Array.from({ length: m(e)[0] }, (e, t) => `all(a[${t}]==b[${t}])`).join("&&");
519
+ else if (/^(.*)\[(\d+)\]$/.test(e) && this.version === 300) {
520
+ let [, t, n] = /^(.*)\[(\d+)\]$/.exec(e);
521
+ i = Array.from({ length: Number(n) }, (e, n) => r(t, `a[${n}]`, `b[${n}]`)).join("&&");
522
+ } else {
523
+ let t = this.program.structs.get(e);
524
+ t || this.fail("GLSL ES 1.00 equality excludes arrays and samplers"), i = t.map((e) => r(e.type, `a.${p(e.name)}`, `b.${p(e.name)}`)).join("&&");
525
+ }
526
+ return this.helpers.add(`fn ${n}(a:${y(e)},b:${y(e)})->bool{return ${i};}`), n;
527
+ }
528
+ find(e) {
529
+ for (let t = this.scopes.length - 1; t >= 0; t--) {
530
+ let n = this.scopes[t].get(e);
531
+ if (n) return n;
532
+ }
533
+ }
534
+ define(e, t, n = p(e)) {
535
+ let r = this.scopes.at(-1);
536
+ return r.has(e) && this.fail(`Duplicate variable ${e}`), r.set(e, {
537
+ type: t,
538
+ code: n
539
+ }), n;
540
+ }
541
+ convert(e, t) {
542
+ if (t === e.type) return e;
543
+ if (u(t) === "bool" && u(e.type) !== "bool") return x(`(${e.code}!=${y(e.type)}(0))`, t, e.before);
544
+ if (u(e.type) === "bool" && u(t) !== "bool") return x(`select(${y(t)}(0),${y(t)}(1),${e.code})`, t, e.before);
545
+ if (d(t) > 1 && d(e.type) === 1 && u(t) !== u(e.type)) return this.convert(this.convert(e, u(t)), t);
546
+ if (u(t) === u(e.type) && d(t) > 1 && d(e.type) === 1 || d(t) === d(e.type) && [
547
+ "float",
548
+ "int",
549
+ "uint",
550
+ "bool"
551
+ ].includes(u(t)) && [
552
+ "float",
553
+ "int",
554
+ "uint",
555
+ "bool"
556
+ ].includes(u(e.type))) return x(`${y(t)}(${e.code})`, t, e.before);
557
+ this.fail(`Cannot convert ${e.type} to ${t}`);
558
+ }
559
+ join(e, t) {
560
+ let n = Math.max(d(e.type), d(t.type)), r = f(u(e.type) === "float" || u(t.type) === "float" ? "float" : u(e.type), n);
561
+ return [this.convert(e, r), this.convert(t, r)];
562
+ }
563
+ literal(e) {
564
+ let t = e.value;
565
+ return t === "true" || t === "false" ? x(t, "bool") : /[uU]$/.test(t) ? x(t.slice(0, -1) + "u", "uint") : /[.eEfF]/.test(t) ? (t = t.replace(/[fF]$/, ""), t.startsWith(".") && (t = "0" + t), t.endsWith(".") && (t += "0"), x(`f32(${t})`, "float")) : Number(t) > 2147483647 ? (Number(t) > 4294967295 && this.fail(`Integer literal ${t} does not fit 32 bits`), x(`bitcast<i32>(${t}u)`, "int")) : x(`i32(${t})`, "int");
566
+ }
567
+ assign(e, t, n = "=", r) {
568
+ [
569
+ "name",
570
+ "index",
571
+ "member"
572
+ ].includes(e.op) || this.fail("Assignment needs a variable, element, field or swizzle");
573
+ let i = r ?? this.expr(e), a = this.convert(t, i.type), o = [...i.before, ...a.before];
574
+ if (e.op === "member" && /^[ibu]?vec[234]$/.test(this.expr(e.args[0]).type) && /^[xyzwrgba stpq]+$/.test(e.value) && e.value.length > 1) {
575
+ let t = i.code.slice(0, -e.value.length - 1), r = e.value.replace(/[rgba]/g, (e) => "xyzw"["rgba".indexOf(e)]).replace(/[stpq]/g, (e) => "xyzw"["stpq".indexOf(e)]);
576
+ new Set(r).size !== r.length && this.fail("Repeated component in swizzle assignment");
577
+ let s = this.temp();
578
+ o.push(`let ${s}=${a.code};`);
579
+ for (let e = 0; e < r.length; e++) o.push(`${t}.${r[e]} ${n} ${s}[${e}];`);
580
+ } else o.push(`${i.code} ${n} ${a.code};`);
581
+ return o;
582
+ }
583
+ expr(e) {
584
+ if (e.op === "literal") return this.literal(e);
585
+ if (e.op === "name") {
586
+ let t = this.find(e.value);
587
+ return t || this.fail(`Unknown identifier ${e.value}`), x(t.code, t.type);
588
+ }
589
+ if (e.op === "index") {
590
+ let t = this.expr(e.args[0]), n = this.convert(this.expr(e.args[1]), "int"), r = /^(.*)\[([^\]]+)\]$/.exec(t.type);
591
+ if (r && Object.hasOwn(g, r[1])) {
592
+ let e = /^i32\((\d+)\)$/.exec(n.code)?.[1];
593
+ if (e !== void 0) return +e >= +r[2] && this.fail(`Sampler array index ${e} is outside its ${r[2]} elements`), x(`${t.code}__${e}`, r[1], t.before);
594
+ let i = this.temp();
595
+ return x(`margo_pick(${t.code},${r[2]},${i})`, r[1], [
596
+ ...t.before,
597
+ ...n.before,
598
+ `let ${i}=${n.code};`
599
+ ]);
600
+ }
601
+ let i = r ? r[1] : t.type.startsWith("mat") ? "vec" + t.type.at(-1) : u(t.type);
602
+ return x(`${t.code}[${n.code}]`, i, [...t.before, ...n.before]);
603
+ }
604
+ if (e.op === "member") {
605
+ let t = this.expr(e.args[0]), n = e.value, r = this.program.structs.get(t.type);
606
+ if (r) {
607
+ let e = r.find((e) => e.name === n);
608
+ return e || this.fail(`Unknown struct member ${n}`), x(`${t.code}.${p(n)}`, e.type, t.before);
609
+ }
610
+ let i = /^[xyzw]{1,4}$/.test(n) ? "xyzw" : /^[rgba]{1,4}$/.test(n) ? "rgba" : /^[stpq]{1,4}$/.test(n) ? "stpq" : "";
611
+ (!i || [...n].some((e) => i.indexOf(e) >= d(t.type))) && this.fail(`Invalid swizzle ${n}`);
612
+ let a = [...n].map((e) => "xyzw"[i.indexOf(e)]).join("");
613
+ return x(`(${t.code}).${a}`, f(u(t.type), n.length), t.before);
614
+ }
615
+ if (e.op === "prefix" && e.value === "-" && e.args[0].op === "literal" && e.args[0].value === "2147483648") return x("i32(-2147483648)", "int");
616
+ if (e.op === "prefix" || e.op === "postfix") {
617
+ let t = this.expr(e.args[0]);
618
+ if (e.value === "++" || e.value === "--") {
619
+ let n = this.temp(), r = x(`${y(u(t.type))}(1)`, u(t.type)), i = this.assign(e.args[0], this.arith(e.value[0], x(t.code, t.type), r), "=", {
620
+ ...t,
621
+ before: []
622
+ }), a = e.op === "postfix" ? [
623
+ ...t.before,
624
+ `let ${n}=${t.code};`,
625
+ ...i
626
+ ] : [...t.before, ...i];
627
+ return x(e.op === "postfix" ? n : t.code, t.type, a);
628
+ }
629
+ return e.value === "-" && t.type.startsWith("mat") ? x(`(${t.code}*(-1.0))`, t.type, t.before) : x(`(${e.value === "+" ? "" : e.value}${t.code})`, e.value === "!" ? "bool" : t.type, t.before);
630
+ }
631
+ if (e.op === "conditional") {
632
+ let t = this.expr(e.args[0]), n = this.expr(e.args[1]), r = this.convert(this.expr(e.args[2]), n.type), i = this.temp();
633
+ return x(i, n.type, [
634
+ ...t.before,
635
+ `var ${i}:${y(n.type)};`,
636
+ `if(${t.code}){${n.before.join("\n")}${i}=${n.code};}else{${r.before.join("\n")}${i}=${r.code};}`
637
+ ]);
638
+ }
639
+ if (e.op === "binary") {
640
+ let t = e.value;
641
+ if ([
642
+ "=",
643
+ "+=",
644
+ "-=",
645
+ "*=",
646
+ "/=",
647
+ "%=",
648
+ "<<=",
649
+ ">>=",
650
+ "&=",
651
+ "|=",
652
+ "^="
653
+ ].includes(t)) {
654
+ let n = this.expr(e.args[0]), r = this.expr(e.args[1]), i = t === "=" ? r : this.arith(t.slice(0, -1), x(n.code, n.type), r);
655
+ return x(n.code, n.type, this.assign(e.args[0], i, "=", n));
656
+ }
657
+ let n = this.expr(e.args[0]), r = this.expr(e.args[1]);
658
+ if (t === ",") return x(r.code, r.type, [
659
+ ...n.before,
660
+ ...n.type === "void" ? n.code ? [n.code + ";"] : [] : [`let ${this.temp()}=${n.code};`],
661
+ ...r.before
662
+ ]);
663
+ if (t === "&&" || t === "||") {
664
+ if (!r.before.length) return x(`(${n.code}${t}${r.code})`, "bool", n.before);
665
+ let e = this.temp();
666
+ return x(e, "bool", [
667
+ ...n.before,
668
+ `var ${e}=${n.code};`,
669
+ `if(${t === "||" ? "!" : ""}${e}){${r.before.join("\n")}${e}=${r.code};}`
670
+ ]);
671
+ }
672
+ if (t === "^^") return x(`(${n.code}!=${r.code})`, "bool", [...n.before, ...r.before]);
673
+ if (t === "==" || t === "!=") {
674
+ n.type !== r.type && this.fail("Equality operands must have matching types");
675
+ let e = [
676
+ "float",
677
+ "int",
678
+ "uint",
679
+ "bool"
680
+ ].includes(n.type) ? `(${n.code}==${r.code})` : `${this.equality(n.type)}(${n.code},${r.code})`;
681
+ return x(t === "!=" ? `!(${e})` : e, "bool", [...n.before, ...r.before]);
682
+ }
683
+ return this.arith(t, n, r);
684
+ }
685
+ if (e.op === "call") return this.call(e.args[0], e.args.slice(1));
686
+ this.fail(`Unknown expression ${e.op}`);
687
+ }
688
+ arith(e, t, n) {
689
+ let r = m(t.type), i = m(n.type);
690
+ if (e === "*" && (r || i)) return x(`(${t.code}*${n.code})`, r && i ? h(i[0], r[1]) : r && n.type.startsWith("vec") ? `vec${r[1]}` : i && t.type.startsWith("vec") ? `vec${i[0]}` : r ? t.type : n.type, [...t.before, ...n.before]);
691
+ if ((r || i) && [
692
+ "+",
693
+ "-",
694
+ "/"
695
+ ].includes(e)) {
696
+ let a = r ? t.type : n.type, [o, s] = r ?? i, c = this.temp(), l = this.temp(), u = (e, t, n) => e.type.startsWith("mat") ? `${t}[${n}]` : `vec${s}f(f32(${t}))`;
697
+ return x(`${y(a)}(${Array.from({ length: o }, (r, i) => `(${u(t, c, i)}${e}${u(n, l, i)})`).join(",")})`, a, [
698
+ ...t.before,
699
+ ...n.before,
700
+ `let ${c}=${t.code};`,
701
+ `let ${l}=${n.code};`
702
+ ]);
703
+ }
704
+ if (e === "<<" || e === ">>") {
705
+ let r = this.convert(n, f("uint", d(t.type)));
706
+ return x(`(${t.code}${e}${r.code})`, t.type, [...t.before, ...r.before]);
707
+ }
708
+ let [a, o] = this.join(t, n), s = [
709
+ "==",
710
+ "!=",
711
+ "<",
712
+ "<=",
713
+ ">",
714
+ ">="
715
+ ].includes(e);
716
+ return x(`(${a.code}${e}${o.code})`, s ? "bool" : a.type, [...a.before, ...o.before]);
717
+ }
718
+ call(e, t) {
719
+ if (e.op === "member" && e.value === "length" && !t.length) {
720
+ let t = this.expr(e.args[0]), n = /\[(\d+)\]$/.exec(t.type);
721
+ return n || this.fail("length() needs an array"), x(`i32(${n[1]})`, "int", t.before);
722
+ }
723
+ e.op !== "name" && this.fail("Function calls must use a named function");
724
+ let n = e.value, r = t.map((e) => this.expr(e)), i = r.flatMap((e) => e.before), a = r.map((e) => e.code), o = r[0] ?? x("", "void"), s = (e) => ((r.length !== 1 || o.type !== "vec2") && this.fail(`${n} needs one vec2 coordinate`), x(`sample(${this.host.colorReaders[e ? "getToColor" : "getFromColor"]},${this.flipY ? `vec2f(${o.code}.x,1.0-${o.code}.y)` : o.code})`, "vec4", i));
725
+ if (Object.hasOwn(this.host.colorReaders, n)) return s(n === "getToColor");
726
+ let c = /^(texture2D|texture)(Proj)?(Lod|Grad|Offset)?$/.exec(n);
727
+ if (c && Object.hasOwn(g, o.type)) return this.lookup(!!c[2], c[3] ?? "", r, i);
728
+ if (n === "texelFetch" || n === "textureSize") return this.texel(n, r, i);
729
+ let l = /^(.*)\[(\d+)\]$/.exec(n);
730
+ if (l) {
731
+ r.length !== Number(l[2]) && this.fail(`${n} needs ${l[2]} elements`);
732
+ let e = r.map((e) => this.convert(e, l[1]));
733
+ return x(`${y(n)}(${e.map((e) => e.code).join(",")})`, n, e.flatMap((e) => e.before));
734
+ }
735
+ if (this.program.structs.has(n)) return x(`${y(n)}(${a.join(",")})`, n, i);
736
+ if (/^(float|int|uint|bool|[ibu]?vec[234]|mat[234](x[234])?)$/.test(n)) {
737
+ let e = m(n);
738
+ if (e && r.length === 1 && m(o.type)) {
739
+ let [t, r] = e, [a, s] = m(o.type), c = this.temp();
740
+ return x(`${y(n)}(${Array.from({ length: t }, (e, t) => `vec${r}f(${Array.from({ length: r }, (e, n) => t < a && n < s ? `${c}[${t}][${n}]` : t === n ? "1.0" : "0.0").join(",")})`).join(",")})`, n, [...i, `let ${c}=${o.code};`]);
741
+ }
742
+ if (e && r.length === 1 && [
743
+ "float",
744
+ "int",
745
+ "uint"
746
+ ].includes(o.type)) {
747
+ let [t, r] = e, a = Array.from({ length: t }, (e, t) => `${y("vec" + r)}(${Array.from({ length: r }, (e, n) => n === t ? `f32(${o.code})` : "0.0").join(",")})`);
748
+ return x(`${y(n)}(${a.join(",")})`, n, i);
749
+ }
750
+ let t = e ? e[0] * e[1] : d(n), a = r.reduce((e, t) => e + this.components(t.type), 0);
751
+ if (!(e ? a === t && (r.every((t) => t.type === `vec${e[1]}`) || r.every((e) => d(e.type) === 1 && !m(e.type))) : !r.some((e) => m(e.type)) && (r.length === 1 || a === t)) && (r.length > 1 || !e && d(n) > 1)) {
752
+ a < t && this.fail(`${n} needs ${t} components`);
753
+ let e = [...i], o = [];
754
+ for (let t of r) {
755
+ let r = this.temp(), i = m(t.type);
756
+ e.push(`let ${r}=${t.code};`);
757
+ let a = i ? Array.from({ length: i[0] * i[1] }, (e, t) => `${r}[${Math.floor(t / i[1])}][${t % i[1]}]`) : d(t.type) > 1 ? Array.from({ length: d(t.type) }, (e, t) => `${r}.${"xyzw"[t]}`) : [r];
758
+ for (let e of a) o.push(this.convert(x(e, u(t.type)), u(n)).code);
759
+ }
760
+ return x(`${y(n)}(${o.slice(0, t).join(",")})`, n, e);
761
+ }
762
+ if (!n.startsWith("mat") && d(n) === 1 && r.length === 1 && (d(o.type) > 1 || /^mat/.test(o.type))) return this.convert(x(`(${o.code})${o.type.startsWith("mat") ? "[0].x" : ".x"}`, u(o.type), i), n);
763
+ if (d(n) > 1 && r.length === 1 && d(o.type) > d(n)) return x(`${y(n)}((${o.code}).${"xyzw".slice(0, d(n))})`, n, i);
764
+ let s = r.map((e) => u(e.type) === u(n) ? e : this.convert(e, f(u(n), d(e.type))));
765
+ return x(`${y(n)}(${s.map((e) => e.code).join(",")})`, n, s.flatMap((e) => e.before));
766
+ }
767
+ let p = this.functions.filter((e) => e.name === n && e.params.length === r.length), _ = p.find((e) => e.params.every((e, t) => e.type === r[t].type)) ?? p.find((e) => e.params.every((e, t) => d(e.type) === d(r[t].type)));
768
+ if (_) {
769
+ let e = _.params.map((e, t) => this.convert(r[t], e.type)), n = e.flatMap((e) => e.before);
770
+ e.some((e) => e.code.startsWith("margo_pick(") || /sampler\w*\[/.test(e.type)) && this.fail(`${_.name} takes a sampler array element; index it with a constant`);
771
+ let i = `${this.names.get(_)}(${e.map((e) => this.host.sample && Object.hasOwn(g, e.type) ? `${e.code},${this.host.samplerOf?.(e.code) ?? e.code + "s"}${this.host.samplerMode ? "," + this.host.samplerMode(e.code) : ""}` : e.code).join(",")})`;
772
+ if (!_.params.some((e) => /\b(out|inout)\b/.test(e.qualifier))) return x(i, _.type, n);
773
+ let a = this.temp();
774
+ return n.push(`let ${a}=${i};`), _.params.forEach((e, i) => {
775
+ /\b(out|inout)\b/.test(e.qualifier) && n.push(...this.assign(t[i], x(`${a}.out_${i}`, e.type), "=", {
776
+ ...r[i],
777
+ before: []
778
+ }));
779
+ }), x(_.type === "void" ? "" : `${a}.result`, _.type, n);
780
+ }
781
+ if (n === "mix" && r.length === 3 && u(r[2].type) === "bool") {
782
+ let e = d(r[1].type) > d(o.type) ? r[1].type : o.type, [t, n] = [this.convert(o, e), this.convert(r[1], e)];
783
+ return x(`select(${t.code},${n.code},${r[2].code})`, e, [
784
+ ...t.before,
785
+ ...n.before,
786
+ ...r[2].before
787
+ ]);
788
+ }
789
+ let v = {
790
+ floatBitsToInt: "int",
791
+ floatBitsToUint: "uint",
792
+ intBitsToFloat: "float",
793
+ uintBitsToFloat: "float"
794
+ };
795
+ if (v[n] && r.length === 1) {
796
+ let e = f(v[n], d(o.type));
797
+ return x(`bitcast<${y(e)}>(${o.code})`, e, i);
798
+ }
799
+ if ((n === "isnan" || n === "isinf") && r.length === 1) {
800
+ let e = d(o.type), t = y(f("uint", e)), r = this.temp();
801
+ return x(`((${r}&${t}(0x7fffffffu))${n === "isnan" ? ">" : "=="}${t}(0x7f800000u))`, f("bool", e), [...i, `let ${r}=bitcast<${t}>(${o.code});`]);
802
+ }
803
+ if (n === "modf" && r.length === 2) {
804
+ let e = this.temp();
805
+ return x(`${e}.fract`, o.type, [
806
+ ...i,
807
+ `let ${e}=modf(${o.code});`,
808
+ ...this.assign(t[1], x(`${e}.whole`, o.type), "=", {
809
+ ...r[1],
810
+ before: []
811
+ })
812
+ ]);
813
+ }
814
+ let b = m(o.type);
815
+ if (n === "inverse" && this.version === 300 && r.length === 1 && b && b[0] === b[1]) return x(`${this.inverse(b[0])}(${o.code})`, o.type, i);
816
+ if (n === "outerProduct" && r.length === 2) {
817
+ let e = this.temp(), t = this.temp(), n = h(d(r[1].type), d(o.type));
818
+ return x(`${y(n)}(${Array.from({ length: d(r[1].type) }, (n, r) => `${e}*${t}[${r}]`).join(",")})`, n, [
819
+ ...i,
820
+ `let ${e}=${o.code};`,
821
+ `let ${t}=${a[1]};`
822
+ ]);
823
+ }
824
+ if (n === "transpose" && r.length === 1 && b) return x(`transpose(${o.code})`, h(b[1], b[0]), i);
825
+ let S = {
826
+ packSnorm2x16: ["pack2x16snorm", "uint"],
827
+ unpackSnorm2x16: ["unpack2x16snorm", "vec2"],
828
+ packUnorm2x16: ["pack2x16unorm", "uint"],
829
+ unpackUnorm2x16: ["unpack2x16unorm", "vec2"],
830
+ packHalf2x16: ["pack2x16float", "uint"],
831
+ unpackHalf2x16: ["unpack2x16float", "vec2"]
832
+ };
833
+ if (S[n] && r.length === 1) return x(`${S[n][0]}(${o.code})`, S[n][1], i);
834
+ if ((/* @__PURE__ */ "radians.degrees.sin.cos.tan.asin.acos.exp.log.exp2.log2.sqrt.inversesqrt.abs.sign.floor.ceil.fract.normalize.dFdx.dFdy.fwidth.trunc.round.roundEven.sinh.cosh.tanh.asinh.acosh.atanh".split(".")).includes(n)) return r.length !== 1 && this.fail(`${n} needs one argument`), x(`${n === "dFdy" && (this.host.yUp ?? this.flipY) ? "-" : ""}${{
835
+ inversesqrt: "inverseSqrt",
836
+ dFdx: "dpdx",
837
+ dFdy: "dpdy",
838
+ roundEven: "round"
839
+ }[n] ?? n}(${a.join(",")})`, o.type, i);
840
+ if (n === "atan") return x(`${r.length === 2 ? "atan2" : "atan"}(${a.join(",")})`, o.type, i);
841
+ if ([
842
+ "length",
843
+ "distance",
844
+ "dot",
845
+ "determinant"
846
+ ].includes(n)) return x(`${n}(${a.join(",")})`, "float", i);
847
+ if (["any", "all"].includes(n)) return x(`${n}(${a.join(",")})`, "bool", i);
848
+ if (n === "not") return x(`(!${o.code})`, o.type, i);
849
+ if ([
850
+ "cross",
851
+ "reflect",
852
+ "refract",
853
+ "transpose",
854
+ "faceforward"
855
+ ].includes(n)) return x(`${n === "faceforward" ? "faceForward" : n}(${a.join(",")})`, o.type, i);
856
+ let C = {
857
+ lessThan: "<",
858
+ lessThanEqual: "<=",
859
+ greaterThan: ">",
860
+ greaterThanEqual: ">=",
861
+ equal: "==",
862
+ notEqual: "!="
863
+ };
864
+ if (C[n]) return x(`(${a[0]}${C[n]}${a[1]})`, f("bool", d(o.type)), i);
865
+ if ([
866
+ "min",
867
+ "max",
868
+ "pow",
869
+ "step",
870
+ "mod",
871
+ "clamp",
872
+ "mix",
873
+ "smoothstep"
874
+ ].includes(n)) {
875
+ let e = [
876
+ "clamp",
877
+ "mix",
878
+ "smoothstep"
879
+ ].includes(n) ? 3 : 2;
880
+ r.length !== e && this.fail(`${n} needs ${e} arguments`);
881
+ let t = r.reduce((e, t) => d(t.type) > d(e) ? t.type : e, o.type), i = r.map((e) => this.convert(e, t)), a = i.map((e) => e.code), s = i.flatMap((e) => e.before);
882
+ if (n === "mod") {
883
+ let e = this.temp(), n = this.temp();
884
+ return x(`(${e}-${n}*floor(${e}/${n}))`, t, [
885
+ ...s,
886
+ `let ${e}=${a[0]};`,
887
+ `let ${n}=${a[1]};`
888
+ ]);
889
+ }
890
+ return x(`${n}(${a.join(",")})`, t, s);
891
+ }
892
+ if (n === "matrixCompMult" && b) return x(`${y(o.type)}(${Array.from({ length: b[0] }, (e, t) => `${a[0]}[${t}]*${a[1]}[${t}]`).join(",")})`, o.type, i);
893
+ this.fail(`Unknown function or overload ${n}`);
894
+ }
895
+ picked(e, t, n) {
896
+ let r = /^margo_pick\((\w+),(\d+),(\w+)\)$/.exec(e.code);
897
+ if (!r) return;
898
+ let i = Array.from({ length: +r[2] }, (n, i) => t(x(`${r[1]}__${i}`, e.type)));
899
+ return x(i.reduce((e, t, n) => n ? `select(${e},${t.code},${r[3]}==${n})` : t.code, ""), i[0].type, [...n, ...i.flatMap((e) => e.before)]);
900
+ }
901
+ lookup(e, t, n, r) {
902
+ let [i, a, ...o] = n, s = this.picked(i, (r) => this.lookup(e, t, [r, ...n.slice(1)], []), r);
903
+ if (s) return s;
904
+ let c = _(i.type), l = i.type.endsWith("Shadow"), u = ({
905
+ sampler2D: 2,
906
+ samplerCube: 3,
907
+ sampler3D: 3,
908
+ sampler2DArray: 3
909
+ }[c] ?? 2) + +!!l, f = t === "Grad" ? 2 : +!!t;
910
+ (!a || o.length < f || o.length > f + (t === "Lod" || t === "Grad" ? 0 : 1)) && this.fail(`texture${e ? "Proj" : ""}${t} has the wrong number of arguments`), e && c !== "sampler2D" && c !== "sampler3D" && this.fail("A projective lookup needs a 2D or 3D sampler"), e && l && d(a.type) !== 4 && this.fail("textureProj of a sampler2DShadow takes vec4 coordinates"), d(a.type) !== (e ? u + 1 : u) && !(e && c === "sampler2D" && d(a.type) === 4) && this.fail(`${i.type} lookups take vec${e ? u + 1 : u} coordinates`), /^[iu]samplerCube/.test(i.type) && this.fail(`${i.type} lookups need a cube texture of integers, which WGSL cannot read; use a 2D array`);
911
+ let p = e ? `(${a.code}.${u === 2 ? "xy" : "xyz"}/${a.code}.${d(a.type) === 4 ? "w" : "z"})` : a.code, m;
912
+ if (l) {
913
+ let e = this.temp(), t = u - 1;
914
+ r = [...r, `let ${e}=${p};`], m = `${e}.${"xyzw"[t]}`, p = t === 2 ? `${e}.xy` : `${e}.xyz`;
915
+ }
916
+ let h = u - +!!l, g = (e) => this.flipY && c !== "samplerCube" && c !== "sampler3D" ? `vec${h}f(${e}.x,1.0-${e}.y${h === 3 ? `,${e}.z` : ""})` : e, y = this.host.sample, b = m ? { compare: m } : {};
917
+ if (t === "Lod") b.lod = o[0].code;
918
+ else if (t === "Grad") {
919
+ let e = (e) => this.flipY && c !== "samplerCube" && c !== "sampler3D" ? `vec2f(${e.code}.x,-${e.code}.y)` : e.code;
920
+ b.ddx = e(o[0]), b.ddy = e(o[1]);
921
+ } else t === "Offset" && (b.offset = this.flipY ? `vec2i(${o[0].code}.x,-${o[0].code}.y)` : o[0].code);
922
+ return o.length > f && (b.bias = o[f].code), y ? x(y(i.code, i.type, g(p), b), v(i.type), r) : (i.type !== "sampler2D" && this.fail("Only sampler2D images can be read here"), t === "Offset" && (p = `(${p}+vec2f(${o[0].code})/vec2f(textureDimensions(${i.code})))`), x(`sample(${i.code},${g(p)})`, "vec4", r));
923
+ }
924
+ texel(e, t, n) {
925
+ let [r, i] = t;
926
+ (!r || !Object.hasOwn(g, r.type)) && this.fail(`${e} needs a sampler`);
927
+ let a = this.picked(r, (n) => this.texel(e, [n, ...t.slice(1)], []), n);
928
+ if (a) return a;
929
+ let o = _(r.type);
930
+ e === "texelFetch" && r.type.endsWith("Shadow") && this.fail("texelFetch takes no shadow sampler"), t.length !== (e === "textureSize" ? 2 : 3) && this.fail(`${e} has the wrong number of arguments`);
931
+ let s = this.convert(t.at(-1), "int"), c = this.temp(), l = this.temp();
932
+ if (n = [...n, ...s.before], e === "textureSize") {
933
+ let e = o === "sampler2D" || o === "samplerCube" ? "ivec2" : "ivec3", t = `textureDimensions(${r.code},${l})`;
934
+ return x(o === "sampler2DArray" ? `vec3<i32>(vec2<i32>(${t}),i32(textureNumLayers(${r.code})))` : `${y(e)}(${t})`, e, [...n, `let ${l}=${s.code};`]);
935
+ }
936
+ o === "samplerCube" && this.fail("texelFetch needs a 2D, 3D or array sampler");
937
+ let u = this.convert(i, o === "sampler2D" ? "ivec2" : "ivec3"), d = [
938
+ ...n,
939
+ ...u.before,
940
+ `let ${c}=${u.code};`,
941
+ `let ${l}=${s.code};`
942
+ ], f = this.flipY && o !== "sampler3D" ? `vec2i(${c}.x,i32(textureDimensions(${r.code},${l}).y)-1-${c}.y)` : `${c}.xy`;
943
+ return x(o === "sampler2DArray" ? `textureLoad(${r.code},${f},${c}.z,${l})` : o === "sampler3D" ? `textureLoad(${r.code},${c},${l})` : `textureLoad(${r.code},${f},${l})`, v(r.type), d);
944
+ }
945
+ inverse(e) {
946
+ let t = `margo_inverse${e}`, n = `mat${e}x${e}<f32>`;
947
+ if (e === 2) this.helpers.add(`fn ${t}(m:${n})->${n}{return ${n}(m[1][1],-m[0][1],-m[1][0],m[0][0])*(1.0/determinant(m));}`);
948
+ else {
949
+ let r = (t, n) => {
950
+ let r = [...Array(e).keys()].filter((e) => e !== t), i = [...Array(e).keys()].filter((e) => e !== n);
951
+ return `determinant(mat${e - 1}x${e - 1}<f32>(${r.map((t) => `vec${e - 1}f(${i.map((e) => `m[${t}][${e}]`).join(",")})`).join(",")}))`;
952
+ }, i = [];
953
+ for (let t = 0; t < e; t++) for (let n = 0; n < e; n++) i.push(`${(n + t) % 2 ? "-" : ""}${r(n, t)}`);
954
+ this.helpers.add(`fn ${t}(m:${n})->${n}{return ${n}(${i.join(",")})*(1.0/determinant(m));}`);
955
+ }
956
+ return t;
957
+ }
958
+ declarations(e, t = !1) {
959
+ return e.map((e) => {
960
+ let n = e.init ? this.convert(this.expr(e.init), e.type) : void 0, r = this.define(e.name, e.type);
961
+ if (/\buniform\b/.test(e.qualifier)) {
962
+ let t = this.uniforms[e.name];
963
+ t === void 0 && this.fail(`Supply uniform ${e.name}`), n = x(this.parameter(t, e.type), e.type);
964
+ }
965
+ let i = /\bconst\b|\buniform\b/.test(e.qualifier);
966
+ return t && n?.before.length && this.fail(`Global initializer ${e.name} is not constant`), [...n?.before ?? [], `${t ? i ? "const" : "var<private>" : i ? "let" : "var"} ${r}:${y(e.type)}${n ? "=" + n.code : ""};`].join("\n");
967
+ });
968
+ }
969
+ arrayCount(e) {
970
+ let t = Number(e);
971
+ return (!Number.isSafeInteger(t) || t < 1 || t > 16384) && this.fail("Uniform array length must be in 1..16384"), t;
972
+ }
973
+ components(e) {
974
+ let t = /^(.*)\[([^\]]+)\]$/.exec(e);
975
+ return t ? this.arrayCount(t[2]) * this.components(t[1]) : e.startsWith("mat") ? m(e)[0] * m(e)[1] : d(e);
976
+ }
977
+ parameter(e, t) {
978
+ let n = Array.isArray(e) ? e : [e];
979
+ n.length !== this.components(t) && this.fail(`Uniform ${t} needs ${this.components(t)} components`);
980
+ let r = 0, i = (e) => {
981
+ let t = /^(.*)\[([^\]]+)\]$/.exec(e);
982
+ if (t) return `${y(e)}(${Array.from({ length: this.arrayCount(t[2]) }, () => i(t[1])).join(",")})`;
983
+ let a = u(e), o = this.components(e), s = Array.from({ length: o }, () => {
984
+ let e = n[r++];
985
+ if (a === "bool") {
986
+ if (typeof e == "boolean" || e === 0 || e === 1) return String(!!e);
987
+ this.fail("Boolean uniforms need true, false, zero or one");
988
+ }
989
+ return (typeof e != "number" || !Number.isFinite(e) || a === "float" && !Number.isFinite(Math.fround(e))) && this.fail("Uniform values must fit finite 32-bit numbers"), (a === "int" || a === "uint") && (!Number.isSafeInteger(e) || e < (a === "uint" ? 0 : -2147483648) || e > (a === "uint" ? 4294967295 : 2147483647)) && this.fail("Integer uniform is outside 32-bit range"), `${y(a)}(${Object.is(e, -0) ? "-0.0" : e})`;
990
+ });
991
+ return o === 1 ? s[0] : `${y(e)}(${s.join(",")})`;
992
+ };
993
+ return i(t);
994
+ }
995
+ returnValue(e) {
996
+ let t = this.active, n = e ? this.convert(this.expr(e), t.type) : void 0, r = t.params.map((e, t) => /\b(out|inout)\b/.test(e.qualifier) ? this.find(e.name).code : void 0).filter((e) => e !== void 0);
997
+ return [...n?.before ?? [], `return${r.length ? " " + this.names.get(t) + "_result(" + [...n ? [n.code] : [], ...r].join(",") + ")" : n ? " " + n.code : ""};`];
998
+ }
999
+ body(e) {
1000
+ this.scopes.push(/* @__PURE__ */ new Map());
1001
+ try {
1002
+ return e.flatMap((e) => this.statement(e)).join("\n");
1003
+ } finally {
1004
+ this.scopes.pop();
1005
+ }
1006
+ }
1007
+ statement(e) {
1008
+ if (e.kind === "block") return ["{" + this.body(e.body ?? []) + "}"];
1009
+ if (e.kind === "decl") return this.declarations(e.decls);
1010
+ if (e.kind === "return") return this.returnValue(e.expr);
1011
+ if ([
1012
+ "break",
1013
+ "continue",
1014
+ "discard"
1015
+ ].includes(e.kind)) return [e.kind + ";"];
1016
+ if (e.kind === "expr") {
1017
+ let t = this.expr(e.expr);
1018
+ return [...t.before, ...t.code ? [t.type === "void" ? t.code + ";" : "_=" + t.code + ";"] : []];
1019
+ }
1020
+ if (e.kind === "if") {
1021
+ let t = this.expr(e.expr);
1022
+ return [...t.before, `if(${t.code}){${this.body(e.body ?? [])}}${e.other ? "else{" + this.body(e.other) + "}" : ""}`];
1023
+ }
1024
+ if (e.kind === "switch") return this.switch(e);
1025
+ if ([
1026
+ "for",
1027
+ "while",
1028
+ "do"
1029
+ ].includes(e.kind)) {
1030
+ this.scopes.push(/* @__PURE__ */ new Map());
1031
+ try {
1032
+ let t = e.init ? this.statement(e.init) : [], n = e.expr ? this.expr(e.expr) : void 0, r = e.update ? this.expr(e.update) : void 0, i = n ? [...n.before, `if(!(${n.code})){break;}`].join("\n") : "", a = r ? [...r.before, ...r.before.length === 0 && r.code ? [r.code + ";"] : []].join("\n") : "";
1033
+ return [
1034
+ "{",
1035
+ ...t,
1036
+ `loop{${e.kind === "do" ? "" : i}\n${this.body(e.body ?? [])}\ncontinuing{${e.kind === "do" ? `${n?.before.join("\n") ?? ""}\nbreak if !(${n?.code ?? "true"});` : a}}}`,
1037
+ "}"
1038
+ ];
1039
+ } finally {
1040
+ this.scopes.pop();
1041
+ }
1042
+ }
1043
+ this.fail(`Unknown statement ${e.kind}`);
1044
+ }
1045
+ switch(e) {
1046
+ let t = this.expr(e.expr);
1047
+ t.type !== "int" && t.type !== "uint" && this.fail("A switch selector is an int or uint scalar");
1048
+ let n = e.cases ?? [], r = (e) => [
1049
+ "break",
1050
+ "return",
1051
+ "continue",
1052
+ "discard"
1053
+ ].includes(e.at(-1)?.kind ?? ""), i = n.map((e, i) => {
1054
+ let a = [];
1055
+ for (let e = i; e < n.length && (a.push(...n[e].body), !r(n[e].body)); e++);
1056
+ return `case ${e.labels.map((e) => e === null ? "default" : t.type === "uint" ? `${e >>> 0}u` : `i32(${e | 0})`).join(",")}{${this.body(a)}}`;
1057
+ });
1058
+ return n.some((e) => e.labels.includes(null)) || i.push("default{}"), [...t.before, `switch(${t.code}){${i.join("\n")}}`];
1059
+ }
1060
+ emit() {
1061
+ let e = this.scopes[0];
1062
+ for (let [t, n] of Object.entries(this.host.names)) e.set(t, n);
1063
+ let t = [...this.program.structs].map(([e, t]) => `struct ${p(e)}{${t.map((e) => p(e.name) + ":" + y(e.type)).join(",")}}`).join("\n"), n = this.declarations(this.program.globals.filter((e) => e.name === "gl_FragCoord" || !Object.hasOwn(this.host.names, e.name)), !0).join("\n"), r = this.functions.filter((e) => e.params.some((e) => /\b(out|inout)\b/.test(e.qualifier))).map((e) => `struct ${this.names.get(e)}_result{${[...e.type === "void" ? [] : [`result:${y(e.type)}`], ...e.params.flatMap((e, t) => /\b(out|inout)\b/.test(e.qualifier) ? [`out_${t}:${y(e.type)}`] : [])].join(",")}}`).join("\n"), i = this.functions.map((e) => {
1064
+ this.active = e, this.scopes.push(/* @__PURE__ */ new Map());
1065
+ try {
1066
+ let t = e.params.map((e, t) => `argument_${t}:${y(e.type)}${this.host.sample && Object.hasOwn(g, e.type) ? `,argument_${t}s:sampler${e.type.endsWith("Shadow") ? "_comparison" : ""}${this.host.samplerMode ? `,argument_${t}m:u32` : ""}` : ""}`), n = e.params.map((e, t) => Object.hasOwn(g, e.type) ? (/\b(out|inout)\b/.test(e.qualifier) && this.fail("Samplers cannot be output parameters"), this.define(e.name, e.type, "argument_" + t), "") : `var ${this.define(e.name, e.type)}:${y(e.type)} = ${/\bout\b/.test(e.qualifier) ? y(e.type) + "()" : "argument_" + t};`), r = e.params.some((e) => /\b(out|inout)\b/.test(e.qualifier)) ? `${this.names.get(e)}_result` : e.type === "void" ? "" : y(e.type), i = e.body.flatMap((e) => this.statement(e));
1067
+ return e.type === "void" && e.body.at(-1)?.kind !== "return" && i.push(...this.returnValue()), `fn ${this.names.get(e)}(${t.join(",")})${r ? "->" + r : ""}{\n${n.join("\n")}\n${i.join("\n")}\n}`;
1068
+ } finally {
1069
+ this.scopes.pop();
1070
+ }
1071
+ }).join("\n"), a = this.host.entry, o = this.functions.find((e) => e.name === a.name && e.type === a.type && e.params.length === a.params.length && e.params.every((e, t) => e.type === a.params[t]));
1072
+ return o || this.fail(this.host.missingEntry), [
1073
+ t,
1074
+ n,
1075
+ r,
1076
+ this.host.prologue,
1077
+ [...this.helpers].join(b),
1078
+ i,
1079
+ this.host.epilogue(this.names.get(o))
1080
+ ].join(b);
1081
+ }
1082
+ };
1083
+ //#endregion
1084
+ //#region ../shader/src/glsl/preprocess.ts
1085
+ function C(t, n = { version: 100 }) {
1086
+ n.version = /^\s*#\s*version\s+300\s+es\s*$/m.test(t.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, "")) ? 300 : 100;
1087
+ let r = /* @__PURE__ */ new Map([["GL_ES", { body: "1" }], ["__VERSION__", { body: String(n.version) }]]), i = (t) => {
1088
+ let n = t;
1089
+ for (let t = 0; t < 64; t++) {
1090
+ let t = !1;
1091
+ n = n.replace(/\b[A-Za-z_]\w*\b/g, (e, n, i) => {
1092
+ let a = r.get(e);
1093
+ return !a || a.params || i[n - 1] === "#" ? e : (a.body !== e && (t = !0), a.body);
1094
+ });
1095
+ for (let [i, a] of r) {
1096
+ if (!a.params) continue;
1097
+ let r = RegExp("\\b" + i + "\\s*\\(", "g"), o;
1098
+ for (; o = r.exec(n);) {
1099
+ let s = 1, c = r.lastIndex, l = c, u = [];
1100
+ for (; c < n.length && s; c++) {
1101
+ let e = n[c];
1102
+ e === "(" ? s++ : e === ")" ? --s === 0 && u.push(n.slice(l, c)) : e === "," && s === 1 && (u.push(n.slice(l, c)), l = c + 1);
1103
+ }
1104
+ if (u.length === 1 && u[0].trim() === "" && a.params.length === 0 && (u.length = 0), s || u.length !== a.params.length) throw e("failed", `GLSL macro ${i} has invalid arguments; correct its invocation`);
1105
+ let d = a.body.replace(/\b[A-Za-z_]\w*\b/g, (e) => {
1106
+ let t = a.params.indexOf(e);
1107
+ return t < 0 ? e : u[t];
1108
+ });
1109
+ n = n.slice(0, o.index) + d + n.slice(c), r.lastIndex = o.index + d.length, t = !0;
1110
+ }
1111
+ }
1112
+ if (n.length > 262144) throw e("failed", "Expanded GLSL is too large; reduce macro expansion below 262144 code units");
1113
+ if (!t) return n;
1114
+ }
1115
+ throw e("failed", "GLSL macro expansion is recursive or too deep; reduce macro nesting below 64");
1116
+ }, a = (t) => {
1117
+ let n = t.args.map(a), r = n[0] ?? 0, i = n[1] ?? 0;
1118
+ if (t.op === "literal") return Number(t.value.replace(/[uU]$/, ""));
1119
+ if (t.op === "name") return 0;
1120
+ if (t.op === "conditional") return r ? n[1] : n[2];
1121
+ if (t.op === "prefix") return t.value === "!" ? +!r : t.value === "-" ? -r : t.value === "~" ? ~r : r;
1122
+ switch (t.value) {
1123
+ case "+": return r + i;
1124
+ case "-": return r - i;
1125
+ case "*": return r * i;
1126
+ case "/": return Math.trunc(r / i);
1127
+ case "%": return r % i;
1128
+ case "==": return +(r === i);
1129
+ case "!=": return +(r !== i);
1130
+ case "<": return +(r < i);
1131
+ case ">": return +(r > i);
1132
+ case "<=": return +(r <= i);
1133
+ case ">=": return +(r >= i);
1134
+ case "&&": return +(!!r && !!i);
1135
+ case "||": return +(!!r || !!i);
1136
+ case "&": return r & i;
1137
+ case "|": return r | i;
1138
+ case "^": return r ^ i;
1139
+ case "<<": return r << i;
1140
+ case ">>": return r >> i;
1141
+ default: throw e("failed", "Invalid GLSL preprocessor condition; use an integer constant expression");
1142
+ }
1143
+ }, o = (e) => {
1144
+ let t = new l("const int condition=" + i(e.replace(/\bdefined\s*(?:\(\s*([A-Za-z_]\w*)\s*\)|([A-Za-z_]\w*))/g, (e, t, n) => r.has(t ?? n) ? "1" : "0")) + ";").parse();
1145
+ return !!a(t.globals[0].init);
1146
+ }, s = [], c = !0, u = [];
1147
+ t = t.replace(/\/\*[\s\S]*?\*\//g, (e) => e.replace(/[^\n]/g, " ")).replace(/\/\/[^\n]*/g, "").replace(/\\\r?\n/g, "");
1148
+ for (let n of t.split(/\r?\n/)) {
1149
+ let t = /^\s*#\s*(\w+)\s*(.*)$/.exec(n);
1150
+ if (!t) {
1151
+ u.push(c ? i(n) : "");
1152
+ continue;
1153
+ }
1154
+ u.push("");
1155
+ let a = t[1], l = t[2].trim();
1156
+ if ([
1157
+ "if",
1158
+ "ifdef",
1159
+ "ifndef"
1160
+ ].includes(a)) {
1161
+ let e = c && (a === "if" ? o(l) : a === "ifdef" ? r.has(l) : !r.has(l));
1162
+ s.push({
1163
+ parent: c,
1164
+ taken: e,
1165
+ active: e
1166
+ }), c = e;
1167
+ } else if (a === "else" || a === "elif") {
1168
+ let t = s.at(-1);
1169
+ if (!t) throw e("failed", "GLSL conditional has no matching #if; correct the directives");
1170
+ t.active = t.parent && !t.taken && (a === "else" || o(l)), t.taken ||= t.active, c = t.active;
1171
+ } else if (a === "endif") {
1172
+ let t = s.pop();
1173
+ if (!t) throw e("failed", "GLSL #endif has no matching #if; correct the directives");
1174
+ c = t.parent;
1175
+ } else if (c) {
1176
+ if (a === "define") {
1177
+ let t = /^([A-Za-z_]\w*)(?:\(([^)]*)\))?\s*(.*)$/.exec(l);
1178
+ if (!t) throw e("failed", "Invalid GLSL #define; supply a name and replacement");
1179
+ r.set(t[1], {
1180
+ params: t[2] === void 0 ? void 0 : t[2].trim() ? t[2].split(",").map((e) => e.trim()) : [],
1181
+ body: t[3]
1182
+ });
1183
+ } else if (a === "undef") r.delete(l);
1184
+ else if (a === "version") {
1185
+ if (l !== "100" && !/^300\s+es$/.test(l)) throw e("unsupported", "GLSL import accepts GLSL ES 1.00 and 3.00; use #version 100 or #version 300 es, or remove the directive");
1186
+ } else if (![
1187
+ "line",
1188
+ "pragma",
1189
+ "extension"
1190
+ ].includes(a)) throw e("failed", `GLSL #${a} is invalid in this transition; correct its preprocessing directives`);
1191
+ }
1192
+ }
1193
+ if (s.length) throw e("failed", "Unclosed GLSL preprocessor conditional; add the matching #endif");
1194
+ return u.join("\n");
1195
+ }
1196
+ //#endregion
1197
+ //#region src/glsl.ts
1198
+ var w = (e, t) => ({
1199
+ uniforms: e,
1200
+ flipY: t,
1201
+ names: {
1202
+ progress: {
1203
+ code: "settings.x",
1204
+ type: "float"
1205
+ },
1206
+ ratio: {
1207
+ code: "(f32(textureDimensions(after).x)/f32(textureDimensions(after).y))",
1208
+ type: "float"
1209
+ },
1210
+ from: {
1211
+ code: "before",
1212
+ type: "sampler2D"
1213
+ },
1214
+ to: {
1215
+ code: "after",
1216
+ type: "sampler2D"
1217
+ },
1218
+ gl_FragCoord: {
1219
+ code: "user_frag_coord",
1220
+ type: "vec4"
1221
+ }
1222
+ },
1223
+ colorReaders: {
1224
+ getFromColor: "before",
1225
+ getToColor: "after"
1226
+ },
1227
+ prologue: "var<private> user_frag_coord:vec4f;",
1228
+ entry: {
1229
+ name: "transition",
1230
+ type: "vec4",
1231
+ params: ["vec2"]
1232
+ },
1233
+ missingEntry: "Supply vec4 transition(vec2 uv)",
1234
+ epilogue: (e) => [
1235
+ "fn transition(a:texture_2d<f32>,b:texture_2d<f32>,uv:vec2f,p:f32)->vec4f{",
1236
+ "user_frag_coord=vec4f(uv.x*f32(textureDimensions(after).x),(1.0-uv.y)*f32(textureDimensions(after).y),0.0,1.0);",
1237
+ `return ${e}(${t ? "vec2f(uv.x,1.0-uv.y)" : "uv"});`,
1238
+ "}"
1239
+ ].join("\n")
1240
+ });
1241
+ function T(t, n = {}) {
1242
+ if (typeof t != "string" || !t.trim() || t.length > 65536) throw TypeError("GLSL transition needs 1..65536 source code units; supply vec4 transition(vec2 uv)");
1243
+ if (n.flipY !== void 0 && typeof n.flipY != "boolean") throw TypeError("GLSL flipY must be boolean; choose true for bottom-left GLSL coordinates");
1244
+ let r = {};
1245
+ for (let n of t.matchAll(/\buniform\s+(?:(?:lowp|mediump|highp)\s+)?\w+\s+(\w+)\s*;[^\n]*?\/\/\s*=\s*([^\n]+)/g)) try {
1246
+ r[n[1]] = JSON.parse(n[2]);
1247
+ } catch {
1248
+ throw e("failed", `GLSL default for ${n[1]} is not JSON; correct its // = annotation`);
1249
+ }
1250
+ Object.assign(r, n.uniforms);
1251
+ let i = { version: 100 };
1252
+ return new S(new l(C(t, i)).parse(), w(r, n.flipY ?? !0), i.version).emit();
1253
+ }
1254
+ async function E(e, n, r = {}) {
1255
+ return r.signal?.throwIfAborted(), t(e, T(n, r), r);
1256
+ }
1257
+ async function D(e, t, r, i, a = {}) {
1258
+ return a.signal?.throwIfAborted(), n.custom(e, t, r, T(i, a), a);
1259
+ }
1260
+ //#endregion
1261
+ export { E as createGLSLTransition, D as createLiveGLSLTransition, T as translateGLSLTransition };